Changeset 8208


Ignore:
Timestamp:
02/04/12 17:05:03 (8 years ago)
Author:
mnagni
Message:

Complete - # 22421: CEDA Project - Abstract
 http://team.ceda.ac.uk/trac/ceda/ticket/22421

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

Legend:

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

    r8204 r8208  
    290290    return _returnNotNoneText(publishedDate) 
    291291 
     292def findSummary(resourceMigration): 
     293    """ 
     294        Returns the <entry><summary> tag of an atom document 
     295        @param resourceMigration: a MigrationObject instance 
     296        @return: the <summary> value or None if empty 
     297    """ 
     298    resourceXML = getAtomDocumentByMO(resourceMigration) 
     299    summary = resourceXML.find('%ssummary' % (atomNS)) 
     300    return _returnNotNoneText(summary) 
     301 
    292302def findID(dataEntXML): 
    293303    ent_id = dataEntXML.find('%sid' % (atomNS)) 
     
    818828    return ceda_acquisition 
    819829 
    820 def createCEDA_Project(): 
     830def createCEDA_Project(abstract = None): 
    821831    ceda_project = CEDA_Project() 
     832    if abstract: 
     833        ceda_project.abstract = abstract  
    822834    return ceda_project     
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment_data.py

    r8195 r8208  
    66from libs.migration.processor.commons import findLinksInDeployment,\ 
    77    findSubTypeInDPT, hasAtomDocumentSameHash, getAtomDocumentHashByMO,\ 
    8     createCEDA_Processing, createCEDA_Instrument, createCEDA_Project 
     8    createCEDA_Processing, createCEDA_Instrument, createCEDA_Project,\ 
     9    findSummary 
    910from libs.migration.MigrationEPB import MigrationEPB 
    1011from MolesManager.moles3epb import Moles3EPB 
     
    2526        if links.has_key('ACTIVITY'): 
    2627            for link in links['ACTIVITY']: 
    27                 activity = MigrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom', self._migrationSessions.migrationSession)             
    28                 project = createCEDA_Project() 
     28                activity = MigrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom', self._migrationSessions.migrationSession) 
     29                i_abstract = findSummary(activity) 
     30                project = createCEDA_Project(abstract=i_abstract) 
    2931                self._commitDeploymentMigration(project, activity, 'ceda_project_id') 
    3032        return project 
  • mauRepo/MolesManager/trunk/src/libs/migration/tests/moles3epbtests.py

    r8198 r8208  
    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 
    23 from libs.migration.tests.test_utils import createObservationCollection 
     23from test_utils import createObservationCollection,\ 
     24    createProject 
     25from ea_model.ceda_metadatamodel.ceda_project.ceda_project import CEDA_Project 
    2426 
    2527 
     
    9092    def checkObservationCollection(self): 
    9193        session = Moles3EPB.getNewMolesSession(); 
    92         observationCollection = self._createObservationCollection() 
     94        observationCollection = createObservationCollection() 
    9395         
    9496        self.logging.info('Stores an empty new CEDA_ObservationCollection') 
     
    185187        session.commit() 
    186188 
     189    def checkCEDA_Project(self): 
     190        session = Moles3EPB.getNewMolesSession(); 
     191        project = createProject() 
     192     
     193        self.logging.info('Stores an empty new CEDA_Project') 
     194        Moles3EPB.addCedaObject(project, session) 
     195        session.commit() 
     196         
     197        self.logging.info('Tries to retrieve it') 
     198        self.assertTrue(hasattr(project, 'id'), "Cannot create  TM_Instant")         
     199        res = Moles3EPB.search(CEDA_Project, project.id, session) 
     200        for item in res:                 
     201            self.assertTrue(item.abstract == 'test_abstract', "Cannot retrieve the abstract from stored project") 
     202         
     203        self.logging.info('Deletes it') 
     204        session.delete(project) 
     205        session.commit() 
     206     
     207 
    187208    def _createObservation(self): 
    188209        observation = CEDA_Observation() 
  • mauRepo/MolesManager/trunk/src/libs/migration/tests/test_utils.py

    r8205 r8208  
    88    createCI_Citation 
    99from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     10from ea_model.ceda_metadatamodel.ceda_project.ceda_project import CEDA_Project 
    1011 
    1112def createObservationCollection(): 
     
    3637    observation.dataLineage = "test_dataLineage"         
    3738    return observation 
     39 
     40def createProject(): 
     41    ''' 
     42        Creates a CEDA_Project with the following data: 
     43        project.abstract = 'test_abstract'                 
     44    '''     
     45    ceda_project = CEDA_Project() 
     46    ceda_project.abstract = 'test_abstract'  
     47    return ceda_project 
Note: See TracChangeset for help on using the changeset viewer.