Changeset 8187 for mauRepo


Ignore:
Timestamp:
26/03/12 15:26:54 (8 years ago)
Author:
mnagni
Message:

Incomplete - # 22412: CEDA Observation - publisher, curator
 http://team.ceda.ac.uk/trac/ceda/ticket/22412

Location:
mauRepo/MolesManager/trunk/src/libs/migration/processor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8186 r8187  
    3333from ea_model.iso_19108_2006_temporal_schema.temporal_reference_system.tm_position import TM_Position 
    3434from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_instant import TM_Instant 
     35from ea_model.moles3_4.utilities.mo_organization import MO_Organization 
     36from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_contact import CI_Contact 
     37from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_address import CI_Address 
     38from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_onlineresource import CI_OnlineResource 
     39from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_telephone import CI_Telephone 
    3540 
    3641base = '/exist/rest/atoms' 
     
    187192        raise NoDataLineage(dataEntityMigration) 
    188193    return lineage.text 
     194 
     195def extractMolesProviderID(migrationObject): 
     196    resourceXML = getAtomDocumentByMO(migrationObject) 
     197    provider_id = resourceXML.find('%sentity/%smolesISO/%sproviderID' % (molesNS, molesNS, molesNS)) 
     198    return _returnNotNoneText(provider_id) 
    189199 
    190200def extractMolesCreationDate(migrationObject): 
     
    461471    return tm_instant 
    462472 
     473def createCI_Address(deliveryPoint = None, electronicMailAddress = None, city = None, country = None, postalCode = None): 
     474    ''' 
     475        Creates a new CI_Address instance 
     476        @param deliveryPoint: an array of Strings 
     477        @param electronicMailAddress: an array of Strings  
     478        @param city: a string 
     479        @param country: a string                 
     480        @param postalCode: a string         
     481    ''' 
     482    ci_address = CI_Address() 
     483    if electronicMailAddress: 
     484        ci_address.electronicMailAddress = deliveryPoint 
     485    if postalCode: 
     486        ci_address.postalCode = postalCode         
     487    if city: 
     488        ci_address.city = city         
     489    if country: 
     490        ci_address.country = country         
     491    if postalCode: 
     492        ci_address.postalCode = postalCode         
     493    return ci_address 
     494 
     495def createCI_OnlineResource(linkage, name=None): 
     496    ''' 
     497        Creates a new CI_OnlineResource instance 
     498        @param linkage: a URL instance 
     499        @param name: a String 
     500    ''' 
     501    ci_online_resource = CI_OnlineResource() 
     502    ci_online_resource.linkage = linkage 
     503    if name: 
     504        ci_online_resource.name = name 
     505    return ci_online_resource 
     506 
     507def createCI_Telephone(voice=None, facsimile=None): 
     508    ''' 
     509        Creates a new CI_Telephone instance 
     510        @param voice: an array of strings         
     511        @param facsimile: an array of strings 
     512    ''' 
     513    ci_telephone = CI_Telephone() 
     514    if voice: 
     515        ci_telephone.voice = voice 
     516    if facsimile: 
     517        ci_telephone.facsimile = voice         
     518    return ci_telephone 
     519 
     520def createCI_Contact(phone, address = None, onlineResource = None): 
     521    ''' 
     522        Creates a new CI_Contact instance 
     523        @param phone: a CI_Telephone instance         
     524        @param address: a CI_Address instance 
     525        @param onlineResource: a CI_OnlineResource instance 
     526    ''' 
     527    ci_contact = CI_Contact() 
     528    ci_contact.phone = phone 
     529    if address: 
     530        ci_contact.address = address 
     531    if onlineResource: 
     532        ci_contact.onlineResource = onlineResource         
     533    return ci_contact 
     534 
     535def createCI_Individual(name = None, contactInfo = None): 
     536    ''' 
     537        Creates a new CI_Individual instance 
     538        @param name: a String 
     539        @param contactInfo: an array of CI_Contact         
     540    '''     
     541    ci_party = CI_Individual() 
     542    if name: 
     543        ci_party.name = name 
     544    if contactInfo: 
     545        ci_party.contactInfo = contactInfo         
     546    return ci_party 
     547 
     548def createMO_Organization(name = None, contactInfo = None): 
     549    ''' 
     550        Creates a new MO_Organization instance 
     551        @param name: a String 
     552        @param contactInfo: an array of CI_Contact         
     553    '''        
     554    ci_party = MO_Organization() 
     555    if name: 
     556        ci_party.name = name 
     557    if contactInfo: 
     558        ci_party.contactInfo = contactInfo          
     559    return ci_party 
     560 
     561def createMO_ResponsiblePartyInfo_(role, party): 
     562    """ 
     563        @param role: a CI_RoleCode/MO_RoleValue assigned to this ResponsibleParty 
     564        @param party: a list of MO_Organization/CI_Individual instances  
     565    """ 
     566    mo_responsableInfo = MO_ResponsiblePartyInfo() 
     567    mo_responsableInfo.role = role 
     568    mo_responsableInfo.party = party 
     569    return mo_responsableInfo 
     570 
    463571def createMO_ResponsiblePartyInfoAsCI_Organization(role, names): 
    464572    ''' 
     
    483591    mo_responsableInfo = MO_ResponsiblePartyInfo() 
    484592    mo_responsableInfo.role = role 
    485     test = mo_responsableInfo.party 
    486593    parties = [] 
    487594    for name in names: 
     
    491598    mo_responsableInfo.party = parties 
    492599    return mo_responsableInfo 
     600 
     601 
    493602 
    494603def createCI_Date(dateType, date = None): 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8186 r8187  
    1414    findDOIInMigrationDocument, extractContent, createCI_Citation, createCI_Date, createDate,\ 
    1515    createTM_Position, createTM_Instant, extractMolesCreationDate,\ 
    16     createDateTime, isoDateTimeStringToTimeDate 
     16    createDateTime, isoDateTimeStringToTimeDate, extractMolesProviderID,\ 
     17    DO_UKSSDC, createMO_ResponsiblePartyInfo_, createMO_Organization,\ 
     18    createCI_Contact, createCI_Address, createCI_OnlineResource,\ 
     19    createCI_Telephone 
    1720from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    1821from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    3033from libs.migration.processor.check.check import moles3Append 
    3134from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 
     35from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.url import URL 
    3236 
    3337class DeploymentProcessor(object): 
     
    239243            Moles3EPB.addIdentifierToObservation(identifier, observation, self._migrationSessions.molesSession)                     
    240244 
     245    def _assignPublisherCurator(self, observation):         
     246        ''' 
     247            @param relatedPartyInfos: a MO_ResponsiblePartyInfo list 
     248            @return True if the documents changed, False otherwise 
     249        ''' 
     250        provider_id = extractMolesProviderID(self._deploymentMigration) 
     251        party = None 
     252        if provider_id == DO_BADC: 
     253            #linkage = URL("http://badc.rl.ac.uk") 
     254            i_onlineResources = createCI_OnlineResource(linkage = URL(), name = 'British Atmospheric Data Centre Website') 
     255            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')                                    
     256            i_phone = createCI_Telephone(voice=['+44(0)1235 446432'])                                    
     257            contact = createCI_Contact(phone=i_phone, address=i_address, onlineResource=i_onlineResources)                        
     258            party = createMO_Organization(name = "NERC - British Atmospheric Data Centre", contactInfo = [contact]) 
     259        elif provider_id == DO_NEODC: 
     260            #linkage = URL("http://www.neodc.rl.ac.uk") 
     261            i_onlineResources = createCI_OnlineResource(linkage = URL(), name = 'NERC Earth Observation Data Centre website') 
     262            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')                                    
     263            i_phone = createCI_Telephone(voice=['+44(0)1235 446432'])                                  
     264            contact = createCI_Contact(phone=i_phone, address=i_address, onlineResource=i_onlineResources)                        
     265            party = createMO_Organization(name = 'NERC - British Atmospheric Data Centre', contactInfo = [contact]) 
     266        elif provider_id == DO_UKSSDC: 
     267            #linkage = URL("http://www.ukssdc.rl.ac.uk") 
     268            i_onlineResources = createCI_OnlineResource(linkage = URL(), name = 'UK Solar System Data Centre website') 
     269            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')                                    
     270            i_phone = createCI_Telephone(voice=['+44(0)1235 445173'])                                  
     271            contact = createCI_Contact(phone=i_phone, address=i_address, onlineResource=i_onlineResources)                        
     272            party = createMO_Organization(name = 'NERC - UK Solar System Data Centre', contactInfo = [contact]) 
     273         
     274        if party: 
     275            Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_publisher, party), observation, self._migrationSessions.molesSession) 
     276            Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_custodian, party), observation, self._migrationSessions.molesSession) 
     277            Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_distributor, party), observation, self._migrationSessions.molesSession) 
     278            Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_pointofcontact, party), observation, self._migrationSessions.molesSession) 
     279            Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_metadataowner, party), observation, self._migrationSessions.molesSession) 
     280            Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_curator, party), observation, self._migrationSessions.molesSession)                                                             
     281 
    241282    def createNewObservation(self): 
    242283        ceda_observation = CEDA_Observation() 
     
    251292        self._assignDOI(ceda_observation)         
    252293        self._assignCreationDate(ceda_observation) 
     294        self._assignPublisherCurator(ceda_observation)         
    253295        #self._migrationSessions.molesSession.commit() 
    254296        #self._commitMoles3() 
Note: See TracChangeset for help on using the changeset viewer.