Changeset 8162


Ignore:
Timestamp:
13/03/12 16:36:03 (8 years ago)
Author:
mnagni
Message:

Small improvements to implement the observation result (still to do)

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

Legend:

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

    r8158 r8162  
    2222from html5lib import sanitizer, treebuilders 
    2323from libs.migration.authors import authors 
     24from ea_model.ceda_metadatamodel.ceda_result.ceda_result import CEDA_Result 
     25from ea_model.moles3_4.result.mo_onlineresource import MO_OnlineResource 
     26from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.url import URL 
    2427 
    2528base = '/exist/rest/atoms' 
     
    5255 
    5356#MD_Identifier codes 
    54 MD_CODE_MOLES2_CITATION = 'MOLES2_CITATION' 
     57MD_CODE_MOLES2_CITATION = 'ceda_moles2_citation' 
    5558 
    5659htmlParser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("etree"), namespaceHTMLElements=False) 
     
    229232    rel = link.get('rel') 
    230233    if rel and rel.endswith('/' + linkMarker): 
    231         if not linksDict.has_key(linkMarker): 
    232             linksDict[linkMarker] = [] 
    233         linksDict[linkMarker].append(link.get('href')) 
     234            if not linksDict.has_key(linkMarker): 
     235                linksDict[linkMarker] = [] 
     236            linksDict[linkMarker].append({'href': link.get('href'), 'title': link.get('title')}) 
     237 
     238def findDownloadsInDE(dataEntityMigration): 
     239    dataEntXML = getAtomDocumentByMO(dataEntityMigration) 
     240    linksDict = _extractDataEntityLinks(dataEntXML) 
     241    return linksDict 
    234242 
    235243def findDeploymentsInDE(dataEntityMigration): 
     
    280288        for link in linksDict[marker]: 
    281289            try: 
    282                 linkLongName = link.split('/')[-1] 
     290                linkLongName = link['href'].split('/')[-1] 
    283291                linkName = linkLongName.rsplit('__ATOM__')[1] 
    284292                dpt.append(linkName) 
     
    374382    return md_identifier 
    375383 
     384def createCEDA_Result(linkage, name = ""): 
     385    """ 
     386        Creates a new CEDA_Result 
     387        @param linkage: the CEDA_Result.source.linkage.url.??? field 
     388        @param name: the CEDA_Result.source.linkage.name field 
     389    """ 
     390    ceda_result = CEDA_Result() 
     391    on_line_resource = MO_OnlineResource() 
     392    url = URL() 
     393    #url.???? = linkage 
     394    on_line_resource.linkage = url  
     395    on_line_resource.name = name 
     396    ceda_result.source.append(on_line_resource) 
     397    return ceda_result 
     398 
    376399def createDQ_ConformanceResult(explaination = ""): 
    377400    dq_conformanceResult = DQ_ConformanceResult() 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/dataEntity.py

    r8158 r8162  
    1313from libs.migration.processor.commons import findDeploymentsInDE,\ 
    1414    createMD_Identifier, extractContent, MD_CODE_MOLES2_CITATION,\ 
    15     hasAtomDocumentSameHash 
     15    hasAtomDocumentSameHash, findDownloadsInDE 
    1616from libs.migration.processor.deployment import DeploymentProcessor 
    1717from ea_model.moles3_4.utilities.mo_publicationstatevalue import MO_PublicationStateValue 
     
    4343            DataEntityProcessor.log.info("The migration object "+ _migrationObjectDescription(self._dataEntityMigration) + " has not associated cedacat:citation") 
    4444        ceda_observationCollection.identifier.append(createMD_Identifier(title = contentDict['citation'], code = MD_CODE_MOLES2_CITATION)) 
     45     
     46    """ 
     47    def _processResult(self, ceda_observationCollection): 
     48        # TDB - Check that if is an update or not! 
     49        download = findDownloadsInDE(self._dataEntityMigration) 
     50        for dwn in download['DOWNLOAD']: 
     51            if dwn['href'].startswith('http://badc.nerc.ac.uk/browse') or dwn['href'].startswith('http://neodc.nerc.ac.uk/browse'): 
     52        ceda_observationCollection.identifier.append(createMD_Identifier(title = contentDict['citation'], code = MD_CODE_MOLES2_CITATION))                 
     53        #if not contentDict.has_key('citation'): 
     54        #    DataEntityProcessor.log.info("The migration object "+ _migrationObjectDescription(self._dataEntityMigration) + " has not associated cedacat:citation") 
     55        #ceda_observationCollection.identifier.append(createMD_Identifier(title = contentDict['citation'], code = MD_CODE_MOLES2_CITATION)) 
     56    """ 
    4557     
    4658    def _getObservationCollection(self): 
     
    7789        ceda_observationCollection = CEDA_ObservationCollection() 
    7890        self._processCitation(ceda_observationCollection) 
     91        #self._processResult(ceda_observationCollection) 
    7992        ceda_observationCollection.publicationState = MO_PublicationStateValue.cl_working 
    8093                   
     
    113126                ceda_observation = self._processDeploymentMigration(deploymentMigration, cedaObservationCollection) 
    114127                if howManydm > 1:                     
    115                     for identifier in cedaObservationCollection.identifier: 
    116                         if identifier.code == MD_CODE_MOLES2_CITATION: 
     128                    for identifier in cedaObservationCollection.identifier:                         
     129                        if hasattr(identifier, 'authority') and identifier.authority.title == MD_CODE_MOLES2_CITATION: 
    117130                            # TBD --- Here should compare if exists already 
    118131                            ceda_observation.identifier.append(identifier) 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8158 r8162  
    155155        doc_title = extractTitle(self._deploymentMigration) 
    156156         
    157         if doc_title.startswith('deployment_'): 
     157        if doc_title.startswith('deployment_') or doc_title.startswith('Deployment_'): 
    158158            doc_title = extractTitle(self._dataEntityMigration)         
    159         Moles3EPB.addIdentifierToObservation(createMD_Identifier(code = "Data from %s" % (doc_title), title = 'ceda_title'), observation, self._migrationSessions.molesSession) 
     159        Moles3EPB.addIdentifierToObservation(createMD_Identifier(code = doc_title, title = 'ceda_title'), observation, self._migrationSessions.molesSession) 
    160160 
    161161    def _assignDescription(self, observation): 
Note: See TracChangeset for help on using the changeset viewer.