source: mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment_data.py @ 8209

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment_data.py@8209
Revision 8209, 4.7 KB checked in by mnagni, 8 years ago (diff)

Complete - # 22423: CEDA Project - publicationState
 http://team.ceda.ac.uk/trac/ceda/ticket/22423

Line 
1'''
2Created on 13 Feb 2012
3
4@author: mnagni
5'''
6from libs.migration.processor.commons import findLinksInDeployment,\
7    findSubTypeInDPT, hasAtomDocumentSameHash, getAtomDocumentHashByMO,\
8    createCEDA_Processing, createCEDA_Instrument, createCEDA_Project,\
9    findSummary
10from libs.migration.MigrationEPB import MigrationEPB
11from MolesManager.moles3epb import Moles3EPB
12from ea_model.moles3_4.utilities.mo_publicationstatevalue import MO_PublicationStateValue
13
14class DeploymentDataProcessor(object):
15   
16    def __init__(self, deploymentMigration, migrationSessions):
17        self._migrationSessions = migrationSessions
18        self._deploymentMigration = deploymentMigration
19       
20    def _commitDeploymentMigration(self, associateWithCedaObservation, dataProductionTool, dataProductionToolField):
21        Moles3EPB.addCedaObject(associateWithCedaObservation, self._migrationSessions.molesSession, True)
22        setattr(dataProductionTool, dataProductionToolField, associateWithCedaObservation.id)                                 
23        self._migrationSessions.migrationSession.commit() 
24       
25    def createProject(self, links):
26        project = None
27        if links.has_key('ACTIVITY'):
28            for link in links['ACTIVITY']:
29                activity = MigrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom', self._migrationSessions.migrationSession)
30                i_abstract = findSummary(activity)
31                project = createCEDA_Project(abstract=i_abstract, publication_state=MO_PublicationStateValue.cl_working)
32                self._commitDeploymentMigration(project, activity, 'ceda_project_id')
33        return project
34       
35    def createProcess(self, links):
36        associateWithCedaObservation = None
37        hasCedaProcessing = False
38        hasCedaComposite = False
39        hasCedaAcquisition = False
40        for dpt in links['DPT']:
41            dataProductionTool = MigrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, dpt + '.atom', self._migrationSessions.migrationSession)
42           
43            #has the document changed?           
44            #if hasAtomDocumentSameHash(dataProductionTool):
45            #    dataProductionTool.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration)
46            #    self._migrationSessions.migrationSession.commit()
47            #    continue
48           
49            subType = findSubTypeInDPT(dataProductionTool)
50            if subType == 'model':
51                associateWithCedaObservation = createCEDA_Processing()
52                self._commitDeploymentMigration(associateWithCedaObservation, dataProductionTool, 'ceda_processing_id')
53                if not (hasCedaComposite or hasCedaProcessing):
54                    hasCedaProcessing = True
55                    hasCedaComposite = False
56                    hasCedaAcquisition = False 
57            else:
58                associateWithCedaObservation = createCEDA_Instrument()
59                self._commitDeploymentMigration(associateWithCedaObservation, dataProductionTool, 'ceda_instrument_id')
60               
61               
62        #if not a DPT.subType == 'model' then....
63        for obs in links['OBS']:
64            observationStation = MigrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom', self._migrationSessions.migrationSession)
65 
66            #has the document changed?           
67            #if hasAtomDocumentSameHash(observationStation):
68            #    observationStation.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration)
69            #    self._migrationSessions.migrationSession.commit()
70            #    continue                       
71           
72            subType = findSubTypeInDPT(observationStation)
73            if subType == 'satellite':
74                    associateWithCedaObservation = createCEDA_Processing()
75                    self._commitDeploymentMigration(associateWithCedaObservation, dataProductionTool, 'ceda_compositeprocess_id')   
76                    if not hasCedaComposite:
77                        hasCedaProcessing = True
78                        hasCedaComposite = False
79                        hasCedaAcquisition = False               
80            else:
81                pass
82                '''
83                associateWithCedaObservation = createCEDA_Acquisition()
84                self._commitDeploymentMigration(associateWithCedaObservation, dataProductionTool, 'ceda_acquisition_id')
85                '''               
86                if not (hasCedaComposite or hasCedaProcessing or hasCedaAcquisition):
87                    hasCedaProcessing = True
88                    hasCedaComposite = False
89                    hasCedaAcquisition = True                           
90        return associateWithCedaObservation                           
91       
Note: See TracBrowser for help on using the repository browser.