Changeset 8198 for mauRepo


Ignore:
Timestamp:
31/03/12 14:18:08 (8 years ago)
Author:
mnagni
Message:

Complete - # 22418: CEDA Observation - moles2 link
 http://team.ceda.ac.uk/trac/ceda/ticket/22418
Complete - # 22397: CEDA Observation geographicExtent
 http://team.ceda.ac.uk/trac/ceda/ticket/22397
Incomplete - # 22412: CEDA Observation - publisher, curator
 http://team.ceda.ac.uk/trac/ceda/ticket/22412

Location:
mauRepo/MolesManager/trunk/src
Files:
2 added
6 edited

Legend:

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

    r8183 r8198  
    1010from libs.migration.processor.check.check import moles3Append 
    1111from libs.migration.processor.commons import createDQ_Element 
     12from ea_model.iso_19115_2006_metadata_corrigendum.reference_system_information.md_identifier import MD_Identifier 
     13from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_citation import CI_Citation 
     14from ea_model.moles3_4.observationcollection.mo_observationcollection import MO_ObservationCollection 
    1215 
    1316#molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT) 
     
    6265 
    6366    @classmethod 
    64     def extractObservationbytitle(self, title, session = None): 
     67    def extractCollectionIdentifierByTitle(self, i_title, session = None): 
    6568        """ 
    66             Checks if a CEDA_Observation contains a specific title (observation.identifier.code) 
    67             @param title: the CEDA_Observation title 
    68             @return: a collection of CEDA_Observation   
     69            Loooks for an MD_Identifier from a CEDA_ObservationCollection contains a specific title (observation.identifier.code) 
     70            @param i_title: the CEDA_ObservationCollection.identifier.title value to search for 
     71            @return: a tuple containing a CEDA_ObservationCollection and the CEDA_ObservationCollection.idenfitier element having the title   
    6972        """ 
    7073        intSession = Moles3EPB._getSession(session) 
    71         return intSession.query(CEDA_Observation).filter(CEDA_Observation.identifier.code.like(title)) 
     74        return intSession.query(CEDA_ObservationCollection, MD_Identifier). \ 
     75            join(MO_ObservationCollection).join(MO_ObservationCollection.identifier). \ 
     76            join(MD_Identifier.authority).filter(CI_Citation.title.like('%' + i_title + '%')) 
    7277     
    7378    @classmethod 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8196 r8198  
    530530    ''' 
    531531        Creates a new CI_OnlineResource instance 
    532         @param linkage: a URL instance 
     532        @param linkage: a string (the URL class is associated with a String) 
    533533        @param name: a String 
    534534    ''' 
     
    593593    return ci_party 
    594594 
    595 def createMO_ResponsiblePartyInfo_(role, party): 
     595def createMO_ResponsiblePartyInfo_(role, i_party): 
    596596    """ 
    597597        @param role: a CI_RoleCode/MO_RoleValue assigned to this ResponsibleParty 
     
    600600    mo_responsableInfo = MO_ResponsiblePartyInfo() 
    601601    mo_responsableInfo.role = role 
    602     mo_responsableInfo.party = party 
     602    mo_responsableInfo.party = i_party 
    603603    return mo_responsableInfo 
    604604 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/dataEntity.py

    r8188 r8198  
    1313from libs.migration.processor.commons import findDeploymentsInDE,\ 
    1414    createMD_Identifier, extractContent, MD_CODE_MOLES2_CITATION,\ 
    15     hasAtomDocumentSameHash, createCI_Citation, createCI_Date 
     15    hasAtomDocumentSameHash 
    1616from libs.migration.processor.deployment import DeploymentProcessor 
    1717from ea_model.moles3_4.utilities.mo_publicationstatevalue import MO_PublicationStateValue 
     
    1919import logging 
    2020from libs.migration.processor.check.check import moles3Append 
    21 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 
    2221 
    2322class DataEntityProcessor(object): 
     
    4342        contentDict = extractContent(self._dataEntityMigration) 
    4443        if not contentDict.has_key('citation'): 
    45             DataEntityProcessor.log.info("The migration object "+ _migrationObjectDescription(self._dataEntityMigration) + " has not associated cedacat:citation") 
     44            DataEntityProcessor.log.info("The migration object "+ _migrationObjectDescription(self._dataEntityMigration) \ 
     45                                         + " has not associated cedacat:citation") 
    4646        else: 
    4747            newIdentifier = createMD_Identifier(code = contentDict['citation']) 
     
    9393            ceda_observation = deProcessor.process() 
    9494            Moles3EPB.addObservationToObservationCollection(cedaObservationCollection, ceda_observation, self.migrationSessions.molesSession, True)             
    95             MigrationEPB.associateObservationCollectionToDataEntity(deploymentMigration, cedaObservationCollection.id, self.migrationSessions.migrationSession, True) 
     95            MigrationEPB.associateObservationCollectionToDataEntity(deploymentMigration, \ 
     96                         cedaObservationCollection.id, self.migrationSessions.migrationSession, True) 
    9697        except NoAssociatedAuthor as ex: 
    9798            raise ex                  
     
    112113         
    113114        #retreives the DataEntityMigration sorted by creation date 
    114         deploymentMigrations = MigrationEPB.getAllDeploymentsMigrationByDataEntitySortedByDate(self._dataEntityMigration, deploymentsLinks, self.migrationSessions.migrationSession) 
     115        deploymentMigrations = MigrationEPB.getAllDeploymentsMigrationByDataEntitySortedByDate( \ 
     116                                                self._dataEntityMigration, deploymentsLinks, self.migrationSessions.migrationSession) 
    115117        howManydm = deploymentMigrations.count() 
    116118        for deploymentMigration in deploymentMigrations: 
    117119            try: 
    118120                ceda_observation = self._processDeploymentMigration(deploymentMigration, cedaObservationCollection) 
    119                 if howManydm > 1:                     
    120                     for identifier in cedaObservationCollection.identifier:                         
    121                         if hasattr(identifier, 'authority') and identifier.authority.title == MD_CODE_MOLES2_CITATION: 
    122                             # TBD --- Here should compare if exists already 
    123                             ceda_observation.identifier.append(identifier) 
    124                             self.migrationSessions.molesSession.commit() 
     121                if howManydm == 1: 
     122                    collection_identifier = Moles3EPB.extractCollectionIdentifierByTitle(MD_CODE_MOLES2_CITATION, self.migrationSessions.molesSession) 
     123                    if collection_identifier.count()==1: 
     124                        ceda_observation.identifier.append(collection_identifier.firt()) 
     125                        self.migrationSessions.molesSession.commit()                 
    125126            except Exception as ex: 
    126127                exs.append(ex) 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8196 r8198  
    1818    createCI_Telephone, extractMolesTemporalRange, isoDateStringToTimeDate,\ 
    1919    createTM_Period, createCI_Individual, findAccessLinksInMigrationDocument,\ 
    20     findLinksInDeployment, DT_DEPLOYMENTS, buildExistDocPath 
     20    findLinksInDeployment 
    2121from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    2222from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    3434from libs.migration.processor.check.check import moles3Append 
    3535from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 
    36 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.url import URL 
    3736 
    3837class DeploymentProcessor(object): 
     
    107106 
    108107        i_party = createMO_Organization(name = CEDA) 
    109         observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_curator, i_party))                                
     108        observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_curator, [i_party]))                                
    110109         
    111110        if authors.has_key(doc_authors['authors']): 
     
    152151             
    153152            if tmp_auth['author'] == 'unknown': 
    154                 DeploymentProcessor.log.info("%s %s %s has unknown author" % (whereAreAuthors.doc_status, whereAreAuthors.doc_owner, whereAreAuthors.doc_name))         
     153                DeploymentProcessor.log.info("%s %s %s has unknown author" \ 
     154                                             % (whereAreAuthors.doc_status, whereAreAuthors.doc_owner, whereAreAuthors.doc_name))         
    155155                   
    156156            for item in tmp_auth['co_author_type']: 
     
    161161             
    162162                if (tmp_auth['co_author'][tmp_auth['co_author_type'].index(item)] == 'unknown'): 
    163                     DeploymentProcessor.log.info("%s %s %s has unknown author" % (whereAreAuthors.doc_status, whereAreAuthors.doc_owner, whereAreAuthors.doc_name)) 
     163                    DeploymentProcessor.log.info("%s %s %s has unknown author" \ 
     164                                                 % (whereAreAuthors.doc_status, whereAreAuthors.doc_owner, whereAreAuthors.doc_name)) 
    164165        except Exception as e: 
    165166            print e 
     
    178179            doc_title = extractTitle(self._dataEntityMigration)             
    179180        auth = createCI_Citation(title = 'ceda_title')                   
    180         Moles3EPB.addIdentifierToObservation(createMD_Identifier(code = doc_title, authority = auth), observation, self._migrationSessions.molesSession) 
     181        Moles3EPB.addIdentifierToObservation(createMD_Identifier(code = doc_title, authority = auth), \ 
     182                                             observation, self._migrationSessions.molesSession) 
    181183 
    182184    def _assignDescription(self, observation): 
     
    189191         
    190192    def updateObservation(self): 
    191         ceda_observation = EPB.searchOrCreate(CEDA_Observation, self._migrationSessions.molesSession, self._deploymentMigration.ceda_observation_id) 
     193        ceda_observation = EPB.searchOrCreate(CEDA_Observation, self._migrationSessions.molesSession, \ 
     194                                              self._deploymentMigration.ceda_observation_id) 
    192195        return ceda_observation 
    193196 
     
    209212            if dwn['href'].startswith('http://badc.nerc.ac.uk/browse') or dwn['href'].startswith('http://neodc.nerc.ac.uk/browse'): 
    210213                int_description = "download directly from archive"                 
    211             observation.result = createCEDA_Result(linkage = dwn['href'], name = dwn['title'], function = CI_OnLineFunctionCode.cl_download, description = int_description, applicationProfile = int_applicationProfile)                                 
     214            observation.result = createCEDA_Result(linkage = dwn['href'], name = dwn['title'], \ 
     215                                                   function = CI_OnLineFunctionCode.cl_download, \ 
     216                                                   description = int_description, applicationProfile = int_applicationProfile)                                 
    212217 
    213218 
     
    255260        party = None 
    256261        if provider_id == DO_BADC: 
    257             #linkage = URL("http://badc.rl.ac.uk") 
    258             i_onlineResources = createCI_OnlineResource(linkage = URL(), name = 'British Atmospheric Data Centre Website') 
    259             i_address = createCI_Address(deliveryPoint = ['British Atmospheric Data Centre, STFC Rutherford Appleton Laboratory'], electronicMailAddress=['badc@rl.ac.uk'], postalCode='OX11 0QX', country='UK', city='Harwell Oxford')                                    
     262            i_linkage = 'http://badc.rl.ac.uk' 
     263            i_onlineResources = createCI_OnlineResource(linkage = i_linkage, name = 'British Atmospheric Data Centre Website') 
     264            i_address = createCI_Address(deliveryPoint = ['British Atmospheric Data Centre, STFC Rutherford Appleton Laboratory'], \ 
     265                                         electronicMailAddress=['badc@rl.ac.uk'], postalCode='OX11 0QX', country='UK', city='Harwell Oxford')                                    
    260266            i_phone = createCI_Telephone(voice=['+44(0)1235 446432'])                                    
    261267            contact = createCI_Contact(phone=i_phone, address=i_address, onlineResource=i_onlineResources)                        
    262268            party = createMO_Organization(name = "NERC - British Atmospheric Data Centre", contactInfo = [contact]) 
    263269        elif provider_id == DO_NEODC: 
    264             #linkage = URL("http://www.neodc.rl.ac.uk") 
    265             i_onlineResources = createCI_OnlineResource(linkage = URL(), name = 'NERC Earth Observation Data Centre website') 
    266             i_address = createCI_Address(deliveryPoint = ['NERC - Earth Observation Data Centre, STFC Rutherford Appleton Laboratory'], electronicMailAddress=['neodc@rl.ac.uk'], postalCode='OX11 0QX', country='UK', city='Harwell Oxford')                                    
     270            i_linkage = 'http://www.neodc.rl.ac.uk' 
     271            i_onlineResources = createCI_OnlineResource(linkage = i_linkage, name = 'NERC Earth Observation Data Centre website') 
     272            i_address = createCI_Address(deliveryPoint = ['NERC - Earth Observation Data Centre, STFC Rutherford Appleton Laboratory'], \ 
     273                                         electronicMailAddress=['neodc@rl.ac.uk'], postalCode='OX11 0QX', country='UK', city='Harwell Oxford')                                    
    267274            i_phone = createCI_Telephone(voice=['+44(0)1235 446432'])                                  
    268275            contact = createCI_Contact(phone=i_phone, address=i_address, onlineResource=i_onlineResources)                        
    269276            party = createMO_Organization(name = 'NERC - British Atmospheric Data Centre', contactInfo = [contact]) 
    270277        elif provider_id == DO_UKSSDC: 
    271             #linkage = URL("http://www.ukssdc.rl.ac.uk") 
    272             i_onlineResources = createCI_OnlineResource(linkage = URL(), name = 'UK Solar System Data Centre website') 
    273             i_address = createCI_Address(deliveryPoint = ['UK Solar System Data Centre, STFC Rutherford Appleton Laboratory'], electronicMailAddress=['support@rl.ac.uk'], postalCode='OX11 0QX', country='UK', city='Harwell Oxford')                                    
     278            i_linkage = 'http://www.ukssdc.rl.ac.uk' 
     279            i_onlineResources = createCI_OnlineResource(linkage = i_linkage, name = 'UK Solar System Data Centre website') 
     280            i_address = createCI_Address(deliveryPoint = ['UK Solar System Data Centre, STFC Rutherford Appleton Laboratory'], \ 
     281                                         electronicMailAddress=['support@rl.ac.uk'], postalCode='OX11 0QX', country='UK', city='Harwell Oxford')                                    
    274282            i_phone = createCI_Telephone(voice=['+44(0)1235 445173'])                                  
    275283            contact = createCI_Contact(phone=i_phone, address=i_address, onlineResource=i_onlineResources)                        
  • mauRepo/MolesManager/trunk/src/libs/migration/tests/migrationprocess.py

    r8186 r8198  
    4646         
    4747        ex = mp.process(dataEntity) 
    48         ex = mp.process() 
     48        #ex = mp.process() 
    4949        for e in ex: 
    5050            print e 
  • mauRepo/MolesManager/trunk/src/libs/migration/tests/moles3epbtests.py

    r8186 r8198  
    2121from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_instant import TM_Instant 
    2222from ea_model.iso_19108_2006_temporal_schema.temporal_reference_system.tm_position import TM_Position 
     23from libs.migration.tests.test_utils import createObservationCollection 
    2324 
    2425 
     
    4849    def checkEmptyObservationCollection(self): 
    4950        session = Moles3EPB.getNewMolesSession(); 
    50         observationCollection = CEDA_ObservationCollection() 
     51        observationCollection = createObservationCollection() 
    5152         
    5253        self.logging.info('Stores an empty new CEDA_ObservationCollection') 
     
    183184        session.delete(tm_instant) 
    184185        session.commit() 
    185  
    186     def _createObservationCollection(self): 
    187         observationCollection = CEDA_ObservationCollection() 
    188         return observationCollection 
    189186 
    190187    def _createObservation(self): 
Note: See TracChangeset for help on using the changeset viewer.