Changeset 8416 for mauRepo/MolesManager
- Timestamp:
- 27/06/12 16:41:44 (9 years ago)
- Location:
- mauRepo/MolesManager/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/MolesManager/trunk/src/MolesManager/moles3epb.py
r8409 r8416 41 41 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_citation import CI_Citation 42 42 from ea_model.iso_19115_2006_metadata_corrigendum.extent_information.ex_geographicboundingbox import EX_GeographicBoundingBox 43 from libs.postgisutil import unifyGeometries, create_st_setSRID 43 from libs.postgisutil import unifyGeometries, create_st_setSRID, getBox2D,\ 44 unifyGeometriesAsBBox 44 45 from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 45 46 from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation … … 113 114 def updateCedaObject(self, ceda_object, cols_to_update): 114 115 """ 115 Update and eventuallycommit a CEDA Object in MOLES3 db.116 Update, eventually add to the session, and commit a CEDA Object in MOLES3 db. 116 117 @param ceda_object: the CEDA object to update 117 118 @param cols_to_update: a dictionary containing the columns to update for the given ceda_object and the desired value. … … 121 122 coll = None 122 123 try: 123 coll = self._session.merge(ceda_object) 124 if ceda_object in self._session: 125 coll = self._session.merge(ceda_object) 126 else: 127 self._session.add(ceda_object) 128 coll = ceda_object 124 129 except Exception as e: 125 130 print e … … 157 162 ge.eastBoundLongitude, ge.northBoundLatitude) 158 163 return None 159 160 161 162 def getUnifyObservationCollectionGE(self, collection): 164 165 def getUnifyObservationCollectionGEAsBBox(self, collection): 163 166 """ 164 167 Returns the union of the collections.member'a GeographicExtension(s) … … 170 173 bboxes.append(self.getGeograpicExtentGeometry(ge)) 171 174 172 return unifyGeometries(bboxes, self) 175 return unifyGeometriesAsBBox(bboxes, self) 176 173 177 174 178 def retrieveGUIDFromInstance(self, instance): -
mauRepo/MolesManager/trunk/src/libs/migration/processor/dataEntity.py
r8415 r8416 38 38 isoDateTimeStringToTimeDate, findUpdatedDate, createDate,\ 39 39 calculateHash, findDOIInMigrationDocument,\ 40 hasMOBeenProcessed, getAtomDocumentHashByMO, extractTitle, extractSummary 40 hasMOBeenProcessed, getAtomDocumentHashByMO, extractTitle, extractSummary,\ 41 createEX_GeographicBoundingBox 41 42 from libs.migration.processor.deployment import DeploymentProcessor 42 43 from logging import StreamHandler … … 66 67 # raise MigrationObjectException("DataEntityProcessor cannot process an None item") 67 68 self._dataEntityMigration = dataEntityMigration 68 self._dataEntityHasSameHash = hasMOSameHash(self._dataEntityMigration) 69 self._dataEntityHasSameHash = hasMOSameHash(self._dataEntityMigration) 70 self._dataEntityHasBeenProcessed = hasMOBeenProcessed(self._dataEntityMigration) 69 71 self.epbRepo = epbRepo 70 72 71 def _checkGeographicExtent(self, ceda_observationCollection): 72 union = self.moles3epb.getUnifyObservationCollectionGE(ceda_observationCollection) 73 def _assignGeographicExtent(self, ceda_observationCollection): 74 bbox = self.epbRepo.moles3EPB.getUnifyObservationCollectionGEAsBBox(ceda_observationCollection) 75 if bbox: 76 upperCornerData, lowerCornerData = bbox[4:len(bbox)-1].split(',') 77 east, north = upperCornerData.split() 78 west, south = lowerCornerData.split() 79 geographicExtent = createEX_GeographicBoundingBox(float(east), float(north), \ 80 float(west), float(south)) 81 if self._dataEntityHasBeenProcessed: 82 DataEntityProcessor.log.warn('The _assignGeographicExtent update is skipped because not implemented') 83 return 84 85 self.epbRepo.moles3EPB.updateCedaObject(ceda_observationCollection, {'geographicExtent': geographicExtent}) 86 else: 87 print "No Geographic Extent" 88 return 89 73 90 74 91 def _assignDescription(self, ceda_observationCollection): 75 if self._dataEntityHasSameHash:76 return77 78 92 description = extractSummary(self._dataEntityMigration) 79 93 … … 82 96 83 97 def _processTitle(self, ceda_observationCollection): 84 if self._dataEntityHasSameHash:85 return86 87 98 ititle = extractTitle(self._dataEntityMigration) 88 99 if ceda_observationCollection.identifier: … … 97 108 i_citation = createCI_Citation(title = CEDA_TITLE) 98 109 newIdentifier = createMD_Identifier(code = ititle, authority=i_citation) 99 ceda_observationCollection.identifier.append(newIdentifier) 110 111 if self._dataEntityHasBeenProcessed: 112 DataEntityProcessor.log.warn('The _assignGeographicExtent update is skipped because not implemented') 113 return 114 115 self.epbRepo.moles3EPB.updateCedaObject(ceda_observationCollection, {'identifier': newIdentifier}) 100 116 101 117 def _processCitation(self, ceda_observationCollection): … … 104 120 DataEntityProcessor.log.info("The migration object "+ migrationObjectDescription(self._dataEntityMigration) \ 105 121 + " has not associated cedacat:citation") 106 else: 107 ci_dates = [] 108 doc_date = findPublishedDate(self._dataEntityMigration) 109 if doc_date: 110 i_date = createDate(isoDateTimeStringToTimeDate(doc_date)) 111 ci_dates.append(createCI_Date(getCLValue(CI_DateTypeCode.cl_publication), date = i_date)) 112 113 doc_date = findUpdatedDate(self._dataEntityMigration) 114 if doc_date: 115 i_date = createDate(isoDateTimeStringToTimeDate(doc_date)) 116 ci_dates.append(createCI_Date(getCLValue(CI_DateTypeCode.cl_revision), date = i_date)) 117 118 i_citation = createCI_Citation(title = 'ceda_moles2_citation', date=ci_dates) 119 newIdentifier = createMD_Identifier(code = contentDict['citation'], authority=i_citation) 120 ceda_observationCollection.identifier.append(newIdentifier) 122 return 123 124 ci_dates = [] 125 doc_date = findPublishedDate(self._dataEntityMigration) 126 if doc_date: 127 i_date = createDate(isoDateTimeStringToTimeDate(doc_date)) 128 ci_dates.append(createCI_Date(getCLValue(CI_DateTypeCode.cl_publication), date = i_date)) 129 130 doc_date = findUpdatedDate(self._dataEntityMigration) 131 if doc_date: 132 i_date = createDate(isoDateTimeStringToTimeDate(doc_date)) 133 ci_dates.append(createCI_Date(getCLValue(CI_DateTypeCode.cl_revision), date = i_date)) 134 135 i_citation = createCI_Citation(title = 'ceda_moles2_citation', date=ci_dates) 136 newIdentifier = createMD_Identifier(code = contentDict['citation'], authority=i_citation) 137 138 if self._dataEntityHasBeenProcessed: 139 DataEntityProcessor.log.warn('The _assignGeographicExtent update is skipped because not implemented') 140 return 141 142 ceda_observationCollection = self.epbRepo.moles3EPB.updateCedaObject(ceda_observationCollection, {'identifier': newIdentifier}) 143 121 144 122 145 def _execute(self, ceda_observationCollection): … … 127 150 """ 128 151 129 self._processTitle(ceda_observationCollection)130 self._assignDescription(ceda_observationCollection)131 132 152 if not self._dataEntityHasSameHash: 133 self._processCitation(ceda_observationCollection) 134 #self._processResult(ceda_observationCollection) 153 self._processTitle(ceda_observationCollection) 154 self._assignDescription(ceda_observationCollection) 155 self._processCitation(ceda_observationCollection) 135 156 136 157 #Is a first time process? … … 224 245 225 246 except Exception as ex: 226 exs.append(ex) 227 228 self._checkGeographicExtent(obsColl) 247 exs.append(ex) 248 self._assignGeographicExtent(obsColl) 229 249 230 250 return exs -
mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py
r8409 r8416 439 439 if ge: 440 440 geographicExtent = createEX_GeographicBoundingBox(ge['east'], ge['north'], ge['west'], ge['south']) 441 if not self._deploymentHasBeenProcessed: 442 observation.geographicExtent.append(geographicExtent) 441 if self._deploymentHasBeenProcessed: 442 DeploymentProcessor.log.warn('The _assignGeographicExtent update is skipped because not implemented') 443 observation.geographicExtent.append(geographicExtent) 444 else: 445 print "No Geographic Extent" 443 446 return 444 447 #Still have to update observation.geographicExtent -
mauRepo/MolesManager/trunk/src/libs/postgisutil.py
r8392 r8416 56 56 return _processGeometries(bboxes, epb, 'ST_Union') 57 57 58 def unifyGeometriesAsBBox(bboxes, epb): 59 union = _processGeometries(bboxes, epb, 'ST_Union') 60 return getBox2D(union, epb) 61 58 62 def intersectGeometries(bboxes, epb): 59 63 return _processGeometries(bboxes, epb, 'ST_Intersection') 64 65 def getBox2D(geometry, epb): 66 cmdString = 'SELECT ST_Box2D(st_setSRID(\'%s\', 4326));' % (geometry) 67 bbox = normalizeUnicode(epb.executeNative(cmdString).first()[0]) 68 return bbox 60 69 61 70 def _processGeometries(bboxes, epb, function): … … 86 95 87 96 def normalizeUnicode(text): 88 return unicodedata.normalize('NFKD', text).encode('ascii','ignore') 97 if isinstance(text, unicode): 98 return unicodedata.normalize('NFKD', text).encode('ascii','ignore') 99 return text
Note: See TracChangeset
for help on using the changeset viewer.