source: mauRepo/MolesManager/trunk/src/libs/migration/processor/migrationProcess.py @ 8333

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

fixed a bug in data_entity loop

Line 
1'''
2Created on 10 Jan 2012
3
4@author: mnagni
5'''
6from libs.migration.processor.dataEntity import DataEntityProcessor
7from libs.migration.MigrationEPB import MigrationEPB
8import logging
9from logging import StreamHandler
10from libs.migration.processor.EPBRepo import EPBRepo
11
12class MigrationProcess():
13    log = logging.getLogger('MigrationProcess')
14    log.addHandler(StreamHandler())
15    log.setLevel(logging.DEBUG)
16   
17    """
18        Manages the migration process from Moles2 to Moles3.
19    """
20    def __init__(self):
21        pass
22   
23    def process(self, dataEntityObject = None):
24        """
25            Starts the migration. If no DataEntityMigration instance is given then all the DataEntityMigration objects in the
26            data_entity_migration table are processed
27            1) each DataEntityMigration is associated to a "dataent_xxxx" file, called "data entity" in Moles2
28            2) each "data entity" is associated with a CEDA_ObservationCollection
29            @param dataEntityObject: a DataEntityMigration instance to process.
30            @return: a list of collected exceptions
31        """
32        exs = []
33        data_ents = EPBRepo.migrationEPB.getDataEntityMigrationbyPath(dataEntityObject)
34        """
35        #Does the migrationObject exists?
36        if dataEntityObject:
37            data_ents.append(MigrationEPB.getDataEntityMigrationbyPath(dataEntityObject, session = self.migrationSessions.migrationSession))
38        else: #then process all the DataEntities
39            data_ents = MigrationEPB.getAllDataEntityMigration(session = self.migrationSessions.migrationSession)
40        """
41           
42        #loops over the data entities
43        for dataEntityMigration in data_ents:                         
44            dep = DataEntityProcessor(dataEntityMigration)           
45            exs.extend(dep.process())
46            MigrationProcess.log.info("Done")           
47        return exs
48       
49    def commitAll(self):
50        self._migrationSession.commit()
51        self._molesSession.commit()
52
53    def rollbackAll(self):
54        self._migrationSession.rollback()
55        self._molesSession.rollback()
Note: See TracBrowser for help on using the repository browser.