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

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

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

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