Changeset 8358
- Timestamp:
- 17/06/12 15:40:15 (9 years ago)
- Location:
- mauRepo/MolesManager/trunk/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/MolesManager/trunk/src/MolesManager/moles3epb.py
r8350 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 10 Jan 2012 3 30 … … 5 32 ''' 6 33 from libs.epb import EPB 7 from libs.migration.exception.exceptions import NoDBManager8 34 from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 9 35 from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation … … 127 153 @param instance: an instance of CEDA_Observation os CEDA_ObservationCollection 128 154 """ 129 if instance is None :155 if instance is None or not hasattr(instance, 'id'): 130 156 return None 131 157 if type(instance) == CEDA_ObservationCollection: -
mauRepo/MolesManager/trunk/src/MolesManager/molesSessionMiddleware.py
r8351 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 9 Jan 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from MolesManager.moles3epb import Moles3EPBFactory … … 12 39 from libs.migration.InfodbEPB import InfodbEPBFactory 13 40 from libs.migration.MigrationEPB import MigrationEPBFactory 14 from sqlalchemy .exc import SQLAlchemyError41 from sqlalchemy import exc 15 42 from django.core.context_processors import csrf 16 43 from django.shortcuts import render_to_response … … 49 76 self._migration() #see the note on MolesSessionMiddleware._migration 50 77 51 """52 def _getMolesSession(self):53 '''54 @deprecated: db session is going to be removed from all GUI-related instances55 '''56 if not MolesSessionMiddleware._epbInitialized:57 self._doInitialization()58 59 return self._getNewMolesSession()60 """61 62 78 def _migration(self, runMigration = RUN_MIGRATION): 63 79 if runMigration and not MolesSessionMiddleware._migrationThread.isAlive(): 64 80 #t.setDaemon(False) 65 81 MolesSessionMiddleware._migrationThread.start() 66 67 """ 68 Represents the access to the Moles database. 69 Creates from the existing db connections pools a new session 70 to be used by all the DB operations involved in the actual HTTPRequest 71 """ 72 82 73 83 def process_request(self, request): 74 84 try: … … 77 87 78 88 request.moles3EPB = MolesSessionMiddleware._moles3EPBFactory.createEPB() 79 except SQLAlchemyError as ex: 80 MolesSessionMiddleware._epbInitialized = False 81 return self.process_exception(request, ex) 89 except exc.DBAPIError, e: 90 # an exception is raised, Connection is invalidated. 91 #if e.connection_invalidated: 92 # print "Connection was invalidated!" 93 return self.process_exception(request, e) 82 94 83 95 def process_response(self, request, response): … … 88 100 89 101 def process_exception(self, request, exception): 90 try: 91 c = {} 92 c['exception'] = exception 93 c.update(csrf(request)) 94 return render_to_response('errorTemplate.html', c) 95 except SQLAlchemyError as ex: 96 MolesSessionMiddleware._epbInitialized = False 97 102 c = {} 103 c['exception'] = exception 104 c.update(csrf(request)) 105 return render_to_response('errorTemplate.html', c) -
mauRepo/MolesManager/trunk/src/libs/commons_db.py
r8344 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 17 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from sqlalchemy import MetaData, create_engine 7 from sqlalchemy.orm import sessionmaker , scoped_session34 from sqlalchemy.orm import sessionmaker 8 35 from sqlalchemy.sql.expression import text 9 36 class DbManagerCollection(object): … … 25 52 Represents a database instance managed by an SQLAlchemy engine. 26 53 """ 27 def __init__(self, connection, script = None, sql_echo=False, session_event_manager = None ):54 def __init__(self, connection, script = None, sql_echo=False, session_event_manager = None, ipool_size = 10): 28 55 """ 29 56 @param connection: the URL used to open a connection to the database … … 31 58 @param sql_echo: sets the SQLalchemy create_engine.echo param. Default is False 32 59 @param session_event_manager: a python method defining session events \ 33 (see http://docs.sqlalchemy.org/en/latest/orm/events.html?highlight=session%20events#sqlalchemy.orm.events.SessionEvents) 60 (see http://docs.sqlalchemy.org/en/latest/orm/events.html?highlight=session%20events#sqlalchemy.orm.events.SessionEvents) 61 @param ipool_size: sets the connections pool size (note that this is the maximum size not the number of the pre-allocated ones) 34 62 """ 35 63 self._connection = connection 36 64 self._script = script 37 self.engine = None 38 try: 39 self.engine = create_engine(self._connection, echo=sql_echo) 40 except Exception as e: 41 print e 65 self.engine = create_engine(self._connection, pool_size = ipool_size, pool_recycle=3600, echo=sql_echo) 42 66 self.metadata = MetaData(bind=self.engine) 43 67 self._session = None … … 46 70 self._script(self.metadata) 47 71 self.metadata.create_all(bind=self.engine) 48 #self._session = scoped_session(sessionmaker())49 72 if self.engine: 50 73 self.engine.connect() … … 55 78 @return: a sqlalchemy.orm.session.Session instance if the ORM is fully configured, otherwise a sqlalchemy.engine.base.Connection instance 56 79 """ 57 #session = scoped_session(sessionmaker(bind=self.engine))()58 80 session = sessionmaker(bind=self.engine)() 59 81 if self._session_event_manager: 60 82 self._session_event_manager(session) 61 83 return session 62 #if self._session:63 # ret = self._session()64 # if self._session_event_manager:65 # self._session_event_manager(ret)66 # return ret67 #if self.engine:68 # return self.engine.connect()69 84 70 85 def closeDbSession(self, dbSession): … … 84 99 t = text(sqlNative) 85 100 return self._connection.execute(t) 101 102 class NoDBManager(Exception): 103 def __init__(self, value): 104 self.value = value 105 def __str__(self): 106 return "No DBManager has been set for %s" % (self.value) 86 107 87 108 def doInsertOrUpdate(items, session, update = True): -
mauRepo/MolesManager/trunk/src/libs/epb.py
r8344 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 10 Jan 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from sqlalchemy.orm import subqueryload -
mauRepo/MolesManager/trunk/src/libs/migration/client.py
r8334 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 9 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from libs.migration.processor.loadResources import LoadResources … … 22 49 23 50 def __init__(self, moles3EPB, migrationEPB, infodbEPB, interval=600): 24 EPBRepo.moles3EPB = moles3EPB 25 EPBRepo.migrationEPB = migrationEPB 26 EPBRepo.infodbEPB = infodbEPB 51 self.epbRepo = EPBRepo(moles3EPB, migrationEPB, infodbEPB) 27 52 28 53 threading.Thread.__init__(self) … … 47 72 48 73 def _migrate(self): 49 lr = LoadResources( )74 lr = LoadResources(self.epbRepo) 50 75 ex = lr.process() 51 76 for e in ex: 52 77 print e 53 78 54 mp = MigrationProcess( )79 mp = MigrationProcess(self.epbRepo) 55 80 ex = mp.process() 56 81 for e in ex: -
mauRepo/MolesManager/trunk/src/libs/migration/exception/exceptions.py
r8269 r8358 12 12 except Exception as ex: 13 13 print ex 14 15 class NoDBManager(Exception):16 def __init__(self, value):17 self.value = value18 def __str__(self):19 return "No DBManager has been set for %s" % (self.value)20 14 21 15 class NoCreationDate(Exception): -
mauRepo/MolesManager/trunk/src/libs/migration/processor/EPBRepo.py
r8326 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 1 Jun 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 class EPBRepo(object): 7 moles3EPB = None 8 migrationEPB = None 9 infodbEPB = None 34 35 def __init__(self, moles3EPB, migrationEPB, infodbEPB): 36 self.moles3EPB = moles3EPB 37 self.migrationEPB = migrationEPB 38 self.infodbEPB = infodbEPB 39 40 41 -
mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py
r8323 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 15 Nov 2011 3 30 … … 143 170 return calculateHash(text) 144 171 145 def hasAtomDocumentSameHash(migrationObject): 172 def hasMOBeenProcessed(migrationObject): 173 ''' 174 Checks if a migration object has been already processed. 175 @param migrationObject: an instance of DataEntityMigration or DeploymentsMigration 176 @return True if has been processed, otherwise False 177 ''' 178 if migrationObject is None: 179 return False 180 181 if not hasattr(migrationObject, 'doc_hash'): 182 return False 183 else: 184 if migrationObject.doc_hash is None: 185 return False 186 187 return True 188 189 def hasMOSameHash(migrationObject): 190 ''' 191 Checks if a migration object has changed. 192 @param migrationObject: an instance of DataEntityMigration or DeploymentsMigration or DeploymentDataMigration 193 @return True if the hash of the actual document is the same of the migrationObject, otherwise False 194 ''' 195 if not hasMOBeenProcessed(migrationObject): 196 return False 146 197 return getAtomDocumentHashByMO(migrationObject) == migrationObject.doc_hash 147 198 … … 786 837 return md_metadata 787 838 788 def createMO_OnlineResource(linkage, name = None, function = None, description = None, applicationProfile = None):839 def createMO_OnlineResource(linkage, instance = None, name = None, function = None, description = None, applicationProfile = None): 789 840 """ 790 841 Creates a new CEDA_Result … … 795 846 @param applicationProfile: the MO_OnlineResource.applicationProfile field 796 847 """ 797 on_line_resource = MO_OnlineResource() 848 if instance is None: 849 on_line_resource = MO_OnlineResource() 850 798 851 on_line_resource.linkage = linkage 799 if name :852 if name and on_line_resource.name != name: 800 853 on_line_resource.name = name 801 if function :854 if function and on_line_resource.function != function: 802 855 on_line_resource.function = function 803 if description :856 if description and on_line_resource.description != description: 804 857 on_line_resource.description = description 805 if applicationProfile :858 if applicationProfile and on_line_resource.applicationProfile != applicationProfile: 806 859 on_line_resource.applicationProfile = applicationProfile 807 860 return on_line_resource -
mauRepo/MolesManager/trunk/src/libs/migration/processor/dataEntity.py
r8351 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 15 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 from MolesManager.moles3epb import Moles3EPB7 33 from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import \ 8 34 CEDA_ObservationCollection 9 from libs.migration.MigrationEPB import MigrationEPB10 35 from libs.migration.exception.exceptions import MigrationObjectException, NoAssociatedAuthor,\ 11 36 migrationObjectDescription, NoAssociatedDeployments 12 37 from libs.migration.processor.commons import findDeploymentsInDE,\ 13 38 createMD_Identifier, extractContent,\ 14 has AtomDocumentSameHash, createCI_Citation, createCI_Date, findPublishedDate,\39 hasMOSameHash, createCI_Citation, createCI_Date, findPublishedDate,\ 15 40 isoDateTimeStringToTimeDate, findUpdatedDate, createDate,\ 16 calculateHash, extractUpdateFrequency,findDOIInMigrationDocument,\17 getAtomDocumentHash41 calculateHash, findDOIInMigrationDocument,\ 42 hasMOBeenProcessed, getAtomDocumentHashByMO 18 43 from libs.migration.processor.deployment import DeploymentProcessor 19 44 from ea_model.moles3_4.utilities.mo_publicationstatevalue import MO_PublicationStateValue … … 22 47 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 23 48 from MolesManager.ceda_guid import CedaGUID 24 from ea_model.iso_19115_2006_metadata_corrigendum.maintenance_information.md_maintenancefrequencycode import MD_MaintenanceFrequencyCode25 from libs.migration.processor.EPBRepo import EPBRepo26 49 27 50 class DataEntityProcessor(object): … … 32 55 Processes a DataEntityMigration item. Note that each DataEntity is associated to a "dataent_xxxx" file in Moles2 33 56 ''' 34 def __init__(self, dataEntityMigration ):57 def __init__(self, dataEntityMigration, epbRepo): 35 58 ''' 36 59 Initializes the class 37 60 @param _dataEntityMigration: the DataEntityMigration instance 61 @param epbRepo: an instance of EPBRepo 38 62 ''' 39 if dataEntityMigration is None: 40 raise MigrationObjectException("DataEntityProcessor cannot process an None item") 41 self._dataEntityMigration = dataEntityMigration 63 #if dataEntityMigration is None: 64 # raise MigrationObjectException("DataEntityProcessor cannot process an None item") 65 self._dataEntityMigration = dataEntityMigration 66 self._dataEntityHasSameHash = hasMOSameHash(self._dataEntityMigration) 67 self.epbRepo = epbRepo 42 68 43 69 def _processCitation(self, ceda_observationCollection): 44 # TDB - Check that if is an update or not!45 70 contentDict = extractContent(self._dataEntityMigration) 46 71 if not contentDict.has_key('citation'): … … 62 87 newIdentifier = createMD_Identifier(code = contentDict['citation'], authority=i_citation) 63 88 ceda_observationCollection.identifier.append(newIdentifier) 64 65 def _getObservationCollection(self):66 return EPBRepo.moles3EPB.search(CEDA_ObservationCollection, self._dataEntityMigration.ceda_observation_coll_id)67 68 def _processObservationCollection(self):69 #Moles3 object exists...70 if self._dataEntityMigration.ceda_observation_coll_id:71 # ...and the data entity document has not changed72 if hasAtomDocumentSameHash(self._dataEntityMigration):73 return self._getObservationCollection()74 else:75 self.updateObservationCollection()76 89 77 #... does not exist so create it 78 return self.createNewObservationCollection() 79 80 def updateObservationCollection(self): 81 """ 82 Updated the existing CEDA_ObservationCollection instance binded to the self._dataEntityMigration object. 83 @return: the persisted and updated CEDA_ObservationCollection element 84 """ 85 ceda_observationCollection = self._getObservationCollection() 86 # TBD 87 #self._processCitation(ceda_observationCollection) 88 return ceda_observationCollection 89 90 def _update(self): 91 # ...and the data entity document has not changed 92 if hasAtomDocumentSameHash(self._dataEntityMigration): 93 return self._getObservationCollection() 94 else: 95 return self.updateObservationCollection() 96 97 def _create(self): 90 def _execute(self, ceda_observationCollection): 98 91 """ 99 92 Creates a new CEDA_ObservationCollection instance in the Moles3DB using the self._dataEntityMigration object. … … 101 94 @return: the persisted CEDA_ObservationCollection element 102 95 """ 103 ceda_observationCollection = CEDA_ObservationCollection() 104 self._processCitation(ceda_observationCollection) 105 #self._processResult(ceda_observationCollection) 106 ceda_observationCollection.publicationState = MO_PublicationStateValue.cl_working 107 108 EPBRepo.moles3EPB.persistInstance(ceda_observationCollection) 109 EPBRepo.migrationEPB.updateMigrationObject(self._dataEntityMigration, {'ceda_observation_coll_id': ceda_observationCollection.id}) 96 if not self._dataEntityHasSameHash: 97 self._processCitation(ceda_observationCollection) 98 #self._processResult(ceda_observationCollection) 99 100 #Is a first time process? 101 if not hasMOBeenProcessed(self._dataEntityMigration): 102 docHash = getAtomDocumentHashByMO(self._dataEntityMigration) 103 ceda_observationCollection.publicationState = MO_PublicationStateValue.cl_working 104 self.epbRepo.moles3EPB.persistInstance(ceda_observationCollection) 105 self.epbRepo.migrationEPB.updateMigrationObject(self._dataEntityMigration, \ 106 {'ceda_observation_coll_id': ceda_observationCollection.id, \ 107 'doc_hash': docHash}) 110 108 109 #Has to updated the hash? 110 if not self._dataEntityHasSameHash and hasMOBeenProcessed(self._dataEntityMigration): 111 docHash = getAtomDocumentHashByMO(self._dataEntityMigration) 112 self.epbRepo.migrationEPB.updateMigrationObject(self._dataEntityMigration, \ 113 {'doc_hash': docHash}) 111 114 112 #Adds the CedaGUID 113 ceda_guid = CedaGUID() 114 ceda_guid.id = calculateHash(self._dataEntityMigration.data_ent_id) 115 ceda_guid.ceda_observationcollection = ceda_observationCollection.id 116 EPBRepo.moles3EPB.persistInstance(ceda_guid) 117 DataEntityProcessor.log.info("GUID for this ObservationCollection: %s" % (ceda_guid.id)) 118 119 return ceda_observationCollection 120 121 def _processResultAccumulation(self, ceda_observation): 122 ceda_observation = EPBRepo.moles3EPB.loadAttributes(ceda_observation, "resultAccumulation") 123 if ceda_observation.resultAccumulation is None: 124 updateFrequency = extractUpdateFrequency(self._dataEntityMigration) 125 if updateFrequency: 126 resultAccumulation = MD_MaintenanceFrequencyCode.from_string(updateFrequency) 127 EPBRepo.moles3EPB.updateCedaObject(ceda_observation, {'resultAccumulation': resultAccumulation}) 115 #Has a proper CEDAGUID? 116 if self.epbRepo.moles3EPB.retrieveGUIDFromInstance(ceda_observationCollection) is None: 117 #Adds the CedaGUID 118 ceda_guid = CedaGUID() 119 ceda_guid.id = calculateHash(self._dataEntityMigration.data_ent_id) 120 setattr(ceda_guid, 'ceda_observationcollection', ceda_observationCollection.id) 121 self.epbRepo.moles3EPB.persistInstance(ceda_guid) 122 DataEntityProcessor.log.info("GUID for this ObservationCollection: %s" % (ceda_guid.id)) 128 123 129 124 def _processDOI(self, deploymentMigration, ceda_observation, deProcessor, single_deployment): … … 134 129 #collection_identifier = Moles3EPB.extractCollectionIdentifierByTitle(MD_CODE_MOLES2_CITATION, self.migrationSessions.molesSession) 135 130 #if collection_identifier.count()==1: 136 # ceda_observation.identifier.append(collection_identifier.first()) 137 131 # ceda_observation.identifier.append(collection_identifier.first()) 138 132 deProcessor.assignDOI(ceda_observation, doi) 139 133 140 134 def _processDeploymentMigration(self, deploymentMigration, single_deployment): 141 deProcessor = DeploymentProcessor(self._dataEntityMigration, deploymentMigration )135 deProcessor = DeploymentProcessor(self._dataEntityMigration, deploymentMigration, self.epbRepo) 142 136 try: 143 137 DataEntityProcessor.log.info("Processing deployment: %s" % (migrationObjectDescription(deploymentMigration))) 144 ceda_observation = deProcessor.process() 145 try: 146 self._processResultAccumulation(ceda_observation) 147 except Exception as ex: 148 pass 138 ceda_observation = deProcessor.process() 149 139 try: 150 140 self._processDOI(deploymentMigration, ceda_observation, deProcessor, single_deployment) 151 141 except Exception as ex: 152 pass 153 154 if not hasAtomDocumentSameHash(deploymentMigration): 155 doc_hash = getAtomDocumentHash(deploymentMigration.docStatus, deploymentMigration.docType, deploymentMigration.docOwner, deploymentMigration.docName) 156 EPBRepo.migrationEPB.updateMigrationObject(deploymentMigration, {'doc_hash': doc_hash}) 142 pass 157 143 except NoAssociatedAuthor as ex: 158 144 raise ex … … 165 151 166 152 def process(self): 167 cedaObservationCollection= None153 obsColl = None 168 154 exs = [] 169 155 DataEntityProcessor.log.info("Processing dataEntity: %s" % (migrationObjectDescription(self._dataEntityMigration))) 170 156 try : 171 157 if self._dataEntityMigration.ceda_observation_coll_id: 172 cedaObservationCollection = self._update()158 obsColl = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, self._dataEntityMigration.ceda_observation_coll_id) 173 159 else: 174 cedaObservationCollection = self._create() 160 obsColl = CEDA_ObservationCollection() 161 self._execute(obsColl) 175 162 except Exception as ex: 176 163 exs.append(ex) 177 164 return exs 178 179 165 180 166 #retrieves the associated deployment links from the data_entity 181 deploymentsLinks = findDeploymentsInDE(self._dataEntityMigration) 182 167 deploymentsLinks = findDeploymentsInDE(self._dataEntityMigration) 183 168 #retrieves the DataEntityMigration sorted by creation date 184 deploymentMigrations = EPBRepo.migrationEPB.getAllDeploymentsMigrationByDataEntitySortedByDate( \169 deploymentMigrations = self.epbRepo.migrationEPB.getAllDeploymentsMigrationByDataEntitySortedByDate( \ 185 170 self._dataEntityMigration, deploymentsLinks) 186 171 howManydm = 0 … … 192 177 try: 193 178 ceda_observation = self._processDeploymentMigration(deploymentMigration, howManydm == 1) 194 EPBRepo.moles3EPB.updateCedaObject(cedaObservationCollection, {'member': ceda_observation}) 179 #Is a first time process? 180 if not hasMOBeenProcessed(deploymentMigration): 181 self.epbRepo.moles3EPB.updateCedaObject(obsColl, {'member': ceda_observation}) 195 182 196 183 except Exception as ex: 197 exs.append(ex) 198 except RuntimeError as er: 199 print er 200 #self.migrationSessions.molesSession.commit() 201 184 exs.append(ex) 202 185 return exs -
mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py
r8326 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 15 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from libs.migration.processor.commons import findMolesLineage,\ 7 34 createMO_ResponsiblePartyInfo,\ 8 DO_BADC, DO_NEODC, findAuthorsInResource, CEDA,\35 DO_BADC, DO_NEODC, findAuthorsInResource, \ 9 36 createMD_Identifier, extractSummary, extractQuality, \ 10 has AtomDocumentSameHash, getAtomDocumentHashByMO, extractTitle,\37 hasMOSameHash, getAtomDocumentHashByMO, extractTitle,\ 11 38 createCEDA_Result,\ 12 39 createEX_GeographicBoundingBox, extractGeographicExtentInMigrationDocument, findDownloadLinksInMigrationDocument,\ 13 findDOIInMigrationDocument,extractContent, createCI_Citation, createCI_Date, createDate,\40 extractContent, createCI_Citation, createCI_Date, createDate,\ 14 41 createTM_Position, createTM_Instant, extractMolesCreationDate,\ 15 42 createDateTime, isoDateTimeStringToTimeDate, extractMolesProviderID,\ … … 23 50 createCI_ResponsibleParty, extractUpdateFrequency,\ 24 51 findLinksInMigrationDocument, findSubTypeInDPT, extractMolesPublishedDate,\ 25 createMD_Keywords 52 createMD_Keywords, hasMOBeenProcessed 26 53 from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 27 54 from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 28 from libs.migration.MigrationEPB import MigrationEPB29 55 from libs.epb import EPB 30 56 from libs.migration.processor.deployment_data import DeploymentDataProcessor … … 32 58 from libs.migration.exception.exceptions import NoDataLineage,\ 33 59 NoAssociatedAuthor 34 from MolesManager.moles3epb import Moles3EPB35 60 from libs.migration.authors import authors 36 61 from logging import StreamHandler … … 42 67 from copy import deepcopy 43 68 import datetime 44 from libs.migration.InfodbEPB import InfodbEPB45 69 from ea_model.ceda_metadatamodel.ceda_result import ceda_curationvalue 46 70 from ea_model.ceda_metadatamodel.ceda_utilities.ceda_reviewfrequencyvalue import CEDA_ReviewFrequencyValue … … 50 74 from ea_model.iso_19115_2006_metadata_corrigendum.maintenance_information.md_maintenancefrequencycode import MD_MaintenanceFrequencyCode 51 75 from ea_model.ceda_metadatamodel.ceda_result.ceda_curationvalue import CEDA_CurationValue 52 from libs.migration.processor.EPBRepo import EPBRepo 53 76 77 MET_GEO_FEATURE = 'Meteorological geographical features' 78 ORTHOIMAGERY = 'Orthoimagery' 79 54 80 class DeploymentProcessor(object): 55 81 ''' … … 61 87 log.addHandler(StreamHandler()) 62 88 log.setLevel(logging.INFO) 63 def __init__(self, dataEntityMigration, deploymentMigration ):89 def __init__(self, dataEntityMigration, deploymentMigration, epbRepo): 64 90 ''' 65 91 Initializes the class 66 92 @param dataEntityMigration: a DataEntityMigration instance 67 @param deploymentMigration: the DeploymentMigration instance 93 @param deploymentMigration: the DeploymentMigration instance 94 @param epbRepo: an instance of EPBRepo 68 95 ''' 69 96 self._dataEntityMigration = dataEntityMigration 70 97 self._deploymentMigration = deploymentMigration 71 self._dataEntityHasSameHash = hasAtomDocumentSameHash(self._dataEntityMigration) and self._dataEntityMigration.doc_hash is not None 72 self._deploymentHasSameHash = hasAtomDocumentSameHash(self._deploymentMigration) and self._deploymentMigration.doc_hash is not None 98 self.epbRepo = epbRepo 99 self._dataEntityHasSameHash = hasMOSameHash(self._dataEntityMigration) 100 self._deploymentHasSameHash = hasMOSameHash(self._deploymentMigration) 101 self._deploymentHasBeenProcessed = hasMOBeenProcessed(self._deploymentMigration) 73 102 74 103 def _existsCEDAasPublisher(self): … … 113 142 114 143 115 def _assignName(self, observation): 116 ''' 117 @param relatedPartyInfos: a MO_ResponsiblePartyInfo list 118 @return True if the documents changed, False otherwise 119 ''' 120 whereAreAuthors = self._deploymentMigration 121 doc_authors = findAuthorsInResource(self._deploymentMigration) 122 if doc_authors['authors'] in [DO_BADC, DO_NEODC]: 123 doc_authors = findAuthorsInResource(self._dataEntityMigration) 124 whereAreAuthors = self._dataEntityMigration 125 126 ind_names = [] 127 org_names = [] 128 if authors.has_key(doc_authors['authors']): 129 tmp_auth = authors[doc_authors['authors']] 130 ret = self._extractIndividualsAndOrganizations(tmp_auth, whereAreAuthors) 131 132 if len(ret['ind']) > 0: 133 i_party = createCI_Individual(name = ret['ind'][0]) 134 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_author, [i_party])) 135 if len(ret['org']) > 0: 136 i_party = createMO_Organization(name = ret['org'][0]) 137 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_author, [i_party])) 138 139 if len(ret['ind']) > 1: 140 ind_names.extend(ret['ind'][1:]) 141 if len(ret['org']) > 1: 142 org_names.extend(ret['org'][1:]) 143 if len(ret['co_ind']) > 0: 144 ind_names.extend(ret['co_ind']) 145 if len(ret['co_org']) > 0: 146 org_names.extend(ret['co_org']) 147 148 else: 149 raise NoAssociatedAuthor(doc_authors['authors'], migrationObject = whereAreAuthors) 150 151 if doc_authors['contributors'] and authors.has_key(doc_authors['contributors']): 152 tmp_auth = authors[doc_authors['contributors']] 153 ret = self._extractIndividualsAndOrganizations(tmp_auth, whereAreAuthors) 154 ind_names.extend(ret['ind']) 155 ind_names.extend(ret['co_ind']) 156 org_names.extend(ret['org']) 157 org_names.extend(ret['co_org']) 158 159 i_party = [] 160 for nm in ind_names: 161 i_party.append(createCI_Individual(name = nm)) 162 163 for nm in org_names: 164 i_party.append(createMO_Organization(name = nm)) 165 166 if i_party: 167 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_coinvestigator, i_party)) 144 168 145 169 146 def _extractIndividualsAndOrganizations(self, tmp_auth, whereAreAuthors): … … 204 181 print e 205 182 return ret 206 207 def _assignLineage(self, observation): 208 data_lineage = findMolesLineage(self._dataEntityMigration) 209 if data_lineage is None: 210 raise NoDataLineage(self._dataEntityMigration) 211 observation.dataLineage = data_lineage 212 213 def _assignTitle(self, observation): 214 doc_title = extractTitle(self._deploymentMigration) 215 if doc_title is None: 216 doc_title = extractTitle(self._dataEntityMigration) 217 218 if doc_title.startswith('deployment_') or doc_title.startswith('Deployment_'): 219 links = findLinksInMigrationDocument(self._deploymentMigration) 220 dptList = links['DPT'] 221 if links.has_key('DPT'): 222 doc_title = 'Data from ' + dptList[0]['title'] 223 if len(dptList) > 2: 224 for dpt in dptList[1:-2]: 225 doc_title += ', ' + dpt['title'] 226 if len(dptList) > 1: 227 doc_title += ' and ' + dptList[-1] 228 229 links = findLinksInDeployment(self._deploymentMigration) 230 if links.has_key('OBS'): 231 obsList = [] 232 for obs in links['OBS']: 233 observationStation = EPBRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom') 234 obsList.append((extractTitle(observationStation), findSubTypeInDPT(observationStation))) 235 236 if obsList[0][1] in ['stationary platform' ,'moving platform', 'ship','aircraft','satellite','computer']: 237 doc_title += ' on ' 238 else : 239 doc_title += ' at ' 240 doc_title += obsList[0][0] 241 if len(obsList) > 2: 242 for obs in obsList[1:-2]: 243 doc_title += ', ' + obs[0] 244 if len(obsList) > 1: 245 doc_title += ' and ' + obsList[-1][0] 246 247 if links.has_key('ACTIVITY'): 248 for link in links['ACTIVITY']: 249 activity = EPBRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom') 250 251 projSubType = findSubTypeInDPT(activity) 252 doc_title += ' for the ' + extractTitle(activity) 253 if projSubType[0:14] == 'dgActivityData': 254 doc_title += ' ' + projSubType[14:] 255 else : 256 doc_title += ' ' + projSubType 257 258 else: 259 if doc_title[0:10] != 'Data from' : 260 doc_title = "Data from " + doc_title 261 auth = createCI_Citation(title = 'ceda_title') 262 identifier = createMD_Identifier(code = doc_title, authority = auth) 263 observation.identifier.append(identifier) 264 265 def _assignDescription(self, observation): 266 description = extractSummary(self._deploymentMigration, self._dataEntityMigration) 267 if description: 268 observation.description = description 269 270 def _assignQuality(self, observation): 271 doc_quality = extractQuality(self._dataEntityMigration) 272 doc_date = findUpdatedDate(self._dataEntityMigration) 273 ci_dates = [] 274 if doc_date: 275 i_date = createDate(isoDateTimeStringToTimeDate(doc_date)) 276 ci_dates.append(createCI_Date(CI_DateTypeCode.cl_revision, date = i_date)) 277 else: 278 i_date = createDate(isoDateTimeStringToTimeDate(datetime.datetime.now())) 279 ci_dates.append(createCI_Date(CI_DateTypeCode.cl_creation, date = i_date)) 280 281 i_specification = createCI_Citation(title = "CEDA Data Quality Statement", date=ci_dates) 282 i_dq_result = createDQ_ConformanceResult(doc_quality, True, i_specification) 283 i_quality_element = createDQ_Element(i_dq_result) 284 observation.resultQuality.append(i_quality_element) 285 183 184 286 185 def updateObservation(self): 287 186 return EPB.searchOrCreate(CEDA_Observation, self._deploymentMigration.ceda_observation_id) 288 289 290 def _assignResult(self, observation):291 # TDB - Check that if is an update or not!292 download = findDownloadLinksInMigrationDocument(self._deploymentMigration)293 content = None294 if len(download) == 0:295 download = findDownloadLinksInMigrationDocument(self._dataEntityMigration)296 content = extractContent(self._dataEntityMigration)297 else:298 content = extractContent(self._deploymentMigration)299 for dwn in download:300 int_description = None301 int_applicationProfile = None302 if content.has_key('formats'):303 #int_applicationProfile = content['formats']304 pass305 if dwn['href'].startswith('http://badc.nerc.ac.uk/browse') or dwn['href'].startswith('http://neodc.nerc.ac.uk/browse'):306 int_description = "download directly from archive"307 i_source = createMO_OnlineResource(linkage = dwn['href'], name = dwn['title'], \308 function = CI_OnLineFunctionCode.cl_download, \309 description = int_description, applicationProfile = int_applicationProfile)310 311 dataentity_id = '%s__ATOM__%s' % (self._dataEntityMigration.doc_owner, self._dataEntityMigration.doc_name)312 dataentity_id = dataentity_id.replace('.atom', '')313 infodb_de = EPBRepo.infodbEPB.getCedaInfoApp_dataentityByDE_ID(dataentity_id)314 i_logical_path = '/dummy'315 if infodb_de is None:316 i_logical_path = dwn['href'][dwn['href'].index('/browse/') + 7:]317 318 if infodb_de and infodb_de.has_key('logical_path'):319 i_logical_path = infodb_de['logical_path']320 321 i_category = ceda_curationvalue.CEDA_CurationValue.cl_a322 if infodb_de and infodb_de.has_key('category') and infodb_de['category']:323 i_category = CEDA_CurationValue.from_string(infodb_de['category'].lower()) #self._getcurationcategory(infodb_de['category'])324 observation.result = createCEDA_Result(i_category, i_logical_path, source = [i_source])325 326 327 def _assignGeographicExtent(self, observation):328 # TDB - Check that if is an update or not!329 ge = extractGeographicExtentInMigrationDocument(self._deploymentMigration)330 if not ge:331 ge = extractGeographicExtentInMigrationDocument(self._dataEntityMigration)332 if ge:333 observation.geographicExtent.append(createEX_GeographicBoundingBox(ge['east'], ge['north'], ge['west'], ge['south']))334 335 def _assignCreationDate(self, observation):336 # TDB - Check that if is an update or not!337 creation_date = extractMolesPublishedDate(self._deploymentMigration)338 if creation_date is None:339 creation_date = extractMolesCreationDate(self._deploymentMigration)340 py_datetime = isoDateTimeStringToTimeDate(creation_date)341 date_time = createDateTime(py_datetime)342 tm_position = createTM_Position(dateTime8601 = date_time)343 observation.resultTime = createTM_Instant(tm_position)344 187 345 188 def assignDOI(self, observation, doi): … … 348 191 349 192 #Check if a doi has been already assigned 350 observation = EPBRepo.moles3EPB.loadAttributes(observation, 'identifier')193 observation = self.epbRepo.moles3EPB.loadAttributes(observation, 'identifier') 351 194 obs_identifier = observation.identifier 352 195 if obs_identifier: … … 372 215 i_authority = createCI_Citation("DOI", date = ci_date) 373 216 identifier = createMD_Identifier(code = doi, authority=i_authority) 374 EPBRepo.moles3EPB.updateCedaObject(observation, {'identifier': identifier})217 self.epbRepo.moles3EPB.updateCedaObject(observation, {'identifier': identifier}) 375 218 DeploymentProcessor.log.info("DOI: %s" % (doi)) 376 219 377 def _assignPublisherCurator(self, observation): 220 def _assignKeywords(self, ceda_observation): 221 if self._deploymentHasSameHash: 222 return 223 224 provider_id = extractMolesProviderID(self._deploymentMigration) 225 i_keywords = [] 226 if provider_id == DO_BADC: 227 i_keywords.append(MET_GEO_FEATURE) 228 if provider_id == DO_NEODC: 229 i_keywords.append(ORTHOIMAGERY) 230 if len(i_keywords) > 0: 231 #Is a first time process? 232 if not self._deploymentHasBeenProcessed: 233 ceda_observation.keywords.append(createMD_Keywords(i_keywords)) 234 else: 235 ceda_observation.keywords.keyword = i_keywords 236 237 def _assignLineage(self, observation): 238 if self._deploymentHasSameHash: 239 return 240 241 data_lineage = findMolesLineage(self._dataEntityMigration) 242 if data_lineage is None: 243 raise NoDataLineage(self._dataEntityMigration) 244 245 if data_lineage != observation.dataLineage: 246 observation.dataLineage = data_lineage 247 248 def _assignResult(self, observation): 249 if self._deploymentHasSameHash and self._dataEntityHasSameHash: 250 return 251 252 i_sources = [] 253 download = findDownloadLinksInMigrationDocument(self._deploymentMigration) 254 content = None 255 if len(download) == 0: 256 download = findDownloadLinksInMigrationDocument(self._dataEntityMigration) 257 content = extractContent(self._dataEntityMigration) 258 else: 259 content = extractContent(self._deploymentMigration) 260 for dwn in download: 261 int_description = None 262 int_applicationProfile = None 263 if content.has_key('formats'): 264 #int_applicationProfile = content['formats'] 265 pass 266 if dwn['href'].startswith('http://badc.nerc.ac.uk/browse') or dwn['href'].startswith('http://neodc.nerc.ac.uk/browse'): 267 int_description = "download directly from archive" 268 i_sources.append(createMO_OnlineResource(linkage = dwn['href'], name = dwn['title'], \ 269 function = CI_OnLineFunctionCode.cl_download, \ 270 description = int_description, applicationProfile = int_applicationProfile)) 271 272 dataentity_id = '%s__ATOM__%s' % (self._dataEntityMigration.doc_owner, self._dataEntityMigration.doc_name) 273 dataentity_id = dataentity_id.replace('.atom', '') 274 infodb_de = self.epbRepo.infodbEPB.getCedaInfoApp_dataentityByDE_ID(dataentity_id) 275 i_logical_path = '/dummy' 276 if infodb_de is None: 277 i_logical_path = dwn['href'][dwn['href'].index('/browse/') + 7:] 278 279 if infodb_de and infodb_de.has_key('logical_path'): 280 i_logical_path = infodb_de['logical_path'] 281 282 i_category = ceda_curationvalue.CEDA_CurationValue.cl_a 283 if infodb_de and infodb_de.has_key('category') and infodb_de['category']: 284 i_category = CEDA_CurationValue.from_string(infodb_de['category'].lower()) 285 286 if not self._deploymentHasBeenProcessed: 287 observation.result = createCEDA_Result(i_category, i_logical_path, source = i_sources) 288 return 289 290 if observation.result.internalPath != i_logical_path: 291 observation.result.internalPath = i_logical_path 292 293 if observation.result.curationCategory != i_category: 294 observation.result.curationCategory = i_category 295 296 #Still have to update observation.result.source 297 298 def _assignPublisherCurator(self, observation): 299 if self._deploymentHasSameHash: 300 return 301 378 302 provider_id = extractMolesProviderID(self._deploymentMigration) 379 303 party = None … … 403 327 party = createMO_Organization(name = 'NERC - UK Solar System Data Centre', contactInfo = [contact]) 404 328 405 if party :329 if party and not self._deploymentHasBeenProcessed: 406 330 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_publisher, [party])) 407 331 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_custodian, deepcopy([party]))) … … 409 333 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_pointofcontact, deepcopy([party]))) 410 334 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_metadataowner, deepcopy([party]))) 411 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_curator, deepcopy([party]))) 412 413 def _assignPhenomenonTime(self, observation): 414 doc_phenomenon_time = extractMolesTemporalRange(self._deploymentMigration) 415 335 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_curator, deepcopy([party]))) 336 return 337 #Still have to update observation.result.source 338 339 def _assignQuality(self, observation): 340 if self._dataEntityHasSameHash: 341 return 342 343 doc_quality = extractQuality(self._dataEntityMigration) 344 doc_date = findUpdatedDate(self._dataEntityMigration) 345 ci_dates = [] 346 if doc_date: 347 i_date = createDate(isoDateTimeStringToTimeDate(doc_date)) 348 ci_dates.append(createCI_Date(CI_DateTypeCode.cl_revision, date = i_date)) 349 else: 350 i_date = createDate(isoDateTimeStringToTimeDate(datetime.datetime.now())) 351 ci_dates.append(createCI_Date(CI_DateTypeCode.cl_creation, date = i_date)) 352 353 i_specification = createCI_Citation(title = "CEDA Data Quality Statement", date=ci_dates) 354 i_dq_result = createDQ_ConformanceResult(doc_quality, True, i_specification) 355 i_quality_element = createDQ_Element(i_dq_result) 356 357 if not self._deploymentHasBeenProcessed: 358 observation.resultQuality.append(i_quality_element) 359 return 360 #Still have to update observation.result.source 361 362 def _assignDescription(self, observation): 363 if self._dataEntityHasSameHash and self._deploymentHasSameHash: 364 return 365 366 description = extractSummary(self._deploymentMigration, self._dataEntityMigration) 367 if description: 368 observation.description = description 369 370 def _assignTitle(self, observation): 371 if self._dataEntityHasSameHash and self._deploymentHasSameHash: 372 return 373 374 doc_title = extractTitle(self._deploymentMigration) 375 if doc_title is None: 376 doc_title = extractTitle(self._dataEntityMigration) 377 378 if doc_title.startswith('deployment_') or doc_title.startswith('Deployment_'): 379 links = findLinksInMigrationDocument(self._deploymentMigration) 380 dptList = links['DPT'] 381 if links.has_key('DPT'): 382 doc_title = 'Data from ' + dptList[0]['title'] 383 if len(dptList) > 2: 384 for dpt in dptList[1:-2]: 385 doc_title += ', ' + dpt['title'] 386 if len(dptList) > 1: 387 doc_title += ' and ' + dptList[-1] 388 389 links = findLinksInDeployment(self._deploymentMigration) 390 if links.has_key('OBS'): 391 obsList = [] 392 for obs in links['OBS']: 393 observationStation = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom') 394 obsList.append((extractTitle(observationStation), findSubTypeInDPT(observationStation))) 395 396 if obsList[0][1] in ['stationary platform' ,'moving platform', 'ship','aircraft','satellite','computer']: 397 doc_title += ' on ' 398 else : 399 doc_title += ' at ' 400 doc_title += obsList[0][0] 401 if len(obsList) > 2: 402 for obs in obsList[1:-2]: 403 doc_title += ', ' + obs[0] 404 if len(obsList) > 1: 405 doc_title += ' and ' + obsList[-1][0] 406 407 if links.has_key('ACTIVITY'): 408 for link in links['ACTIVITY']: 409 activity = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom') 410 411 projSubType = findSubTypeInDPT(activity) 412 doc_title += ' for the ' + extractTitle(activity) 413 if projSubType[0:14] == 'dgActivityData': 414 doc_title += ' ' + projSubType[14:] 415 else : 416 doc_title += ' ' + projSubType 417 else: 418 if doc_title[0:10] != 'Data from' : 419 doc_title = "Data from " + doc_title 420 auth = createCI_Citation(title = 'ceda_title') 421 identifier = createMD_Identifier(code = doc_title, authority = auth) 422 423 if not self._deploymentHasBeenProcessed: 424 observation.identifier.append(identifier) 425 return 426 #Still have to update observation.identifier 427 428 def _assignGeographicExtent(self, observation): 429 if self._dataEntityHasSameHash and self._deploymentHasSameHash: 430 return 431 432 ge = extractGeographicExtentInMigrationDocument(self._deploymentMigration) 433 if not ge: 434 ge = extractGeographicExtentInMigrationDocument(self._dataEntityMigration) 435 geographicExtent = createEX_GeographicBoundingBox(ge['east'], ge['north'], ge['west'], ge['south']) 436 437 if not self._deploymentHasBeenProcessed: 438 observation.geographicExtent.append(geographicExtent) 439 return 440 #Still have to update observation.geographicExtent 441 442 def _assignCreationDate(self, observation): 443 if self._deploymentHasSameHash: 444 return 445 446 creation_date = extractMolesPublishedDate(self._deploymentMigration) 447 if creation_date is None: 448 creation_date = extractMolesCreationDate(self._deploymentMigration) 449 py_datetime = isoDateTimeStringToTimeDate(creation_date) 450 date_time = createDateTime(py_datetime) 451 tm_position = createTM_Position(dateTime8601 = date_time) 452 453 if not self._deploymentHasBeenProcessed: 454 observation.resultTime = createTM_Instant(tm_position) 455 return 456 #Still have to update observation.geographicExtent 457 458 def _assignPhenomenonTime(self, observation): 459 if self._deploymentHasSameHash: 460 return 461 462 doc_phenomenon_time = extractMolesTemporalRange(self._deploymentMigration) 416 463 if doc_phenomenon_time: 464 pt = None 417 465 if '/' in doc_phenomenon_time: 418 466 period = doc_phenomenon_time.split('/') … … 425 473 end_tm_instant = createTM_Instant(end_position) 426 474 427 observation.phenomenonTime= createTM_Period(begin_tm_instant, end_tm_instant)475 pt = createTM_Period(begin_tm_instant, end_tm_instant) 428 476 else: 429 observation.phenomenonTime = createTM_Position(date8601 = createDate(isoDateStringToTimeDate(doc_phenomenon_time))) 430 477 pt = createTM_Position(date8601 = createDate(isoDateStringToTimeDate(doc_phenomenon_time))) 478 479 if not self._deploymentHasBeenProcessed: 480 observation.phenomenonTime = pt 481 #Still have to update observation.phenomenonTime 482 431 483 def _assignPermission(self, observation): 484 if self._deploymentHasSameHash and self._dataEntityHasSameHash: 485 return 486 432 487 access_link = findAccessLinksInMigrationDocument(self._deploymentMigration) 433 488 dwn_link = findDownloadLinksInMigrationDocument(self._deploymentMigration) … … 438 493 i_use_limitation = [] 439 494 495 permission = None 440 496 if len(access_link) == 0: 441 497 if len(dwn_link) == 0: … … 449 505 i_use_limitation.append("Access to these data is restricted. To obtain access please apply for access at: %s" % (access_link[0]['href'])) 450 506 i_accessConstraints.append(MD_RestrictionCode.cl_restricted) 451 observation.permission = createMD_LegalConstraints(useLimitation = i_use_limitation, accessConstrains = i_accessConstraints) 507 observation.permission = createMD_LegalConstraints(useLimitation = i_use_limitation, accessConstrains = i_accessConstraints) 508 509 if not self._deploymentHasBeenProcessed: 510 observation.permission = permission 511 #Still have to update observation.permission 452 512 453 513 ''' … … 455 515 if not contentDict.has_key('access-restricted'): 456 516 contentDict = extractContent(self._dataEntityMigration) 457 ''' 458 517 ''' 518 459 519 def _assignMoles2Link(self, ceda_observation): 520 if self._deploymentHasSameHash: 521 return 522 460 523 i_code = 'http://badc.nerc.ac.uk/view/%s__ATOM__%s' % (self._deploymentMigration.doc_owner, self._deploymentMigration.doc_name) 461 524 i_code = i_code.replace('.atom', '') … … 463 526 i_authority = createCI_Citation('moles2url') 464 527 identifier = createMD_Identifier(code = i_code, authority = i_authority) 465 ceda_observation.identifier.append(identifier) 466 528 if not self._deploymentHasBeenProcessed: 529 ceda_observation.identifier.append(identifier) 530 #Still have to update observation.permission 531 532 def _assignInternalReview(self, ceda_observation): 533 if self._deploymentHasBeenProcessed: 534 return 535 536 i_party = createCI_Individual(name = 'Graham Parton') 537 i_reviewer = createMO_ResponsiblePartyInfo(MO_RoleValue.cl_processor, [i_party]) 538 ceda_observation.internalReview.append( \ 539 createCEDA_Review(reviewer=i_reviewer, reviewFrequency=CEDA_ReviewFrequencyValue.cl_yearly, \ 540 reviewStatus=CEDA_ReviewStatusValue.cl_required)) 541 467 542 def _assignLanguage(self, ceda_observation): 543 if self._deploymentHasBeenProcessed: 544 return 545 468 546 i_date_stamp = createDate(datetime.datetime.now()) 469 547 #i_contact = createCI_Citation("", date = i_date_stamp) 470 548 i_contact = createCI_ResponsibleParty(CI_RoleCode.cl_user) 471 549 ceda_observation.metadata = createMD_Metadata(date_stamp=i_date_stamp, contact = [i_contact], language = "English") 550 551 def _processResultAccumulation(self, ceda_observation): 552 if self._dataEntityHasSameHash: 553 return 554 555 updateFrequency = extractUpdateFrequency(self._dataEntityMigration) 556 if updateFrequency: 557 resultAccumulation = MD_MaintenanceFrequencyCode.from_string(updateFrequency) 558 if not self._deploymentHasBeenProcessed: 559 self.epbRepo.moles3EPB.updateCedaObject(ceda_observation, {'resultAccumulation': resultAccumulation}) 560 return 561 #Still have to update observation.permission 562 563 def _assignName(self, observation): 564 ''' 565 @param relatedPartyInfos: a MO_ResponsiblePartyInfo list 566 @return True if the documents changed, False otherwise 567 ''' 568 if self._deploymentHasSameHash and self._dataEntityHasSameHash: 569 return 570 571 whereAreAuthors = self._deploymentMigration 572 doc_authors = findAuthorsInResource(self._deploymentMigration) 573 if doc_authors['authors'] in [DO_BADC, DO_NEODC]: 574 doc_authors = findAuthorsInResource(self._dataEntityMigration) 575 whereAreAuthors = self._dataEntityMigration 576 577 ind_names = [] 578 org_names = [] 579 if authors.has_key(doc_authors['authors']): 580 tmp_auth = authors[doc_authors['authors']] 581 ret = self._extractIndividualsAndOrganizations(tmp_auth, whereAreAuthors) 582 583 if len(ret['ind']) > 0: 584 i_party = createCI_Individual(name = ret['ind'][0]) 585 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_author, [i_party])) 586 if len(ret['org']) > 0: 587 i_party = createMO_Organization(name = ret['org'][0]) 588 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_author, [i_party])) 589 590 if len(ret['ind']) > 1: 591 ind_names.extend(ret['ind'][1:]) 592 if len(ret['org']) > 1: 593 org_names.extend(ret['org'][1:]) 594 if len(ret['co_ind']) > 0: 595 ind_names.extend(ret['co_ind']) 596 if len(ret['co_org']) > 0: 597 org_names.extend(ret['co_org']) 598 599 else: 600 raise NoAssociatedAuthor(doc_authors['authors'], migrationObject = whereAreAuthors) 601 602 if doc_authors['contributors'] and authors.has_key(doc_authors['contributors']): 603 tmp_auth = authors[doc_authors['contributors']] 604 ret = self._extractIndividualsAndOrganizations(tmp_auth, whereAreAuthors) 605 ind_names.extend(ret['ind']) 606 ind_names.extend(ret['co_ind']) 607 org_names.extend(ret['org']) 608 org_names.extend(ret['co_org']) 609 610 i_party = [] 611 for nm in ind_names: 612 i_party.append(createCI_Individual(name = nm)) 613 614 for nm in org_names: 615 i_party.append(createMO_Organization(name = nm)) 616 617 if i_party: 618 if not self._deploymentHasBeenProcessed: 619 observation.relatedParty.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_coinvestigator, i_party)) 620 return 621 #Still have to update observation.permission 472 622 473 def _assignInternalReview(self, ceda_observation): 474 i_party = createCI_Individual(name = 'Graham Parton') 475 i_reviewer = createMO_ResponsiblePartyInfo(MO_RoleValue.cl_processor, [i_party]) 476 ceda_observation.internalReview.append( \ 477 createCEDA_Review(reviewer=i_reviewer, reviewFrequency=CEDA_ReviewFrequencyValue.cl_yearly, \ 478 reviewStatus=CEDA_ReviewStatusValue.cl_required)) 479 480 def _assignUpdateFrequency(self, ceda_observation): 481 updateFrequency = extractUpdateFrequency(self._deploymentMigration) 482 if updateFrequency: 483 ceda_observation.resultAccumulation = MD_MaintenanceFrequencyCode.from_string(updateFrequency) 484 485 def _assignKeywords(self, ceda_observation): 486 provider_id = extractMolesProviderID(self._deploymentMigration) 487 i_keywords = [] 488 if provider_id == DO_BADC: 489 i_keywords.append('Meteorological geographical features') 490 if provider_id == DO_NEODC: 491 i_keywords.append('Orthoimagery') 492 if len(i_keywords) > 0: 493 ceda_observation.keywords.append(createMD_Keywords(i_keywords)) 494 495 def _create(self): 496 ceda_observation = CEDA_Observation() 623 def _execute(self, ceda_observation): 497 624 self._assignKeywords(ceda_observation) 498 625 self._assignLineage(ceda_observation) 499 626 self._assignResult(ceda_observation) 500 self._assignPublisherCurator(ceda_observation) 501 502 ceda_observation.publicationState = MO_PublicationStateValue.cl_working 627 self._assignPublisherCurator(ceda_observation) 503 628 self._assignQuality(ceda_observation) 504 629 self._assignDescription(ceda_observation) 505 630 self._assignTitle(ceda_observation) 506 self._assignGeographicExtent(ceda_observation) 507 #self._assignDOI(ceda_observation) 631 self._assignGeographicExtent(ceda_observation) 508 632 self._assignCreationDate(ceda_observation) 509 633 self._assignPhenomenonTime(ceda_observation) … … 512 636 self._assignInternalReview(ceda_observation) 513 637 self._assignLanguage(ceda_observation) 514 self._assignUpdateFrequency(ceda_observation) 515 self._assignName(ceda_observation) 516 EPBRepo.moles3EPB.persistInstance(ceda_observation) 517 EPBRepo.migrationEPB.updateMigrationObject(self._deploymentMigration, {'ceda_observation_id': ceda_observation.id}) 518 519 #Adds the CedaGUID 520 ceda_guid = CedaGUID() 521 ceda_guid.id = calculateHash(self._deploymentMigration.depl_id) 522 ceda_guid.ceda_observation = ceda_observation.id 523 EPBRepo.moles3EPB.persistInstance(ceda_guid) 524 DeploymentProcessor.log.info("GUID for this Observation: %s" % (ceda_guid.id)) 525 526 #process the CEDA_Observation.procedure 527 deploymentDataProcessor = DeploymentDataProcessor(self._deploymentMigration) 528 529 links = findLinksInDeployment(self._deploymentMigration) 530 procedure = deploymentDataProcessor.createProcess(links) 531 532 #Temporary commented because CEDA_Project.subProject is not correctly mapped to the DB 533 project = deploymentDataProcessor.createProject(links) 534 EPBRepo.moles3EPB.updateCedaObject(ceda_observation, {'procedure': procedure, 'inSupportOf': project}) 638 self._processResultAccumulation(ceda_observation) 639 self._assignName(ceda_observation) 640 #self._assignDOI(ceda_observation) 641 642 #Is a first time process? 643 if not hasMOBeenProcessed(self._deploymentMigration): 644 ceda_observation.publicationState = MO_PublicationStateValue.cl_working 645 docHash = getAtomDocumentHashByMO(self._dataEntityMigration) 646 self.epbRepo.moles3EPB.persistInstance(ceda_observation) 647 self.epbRepo.migrationEPB.updateMigrationObject(self._deploymentMigration, \ 648 {'ceda_observation_id': ceda_observation.id, 649 'doc_hash': docHash}) 650 651 #Has a proper CEDAGUID? 652 if self.epbRepo.moles3EPB.retrieveGUIDFromInstance(ceda_observation) is None: 653 ceda_guid = CedaGUID() 654 ceda_guid.id = calculateHash(self._deploymentMigration.depl_id) 655 ceda_guid.ceda_observation = ceda_observation.id 656 self.epbRepo.moles3EPB.persistInstance(ceda_guid) 657 DeploymentProcessor.log.info("GUID for this Observation: %s" % (ceda_guid.id)) 658 659 660 if not self._deploymentHasBeenProcessed: 661 deploymentDataProcessor = DeploymentDataProcessor(self._deploymentMigration, self.epbRepo) 662 procedure = deploymentDataProcessor.createProcess() 663 project = deploymentDataProcessor.createProject() 664 self.epbRepo.moles3EPB.updateCedaObject(ceda_observation, {'procedure': procedure, 'inSupportOf': project}) 665 666 #Still have to update observation.procedure 667 #Still have to update observation.project 535 668 536 669 return ceda_observation 537 538 def _getObservation(self):539 return EPBRepo.moles3EPB.search(CEDA_Observation, self._deploymentMigration.ceda_observation_id)540 541 def _update(self):542 if hasAtomDocumentSameHash(self._deploymentMigration):543 return self._getObservation()544 else:545 return self.updateObservation()546 670 547 671 def process(self): … … 549 673 #Moles3 object exists... 550 674 if self._deploymentMigration.ceda_observation_id: 551 ceda_observation = self. _update()675 ceda_observation = self.epbRepo.moles3EPB.search(CEDA_Observation, self._deploymentMigration.ceda_observation_id) 552 676 else: 553 677 #... does not exist so create it 554 ceda_observation = self._create()678 ceda_observation = ceda_observation = CEDA_Observation() 555 679 556 if not self._deploymentHasSameHash: 557 self._deploymentMigration.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 558 self._commitMigration() 559 680 self._execute(ceda_observation) 560 681 return ceda_observation -
mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment_data.py
r8325 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 13 Feb 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from libs.migration.processor.commons import findSubTypeInDPT,\ 7 34 createCEDA_Processing, createCEDA_Instrument, createCEDA_Project,\ 8 35 findSummary, findDocumentationInMigrationDocument, createCI_Citation,\ 9 createMO_OnlineResource, hasAtomDocumentSameHash 10 from libs.migration.MigrationEPB import MigrationEPB 11 from MolesManager.moles3epb import Moles3EPB 36 createMO_OnlineResource, findLinksInDeployment 12 37 from ea_model.moles3_4.utilities.mo_publicationstatevalue import MO_PublicationStateValue 13 from libs.migration.processor.EPBRepo import EPBRepo14 38 15 39 class DeploymentDataProcessor(object): 16 40 17 def __init__(self, deploymentMigration): 41 def __init__(self, deploymentMigration, epbRepo): 42 ''' 43 @param epbRepo: an instance of EPBRepo 44 ''' 18 45 self._deploymentMigration = deploymentMigration 46 self.epbRepo = epbRepo 47 self._links = findLinksInDeployment(self._deploymentMigration) 19 48 20 49 def _commitDeploymentMigration(self, associateWithCedaObservation, dataProductionTool, dataProductionToolField): 21 EPBRepo.moles3EPB.persistInstance(associateWithCedaObservation)22 EPBRepo.migrationEPB.updateMigrationObject(dataProductionTool, {dataProductionToolField: associateWithCedaObservation.id})50 self.epbRepo.moles3EPB.persistInstance(associateWithCedaObservation) 51 self.epbRepo.migrationEPB.updateMigrationObject(dataProductionTool, {dataProductionToolField: associateWithCedaObservation.id}) 23 52 24 53 25 def createProject(self , links):54 def createProject(self): 26 55 project = None 27 if links.has_key('ACTIVITY'):28 for link in links['ACTIVITY']:29 activity = EPBRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom')56 if self._links.has_key('ACTIVITY'): 57 for link in self._links['ACTIVITY']: 58 activity = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom') 30 59 i_abstract = findSummary(activity) 31 60 doc_link = findDocumentationInMigrationDocument(activity) … … 40 69 return project 41 70 42 def createProcess(self , links):71 def createProcess(self): 43 72 associateWithCedaObservation = None 44 73 hasCedaProcessing = False 45 74 hasCedaComposite = False 46 75 hasCedaAcquisition = False 47 for dpt in links['DPT']:48 dataProductionTool = EPBRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, dpt + '.atom')76 for dpt in self._links['DPT']: 77 dataProductionTool = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, dpt + '.atom') 49 78 50 79 #has the document changed? 51 #if has AtomDocumentSameHash(dataProductionTool):80 #if hasMOSameHash(dataProductionTool): 52 81 # dataProductionTool.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 53 82 # self._migrationSessions.migrationSession.commit() … … 79 108 80 109 #if not a DPT.subType == 'model' then.... 81 for obs in links['OBS']:82 observationStation = EPBRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom')110 for obs in self._links['OBS']: 111 observationStation = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom') 83 112 84 113 #has the document changed? 85 #if has AtomDocumentSameHash(observationStation):114 #if hasMOSameHash(observationStation): 86 115 # observationStation.doc_hash = getAtomDocumentHashByMO(self._deploymentMigration) 87 116 # self._migrationSessions.migrationSession.commit() -
mauRepo/MolesManager/trunk/src/libs/migration/processor/loadResources.py
r8325 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 15 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from libs.migration.processor.commons import docStatus, getCollectionRefs,\ … … 11 38 from libs.migration.db.classes import DeploymentDataMigration,\ 12 39 DeploymentsMigration, DataEntityMigration 13 from libs.migration.processor.EPBRepo import EPBRepo14 40 15 41 class LoadResources(object): 42 43 def __init__(self, epbRepo): 44 ''' 45 @param epbRepo: an instance of EPBRepo 46 ''' 47 self.epbRepo = epbRepo 16 48 17 49 def process(self): … … 26 58 return ex 27 59 28 def _createMigrationObject(self, migrationClass, doc_id, docName, docOwner, docStatus, doc Hash, docCreation):60 def _createMigrationObject(self, migrationClass, doc_id, docName, docOwner, docStatus, docCreation): 29 61 migrationObject = None 30 62 if migrationClass == DeploymentsMigration: … … 42 74 migrationObject.doc_name = docName 43 75 migrationObject.doc_owner = docOwner 44 migrationObject.doc_status = docStatus 45 migrationObject.doc_hash = docHash 76 migrationObject.doc_status = docStatus 46 77 migrationObject.doc_creation = stringToTimestamp(docCreation) 47 78 try: 48 EPBRepo.migrationEPB.persistInstance(migrationObject)79 self.epbRepo.migrationEPB.persistInstance(migrationObject) 49 80 except Exception as e: 50 81 print e … … 82 113 @param docOwner: a common.docOwner item 83 114 """ 84 85 docHash = getAtomDocumentHash(docStatus, docType, docOwner, docName) 115 116 #The docHash has to be set/check when the document is processed! 117 #docHash = getAtomDocumentHash(docStatus, docType, docOwner, docName) 86 118 xmlDocument = getAtomDocumentAsElementtree(docStatus, docType, docOwner, docName) 87 119 doc_id = findID(xmlDocument) 88 120 89 121 #The document has been already classified 90 if doc_id is None or EPBRepo.migrationEPB.search(migrationClass, doc_id) is not None:122 if doc_id is None or self.epbRepo.migrationEPB.search(migrationClass, doc_id) is not None: 91 123 return 92 124 … … 94 126 #The document shall be classified 95 127 docCreation = self._extractCreationDate(xmlDocument) 96 self._createMigrationObject(migrationClass, doc_id, docName, docOwner, docStatus, doc Hash, docCreation)128 self._createMigrationObject(migrationClass, doc_id, docName, docOwner, docStatus, docCreation) 97 129 98 130 -
mauRepo/MolesManager/trunk/src/libs/migration/processor/migrationProcess.py
r8333 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 10 Jan 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from libs.migration.processor.dataEntity import DataEntityProcessor 7 from libs.migration.MigrationEPB import MigrationEPB8 34 import logging 9 35 from logging import StreamHandler 10 from libs.migration.processor.EPBRepo import EPBRepo11 36 12 37 class MigrationProcess(): … … 18 43 Manages the migration process from Moles2 to Moles3. 19 44 """ 20 def __init__(self): 21 pass 45 def __init__(self, epbRepo): 46 ''' 47 @param epbRepo: an instance of EPBRepo 48 ''' 49 self.epbRepo = epbRepo 22 50 23 51 def process(self, dataEntityObject = None): … … 31 59 """ 32 60 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 """ 61 data_ents = self.epbRepo.migrationEPB.getDataEntityMigrationbyPath(dataEntityObject) 41 62 42 63 #loops over the data entities 43 64 for dataEntityMigration in data_ents: 44 dep = DataEntityProcessor(dataEntityMigration )65 dep = DataEntityProcessor(dataEntityMigration, self.epbRepo) 45 66 exs.extend(dep.process()) 46 67 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() 68 return exs -
mauRepo/MolesManager/trunk/src/libs/migration/tests/dropAllTables.sql
r8323 r8358 1 DROP TABLE IF EXISTS angle CASCADE;1 DROP TABLE IF EXISTS angle CASCADE; 2 2 DROP TABLE IF EXISTS "any" CASCADE; 3 3 DROP TABLE IF EXISTS cc_concatenatedoperation CASCADE; … … 54 54 DROP TABLE IF EXISTS ci_series CASCADE; 55 55 DROP TABLE IF EXISTS ci_telephone CASCADE; 56 DROP TABLE IF EXISTS class08_4 CASCADE;57 DROP TABLE IF EXISTS class09_1 CASCADE;58 DROP TABLE IF EXISTS class09_2 CASCADE;59 DROP TABLE IF EXISTS class09_3 CASCADE;60 DROP TABLE IF EXISTS class09_4 CASCADE;61 DROP TABLE IF EXISTS class10_1 CASCADE;62 DROP TABLE IF EXISTS class12_1 CASCADE;63 DROP TABLE IF EXISTS class12_2 CASCADE;64 DROP TABLE IF EXISTS class12_3 CASCADE;65 DROP TABLE IF EXISTS class12_4 CASCADE;66 56 DROP TABLE IF EXISTS cl_classificationcollection CASCADE; 67 57 DROP TABLE IF EXISTS cl_classificationcollection_cv_surfacevaluepair CASCADE; … … 552 542 DROP TABLE IF EXISTS uomscale CASCADE; 553 543 DROP TABLE IF EXISTS url CASCADE; 554 DROP TABLE IF EXISTS data_entity_migration CASCADE;555 DROP TABLE IF EXISTS deployment_data_migration CASCADE;556 DROP TABLE IF EXISTS deployments_migration CASCADE;557 544 DROP TABLE IF EXISTS cv_solidvaluepair_cv_discretecoverage CASCADE; 545 DROP TABLE IF EXISTS geometries CASCADE; 546 DROP TABLE IF EXISTS geometry_columns CASCADE; 547 DROP TABLE IF EXISTS spatial_ref_sys CASCADE; 548 549 558 550 DROP TABLE IF EXISTS ceda_guid CASCADE; 551 UPDATE data_entity_migration 552 set ceda_observation_coll_id = NULL, doc_hash = NULL; 559 553 554 UPDATE deployments_migration 555 set ceda_observation_id = NULL, doc_hash = NULL; 556 557 UPDATE deployment_data_migration 558 set ceda_processing_id = NULL, ceda_instrument_id = NULL, 559 ceda_compositeprocess_id = NULL, ceda_acquisition_id = NULL, 560 ceda_project_id = NULL, doc_hash = NULL; 560 561 561 562 -
mauRepo/MolesManager/trunk/src/libs/migration/tests/migrationprocess.py
r8351 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 7 Mar 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from unittest import TestCase … … 38 65 moles3Factory = Moles3EPBFactory(molesDB) 39 66 migrationFactory = MigrationEPBFactory(migrationDB) 40 41 EPBRepo.moles3EPB = moles3Factory.createEPB() 42 EPBRepo.migrationEPB = migrationFactory.createEPB() 43 EPBRepo.infodbEPB = infoFactory.createEPB() 44 ''' 45 lr = LoadResources() 46 ex = lr.process() 47 for e in ex: 48 print e 49 ''' 67 68 self.epbRepo = EPBRepo(moles3Factory.createEPB() , \ 69 migrationFactory.createEPB(), \ 70 infoFactory.createEPB()) 71 72 if False: 73 lr = LoadResources(self.epbRepo) 74 ex = lr.process() 75 for e in ex: 76 print e 77 50 78 def testMigrationProcess(self): 51 mp = MigrationProcess( )79 mp = MigrationProcess(self.epbRepo) 52 80 53 81 dataEntity = MigrationObject() -
mauRepo/MolesManager/trunk/src/libs/migration/tests/testconfig.py
r8323 r8358 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 7 Mar 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 MIGRATION_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3' 7 34 MOLES3_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/Moles3' 8 35 INFO_DB_CONNECTION = 'postgresql://cedainfo:ler239b@bora.badc.rl.ac.uk:5432/cedainfo' 9 10 #TESTMIGRATION_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/ceda_moles3_test'11 #TESTMOLES3_DB_CONNECTION = 'postgresql://badc:rotyn217m@neptune.badc.rl.ac.uk:5432/ceda_moles3_test'12 36 13 37 from libs.migration.db.migrationTables import doTables as doMigration
Note: See TracChangeset
for help on using the changeset viewer.