- Timestamp:
- 02/07/12 17:14:58 (9 years ago)
- Location:
- mauRepo/MolesManager/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/MolesManager/trunk/src/MolesManager/molesSessionMiddleware.py
r8358 r8425 74 74 MolesSessionMiddleware._epbInitialized = True 75 75 76 self._migration() #see the note on MolesSessionMiddleware._migration 77 78 def _migration(self, runMigration = RUN_MIGRATION): 79 if runMigration and not MolesSessionMiddleware._migrationThread.isAlive(): 80 #t.setDaemon(False) 81 MolesSessionMiddleware._migrationThread.start() 76 _migration() 82 77 83 78 def process_request(self, request): … … 103 98 c['exception'] = exception 104 99 c.update(csrf(request)) 105 return render_to_response('errorTemplate.html', c) 100 return render_to_response('errorTemplate.html', c) 101 102 def _migration(runMigration = RUN_MIGRATION): 103 if runMigration and not MolesSessionMiddleware._migrationThread.isAlive(): 104 #t.setDaemon(False) 105 MolesSessionMiddleware._migrationThread.start() -
mauRepo/MolesManager/trunk/src/libs/epb.py
r8358 r8425 38 38 39 39 @classmethod 40 def buildFilter( self, key, keyValue):40 def buildFilter(cls, key, keyValue): 41 41 try: 42 42 return '%s = \'%s\'' % (key, keyValue) … … 45 45 46 46 @classmethod 47 def search( self, clazz, inst_key, session):47 def search(cls, clazz, inst_key, session): 48 48 """ 49 49 Searches a required instance by id … … 65 65 66 66 @classmethod 67 def searchEager( self, clazz, inst_id, session):67 def searchEager(cls, clazz, inst_id, session): 68 68 """ 69 69 Searches a required instance by id loading eagerly ALL its field. Please use carefully because \ … … 81 81 82 82 @classmethod 83 def searchSelectiveLoad( self, clazz, inst_id, attrs, session):83 def searchSelectiveLoad(cls, clazz, inst_id, attrs, session): 84 84 """ 85 85 Searches a required instance by id loading \ … … 108 108 if res is None: 109 109 return None 110 self._drillData(res, attrs)110 EPB._drillData(res, attrs) 111 111 return res 112 112 113 113 @classmethod 114 def loadAttributes( self, instance, attributes, session):114 def loadAttributes(cls, instance, attributes, session): 115 115 """ 116 116 Loads the given instance with the required attributes. … … 138 138 raise Exception("Session is None!") 139 139 session.merge(instance) 140 self._drillData(instance, attributes)140 EPB._drillData(instance, attributes) 141 141 142 142 143 143 @classmethod 144 def searchOrCreate( self, clazz, session, clazz_id = None):144 def searchOrCreate(cls, clazz, session, clazz_id = None): 145 145 if clazz_id is not None: 146 146 return EPB.search(clazz, clazz_id, session) … … 150 150 151 151 @classmethod 152 def getAllObjects( self, clazz, session):152 def getAllObjects(cls, clazz, session): 153 153 res = session.query(clazz) 154 154 if res is None: … … 157 157 158 158 @classmethod 159 def persistInstance( self, instance, session):159 def persistInstance(cls, instance, session): 160 160 """ 161 161 Adds a new migration object. … … 175 175 176 176 @classmethod 177 def _getSession( self, dbManager, session = None):177 def _getSession(cls, dbManager, session = None): 178 178 if session: 179 179 return session … … 181 181 182 182 @classmethod 183 def _drillData( self, obj, attrs):183 def _drillData(cls, obj, attrs): 184 184 """ 185 185 @param obj: its an instance already living inside an SQLAlchemy session … … 188 188 #if is a single field wrap it in a list and recalls itself 189 189 if not isinstance(attrs, list): 190 self._drillData(obj, [attrs])190 EPB._drillData(obj, [attrs]) 191 191 for item in attrs: 192 192 attr = item.split('.')[0] 193 193 if isinstance(obj, list): 194 194 for element in obj: 195 self._drillData(element, [item])195 EPB._drillData(element, [item]) 196 196 else: 197 197 if hasattr(obj, attr): 198 198 nobj = getattr(obj, attr) 199 199 if len(attr) != len(item): 200 self._drillData(nobj, [item[len(attr) + 1:]])200 EPB._drillData(nobj, [item[len(attr) + 1:]]) 201 201 202 202 -
mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py
r8424 r8425 54 54 from libs.migration.processor.deployment_data import DeploymentDataProcessor 55 55 from libs.migration.exception.exceptions import NoDataLineage,\ 56 NoAssociatedAuthor 56 NoAssociatedAuthor, NoAssociatedDeployments 57 57 from libs.migration.authors import authors 58 58 from logging import StreamHandler … … 102 102 self._deploymentHasBeenProcessed = hasMOBeenProcessed(self._deploymentMigration) 103 103 104 def _existsCEDAasPublisher(self):105 for rp in self._ceda_observation.relatedParty:106 if rp.role == getCLValue(MM_RoleValue.cl_publisher):107 for party in rp.parties:108 if party.name == DeploymentProcessor.publisherName:109 return True110 return False111 112 """113 def _extractResponsiblePartyInfo(self, authors = None, parsedParties = []):114 '''115 @param authors: the deployment's authors116 @param parsedParties: a list to fill with the created MO_ResponsiblePartyInfos117 '''118 #First is assumend to be the author119 i_party = createMO_Organization(name = authors[:1])120 parsedParties.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_author, [i_party]))121 i_party = []122 if len(authors) < 2:123 return124 125 for i_name in authors[:1]:126 i_party.append(createMO_Organization(name = i_name))127 parsedParties.append(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_coinvestigator, i_party))128 """129 130 104 def _addResponsiblePartyInfo(self, oldResponsiblePartyInfos, newResponsiblePartyInfo): 131 105 opi = None … … 147 121 def _extractIndividualsAndOrganizations(self, tmp_auth, whereAreAuthors): 148 122 if whereAreAuthors is None: 149 raise Exception("migrationObject is None")123 raise NoAssociatedDeployments("migrationObject is None") 150 124 try: 151 125 if tmp_auth['author'] == 'unknown': … … 329 303 330 304 if party and not self._deploymentHasBeenProcessed: 331 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_publisher), [party])) 332 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_custodian), deepcopy([party]))) 333 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_distributor), deepcopy([party]))) 334 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_pointofcontact), deepcopy([party]))) 335 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_metadataowner), deepcopy([party]))) 336 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_curator), deepcopy([party]))) 305 newrp = [] 306 newrp.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_publisher), [party])) 307 newrp.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_custodian), deepcopy([party]))) 308 newrp.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_distributor), deepcopy([party]))) 309 newrp.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_pointofcontact), deepcopy([party]))) 310 newrp.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_metadataowner), deepcopy([party]))) 311 newrp.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_curator), deepcopy([party]))) 312 self.epbRepo.moles3EPB.updateCedaObject(observation, {'relatedParty': newrp}) 337 313 return 338 314 #Still have to update observation.result.source … … 624 600 if i_party: 625 601 if not self._deploymentHasBeenProcessed: 626 observation.relatedParty.append(createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_coinvestigator), i_party)) 602 rp = createMO_ResponsiblePartyInfo(getCLValue(MM_RoleValue.cl_coinvestigator), i_party) 603 self.epbRepo.moles3EPB.updateCedaObject(observation, {'relatedParty': rp}) 627 604 return 628 605 #Still have to update observation.permission
Note: See TracChangeset
for help on using the changeset viewer.