Changeset 8194 for mauRepo


Ignore:
Timestamp:
28/03/12 16:56:49 (8 years ago)
Author:
mnagni
Message:

Complete - # 22397: CEDA Observation geographicExtent
 http://team.ceda.ac.uk/trac/ceda/ticket/22397
Incomplete - # 22399: CEDA Observation - permission
 http://team.ceda.ac.uk/trac/ceda/ticket/22399

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

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/ascore/utils.py

    r8147 r8194  
    2626        if type(item) == tuple or type(item) == list: 
    2727            for innerItem in item: 
    28                 toHash.extend(collectionProofHash(innerItem, processedItems)) 
     28                toHash.extend(_convertCollectionToList(innerItem, processedItems)) 
    2929        elif type(item) == dict: 
    3030            for innerItem in item.keys(): 
    31                 toHash.extend(collectionProofHash(innerItem, processedItems)) 
     31                toHash.extend(_convertCollectionToList(innerItem, processedItems)) 
    3232            for innerItem in item.values(): 
    33                 toHash.extend(collectionProofHash(innerItem, processedItems)) 
     33                toHash.extend(_convertCollectionToList(innerItem, processedItems)) 
    3434        else: 
    3535            toHash.append(item) 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8193 r8194  
    3939from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_telephone import CI_Telephone 
    4040from ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_period import TM_Period 
     41from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_constraints import MD_Constraints 
     42from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_legalconstraints import MD_LegalConstraints 
    4143 
    4244base = '/exist/rest/atoms' 
     
    229231    content = resourceXML.find('%scontent' % (atomNS)) 
    230232    text = _returnNotNoneText(content) 
    231     doc = htmlParser.parse(unescape(text)) 
    232233    contentDict = {} 
    233     for el in doc.findall('body//div'):     
    234         prop = el.get('property') 
    235         if prop: 
    236             if prop.startswith('cedacat'): 
    237                 contentDict[prop.split(':')[1]] = escape(tostring(el)) 
     234    if text: 
     235        doc = htmlParser.parse(unescape(text)) 
     236        for el in doc.findall('body//div'):     
     237            prop = el.get('property') 
     238            if prop: 
     239                if prop.startswith('cedacat'): 
     240                    contentDict[prop.split(':')[1]] = escape(tostring(el)) 
    238241    return contentDict 
    239242 
     
    648651        ci_citation.date = date  
    649652    return ci_citation 
     653 
     654def createMD_Constraints(useLimitation = None): 
     655    """ 
     656        Creates a new MD_Constrains 
     657        @param useLimitation: a string array 
     658    """  
     659    md_constraints = MD_Constraints() 
     660    if useLimitation and type(useLimitation) == list: 
     661        md_constraints.useLimitation = useLimitation 
     662    return md_constraints 
     663 
     664def createMD_LegalConstraints(useLimitation = None): 
     665    """ 
     666        Creates a new MD_LegalConstrains 
     667        @param useLimitation: a string array 
     668    """  
     669    md_legalconstraints = MD_LegalConstraints() 
     670    if useLimitation and type(useLimitation) == list: 
     671        md_legalconstraints.useLimitation = useLimitation 
     672    return md_legalconstraints 
    650673 
    651674def createMD_Identifier(code, authority = None): 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8193 r8194  
    99    createMD_Identifier, extractSummary, extractQuality, \ 
    1010    hasAtomDocumentSameHash, getAtomDocumentHashByMO, extractTitle,\ 
    11         createMO_ResponsiblePartyInfoAsCI_Organization,\ 
    12         createMO_ResponsiblePartyInfoAsCI_Individual, createCEDA_Result,\ 
     11        createCEDA_Result,\ 
    1312    createEX_GeographicBoundingBox, extractGeographicExtentInMigrationDocument, findDownloadLinksInMigrationDocument,\ 
    1413    findDOIInMigrationDocument, extractContent, createCI_Citation, createCI_Date, createDate,\ 
     
    1817    createCI_Contact, createCI_Address, createCI_OnlineResource,\ 
    1918    createCI_Telephone, extractMolesTemporalRange, isoDateStringToTimeDate,\ 
    20     createTM_Period 
     19    createTM_Period, createCI_Individual 
    2120from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
    2221from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    9089                opi.party.append(np) 
    9190 
     91    def _appendResponsibleParty(self, observation, names, creation_function, role): 
     92        for nm in names: 
     93            i_party = creation_function(name = nm) 
     94            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(role, [i_party]))         
     95 
    9296    def _assignName(self, observation):         
    9397        ''' 
     
    100104            doc_authors = findAuthorsInResource(self._dataEntityMigration) 
    101105            whereAreAuthors = self._dataEntityMigration 
    102                         
    103         Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo(MO_RoleValue.cl_curator, [CEDA]), observation, self._migrationSessions.molesSession) 
     106 
     107        i_party = createMO_Organization(name = CEDA) 
     108        observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_curator, i_party))                                
    104109         
    105110        if authors.has_key(doc_authors['authors']): 
    106             tmp_auth = authors[doc_authors['authors']]             
     111            tmp_auth = authors[doc_authors['authors']] 
    107112            ret = self._extractIndividualsAndOrganizations(tmp_auth, whereAreAuthors) 
    108113            if len(ret['ind']) > 0: 
    109                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Individual(MO_RoleValue.cl_author, [ret['ind']]), observation, self._migrationSessions.molesSession) 
     114                self._appendResponsibleParty(observation, ret['ind'], createCI_Individual, MO_RoleValue.cl_author)                 
    110115            if len(ret['org']) > 0: 
    111                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Organization(MO_RoleValue.cl_author, [ret['org']]), observation, self._migrationSessions.molesSession)                 
     116                self._appendResponsibleParty(observation, ret['org'], createMO_Organization, MO_RoleValue.cl_author)                                 
    112117            if len(ret['co_ind']) > 0: 
    113                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Individual(MO_RoleValue.cl_coinvestigator, [ret['co_ind']]), observation, self._migrationSessions.molesSession) 
     118                self._appendResponsibleParty(observation, ret['co_ind'], createCI_Individual, MO_RoleValue.cl_coinvestigator)                 
    114119            if len(ret['co_org']) > 0: 
    115                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Organization(MO_RoleValue.cl_coinvestigator, [ret['co_org']]), observation, self._migrationSessions.molesSession)                                                           
     120                self._appendResponsibleParty(observation, ret['co_org'], createMO_Organization, MO_RoleValue.cl_coinvestigator)                                                                                          
    116121        else: 
    117122            raise NoAssociatedAuthor(doc_authors['authors'], migrationObject = whereAreAuthors) 
     
    124129            ret = self._extractIndividualsAndOrganizations(tmp_auth, whereAreAuthors) 
    125130            if len(ret['ind']) > 0: 
    126                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Individual(MO_RoleValue.cl_coinvestigator, [ret['ind']]), observation, self._migrationSessions.molesSession) 
     131                self._appendResponsibleParty(observation, ret['ind'], createCI_Individual, MO_RoleValue.cl_coinvestigator) 
    127132            if len(ret['org']) > 0: 
    128                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Organization(MO_RoleValue.cl_coinvestigator, [ret['org']]), observation, self._migrationSessions.molesSession)                 
     133                self._appendResponsibleParty(observation, ret['org'], createMO_Organization, MO_RoleValue.cl_coinvestigator)                 
    129134            if len(ret['co_ind']) > 0: 
    130                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Individual(MO_RoleValue.cl_coinvestigator, [ret['co_ind']]), observation, self._migrationSessions.molesSession) 
     135                self._appendResponsibleParty(observation, ret['co_ind'], createCI_Individual, MO_RoleValue.cl_coinvestigator)                 
    131136            if len(ret['co_org']) > 0: 
    132                 Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfoAsCI_Organization(MO_RoleValue.cl_coinvestigator, [ret['co_org']]), observation, self._migrationSessions.molesSession)                                         
     137                self._appendResponsibleParty(observation, ret['co_org'], createMO_Organization, MO_RoleValue.cl_coinvestigator)                                                         
    133138        else: 
    134139            raise NoAssociatedAuthor(doc_authors['contributors'], migrationObject = whereAreAuthors) 
     
    270275         
    271276        if party: 
    272             Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_publisher, party), observation, self._migrationSessions.molesSession) 
    273             Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_custodian, party), observation, self._migrationSessions.molesSession) 
    274             Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_distributor, party), observation, self._migrationSessions.molesSession) 
    275             Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_pointofcontact, party), observation, self._migrationSessions.molesSession) 
    276             Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_metadataowner, party), observation, self._migrationSessions.molesSession) 
    277             Moles3EPB.addRelatedPartyInfoToObservation(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_curator, party), observation, self._migrationSessions.molesSession)                                                             
     277            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_publisher, [party])) 
     278            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_custodian, [party])) 
     279            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_distributor, [party])) 
     280            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_pointofcontact, [party])) 
     281            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_metadataowner, [party])) 
     282            observation.relatedParty.append(createMO_ResponsiblePartyInfo_(MO_RoleValue.cl_curator, [party]))                                                             
    278283 
    279284    def _assignPhenomenonTime(self, observation):         
     
    295300                observation.phenomenonTime = createTM_Position(date8601 = createDate(isoDateStringToTimeDate(doc_phenomenon_time)))          
    296301 
     302    def _assignPermission(self, observation): 
     303        contentDict = extractContent(self._deploymentMigration) 
     304        if not contentDict.has_key('access-restricted'): 
     305            contentDict = extractContent(self._dataEntityMigration) 
     306        ## TO BE DONE 
     307             
     308             
     309              
     310 
     311     
    297312    def createNewObservation(self): 
    298313        ceda_observation = CEDA_Observation() 
     
    309324        self._assignPublisherCurator(ceda_observation)         
    310325        self._assignPhenomenonTime(ceda_observation)         
     326        self._assignPermission(ceda_observation)         
    311327        #self._migrationSessions.molesSession.commit() 
    312328        #self._commitMoles3() 
Note: See TracChangeset for help on using the changeset viewer.