Changeset 8488


Ignore:
Timestamp:
07/08/12 11:14:39 (7 years ago)
Author:
mnagni
Message:

Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534

Location:
mauRepo/MolesManager/trunk
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/forms/date.py

    r8486 r8488  
    1414 
    1515def createForm(obj = None, mapper = None): 
    16     #mvh = MapperViewHelper() 
    17     #return mvh.fillMapperView(obj, mapper) 
    18  
    1916    form = Model2Form(obj, mapper) 
    2017    return type('CoreForm', (CoreForm,), form._createFields())   
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/forms/formsFactory.py

    r8088 r8488  
    4646    return kwargs  
    4747 
    48 def createFieldInstance(clazz, fieldName, instance): 
     48def createFieldInstance(clazz, fieldName, iinstance): 
    4949    name = getTypeName(clazz) 
    5050    if (name == 'ASEnumType'): 
     
    5353        return formset_factory(createField(getTypeName(clazz.item_type)))     
    5454    elif _fieldFactory.has_key(name): 
    55         kwargs = _extractValue(fieldName, instance) 
     55        kwargs = _extractValue(fieldName, iinstance) 
    5656        return createField(name)(**kwargs) 
    5757 
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/settings.py

    r8486 r8488  
    207207 
    208208#moles3 database connection 
    209 MOLES3 = 'moles3' 
    210209#MOLES3_DB_CONNECTION = 'postgresql://user:pws@host:port/dbName' 
    211210MOLES3_DB_CONNECTION = 'PG_MOLES3_DB_CONNECTION' 
     
    216215 
    217216#moles2 to moles3 migration database connection 
    218 MIGRATION = 'migration' 
    219217#MIGRATION_DB_CONNECTION = 'postgresql://user:pws@host:port/dbName' 
    220218MIGRATION_DB_CONNECTION = 'PG_MIGRATION_DB_CONNECTION' 
     
    225223INFO_DB_CONNECTION = 'PG_INFO_DB_CONNECTION' 
    226224 
     225if os.environ.has_key('MIGRATION_DB_CONNECTION'): 
     226    MIGRATION_DB_CONNECTION = os.environ['MIGRATION_DB_CONNECTION']    
     227     
     228if os.environ.has_key('MOLES3_DB_CONNECTION'): 
     229    MOLES3_DB_CONNECTION = os.environ['MOLES3_DB_CONNECTION'] 
     230     
     231if os.environ.has_key('INFO_DB_CONNECTION'): 
     232    INFO_DB_CONNECTION = os.environ['INFO_DB_CONNECTION']  
    227233 
    228234RUN_MIGRATION = False 
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/settings_local.py

    r8484 r8488  
    22# Override settings.py for local configuration here 
    33# 
    4 MOLES3_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
    5 MIGRATION_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
    6 INFO_DB_CONNECTION = 'postgresql://cedainfo:ler239b@bora.badc.rl.ac.uk:5432/cedainfo' 
     4#MOLES3_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
     5#MIGRATION_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
     6#INFO_DB_CONNECTION = 'postgresql://cedainfo:ler239b@bora.badc.rl.ac.uk:5432/cedainfo' 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/MigrationEPB.py

    r8486 r8488  
    55''' 
    66from cedaMoles.libs.migration.db.classes import DeploymentDataMigration, DataEntityMigration,\ 
    7     DeploymentsMigration 
     7    DeploymentsMigration, MigrationObject 
    88from sqlalchemy.sql.expression import asc 
    99from cedaMoles.libs.epb import EPB 
     
    4343 
    4444    def getAllDeploymentsMigrationByDataEntitySortedByDate(self, dataEntity, deploymentNames): 
    45         return EPB.getAllObjects(DeploymentsMigration, self._session).filter(DeploymentsMigration.doc_name.in_(deploymentNames)).order_by(asc("doc_creation")).all() 
     45        return EPB.getAllObjects(DeploymentsMigration, self._session).filter(MigrationObject.doc_name.in_(deploymentNames)).order_by(asc("doc_creation")).all() 
    4646 
    4747    def _getMigrationObject(self, mo_type, doc_status, doc_owner, doc_name): 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/db/classes.py

    r8195 r8488  
    1717        self.data_ent_id = None     
    1818        self.ceda_observation_coll_id = None 
    19         super(DataEntityMigration, self).__init__() 
     19        super(DataEntityMigration, self).__init__(self) 
    2020 
    21 class DeploymentsMigration(object): 
     21class DeploymentsMigration(MigrationObject): 
    2222    def __init__(self):         
    2323        self.depl_id = None 
    2424        self.ceda_observation_id = None         
    25         super(DeploymentsMigration, self).__init__() 
     25        super(DeploymentsMigration, self).__init__(self) 
    2626         
    27 class DeploymentDataMigration(object): 
     27class DeploymentDataMigration(MigrationObject): 
    2828    def __init__(self):                      
    2929        self.deployment_data_id = None 
     
    3333        self.ceda_acquisition_id = None 
    3434        self.ceda_project_id = None                                 
    35         super(DeploymentDataMigration, self).__init__()            
     35        super(DeploymentDataMigration, self).__init__(self)            
  • mauRepo/MolesManager/trunk/cedaMoles/tests/cedamolestest.py

    r8487 r8488  
    1919            self.epbRepo = CedaMolesTest.epbRepo 
    2020            return 
    21                  
    22         migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT, sql_echo=True)       
     21                         
     22        migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT, sql_echo=True)              
    2323        molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, sql_echo=True, session_event_manager=EVENTS_DB)                          
    2424        infoDB = DbManager(INFO_DB_CONNECTION) 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/migration/moles3epbtests.py

    r8486 r8488  
    55''' 
    66import unittest 
    7 from cedaMoles.MolesManager.moles3epb import Moles3EPB, Moles3EPBFactory 
    8 from cedaMoles.libs.commons_db import DbManager 
    9 from unittest import TestCase 
    107import logging, datetime 
    118from logging import StreamHandler 
     
    1916from test_utils import createObservationCollection,\ 
    2017    createProject   
    21 from cedaMoles.libs.migration.processor.EPBRepo import EPBRepo 
    22 from cedaMoles.tests.testconfig import MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, EVENTS_DB 
    23  
    24  
    25 class Moles3EPBTest(TestCase): 
    26  
    27     def setUp(self): 
    28         molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, sql_echo=True, session_event_manager=EVENTS_DB) 
    29         #molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, session_event_manager=EVENTS_DB)          
    30          
    31         moles3Factory = Moles3EPBFactory(molesDB) 
    32  
    33         self.epbRepo = EPBRepo(moles3Factory.createEPB() , \ 
    34                                None, \ 
    35                                None) 
    36         self.logging = logging.getLogger('Moles3EPBTest') 
    37         self.logging.addHandler(StreamHandler()) 
    38         self.logging.setLevel(logging.DEBUG) 
    39  
    40     def tearDown(self): 
    41         pass 
    42         #self._dropAllTables() 
     18from cedaMoles.tests.testconfig import EVENTS_DB 
     19from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 
     20from cedaMoles.tests.cedamolestest import CedaMolesTest 
     21from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     22from ea_model.ceda_metadatamodel.ceda_project.ceda_project import CEDA_Project 
     23 
     24 
     25class Moles3EPBTest(CedaMolesTest): 
    4326 
    4427    def runTest(self): 
     
    5336 
    5437    def checkEmptyObservationCollection(self): 
    55         session = Moles3EPB.getNewMolesSession(); 
    5638        observationCollection = createObservationCollection() 
    5739         
    5840        self.logging.info('Stores an empty new CEDA_ObservationCollection') 
    59         Moles3EPB.persistInstance(observationCollection, session) 
    60         session.commit() 
     41        self.epbRepo.moles3EPB.persistInstance(observationCollection) 
    6142         
    6243        self.logging.info('Tries to retrieve it') 
    6344        self.assertTrue(hasattr(observationCollection, 'id'), "Cannot create  ObservationCollection")         
    64         res = Moles3EPB.search(CEDA_ObservationCollection, observationCollection.id, session) 
    65         self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    66          
    67         self.logging.info('Deletes it') 
    68         session.delete(observationCollection) 
    69         session.commit() 
     45        res = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, observationCollection.id) 
     46        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     47         
     48        self.logging.info('Deletes it') 
     49        self.epbRepo.moles3EPB.delete(observationCollection)         
    7050         
    7151    def checkEmptyObservation(self): 
    72         session = Moles3EPB.getNewMolesSession(); 
    7352        observation = CEDA_Observation() 
    7453         
    7554        self.logging.info('Tries to stores an empty new %s' % (observation.__class__.__name__)) 
    76         Moles3EPB.persistInstance(observation, session) 
    77         self.assertRaises(IntegrityError, session.commit) 
     55        self.epbRepo.moles3EPB.persistInstance(observation) 
     56        #self.assertRaises(IntegrityError, session.commit) 
    7857        self.logging.info('Catches that Ceda_Observation.dataLineage is missing') 
    79         session.rollback() 
    8058         
    8159        self.logging.info('Adds the dataLineage and tries to store it again') 
    8260        observation.dataLineage = "aNewDataLineage"         
    83         Moles3EPB.persistInstance(observation, session)         
    84         session.commit()         
     61        self.epbRepo.moles3EPB.persistInstance(observation)                 
    8562         
    8663        self.logging.info('Tries to retrieve it') 
    8764        self.assertTrue(hasattr(observation, 'id'), 'Cannot create %s' % (observation.__class__.__name__))         
    88         res = Moles3EPB.search(CEDA_Observation, observation.id, session) 
    89         self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    90          
    91         self.logging.info('Deletes it') 
    92         session.delete(observation) 
    93         session.commit() 
     65        res = self.epbRepo.moles3EPB.search(CEDA_Observation, observation.id) 
     66        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     67         
     68        self.logging.info('Deletes it') 
     69        self.epbRepo.moles3EPB.delete(observation) 
    9470 
    9571    def checkObservationCollection(self): 
    96         session = Moles3EPB.getNewMolesSession(); 
    9772        observationCollection = createObservationCollection() 
    9873         
    9974        self.logging.info('Stores an empty new CEDA_ObservationCollection') 
    100         Moles3EPB.persistInstance(observationCollection, session) 
    101         session.commit() 
     75        self.epbRepo.moles3EPB.persistInstance(observationCollection) 
    10276         
    10377        self.logging.info('Tries to retrieve it') 
    10478        self.assertTrue(hasattr(observationCollection, 'id'), "Cannot create  ObservationCollection")         
    105         res = Moles3EPB.search(CEDA_ObservationCollection, observationCollection.id, session) 
     79        res = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, observationCollection.id) 
    10680        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    10781         
     
    11185        secondObservation = self._createObservation() 
    11286        observationCollection.member.append(secondObservation)      
    113         session.commit() 
    114          
    115         self.assertTrue(Moles3EPB.observationCollectionHasObservation(observationCollection.id, firstObservation.id, session), "The collection should contains the given observation") 
    116          
    117         self.logging.info('Deletes it') 
    118         session.delete(observationCollection) 
    119         session.commit() 
     87         
     88        self.assertTrue(self.epbRepo.moles3EPB.observationCollectionHasObservation(observationCollection.id, firstObservation.id), "The collection should contains the given observation") 
     89         
     90        self.logging.info('Deletes it') 
     91        self.epbRepo.moles3EPB.delete(observationCollection) 
    12092 
    12193    def checkObservation(self): 
    122         session = Moles3EPB.getNewMolesSession(); 
    12394        observation = self._createObservation() 
    12495         
    12596        self.logging.info('Tries to stores a new %s' % (observation.__class__.__name__)) 
    126         Moles3EPB.persistInstance(observation, session)         
    127         session.commit()         
     97        self.epbRepo.moles3EPB.persistInstance(observation)                 
    12898         
    12999        self.logging.info('Tries to retrieve it') 
    130100        self.assertTrue(hasattr(observation, 'id'), 'Cannot create %s' % (observation.__class__.__name__))         
    131         res = Moles3EPB.search(CEDA_Observation, observation.id, session) 
    132         self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    133          
    134         self.logging.info('Deletes it') 
    135         session.delete(observation) 
    136         session.commit() 
     101        res = self.epbRepo.moles3EPB.search(CEDA_Observation, observation.id) 
     102        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     103         
     104        self.logging.info('Deletes it') 
     105        self.epbRepo.moles3EPB.delete(observation) 
    137106 
    138107    def checkCI_Date(self): 
    139         session = Moles3EPB.getNewMolesSession(); 
     108        session = self.epbRepo.moles3EPB.getNewMolesSession(); 
    140109        py_date = datetime.date(2011, 4, 1) 
    141110        dt = createDate(py_date) 
     
    143112         
    144113        self.logging.info('Stores an empty new CEDA_ObservationCollection') 
    145         Moles3EPB.persistInstance(ci_date, session) 
    146         session.commit() 
     114        self.epbRepo.moles3EPB.persistInstance(ci_date) 
    147115         
    148116        self.logging.info('Tries to retrieve it') 
    149117        self.assertTrue(hasattr(ci_date, 'id'), "Cannot create  CI_Date")         
    150         res = Moles3EPB.search(CI_Date, ci_date.id, session) 
    151         self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    152          
    153         self.logging.info('Deletes it') 
    154         session.delete(ci_date) 
    155         session.commit() 
     118        res = self.epbRepo.moles3EPB.search(CI_Date, ci_date.id) 
     119        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     120         
     121        self.logging.info('Deletes it') 
     122        self.epbRepo.moles3EPB.delete(ci_date) 
    156123 
    157124    def checkTM_Position(self): 
    158         session = Moles3EPB.getNewMolesSession(); 
    159125        tm_position = self._createTM_Position() 
    160126         
    161127        self.logging.info('Stores an empty new TM_Position') 
    162         Moles3EPB.persistInstance(tm_position, session) 
    163         session.commit() 
     128        self.epbRepo.moles3EPB.persistInstance(tm_position) 
    164129         
    165130        self.logging.info('Tries to retrieve it') 
    166131        self.assertTrue(hasattr(tm_position, 'id'), "Cannot create  TM_Position")         
    167         res = Moles3EPB.search(TM_Position, tm_position.id, session) 
    168         self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    169          
    170         self.logging.info('Deletes it') 
    171         session.delete(tm_position) 
    172         session.commit()         
    173  
    174  
    175     def checkTM_Instant(self): 
    176         session = Moles3EPB.getNewMolesSession();         
     132        res = self.epbRepo.moles3EPB.search(TM_Position, tm_position.id) 
     133        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     134         
     135        self.logging.info('Deletes it') 
     136        self.epbRepo.moles3EPB.delete(tm_position)         
     137 
     138 
     139    def checkTM_Instant(self):         
    177140        tm_instant = self._createTM_Instant() 
    178141 
    179142        self.logging.info('Stores an empty new TM_Instant') 
    180         Moles3EPB.persistInstance(tm_instant, session) 
    181         session.commit() 
     143        self.epbRepo.moles3EPB.persistInstance(tm_instant) 
    182144         
    183145        self.logging.info('Tries to retrieve it') 
    184146        self.assertTrue(hasattr(tm_instant, 'id'), "Cannot create  TM_Instant")         
    185         res = Moles3EPB.search(TM_Instant, tm_instant.id, session) 
    186         self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
    187          
    188         self.logging.info('Deletes it') 
    189         session.delete(tm_instant) 
    190         session.commit() 
     147        res = self.epbRepo.moles3EPB.search(TM_Instant, tm_instant.id) 
     148        self.assertNotEqual(res, None, "Cannot retrieve the stored instance") 
     149         
     150        self.logging.info('Deletes it') 
     151        self.epbRepo.moles3EPB.delete(tm_instant) 
    191152 
    192153    def checkCEDA_Project(self): 
    193         session = Moles3EPB.getNewMolesSession(); 
    194154        project = createProject() 
    195155     
    196156        self.logging.info('Stores an empty new CEDA_Project') 
    197         Moles3EPB.persistInstance(project, session) 
    198         session.commit() 
     157        self.epbRepo.moles3EPB.persistInstance(project) 
    199158         
    200159        self.logging.info('Tries to retrieve it') 
    201160        self.assertTrue(hasattr(project, 'id'), "Cannot create  TM_Instant")         
    202         res = Moles3EPB.search(CEDA_Project, project.id, session) 
     161        res = self.epbRepo.moles3EPB.search(CEDA_Project, project.id) 
    203162        for item in res:                 
    204163            self.assertTrue(item.abstract == 'test_abstract', "Cannot retrieve the abstract from stored project") 
    205164         
    206165        self.logging.info('Deletes it') 
    207         session.delete(project) 
    208         session.commit() 
    209      
    210     def checkCI_Responsibility(self): 
    211         session = Moles3EPB.getNewMolesSession(); 
    212         EVENTS_DB(session)         
     166        self.epbRepo.moles3EPB.delete(project) 
     167     
     168    ''' 
     169    def checkCI_Responsibility(self):         
    213170        responsibility = createCI_Responsibility() 
    214171        self.logging.info('Stores an empty new CEDA_Project') 
    215         Moles3EPB.persistInstance(responsibility, session) 
    216         session.commit() 
    217         session.expunge(responsibility) 
     172        self.epbRepo.moles3EPB.persistInstance(responsibility) 
     173        self.epbRepo.moles3EPB.expunge(responsibility) 
    218174         
    219175        ci_individual_2 = createCI_Individual('individual_2') 
    220176        responsibility.party.append(ci_individual_2) 
    221         session.merge(responsibility, cascade="merge")         
    222         session.commit()         
     177        #session.merge(responsibility, cascade="merge")         
     178        #session.commit()         
    223179         
    224180        for item in responsibility.party: 
     
    226182                responsibility.party.remove(item) 
    227183                 
    228         session.merge(responsibility) 
    229         session.commit()         
     184        #session.merge(responsibility) 
     185        #session.commit()         
    230186        print responsibility 
    231         session.refresh(responsibility) 
    232         session.delete(responsibility) 
    233         session.commit()         
    234          
     187        #session.refresh(responsibility) 
     188        #session.delete(responsibility) 
     189        #session.commit()         
     190    '''     
    235191 
    236192    def _createObservation(self): 
     
    255211        tm_position = self._createTM_Position()         
    256212        return createTM_Instant(tm_position) 
    257  
    258 if __name__ == "__main__": 
    259     #import sys;sys.argv = ['', 'Test.testName'] 
    260     unittest.main() 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/testconfig.py

    r8486 r8488  
    3232''' 
    3333 
    34 MIGRATION_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
    35 MOLES3_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
    36 INFO_DB_CONNECTION = 'postgresql://cedainfo:ler239b@bora.badc.rl.ac.uk:5432/cedainfo' 
     34#MIGRATION_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
     35#MOLES3_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3_dev1' 
     36#INFO_DB_CONNECTION = 'postgresql://cedainfo:ler239b@bora.badc.rl.ac.uk:5432/cedainfo' 
     37 
     38import os 
     39 
     40MIGRATION_DB_CONNECTION = '' 
     41MOLES3_DB_CONNECTION = '' 
     42INFO_DB_CONNECTION = '' 
     43 
     44if os.environ.has_key('MIGRATION_DB_CONNECTION'): 
     45    MIGRATION_DB_CONNECTION = os.environ['MIGRATION_DB_CONNECTION']    
     46     
     47if os.environ.has_key('MOLES3_DB_CONNECTION'): 
     48    MOLES3_DB_CONNECTION = os.environ['MOLES3_DB_CONNECTION'] 
     49     
     50if os.environ.has_key('INFO_DB_CONNECTION'): 
     51    INFO_DB_CONNECTION = os.environ['INFO_DB_CONNECTION']              
    3752 
    3853from cedaMoles.libs.migration.db.migrationTables import doTables as doMigration 
  • mauRepo/MolesManager/trunk/setup.py

    r8486 r8488  
    3232                        'html5lib==0.95', \ 
    3333                        'ceda-moles-model==0.1.5', 
    34                         'psycopg2'], 
     34                        'psycopg2', 
     35                        'nose'], 
    3536) 
    3637 
Note: See TracChangeset for help on using the changeset viewer.