Changeset 8203 for mauRepo


Ignore:
Timestamp:
01/04/12 15:59:40 (8 years ago)
Author:
mnagni
Message:

Incomplete - # 22392: citation migration from MOLES2
 http://team.ceda.ac.uk/trac/ceda/ticket/22392
Incomplete - # 22398: CEDA Observation - quality statement
 http://team.ceda.ac.uk/trac/ceda/ticket/22398

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

Legend:

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

    r8198 r8203  
    9090            if commit: 
    9191                intSession.commit() 
    92     @classmethod 
    93     def addDocumentQuality(self, doc_quality, observation, session = None, commit = False): 
    94         """ 
    95             Adds an resultQuality element to an Observation if still not assigned or not equal. 
    96             @param doc_quality: the quality string to persist 
    97             @param observation: the observation to update 
    98             @param session: the session to use for the operation 
    99             @param commit: if True commits at the end (defaul False)  
    100         """         
    101         intSession = Moles3EPB._getSession(session) 
    102         for rq in observation.resultQuality: 
    103             for res in rq.result: 
    104                 if hasattr(res, 'explaination') and res.explaination == doc_quality: 
    105                     return True 
    106                     moles3Append(observation, observation.resultQuality, createDQ_Element(explaination = doc_quality)) 
    10792     
    10893    @classmethod 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8202 r8203  
    212212    return _returnNotNoneText(provider_id) 
    213213 
     214def extractMolesQuality(migrationObject): 
     215    resourceXML = getAtomDocumentByMO(migrationObject) 
     216    quality = resourceXML.find('%sentity/%smolesISO/%squality' % (molesNS, molesNS, molesNS)) 
     217    return _returnNotNoneText(quality) 
     218 
    214219def extractMolesTemporalRange(migrationObject): 
    215220    resourceXML = getAtomDocumentByMO(migrationObject) 
     
    743748 
    744749 
    745 def createDQ_ConformanceResult(explaination = ""): 
     750def createDQ_ConformanceResult(explanation, pass_, specification): 
     751    """ 
     752        Creates a DQ_ConformanceResult instance 
     753        @param explanation: a String 
     754        @param pass_: a boolean value 
     755        @param specification: a CI_Citation instance   
     756    """ 
    746757    dq_conformanceResult = DQ_ConformanceResult() 
    747     dq_conformanceResult.explanation = explaination 
     758    dq_conformanceResult.explanation = explanation 
     759    dq_conformanceResult.pass_ = pass_ 
     760    dq_conformanceResult.specification = specification 
    748761    return dq_conformanceResult 
    749762 
    750 def createDQ_Element(explaination = ""): 
     763def createDQ_Element(result): 
     764    """ 
     765        Creates a DQ_Element instance 
     766        @param result: a DQ_Result array (mix 1, max 2 items)  
     767    """ 
    751768    dq_element = DQ_Element() 
    752     dq_element.result = [] 
    753     dq_result = createDQ_ConformanceResult(explaination) 
    754     dq_element.result.append(dq_result) 
     769    if result and (type(result) == list) and (len(result) >= 1 and len(result) <= 2): 
     770        dq_element.result = result 
    755771    return dq_element 
    756772 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8201 r8203  
    1818    createCI_Telephone, extractMolesTemporalRange, isoDateStringToTimeDate,\ 
    1919    createTM_Period, createCI_Individual, findAccessLinksInMigrationDocument,\ 
    20     findLinksInDeployment, createMD_LegalConstraints 
     20    findLinksInDeployment, createMD_LegalConstraints, extractMolesQuality,\ 
     21    createDQ_Element, createDQ_ConformanceResult, findUpdatedDate 
    2122from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    2223from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    3738from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_restrictioncode import MD_RestrictionCode 
    3839from copy import deepcopy 
     40import datetime 
    3941 
    4042class DeploymentProcessor(object): 
     
    191193    def _assignQuality(self, observation): 
    192194        doc_quality = extractQuality(self._dataEntityMigration) 
    193         Moles3EPB.addDocumentQuality(doc_quality, observation, self._migrationSessions.molesSession) 
     195        doc_date = findUpdatedDate(self._dataEntityMigration) 
     196        ci_dates = []             
     197        if doc_date: 
     198            i_date = createDate(isoDateTimeStringToTimeDate(doc_date))                 
     199            ci_dates.append(createCI_Date(CI_DateTypeCode.cl_revision, date = i_date))             
     200        else: 
     201            i_date = createDate(isoDateTimeStringToTimeDate(datetime.datetime.now())) 
     202            ci_dates.append(createCI_Date(CI_DateTypeCode.cl_creation, date = i_date)) 
     203 
     204        i_specification = createCI_Citation(title = "CEDA Data Quality Statement", date=ci_dates) 
     205        i_dq_result = createDQ_ConformanceResult(doc_quality, True, i_specification) 
     206        i_quality_element = createDQ_Element(i_dq_result)         
     207        observation.resultQuality = [i_quality_element] 
    194208         
    195209    def updateObservation(self): 
     
    349363        identifier = createMD_Identifier(code = i_code, authority = i_authority) 
    350364        moles3Append(ceda_observation, 'identifier', identifier) 
    351  
    352365     
    353366    def createNewObservation(self): 
     
    366379        self._assignPhenomenonTime(ceda_observation)         
    367380        self._assignPermission(ceda_observation)         
    368         self._assignMoles2Link(ceda_observation)         
     381        self._assignMoles2Link(ceda_observation) 
     382        self._assignQuality(ceda_observation)                 
    369383        #self._migrationSessions.molesSession.commit() 
    370384        #self._commitMoles3() 
Note: See TracChangeset for help on using the changeset viewer.