Changeset 8295


Ignore:
Timestamp:
02/05/12 11:54:02 (7 years ago)
Author:
mnagni
Message:

added a method on moles3epb to retrieve a CEDA_Observation author

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

Legend:

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

    r8264 r8295  
    1616from sqlalchemy.orm import mapper 
    1717from MolesManager.ceda_guid import CedaGUID 
     18from ea_model.moles3_4.utilities.mo_responsiblepartyinfo import MO_ResponsiblePartyInfo 
     19from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    1820 
    1921 
     
    110112        intSession = Moles3EPB._getSession(session) 
    111113        return intSession.query(CEDA_ObservationCollection, CEDA_Observation).filter(CEDA_ObservationCollection.id==obs_coll_id).filter(CEDA_Observation.id==obs_id).count() > 0 
     114 
     115    @classmethod 
     116    def observationAuthor(self, obs_id, session = None): 
     117        """ 
     118            Lists the CEDA_Observation author. 
     119            @param obs_id: the CEDA_Observation id             
     120            @return: True if the collection contains the given observation, False otherwise   
     121        """ 
     122        intSession = Moles3EPB._getSession(session) 
     123        ret = intSession.query(MO_ResponsiblePartyInfo).join(MO_Observation). \ 
     124            filter(MO_ResponsiblePartyInfo.role == MO_RoleValue.cl_author). \ 
     125            filter(MO_Observation.id == obs_id) 
     126        return ret 
    112127 
    113128    @classmethod 
  • mauRepo/MolesManager/trunk/src/libs/migration/tests/moles3epbmothods.py

    r8254 r8295  
    1515from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 
    1616from ea_model.moles3_4.observationcollection.mo_observationcollection import MO_ObservationCollection 
     17from ea_model.moles3_4.utilities.mo_responsiblepartyinfo import MO_ResponsiblePartyInfo 
     18from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     19from ea_model.moles3_4.observation.mo_observation import MO_Observation 
     20from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    1721 
    1822 
     
    3337 
    3438    def runTest(self): 
    35         self.checkExtractCollectionIdentifierByTitle()    
    36         self.checkExtractObservationByTitleKeywords()  
    37         self.checkExtractProjectObservationCollections() 
     39        #self.checkExtractCollectionIdentifierByTitle()    
     40        #self.checkExtractObservationByTitleKeywords()  
     41        #self.checkExtractProjectObservationCollections() 
    3842        #self.checkExtractObservationCollectionsForObservation() 
     43        self.checkObservationAuthors() 
     44 
     45    def checkObservationAuthors(self): 
     46        session = Moles3EPB.getNewMolesSession(); 
     47        coll = Moles3EPB.observationAuthor(1, session) 
     48        colls = coll.all() 
     49        print colls 
    3950 
    4051    def checkExtractObservationCollectionsForObservation(self): 
Note: See TracChangeset for help on using the changeset viewer.