Changeset 8266 for mauRepo


Ignore:
Timestamp:
19/04/12 23:53:23 (8 years ago)
Author:
mnagni
Message:

Complete - # 22434: CEDA Observation - keywords (following Gemini method)
 http://team.ceda.ac.uk/trac/ceda/ticket/22434

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

Legend:

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

    r8265 r8266  
    4545from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_responsibleparty import CI_ResponsibleParty 
    4646from ea_model.iso_19115_2006_metadata_corrigendum.maintenance_information.md_maintenancefrequencycode import MD_MaintenanceFrequencyCode 
     47from ea_model.iso_19115_2006_metadata_corrigendum.identification_information.md_keywords import MD_Keywords 
    4748 
    4849base = '/exist/rest/atoms' 
     
    496497    resourceDoc = _getDocument(resourceSource) 
    497498    return XML(resourceDoc) 
     499 
     500def createMD_Keywords(keywords, k_type=None, thesaurusName=None): 
     501    ''' 
     502        Creates a new MD_Keywords instance. 
     503        @param keywords: a String array         
     504    '''     
     505    md_keywords = MD_Keywords() 
     506    md_keywords.keyword.extend(keywords) 
     507    if k_type: 
     508        md_keywords.type = k_type  
     509    if thesaurusName: 
     510        md_keywords.thesaurusName = thesaurusName        
     511    return md_keywords 
     512     
    498513 
    499514def createDateTime(datetime): 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/dataEntity.py

    r8264 r8266  
    116116        deProcessor = DeploymentProcessor(self._dataEntityMigration, deploymentMigration, self.migrationSessions) 
    117117        try: 
     118            DataEntityProcessor.log.info("Processing deployment: %s" % (migrationObjectDescription(deploymentMigration))) 
    118119            ceda_observation = deProcessor.process() 
    119120            if ceda_observation.resultAccumulation is None: 
     
    132133            deProcessor.assignDOI(ceda_observation, doi) 
    133134            if doi: 
    134                 DataEntityProcessor.log.info("DOI: %s for " % (doi['href'][4:])) 
    135                 DataEntityProcessor.log.info("  -deployment: %s" % (migrationObjectDescription(deploymentMigration))) 
    136                 DataEntityProcessor.log.info("  -dataEntity: %s" % (migrationObjectDescription(self._dataEntityMigration))) 
     135                DataEntityProcessor.log.info("DOI: %s" % (doi['href'][4:])) 
     136 
    137137            self.migrationSessions.molesSession.commit() 
    138138        except NoAssociatedAuthor as ex: 
     
    155155        cedaObservationCollection = None 
    156156        exs = [] 
     157        DataEntityProcessor.log.info("Processing dataEntity: %s" % (migrationObjectDescription(self._dataEntityMigration))) 
    157158        try : 
    158159            if self._dataEntityMigration.ceda_observation_coll_id: 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8265 r8266  
    2222    createMD_Metadata, createMO_OnlineResource, createCEDA_Review, calculateHash,\ 
    2323    createCI_ResponsibleParty, extractUpdateFrequency,\ 
    24     findLinksInMigrationDocument, findSubTypeInDPT, extractMolesPublishedDate 
     24    findLinksInMigrationDocument, findSubTypeInDPT, extractMolesPublishedDate,\ 
     25    createMD_Keywords 
    2526from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    2627from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    309310         
    310311        i_category = ceda_curationvalue.CEDA_CurationValue.cl_a                             
    311         if infodb_de and infodb_de.has_key('category'): 
     312        if infodb_de and infodb_de.has_key('category') and infodb_de['category']: 
    312313            i_category = CEDA_CurationValue.from_string(infodb_de['category'].lower()) #self._getcurationcategory(infodb_de['category'])                 
    313314        observation.result = createCEDA_Result(i_category, i_logical_path, source = [i_source])                                 
     
    325326        # TDB - Check that if is an update or not! 
    326327        creation_date = extractMolesPublishedDate(self._deploymentMigration) 
     328        if creation_date is None: 
     329            creation_date = extractMolesCreationDate(self._deploymentMigration) 
    327330        py_datetime = isoDateTimeStringToTimeDate(creation_date) 
    328331        date_time = createDateTime(py_datetime)     
     
    459462        if updateFrequency: 
    460463            ceda_observation.resultAccumulation = MD_MaintenanceFrequencyCode.from_string(updateFrequency) 
     464 
     465    def _assignKeywords(self, ceda_observation): 
     466        provider_id = extractMolesProviderID(self._deploymentMigration) 
     467        i_keywords = [] 
     468        if provider_id == DO_BADC: 
     469            i_keywords.append('Meteorological geographical features') 
     470        if provider_id == DO_NEODC: 
     471            i_keywords.append('Orthoimagery') 
     472        if len(i_keywords) > 0: 
     473            ceda_observation.keywords.append(createMD_Keywords(i_keywords))             
    461474     
    462475    def _create(self): 
     
    474487        self._assignPhenomenonTime(ceda_observation)         
    475488        self._assignPermission(ceda_observation)         
    476         self._assignMoles2Link(ceda_observation) 
    477         self._assignQuality(ceda_observation)                 
     489        self._assignMoles2Link(ceda_observation)                 
    478490        self._assignInternalReview(ceda_observation)         
    479491        self._assignLanguage(ceda_observation) 
    480492        self._assignUpdateFrequency(ceda_observation)     
    481         self._assignName(ceda_observation)                             
     493        self._assignName(ceda_observation)   
     494        self._assignKeywords(ceda_observation)                           
    482495        Moles3EPB.addCedaObject(ceda_observation, self._migrationSessions.molesSession, True) 
    483496         
Note: See TracChangeset for help on using the changeset viewer.