Changeset 8195 for mauRepo


Ignore:
Timestamp:
28/03/12 21:50:13 (8 years ago)
Author:
mnagni
Message:

Complete - # 22397: CEDA Observation geographicExtent
 http://team.ceda.ac.uk/trac/ceda/ticket/22397
Incomplete - # 22399: CEDA Observation - permission
 http://team.ceda.ac.uk/trac/ceda/ticket/22399
Incomplete - # 22388: CEDA Observation - inSupportOf
 http://team.ceda.ac.uk/trac/ceda/ticket/22388

Location:
mauRepo/MolesManager/trunk/src/libs/migration
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/libs/migration/db/classes.py

    r8147 r8195  
    3131        self.ceda_instrument_id = None 
    3232        self.ceda_compositeprocess_id = None 
    33         self.ceda_acquisition_id = None                         
     33        self.ceda_acquisition_id = None 
     34        self.ceda_project_id = None                                 
    3435        super(DeploymentDataMigration, self).__init__()            
  • mauRepo/MolesManager/trunk/src/libs/migration/db/migrationTables.py

    r8091 r8195  
    4444                Column('ceda_compositeprocess_id', Integer), 
    4545                Column('ceda_acquisition_id', Integer),                                                                 
     46                Column('ceda_project_id', Integer),                 
    4647                Column('doc_name', TEXT),             
    4748                Column('doc_owner', TEXT),             
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8194 r8195  
    4141from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_constraints import MD_Constraints 
    4242from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_legalconstraints import MD_LegalConstraints 
     43from ea_model.ceda_metadatamodel.ceda_project.ceda_project import CEDA_Project 
    4344 
    4445base = '/exist/rest/atoms' 
     
    7273ihost = 'bora.badc.rl.ac.uk' 
    7374iport = '8080' 
     75 
     76linkMarkers = ['Deployment', 'DOWNLOAD', 'DOCUMENTATION', 'ACCESS', 'LOGO', 'ACTIVITY', 'DPT', 'OBS'] 
    7477 
    7578#MD_Identifier codes 
     
    275278    return _returnNotNoneText(ent_id) 
    276279 
     280def _updateLinksDict(linksDict, link, linkMarker): 
     281    if not linksDict.has_key(linkMarker): 
     282        linksDict[linkMarker] = [] 
     283    rel = link.get('rel') 
     284    if rel and rel.endswith('/' + linkMarker): 
     285        linksDict[linkMarker].append({'href': link.get('href'), 'title': link.get('title')})  
     286 
    277287def _extractLinks(dataEntXML, markers): 
    278288    linksDict = {} 
     
    283293    return linksDict 
    284294 
    285 def _extractMigrationObjectLinks(dataEntXML): 
    286     markers = ['Deployment', 'DOWNLOAD', 'DOCUMENTATION', 'ACCESS', 'LOGO'] 
    287     return _extractLinks(dataEntXML, markers) 
    288  
    289 def _updateLinksDict(linksDict, link, linkMarker): 
    290     if not linksDict.has_key(linkMarker): 
    291         linksDict[linkMarker] = [] 
    292     rel = link.get('rel') 
    293     if rel and rel.endswith('/' + linkMarker): 
    294         linksDict[linkMarker].append({'href': link.get('href'), 'title': link.get('title')}) 
    295  
    296 def _findLinksInMigrationDocument(dataEntityMigration): 
     295def findLinksInMigrationDocument(dataEntityMigration): 
    297296    dataEntXML = getAtomDocumentByMO(dataEntityMigration) 
    298     linksDict = _extractMigrationObjectLinks(dataEntXML) 
     297    linksDict = _extractLinks(dataEntXML, linkMarkers) 
    299298    return linksDict 
    300299 
     
    306305        @return: a list of dictionaries 
    307306    """ 
    308     linksDict = _findLinksInMigrationDocument(migrationObject) 
     307    linksDict = findLinksInMigrationDocument(migrationObject) 
    309308    return linksDict['DOWNLOAD'] 
     309 
     310def findAccessLinksInMigrationDocument(migrationObject): 
     311    """ 
     312        Return a list of dictionaries describing a <link rel="...ACCESS..."> tag type 
     313        Each dictionary has two keys: 'href' and 'title' 
     314        @param migrationObject: the migration instance to retrieve and parse 
     315        @return: a list of dictionaries 
     316    """ 
     317    linksDict = findLinksInMigrationDocument(migrationObject) 
     318    return linksDict['ACCESS'] 
    310319 
    311320def findDOIInMigrationDocument(migrationObject): 
     
    316325        @return: a dictionary relative to the DOI, None otherwise 
    317326    """ 
    318     linksDict = _findLinksInMigrationDocument(migrationObject) 
     327    linksDict = findLinksInMigrationDocument(migrationObject) 
    319328    for link in linksDict['DOCUMENTATION']: 
    320329        if link['href'].startswith('doi:'): 
     
    323332 
    324333def findDeploymentsInDE(dataEntityMigration): 
    325     linksDict = _findLinksInMigrationDocument(dataEntityMigration) 
     334    linksDict = findLinksInMigrationDocument(dataEntityMigration) 
    326335    links = _extractLinksByMarker(linksDict, 'Deployment') 
    327336    return [depName + '.atom' for depName in links] 
     
    366375    return ret 
    367376 
    368 def findLinksInDeployment(deploymentMigration): 
     377def findLinksInDeployment(migrationObject): 
    369378    """ 
    370379        Returns a dictionary of links owned by the given dataEntity document 
    371         @param deploymentMigration: a DeploymentMigration instance 
    372         @return: a dictionary of links. The possible keys are ['ACTIVITY', 'DPT', 'OBS'] 
    373     """ 
    374     resourceXML = getAtomDocumentByMO(deploymentMigration) 
     380        @param deploymentMigration: a MigrationObject instance 
     381        @return: a dictionary of links. 
     382    """ 
    375383    links = {} 
    376     markers = ['ACTIVITY', 'DPT', 'OBS']  
    377     linksDict = _extractLinks(resourceXML, markers) 
    378     for marker in markers:     
     384    linksDict = findLinksInMigrationDocument(migrationObject) 
     385    for marker in linkMarkers:     
    379386        links[marker] = _extractLinksByMarker(linksDict, marker) 
    380387    return links 
     
    765772    ceda_acquisition = CEDA_Acquisition() 
    766773    return ceda_acquisition 
    767      
     774 
     775def createCEDA_Project(): 
     776    ceda_project = CEDA_Project() 
     777    return ceda_project     
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8194 r8195  
    1717    createCI_Contact, createCI_Address, createCI_OnlineResource,\ 
    1818    createCI_Telephone, extractMolesTemporalRange, isoDateStringToTimeDate,\ 
    19     createTM_Period, createCI_Individual 
     19    createTM_Period, createCI_Individual, findAccessLinksInMigrationDocument,\ 
     20    findLinksInDeployment 
    2021from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    2122from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    301302 
    302303    def _assignPermission(self, observation): 
     304        access_link = findAccessLinksInMigrationDocument(self._deploymentMigration) 
     305        if len(access_link) == 0: 
     306            access_link = findAccessLinksInMigrationDocument(self._dataEntityMigration)  
     307                    
    303308        contentDict = extractContent(self._deploymentMigration) 
    304309        if not contentDict.has_key('access-restricted'): 
     
    346351        else: 
    347352            #... does not exist so create it 
    348             ceda_observation = self.createNewObservation()  
     353            ceda_observation = self.createNewObservation() 
    349354         
    350355        #process the CEDA_Observation.procedure 
    351356        deploymentDataProcessor = DeploymentDataProcessor(self._deploymentMigration, self._migrationSessions) 
    352         procedure = deploymentDataProcessor.process() 
     357        links = findLinksInDeployment(self._deploymentMigration) 
     358        procedure = deploymentDataProcessor.createProcess(links) 
     359         
     360        #Temporary commented because CEDA_Project.subProject is not correctly mapped to the DB 
     361        #project = deploymentDataProcessor.createProject(links)         
     362        project = None 
    353363        if procedure: 
    354364            ceda_observation.procedure = procedure 
     365             
     366        if project: 
     367            ceda_observation.inSupportOf = project           
     368             
     369        if procedure or project:                         
    355370            self._migrationSessions.molesSession.commit() 
    356371             
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment_data.py

    r8181 r8195  
    66from libs.migration.processor.commons import findLinksInDeployment,\ 
    77    findSubTypeInDPT, hasAtomDocumentSameHash, getAtomDocumentHashByMO,\ 
    8     createCEDA_Processing, createCEDA_Instrument 
     8    createCEDA_Processing, createCEDA_Instrument, createCEDA_Project 
    99from libs.migration.MigrationEPB import MigrationEPB 
    1010from MolesManager.moles3epb import Moles3EPB 
     
    2121        self._migrationSessions.migrationSession.commit()  
    2222         
    23     def _assignProcess(self): 
    24         links = findLinksInDeployment(self._deploymentMigration) 
     23    def createProject(self, links): 
     24        project = None 
     25        if links.has_key('ACTIVITY'): 
     26            for link in links['ACTIVITY']: 
     27                activity = MigrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom', self._migrationSessions.migrationSession)             
     28                project = createCEDA_Project() 
     29                self._commitDeploymentMigration(project, activity, 'ceda_project_id') 
     30        return project 
     31         
     32    def createProcess(self, links): 
    2533        associateWithCedaObservation = None 
    2634        hasCedaProcessing = False 
     
    3139             
    3240            #has the document changed?             
    33             if hasAtomDocumentSameHash(dataProductionTool): 
    34                 dataProductionTool.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 
    35                 self._migrationSessions.migrationSession.commit() 
    36                 continue 
     41            #if hasAtomDocumentSameHash(dataProductionTool): 
     42            #    dataProductionTool.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 
     43            #    self._migrationSessions.migrationSession.commit() 
     44            #    continue 
    3745             
    3846            subType = findSubTypeInDPT(dataProductionTool) 
     
    5462  
    5563            #has the document changed?             
    56             if hasAtomDocumentSameHash(observationStation): 
    57                 observationStation.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 
    58                 self._migrationSessions.migrationSession.commit() 
    59                 continue                        
     64            #if hasAtomDocumentSameHash(observationStation): 
     65            #    observationStation.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 
     66            #    self._migrationSessions.migrationSession.commit() 
     67            #    continue                        
    6068             
    6169            subType = findSubTypeInDPT(observationStation) 
     
    7684                    hasCedaProcessing = True 
    7785                    hasCedaComposite = False 
    78                     hasCedaAcquisition = True 
    79                      
     86                    hasCedaAcquisition = True                             
     87        return associateWithCedaObservation                             
    8088         
    81         return associateWithCedaObservation                    
    82          
    83     def process(self): 
    84         return self._assignProcess()          
    85          
Note: See TracChangeset for help on using the changeset viewer.