Changeset 8425 for mauRepo


Ignore:
Timestamp:
02/07/12 17:14:58 (7 years ago)
Author:
mnagni
Message:

Complete - # 22488: CEDA Observation Collection - Geographical Extent
 http://team.ceda.ac.uk/trac/ceda/ticket/22488
Complete - # 22513: Missing ValidTime? tag in the CedaSearch?
 http://team.ceda.ac.uk/trac/ceda/ticket/22513

Location:
mauRepo/MolesManager/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/MolesManager/molesSessionMiddleware.py

    r8358 r8425  
    7474        MolesSessionMiddleware._epbInitialized = True       
    7575             
    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()       
    8277    
    8378    def process_request(self, request):   
     
    10398        c['exception'] = exception 
    10499        c.update(csrf(request)) 
    105         return render_to_response('errorTemplate.html', c)         
     100        return render_to_response('errorTemplate.html', c) 
     101     
     102def _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  
    3838 
    3939    @classmethod 
    40     def buildFilter(self, key, keyValue): 
     40    def buildFilter(cls, key, keyValue): 
    4141        try: 
    4242            return '%s = \'%s\'' % (key, keyValue) 
     
    4545 
    4646    @classmethod 
    47     def search(self, clazz, inst_key, session): 
     47    def search(cls, clazz, inst_key, session): 
    4848        """ 
    4949            Searches a required instance by id 
     
    6565 
    6666    @classmethod 
    67     def searchEager(self, clazz, inst_id, session): 
     67    def searchEager(cls, clazz, inst_id, session): 
    6868        """ 
    6969            Searches a required instance by id loading eagerly ALL its field. Please use carefully because \ 
     
    8181 
    8282    @classmethod 
    83     def searchSelectiveLoad(self, clazz, inst_id, attrs, session): 
     83    def searchSelectiveLoad(cls, clazz, inst_id, attrs, session): 
    8484        """ 
    8585            Searches a required instance by id loading \ 
     
    108108        if res is None: 
    109109            return None 
    110         self._drillData(res, attrs) 
     110        EPB._drillData(res, attrs) 
    111111        return res 
    112112 
    113113    @classmethod 
    114     def loadAttributes(self, instance, attributes, session): 
     114    def loadAttributes(cls, instance, attributes, session): 
    115115        """ 
    116116            Loads the given instance with the required attributes. 
     
    138138            raise Exception("Session is None!") 
    139139        session.merge(instance) 
    140         self._drillData(instance, attributes)                     
     140        EPB._drillData(instance, attributes)                     
    141141 
    142142 
    143143    @classmethod     
    144     def searchOrCreate(self, clazz, session, clazz_id = None): 
     144    def searchOrCreate(cls, clazz, session, clazz_id = None): 
    145145        if clazz_id is not None: 
    146146            return EPB.search(clazz, clazz_id, session) 
     
    150150 
    151151    @classmethod 
    152     def getAllObjects(self, clazz, session):      
     152    def getAllObjects(cls, clazz, session):      
    153153        res = session.query(clazz) 
    154154        if res is None: 
     
    157157 
    158158    @classmethod 
    159     def persistInstance(self, instance, session): 
     159    def persistInstance(cls, instance, session): 
    160160        """ 
    161161            Adds a new migration object. 
     
    175175 
    176176    @classmethod 
    177     def _getSession(self, dbManager, session = None): 
     177    def _getSession(cls, dbManager, session = None): 
    178178        if session: 
    179179            return session         
     
    181181 
    182182    @classmethod 
    183     def _drillData(self, obj, attrs): 
     183    def _drillData(cls, obj, attrs): 
    184184        """ 
    185185            @param obj: its an instance already living inside an SQLAlchemy session 
     
    188188        #if is a single field wrap it in a list and recalls itself 
    189189        if not isinstance(attrs, list): 
    190             self._drillData(obj, [attrs]) 
     190            EPB._drillData(obj, [attrs]) 
    191191        for item in attrs: 
    192192            attr = item.split('.')[0]             
    193193            if isinstance(obj, list): 
    194194                for element in obj: 
    195                     self._drillData(element, [item]) 
     195                    EPB._drillData(element, [item]) 
    196196            else: 
    197197                if hasattr(obj, attr): 
    198198                    nobj = getattr(obj, attr)  
    199199                    if len(attr) != len(item): 
    200                         self._drillData(nobj, [item[len(attr) + 1:]]) 
     200                        EPB._drillData(nobj, [item[len(attr) + 1:]]) 
    201201 
    202202         
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8424 r8425  
    5454from libs.migration.processor.deployment_data import DeploymentDataProcessor 
    5555from libs.migration.exception.exceptions import NoDataLineage,\ 
    56     NoAssociatedAuthor 
     56    NoAssociatedAuthor, NoAssociatedDeployments 
    5757from libs.migration.authors import authors 
    5858from logging import StreamHandler 
     
    102102        self._deploymentHasBeenProcessed = hasMOBeenProcessed(self._deploymentMigration) 
    103103 
    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 True 
    110         return False 
    111  
    112     """                     
    113     def _extractResponsiblePartyInfo(self, authors = None, parsedParties = []): 
    114         ''' 
    115             @param authors: the deployment's authors  
    116             @param parsedParties: a list to fill with the created MO_ResponsiblePartyInfos 
    117         ''' 
    118         #First is assumend to be the author 
    119         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             return 
    124          
    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  
    130104    def _addResponsiblePartyInfo(self, oldResponsiblePartyInfos, newResponsiblePartyInfo): 
    131105        opi = None 
     
    147121    def _extractIndividualsAndOrganizations(self, tmp_auth, whereAreAuthors): 
    148122        if whereAreAuthors is None: 
    149             raise Exception("migrationObject is None") 
     123            raise NoAssociatedDeployments("migrationObject is None") 
    150124        try: 
    151125            if tmp_auth['author'] == 'unknown': 
     
    329303         
    330304        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})             
    337313            return         
    338314        #Still have to update observation.result.source 
     
    624600        if i_party: 
    625601            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}) 
    627604                return 
    628605        #Still have to update observation.permission 
Note: See TracChangeset for help on using the changeset viewer.