Changeset 1134 in main


Ignore:
Timestamp:
05/29/12 12:11:20 (7 years ago)
Author:
agalech
Message:

New api functions to work with CAO systems

Location:
trunk/openPLM/document3D
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/document3D/classes.py

    r1070 r1134  
    3535 
    3636 
    37     There are two ways of generating a :class:`.Product`, reading the file **stp** across the class :class:`.NEW_STEP_Import` ( will refill the attribute **label_reference**  for every :class:`Product`), or reading a file **.geo** related to a :class:`.ArbreFile`   
     37    There are two ways of generating a :class:`.Product`, reading the file **.stp** across the class :class:`.NEW_STEP_Import` ( will refill the attribute **label_reference**  for every :class:`Product`), or reading a file **.arb** related to a :class:`.ArbreFile`   
    3838    Therefore there exist two ways of distinguishing the different :class:`.Product`, by means of the attribute **label_reference** if this one is not False , or by means of the combination of attributes  **id** and **doc_id**. 
    3939     
     
    258258     
    259259    
    260     The :class:`.Product` generated from a file **.geo ** (The case of this function) have his attribute **label_reference** False 
     260    The :class:`.Product` generated from a file **.arb ** (The case of this function) have his attribute **label_reference** set to False 
    261261     
    262262    When we generate an :class:`.Product` using :class:`.NEW_STEP_Import` , the attribute **label_reference** will represents and identify the :class:`.Product` ,  
  • trunk/openPLM/document3D/models.py

    r1107 r1134  
    6868 
    6969        return super(Document3D, self).get_content_and_size(doc_file) 
     70     
     71    @property     
     72    def documents_related(self): 
     73        """ 
     74 
     75        If the :class:`.Document3D` has been decomposed, he returns a list with all the :class:`.Document3D` that form a part of the decomposition,  
     76        and for every :class:`.Document3D` for ONLY ONE level of depth 
     77         
     78 
     79        """ 
     80        document_related=[] 
     81         
     82        part=self.PartDecompose 
     83         
     84        if part: 
     85            list_link=ParentChildLink.objects.filter(parent=part, end_time=None) 
     86            for i in range(len(list_link)): 
     87                if Location_link.objects.filter(link=list_link[i]).exists:  
     88                    document_related.append(Document3D.objects.get(PartDecompose=list_link[i].child)) 
     89 
     90        return document_related 
    7091 
    7192#admin.site.register(Document3D) 
     
    200221 
    201222is_stp=Q(filename__iendswith=".stp") | Q(filename__iendswith=".step")#.stp , .STP , .step , .STEP  
    202  
    203     
     223is_catia=Q(filename__iendswith=".catpart") | Q(filename__iendswith=".catproduct") 
     224  
     225         
     226         
     227         
     228         
     229 
    204230class Document3DController(DocumentController): 
    205231    """ 
     
    917943    we recover all the :class:`.ParentChildLink` of the :class:`.Part` and we look for each of them for  possibles  :class:`.Location_link`, these :class:`.Location_link` indicate that the :class:`.ParentChildLink` was the result of a descomposition.If this is the case ,  we are going to look for the  :class:`.DocumentFile` present in :class:`.Document3D` whose attribute PartDecompose is the **child** of the :class:`.ParentChildLink`. 
    918944       
    919     We return all  :class:`.DocumentFile` that fulfill these condition together with the list of :class:`.Location_link` relatives of each :class:`.DocumentFile` 
     945    We return all  :class:`.DocumentFile` that fulfill these condition together with the list of :class:`.Location_link` relatives of each :class:`.DocumentFile`  
     946    for ONLY ONE level of depth 
    920947     
    921948 
     
    946973    return stp_related , list_loc 
    947974                             
    948                                                         
     975                                              
    949976 
    950977     
  • trunk/openPLM/document3D/urls.py

    r942 r1134  
    11from django.conf.urls.defaults import * 
    22import openPLM.document3D.views as views 
    3  
     3import openPLM.document3D.api as api3D 
    44 
    55 
     
    1919    (r'^object/([^/]+)/([^/]+)/([^/]+)/decompose/([^/]+)/$', views.display_decompose), 
    2020    (r'^ajax/decompose/([^/]+)/$', views.ajax_part_creation_form), 
     21 
     22 
     23) 
     24 
     25api_url = r'^api/object/(?P<doc_id>\d+)/' 
     26 
     27urlpatterns += patterns2('', api_url, 
     28    (r'add_zip_file/(?P<unlock>True|False|true|false)/$', api3D.add_zip_file), 
     29    (r'add_zip_file/thumbnail/(?P<thumbnail_extension>[\w]+)/(?P<unlock>True|False|true|false)/$', api3D.add_zip_file, {"thumbnail" : True}), 
     30    (r'prepare_multi_check_out/$', api3D.prepare_multi_check_out), 
     31    (r'decomposed_documents/(?P<type_check_out>[\w]+)/$', api3D.get_decomposition_documents), 
     32 
    2133) 
    2234 
    2335 
     36 
     37urlpatterns += patterns2('', '^api/', 
     38    (r'doc(?:ument)?s3D/$', api3D.get_all_3D_docs), 
     39    ) 
     40 
     41 
  • trunk/openPLM/document3D/views.py

    r1076 r1134  
    1717from openPLM.plmapp.views.main import r2r 
    1818import tempfile 
     19import os 
    1920 
    2021@handle_errors 
     
    216217 
    217218 
    218             document_controller=DocumentController(stp_file.document,User.objects.get(username=settings.COMPANY)) 
     219            document_controller=Document3DController(stp_file.document,User.objects.get(username=settings.COMPANY)) 
    219220 
    220221            index=[1] 
     
    247248                        instances=[] 
    248249                        old_product=json.dumps(data_for_product(product)) # we save the product before update nodes whit new doc_id and doc_path generated during the bomb-child 
    249                         generate_part_doc_links_AUX(request,product, obj,instances) 
     250                        generate_part_doc_links_AUX(request,product, obj,instances,doc3D) 
    250251                        update_indexes.delay(instances)  
    251252                    except Exception as excep: 
     
    287288    else: 
    288289 
    289         document_controller=DocumentController(stp_file.document,request.user) 
     290        document_controller=Document3DController(stp_file.document,request.user) 
    290291        last_time_modification=Form_save_time_last_modification() 
    291292        last_time_modification.fields["last_modif_time"].initial=document_controller.mtime 
     
    540541 
    541542@transaction.commit_on_success 
    542 def generate_part_doc_links_AUX(request,product, parent_ctrl,instances):  # para generar bien el commit on succes 
     543def generate_part_doc_links_AUX(request,product, parent_ctrl,instances,doc3D):  # para generar bien el commit on succes 
    543544    try: 
    544         generate_part_doc_links(request,product, parent_ctrl,instances) 
     545        generate_part_doc_links(request,product, parent_ctrl,instances,doc3D) 
    545546    except Exception as excep: 
    546547        raise excep           
    547 def generate_part_doc_links(request,product, parent_ctrl,instances): 
     548def generate_part_doc_links(request,product, parent_ctrl,instances,doc3D): 
    548549 
    549550    """ 
     
    613614                part_ctrl.attach_to_document(doc_ctrl.object) 
    614615                 
     616                 
     617                 
     618                 
     619                 
     620 
     621                          
     622                 
     623                 
    615624                                     
    616                 Doc3D=Document3D.objects.get(id=doc_ctrl.object.id) 
    617                 Doc3D.PartDecompose=part_ctrl.object 
    618                 Doc3D.no_index=True  
    619                 Doc3D.save() 
    620  
    621                 generate_part_doc_links(request,link.product, part_ctrl,instances) 
     625                new_Doc3D=Document3D.objects.get(id=doc_ctrl.object.id) 
     626                new_Doc3D.PartDecompose=part_ctrl.object 
     627                new_Doc3D.no_index=True  
     628                new_Doc3D.save() 
     629 
     630                #IMPORTANT############################## diferenciar entre node y feuille ###############################" 
     631                for doc_file in doc3D.files.filter(is_catia):  
     632                    fileName,  fileExtension= os.path.splitext(doc_file.filename)  
     633                    if fileName==link.product.name: 
     634                        doc_file.document=new_Doc3D 
     635                        doc_file.save() 
     636                         
     637                         
     638                generate_part_doc_links(request,link.product, part_ctrl,instances,doc3D) 
    622639 
    623640                     
Note: See TracChangeset for help on using the changeset viewer.