Changeset 8494 for mauRepo/MolesManager


Ignore:
Timestamp:
08/08/12 09:32:57 (7 years ago)
Author:
mnagni
Message:

Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534
Fixing some pylint issues

Location:
mauRepo/MolesManager/trunk/cedaMoles
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/moles3epb.py

    r8493 r8494  
    212212        return unifyGeometriesAsBBox(bboxes, self)   
    213213         
    214     def getUnifyObservationCollectionPhenomenonTime(self, collection): 
    215         """ 
    216             Returns the time period of the collections.member'a  phenomenonTime(s) 
    217             @param collection: an CEDA_ObservationColleciton instance  
    218             @return: a tuple (startDate, endDate)  
    219         """ 
    220         ptStart = [] 
    221         ptEnd = []       
    222         for member in collection.member: 
    223             for pt in member.phenomenonTime: 
    224                 ptString = fromPhenomenonTimeToString(pt) 
    225                 if ptString[0] is not None:                     
    226                     ptStart.append(datetime.strptime(ptString[0], '%Y-%m-%d')) 
    227                 if ptString[1] is not None:                     
    228                     ptEnd.append(datetime.strptime(ptString[1], '%Y-%m-%d')) 
    229         ptStart.sort()                     
    230         ptEnd.sort() 
    231         start = None 
    232         end = None 
    233         #takes the earlier date 
    234         if len(ptStart) > 0: 
    235             start = ptStart[0] 
    236         #takes the latest date 
    237         if len(ptEnd) > 0: 
    238             end = ptEnd[len(ptEnd) - 1] 
    239         return start, end   
    240          
    241          
    242          
    243214        #return unifyGeometriesAsBBox(bboxes, self) 
    244215 
     
    327298            @return: a tuple containing the associated CEDA_ObservationCollection   
    328299        """ 
    329         mo_obs = self._session.query(MO_Observation).join(CEDA_Project).filter(CEDA_Project.id == project.id).subquery()       
    330         obsers = self._session.query(CEDA_Observation).join(mo_obs, CEDA_Observation.id == mo_obs.c.id).one() 
    331         #print "obsers: " + str(intSession.query(CEDA_Observation).join(mo_obs, CEDA_Observation.id == mo_obs.c.id).count()) 
    332          
     300        mo_obs = self._session.query(MO_Observation).join(CEDA_Project).\ 
     301            filter(CEDA_Project.id == project.id).subquery()       
     302        obsers = self._session.query(CEDA_Observation).\ 
     303            join(mo_obs, CEDA_Observation.id == mo_obs.c.id).one() 
     304         
     305        ''' 
    333306        cos = self._session.query(CEDA_ObservationCollection).all() 
    334         co = self._session.query(MO_ObservationCollection).join(MO_ObservationCollection.member).filter(MO_ObservationCollection.member.contains(obsers)) 
    335          
    336         observations = self._session.query(MO_ObservationCollection).join(CEDA_Observation). \ 
     307        co = self._session.query(MO_ObservationCollection).\ 
     308            join(MO_ObservationCollection.member).\ 
     309            filter(MO_ObservationCollection.member.contains(obsers)) 
     310        ''' 
     311        observations = self._session.query(MO_ObservationCollection).\ 
     312            join(CEDA_Observation).\ 
    337313            filter(obsers.any(CEDA_Observation.id==obsers.c.id)) 
    338314        print "observation:" + str(observations.count()) 
     
    415391    return "%s-%s-%s" % (dt.year, dt.month, dt.day) 
    416392 
    417 def getUnifyObservationCollectionPhenomenonTime(collection): 
     393def unify_observation_collection_phenomenon_time(collection): 
    418394    """ 
    419395        Returns the time period of the collections.member'a  phenomenonTime(s) 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/commons.py

    r8489 r8494  
    4040import html5lib 
    4141from html5lib import treebuilders 
    42 from ea_model.moles3_4.result.mo_onlineresource import MO_OnlineResource 
    43 from ea_model.iso_19115_2006_metadata_corrigendum.reference_system_information.md_identifier import MD_Identifier 
    44 from ea_model.iso_19115_2006_metadata_corrigendum.identification_information.md_keywords import MD_Keywords 
    45 from ea_model.iso_19103_2005_schema_language.basic_types.primitive.date_and_time.datetime import DateTime 
    46 from ea_model.iso_19103_2005_schema_language.basic_types.primitive.date_and_time.date import Date 
    47 from ea_model.iso_19108_2006_temporal_schema.temporal_reference_system.tm_position import TM_Position 
    48 from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_instant import TM_Instant 
    49 from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_period import TM_Period 
    50 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_address import CI_Address 
    51 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_onlineresource import CI_OnlineResource 
    52 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_telephone import CI_Telephone 
    53 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_contact import CI_Contact 
    54 from ea_model.moles3_4.utilities.mo_individual import MO_Individual 
    55 from ea_model.moles3_4.utilities.mo_organisation import MO_Organisation 
    56 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_date import CI_Date 
    57 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_citation import CI_Citation 
    58 from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_constraints import MD_Constraints 
    59 from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_legalconstraints import MD_LegalConstraints 
    60 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_responsibleparty import CI_ResponsibleParty 
    61 from ea_model.iso_19115_2006_metadata_corrigendum.metadata_entity_set_information.md_metadata import MD_Metadata 
    62 from ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_conformanceresult import DQ_ConformanceResult 
    63 from ea_model.iso_19115_2006_metadata_corrigendum.extent_information.ex_geographicboundingbox import EX_GeographicBoundingBox 
    64 from ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_element import DQ_Element 
    6542from ea_model.ceda_metadatamodel.ceda_project.ceda_project import CEDA_Project 
    66 from ea_model.ceda_metadatamodel.ceda_utilities.ceda_review import CEDA_Review 
    67 from ea_model.ceda_metadatamodel.ceda_acquisition.ceda_acquisition import CEDA_Acquisition 
    68 from ea_model.ceda_metadatamodel.ceda_observationprocess.ceda_compositeprocess import CEDA_CompositeProcess 
     43from ea_model.ceda_metadatamodel.ceda_utilities.ceda_review import CEDA_Review     
    6944from ea_model.ceda_metadatamodel.ceda_acquisition.ceda_instrument import CEDA_Instrument 
    7045from ea_model.ceda_metadatamodel.ceda_computation.ceda_processing import CEDA_Processing 
    7146from ea_model.ceda_metadatamodel.ceda_result.ceda_result import CEDA_Result 
    72 import datetime 
     47from ea_model.moles3_4.utilities.mo_individual import MO_Individual 
     48from ea_model.moles3_4.utilities.mo_organisation import MO_Organisation 
     49from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_instant import TM_Instant 
     50from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_period import TM_Period 
     51from ea_model.moles3_4.result.mo_onlineresource import MO_OnlineResource 
     52from ea_model.ceda_metadatamodel.ceda_acquisition.ceda_acquisition import CEDA_Acquisition 
     53 
     54from ea_model.iso_19103_2005_schema_language.basic_types.\ 
     55    primitive.date_and_time.datetime import DateTime 
     56from ea_model.iso_19103_2005_schema_language.basic_types.\ 
     57    primitive.date_and_time.date import Date 
     58from ea_model.iso_19108_2006_temporal_schema.temporal_reference_system.\ 
     59    tm_position import TM_Position 
     60     
     61from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     62    reference_system_information.md_identifier import MD_Identifier 
     63from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     64    identification_information.md_keywords import MD_Keywords     
     65from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     66    citation_and_responsible_party_information.ci_address import CI_Address 
     67from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     68    citation_and_responsible_party_information.ci_onlineresource import CI_OnlineResource 
     69from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     70    citation_and_responsible_party_information.ci_telephone import CI_Telephone 
     71from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     72    citation_and_responsible_party_information.ci_contact import CI_Contact 
     73from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     74    citation_and_responsible_party_information.ci_date import CI_Date 
     75from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     76    citation_and_responsible_party_information.ci_citation import CI_Citation 
     77from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     78    constraint_information.md_constraints import MD_Constraints 
     79from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     80    constraint_information.md_legalconstraints import MD_LegalConstraints 
     81from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     82    citation_and_responsible_party_information.ci_responsibleparty \ 
     83        import CI_ResponsibleParty 
     84from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     85    metadata_entity_set_information.md_metadata import MD_Metadata 
     86from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     87    data_quality_information.dq_conformanceresult import DQ_ConformanceResult 
     88from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     89    extent_information.ex_geographicboundingbox import EX_GeographicBoundingBox 
     90from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     91    data_quality_information.dq_element import DQ_Element 
     92     
     93from ea_model.ceda_metadatamodel.ceda_observationprocess.\ 
     94    ceda_compositeprocess import CEDA_CompositeProcess 
    7395 
    7496base = '/exist/rest/atoms' 
     
    103125iport = '8080' 
    104126 
    105 linkMarkers = ['Deployment', 'DOWNLOAD', 'DOCUMENTATION', 'ACCESS', 'LOGO', 'ACTIVITY', 'DPT', 'OBS'] 
     127linkMarkers = ['Deployment', 'DOWNLOAD', 'DOCUMENTATION', 'ACCESS', 'LOGO', 'ACTIVITY', \ 
     128               'DPT', 'OBS'] 
    106129 
    107130#MD_Identifier codes 
    108131MD_CODE_MOLES2_CITATION = 'ceda_moles2_citation' 
    109132 
    110 htmlParser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("etree"), namespaceHTMLElements=False) 
     133htmlParser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("etree"), \ 
     134                                 namespaceHTMLElements=False) 
    111135 
    112136def calculateHash(text): 
     
    153177    if migrationObject is None: 
    154178        raise Exception("migrationObject is None") 
    155     mo_typeDict = {'DeploymentsMigration': DT_DEPLOYMENTS, 'DataEntityMigration': DT_DATA_ENTITIES, 'DeploymentDataMigration': DT_DEPLOYMENT_DATA}      
    156     return getAtomDocumentAsElementtree(migrationObject.doc_status, mo_typeDict[type(migrationObject).__name__], migrationObject.doc_owner, migrationObject.doc_name) 
     179    mo_typeDict = {'DeploymentsMigration': DT_DEPLOYMENTS, \ 
     180                   'DataEntityMigration': DT_DATA_ENTITIES, \ 
     181                   'DeploymentDataMigration': DT_DEPLOYMENT_DATA}      
     182    return getAtomDocumentAsElementtree(migrationObject.doc_status, \ 
     183                                    mo_typeDict[type(migrationObject).__name__], \ 
     184                                    migrationObject.doc_owner, migrationObject.doc_name) 
    157185 
    158186def getAtomDocumentHashByMO(migrationObject): 
    159187    if migrationObject is None: 
    160188        raise Exception("migrationObject is None")     
    161     mo_typeDict = {'DeploymentsMigration': DT_DEPLOYMENTS, 'DataEntityMigration': DT_DATA_ENTITIES, 'DeploymentDataMigration': DT_DEPLOYMENT_DATA}      
    162     text = _getAtomDocumentAsText(migrationObject.doc_status, mo_typeDict[type(migrationObject).__name__], migrationObject.doc_owner, migrationObject.doc_name) 
     189    mo_typeDict = {'DeploymentsMigration': DT_DEPLOYMENTS, \ 
     190                   'DataEntityMigration': DT_DATA_ENTITIES, \ 
     191                   'DeploymentDataMigration': DT_DEPLOYMENT_DATA}      
     192    text = _getAtomDocumentAsText(migrationObject.doc_status, \ 
     193                                  mo_typeDict[type(migrationObject).__name__],\ 
     194                                   migrationObject.doc_owner, migrationObject.doc_name) 
    163195    return calculateHash(text) 
    164196 
     
    188220    ''' 
    189221        Checks if a migration object has changed. 
    190         @param migrationObject: an instance of DataEntityMigration or DeploymentsMigration or DeploymentDataMigration 
    191         @return True if the hash of the actual document is the same of the migrationObject, otherwise False 
     222        @param migrationObject: an instance of DataEntityMigration or  
     223            DeploymentsMigration or DeploymentDataMigration 
     224        @return True if the hash of the actual document is the  
     225            same of the migrationObject, otherwise False 
    192226    ''' 
    193227    if not hasMOBeenProcessed(migrationObject): 
     
    198232    if migrationObject is None: 
    199233        raise Exception("migrationObject is None")     
    200     return getAtomDocumentAsElementtree(migrationObject.doc_status, docType, migrationObject.doc_owner, migrationObject.doc_name) 
     234    return getAtomDocumentAsElementtree(migrationObject.doc_status, \ 
     235                                        docType, migrationObject.doc_owner, \ 
     236                                        migrationObject.doc_name) 
    201237 
    202238def _getAtomDocumentAsText(docStatus, docType, docOwner, docName): 
     
    216252        @param timestring: a time string formatted as '%Y-%m-%dT%H:%M:%SZ' 
    217253    '''     
    218     return datetime.datetime.fromtimestamp(time.mktime(time.strptime(timestring, datetime_format))) 
     254    return datetime.datetime.fromtimestamp(\ 
     255                                time.mktime(time.strptime(timestring, datetime_format))) 
    219256 
    220257def isoDateStringToTimeDate(datestring): 
     
    253290 
    254291def findMolesCreationDate(resourceXML): 
    255     creationDate = resourceXML.find('%sentity/%smolesISO/%screated' % (molesNS, molesNS, molesNS)) 
     292    creationDate = resourceXML.find('%sentity/%smolesISO/%screated' \ 
     293                                    % (molesNS, molesNS, molesNS)) 
    256294    return _returnNotNoneText(creationDate) 
    257295 
    258296def findMolesPublishedDate(resourceXML): 
    259     creationDate = resourceXML.find('%sentity/%smolesISO/%spublished' % (molesNS, molesNS, molesNS)) 
     297    creationDate = resourceXML.find('%sentity/%smolesISO/%spublished' \ 
     298                                    % (molesNS, molesNS, molesNS)) 
    260299    return _returnNotNoneText(creationDate) 
    261300 
    262301def findMolesLineage(dataEntityMigration): 
    263302    resourceXML = getAtomDocumentByMO(dataEntityMigration) 
    264     lineage = resourceXML.find('%sentity/%smolesISO/%slineage' % (molesNS, molesNS, molesNS)) 
     303    lineage = resourceXML.find('%sentity/%smolesISO/%slineage' \ 
     304                               % (molesNS, molesNS, molesNS)) 
    265305    if lineage is None: 
    266306        raise NoDataLineage(dataEntityMigration) 
     
    269309def extractMolesProviderID(migrationObject): 
    270310    resourceXML = getAtomDocumentByMO(migrationObject) 
    271     provider_id = resourceXML.find('%sentity/%smolesISO/%sproviderID' % (molesNS, molesNS, molesNS)) 
     311    provider_id = resourceXML.find('%sentity/%smolesISO/%sproviderID' \ 
     312                                   % (molesNS, molesNS, molesNS)) 
    272313    return _returnNotNoneText(provider_id) 
    273314 
    274315def extractMolesQuality(migrationObject): 
    275316    resourceXML = getAtomDocumentByMO(migrationObject) 
    276     quality = resourceXML.find('%sentity/%smolesISO/%squality' % (molesNS, molesNS, molesNS)) 
     317    quality = resourceXML.find('%sentity/%smolesISO/%squality' \ 
     318                               % (molesNS, molesNS, molesNS)) 
    277319    return _returnNotNoneText(quality) 
    278320 
     
    292334def extractQuality(dataEntityMigration): 
    293335    resourceXML = getAtomDocumentByMO(dataEntityMigration) 
    294     quality = resourceXML.find('%sentity/%smolesISO/%squality' % (molesNS, molesNS, molesNS)) 
     336    quality = resourceXML.find('%sentity/%smolesISO/%squality' \ 
     337                               % (molesNS, molesNS, molesNS)) 
    295338    return _returnNotNoneText(quality) 
    296339 
    297340def extractUpdateFrequency(dataEntityMigration): 
    298341    resourceXML = getAtomDocumentByMO(dataEntityMigration) 
    299     update_frequency = resourceXML.find('%sentity/%smolesISO/%supdateFrequency' % (molesNS, molesNS, molesNS)) 
     342    update_frequency = resourceXML.find('%sentity/%smolesISO/%supdateFrequency' \ 
     343                                        % (molesNS, molesNS, molesNS)) 
    300344    return _returnNotNoneText(update_frequency) 
    301345 
     
    377421    rel = link.get('rel') 
    378422    if rel and rel.endswith('/' + linkMarker): 
    379         linksDict[linkMarker].append({'href': link.get('href'), 'title': link.get('title')})  
     423        linksDict[linkMarker].append({'href': link.get('href'), \ 
     424                                      'title': link.get('title')})  
    380425 
    381426def _extractLinks(dataEntXML, markers): 
     
    420465def findDocumentationInMigrationDocument(migrationObject): 
    421466    """ 
    422         Return a list of dictionaries describing a <link rel="...DOCUMENTATION..."> tag type 
     467        Return a list of dictionaries describing a <link rel="...DOCUMENTATION...">  
     468        tag type 
    423469        Each dictionary has two keys: 'href' and 'title' 
    424470        @param migrationObject: the migration instance to retrieve and parse 
     
    468514        Extracts if existing the georss:where/gel:Enveloper/upper-lowerCorner elements. 
    469515        @param migrationObject: a migration object to retrieve to parse for data 
    470         @return: None if no data are found, otherwise a dictionary with keys: 'east', 'north', 'west', 'south' where 
     516        @return: None if no data are found, otherwise a dictionary with keys: 'east',  
     517        'north', 'west', 'south' where 
    471518        the values are float 
    472519    """ 
    473520    resourceXML = getAtomDocumentByMO(migrationObject) 
    474     upperCorner = resourceXML.find('%swhere/%sEnvelope/%supperCorner' % (georssNS, gmlNS, gmlNS)) 
    475     lowerCorner = resourceXML.find('%swhere/%sEnvelope/%slowerCorner' % (georssNS, gmlNS, gmlNS)) 
     521    upperCorner = resourceXML.find('%swhere/%sEnvelope/%supperCorner' \ 
     522                                   % (georssNS, gmlNS, gmlNS)) 
     523    lowerCorner = resourceXML.find('%swhere/%sEnvelope/%slowerCorner' \ 
     524                                   % (georssNS, gmlNS, gmlNS)) 
    476525    ret = None 
    477526    if upperCorner != None and lowerCorner != None: 
    478527        upperCornerData = upperCorner.text.split() 
    479528        lowerCornerData = lowerCorner.text.split() 
    480         ret = {'east': float(upperCornerData[0]), 'north': float(upperCornerData[1]), 'west': float(lowerCornerData[0]), 'south': float(lowerCornerData[1])} 
     529        ret = {'east': float(upperCornerData[0]), 'north': float(upperCornerData[1]), \ 
     530               'west': float(lowerCornerData[0]), 'south': float(lowerCornerData[1])} 
    481531    return ret 
    482532 
     
    512562    ''' 
    513563        Returns a list of Elements representing the inner resource reference items 
    514         @param resourceRefs: the name of the eXist collection name below the 'deployments' one 
     564        @param resourceRefs: the name of the eXist collection name below the  
     565        'deployments' one 
    515566    '''   
    516567    XMLDepl = _getXMLDocument(deploymentRefs) 
     
    520571    ''' 
    521572        Returns a list of Elements representing the inner resource reference items 
    522         @param resourceRefs: the name of the eXist collection name below the 'deployments' one 
     573        @param resourceRefs: the name of the eXist collection name below the  
     574        'deployments' one 
    523575    '''       
    524576    XMLDepl = _getXMLDocument(buildExistOwnerPath(docStatus, docType, docOwner)) 
     
    528580    ''' 
    529581        Returns a list of Elements representing the inner resource reference items 
    530         @param resourceRefs: the name of the eXist collection name below the 'deployments' one 
     582        @param resourceRefs: the name of the eXist collection name below the  
     583        'deployments' one 
    531584    '''       
    532585    XMLDepl = _getXMLDocument(buildExistTypePath(docStatus, docType)) 
     
    538591    ''' 
    539592        Returns a list of Elements representing the inner deployment reference items 
    540         @param basePublished: the name of the eXist collection name below the 'published' one 
     593        @param basePublished: the name of the eXist collection name below the  
     594        'published' one 
    541595    '''   
    542596    XMLPubl = _getXMLDocument(publishedRefs) 
     
    592646    return idate        
    593647         
    594 def createTM_Position(anyOther = None, date8601 = None, dateTime8601 = None, time8601 = None): 
     648def createTM_Position(anyOther = None, \ 
     649                      date8601 = None, \ 
     650                      dateTime8601 = None, \ 
     651                      time8601 = None): 
    595652    ''' 
    596653        Creates a new TM_Position instance 
     
    630687    return tm_period 
    631688 
    632 def createCI_Address(deliveryPoint = None, electronicMailAddress = None, city = None, country = None, postalCode = None): 
     689def createCI_Address(deliveryPoint = None, electronicMailAddress = None, \ 
     690                     city = None, country = None, postalCode = None): 
    633691    ''' 
    634692        Creates a new CI_Address instance 
     
    823881    return md_metadata 
    824882 
    825 def createMO_OnlineResource(linkage, instance = None, name = None, function = None, description = None, applicationProfile = None): 
     883def createMO_OnlineResource(linkage, instance = None, name = None, function = None, \ 
     884                            description = None, applicationProfile = None): 
    826885    """ 
    827886        Creates a new CEDA_Result 
     
    930989    return ceda_review 
    931990 
    932 def createCEDA_Project(abstract = None, publication_state = None, documentation = None, project_resource=None): 
     991def createCEDA_Project(abstract = None, publication_state = None, \ 
     992                       documentation = None, project_resource=None): 
    933993    ceda_project = CEDA_Project() 
    934994    if abstract: 
     
    9621022            pt = createTM_Period(begin_tm_instant, end_tm_instant) 
    9631023        else: 
    964             tm_position = createTM_Position(date8601 = createDate(isoDateStringToTimeDate(doc_phenomenon_time))) 
     1024            tm_position = createTM_Position(date8601 = \ 
     1025                                            createDate(isoDateStringToTimeDate(doc_phenomenon_time))) 
    9651026            pt = createTM_Instant(tm_position) 
    9661027        return pt 
     
    9711032        a TM_Period instance in a string like '2002-07-22/2011-08-06' (start/endDate)  
    9721033        @param phenomenonTime: a aTM_Instace or a TM_Period instance 
    973         @return a pair startDate, endDate. If endDate does not exists return startDate, None 
     1034        @return a pair startDate, endDate. If endDate does not exists return startDate,  
     1035        None 
    9741036    """    
    9751037    if phenomenonTime is None: 
     
    9961058    if gbb is None: 
    9971059        return None 
    998     return '{0} {1},{2} {3}'.format(gbb.eastBoundLongitude, gbb.northBoundLatitude, gbb.westBoundLongitude, gbb.southBoundLatitude) 
     1060    return '{0} {1},{2} {3}'.format(gbb.eastBoundLongitude, gbb.northBoundLatitude, \ 
     1061                                    gbb.westBoundLongitude, gbb.southBoundLatitude) 
    9991062     
    10001063def compareGeographicBoundingBoxes(gb1, gb2): 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/dataEntity.py

    r8486 r8494  
    5050    getCLValue 
    5151from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection  
    52 from cedaMoles.MolesManager.moles3epb import getUnifyObservationCollectionPhenomenonTime 
     52from cedaMoles.MolesManager.moles3epb import unify_observation_collection_phenomenon_time 
    5353CEDA_TITLE = 'ceda_title' 
    5454 
     
    9393         
    9494    def _assignPhenomenonTime(self, ceda_observationCollection): 
    95         start, end = getUnifyObservationCollectionPhenomenonTime(ceda_observationCollection) 
     95        start, end = unify_observation_collection_phenomenon_time(ceda_observationCollection) 
    9696        dateString = start 
    9797        if end is not None: 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/migration/loadresource.py

    r8486 r8494  
    44@author: mnagni 
    55''' 
    6 from unittest import TestCase 
    7 from cedaMoles.libs.commons_db import DbManager 
     6from cedaMoles.tests.cedamolestest import CedaMolesTest 
    87from cedaMoles.libs.migration.processor.loadResources import LoadResources 
    98from cedaMoles.libs.migration.db.classes import DataEntityMigration 
    109from cedaMoles.libs.migration.processor.commons import calculateHash 
    11 from cedaMoles.tests.testconfig import MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT 
    1210 
    13 class LoadResourceTest(TestCase): 
    14     ''' 
    15     classdocs 
    16     ''' 
    17  
    18     def setUp(self): 
    19         migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT) 
    20         #MigrationEPB.overrrideDBManager(migrationDB)      
     11class LoadResourceTest(CedaMolesTest):   
    2112 
    2213    def testLoadResource(self): 
    2314        lr = LoadResources() 
    24         migrationClass = DataEntityMigration 
     15        migrationClass = DataEntityMigration() 
    2516        doc_id = 123 
    2617        docHash = calculateHash('123_docHash') 
    2718        docCreation = '2009-12-10T03:16:25Z' 
    28         lr.createMigrationDoc(migrationClass, doc_id, '123_docName', '123_ddocOwner', '123_docStatus', docHash, docCreation) 
    29         self.assertTrue(lr.updateMigrationDoc(migrationClass, doc_id, docHash, docCreation)) 
    30         self.assertTrue(lr.updateMigrationDoc(migrationClass, doc_id, calculateHash('321_docHash'), docCreation)) 
    31         self.assertTrue(lr.updateMigrationDoc(migrationClass, doc_id, calculateHash('321_docHash'), '2012-12-10T03:16:25Z')) 
     19        lr.createMigrationDoc(migrationClass, doc_id, '123_docName', \ 
     20                              '123_ddocOwner', '123_docStatus', \ 
     21                              docHash, docCreation) 
     22        self.assertTrue(lr.updateMigrationDoc(migrationClass, doc_id, \ 
     23                                              docHash, docCreation)) 
     24        self.assertTrue(lr.updateMigrationDoc(migrationClass, doc_id,  
     25                                                calculateHash('321_docHash'), \ 
     26                                            docCreation)) 
     27        self.assertTrue(lr.updateMigrationDoc(migrationClass, doc_id, \ 
     28                                                calculateHash('321_docHash'), \ 
     29                                            '2012-12-10T03:16:25Z')) 
    3230                 
    3331        self.assertFalse(lr.updateMigrationDoc(migrationClass, 321, docHash, docCreation)) 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/migration/moles3epbtests.py

    r8489 r8494  
    55''' 
    66import logging, datetime 
    7 from cedaMoles.libs.migration.processor.commons import createCI_Date, createDateTime,\ 
    8     createDate, createTM_Position, createTM_Instant 
    9 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 
    10 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_date import CI_Date 
    11 from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_instant import TM_Instant 
    12 from ea_model.iso_19108_2006_temporal_schema.temporal_reference_system.tm_position import TM_Position 
    13 from test_utils import createObservationCollection,\ 
    14     createProject   
    15 from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 
     7from cedaMoles.libs.migration.processor.commons import createCI_Date, \ 
     8    createDateTime, createDate, createTM_Position, createTM_Instant 
     9from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     10    citation_and_responsible_party_information.ci_datetypecode \ 
     11        import CI_DateTypeCode 
     12from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     13    citation_and_responsible_party_information.ci_date import CI_Date 
     14from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_instant \ 
     15        import TM_Instant 
     16from ea_model.iso_19108_2006_temporal_schema.temporal_reference_system.\ 
     17    tm_position import TM_Position 
     18from test_utils import createObservationCollection, createProject   
     19from ea_model.ceda_metadatamodel.ceda_observationcollection.\ 
     20    ceda_observationcollection import CEDA_ObservationCollection 
    1621from cedaMoles.tests.cedamolestest import CedaMolesTest 
    17 from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     22from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation \ 
     23        import CEDA_Observation 
    1824from ea_model.ceda_metadatamodel.ceda_project.ceda_project import CEDA_Project 
    1925 
     
    2430 
    2531    def runTest(self): 
    26         #self.checkEmptyObservationCollection() 
    27         #self.checkEmptyObservation() 
    28         #self.checkObservation() 
    29         #self.checkObservationCollection() 
    30         #self.checkCI_Date() 
    31         #self.checkTM_Instant() 
    32         #self.checkTM_Position() 
     32        self.checkEmptyObservationCollection() 
     33        self.checkEmptyObservation() 
     34        self.checkObservation() 
     35        self.checkObservationCollection() 
     36        self.checkCI_Date() 
     37        self.checkTM_Instant() 
     38        self.checkTM_Position() 
    3339        self.checkCI_Responsibility()  
    3440 
     
    4046         
    4147        Moles3EPBTest.log.info('Tries to retrieve it') 
    42         self.assertTrue(hasattr(observationCollection, 'id'), "Cannot create  ObservationCollection")         
    43         res = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, observationCollection.id) 
     48        self.assertTrue(hasattr(observationCollection, 'id'), "Cannot create  \ 
     49            ObservationCollection")         
     50        res = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, \ 
     51                                            observationCollection.id) 
    4452        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    4553         
     
    5058        observation = CEDA_Observation() 
    5159         
    52         Moles3EPBTest.log.info('Tries to stores an empty new %s' % (observation.__class__.__name__)) 
     60        Moles3EPBTest.log.info('Tries to stores an empty new %s' \ 
     61                               % (observation.__class__.__name__)) 
    5362        self.epbRepo.moles3EPB.persistInstance(observation) 
    5463        #self.assertRaises(IntegrityError, session.commit) 
     
    6069         
    6170        Moles3EPBTest.log.info('Tries to retrieve it') 
    62         self.assertTrue(hasattr(observation, 'id'), 'Cannot create %s' % (observation.__class__.__name__))         
     71        self.assertTrue(hasattr(observation, 'id'), 'Cannot create %s' \ 
     72                        % (observation.__class__.__name__))         
    6373        res = self.epbRepo.moles3EPB.search(CEDA_Observation, observation.id) 
    6474        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     
    7484         
    7585        Moles3EPBTest.log.info('Tries to retrieve it') 
    76         self.assertTrue(hasattr(observationCollection, 'id'), "Cannot create  ObservationCollection")         
    77         res = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, observationCollection.id) 
     86        self.assertTrue(hasattr(observationCollection, 'id'), "Cannot create  \ 
     87                                ObservationCollection")         
     88        res = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, \ 
     89                                            observationCollection.id) 
    7890        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    7991         
     
    8496        observationCollection.member.append(secondObservation)      
    8597         
    86         self.assertTrue(self.epbRepo.moles3EPB.observationCollectionHasObservation(observationCollection.id, firstObservation.id), "The collection should contains the given observation") 
     98        self.assertTrue(self.epbRepo.moles3EPB.\ 
     99            observationCollectionHasObservation(observationCollection.id, \ 
     100                                                firstObservation.id),  
     101                        "The collection should contains the given observation") 
    87102         
    88103        Moles3EPBTest.log.info('Deletes it') 
     
    92107        observation = self._createObservation() 
    93108         
    94         Moles3EPBTest.log.info('Tries to stores a new %s' % (observation.__class__.__name__)) 
     109        Moles3EPBTest.log.info('Tries to stores a new %s' \ 
     110                               % (observation.__class__.__name__)) 
    95111        self.epbRepo.moles3EPB.persistInstance(observation)                 
    96112         
    97113        Moles3EPBTest.log.info('Tries to retrieve it') 
    98         self.assertTrue(hasattr(observation, 'id'), 'Cannot create %s' % (observation.__class__.__name__))         
     114        self.assertTrue(hasattr(observation, 'id'), 'Cannot create %s' \ 
     115                        % (observation.__class__.__name__))         
    99116        res = self.epbRepo.moles3EPB.search(CEDA_Observation, observation.id) 
    100117        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     
    159176        res = self.epbRepo.moles3EPB.search(CEDA_Project, project.id) 
    160177        for item in res:                 
    161             self.assertTrue(item.abstract == 'test_abstract', "Cannot retrieve the abstract from stored project") 
     178            self.assertTrue(item.abstract == 'test_abstract', \ 
     179                            "Cannot retrieve the abstract from stored project") 
    162180         
    163181        Moles3EPBTest.log.info('Deletes it') 
Note: See TracChangeset for help on using the changeset viewer.