Changeset 8202 for mauRepo


Ignore:
Timestamp:
01/04/12 14:16:41 (8 years ago)
Author:
mnagni
Message:

Complete - # 22390: AMEND MOLES2 -> CEDA Moles Author and Co-author migration (plus PI assignment) to CEDA Observation record
 http://team.ceda.ac.uk/trac/ceda/ticket/22390
Incomplete - # 22392: citation migration from MOLES2
 http://team.ceda.ac.uk/trac/ceda/ticket/22392

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

Legend:

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

    r8194 r8202  
    44@author: mnagni 
    55''' 
     6from sqlalchemy.orm.collections import InstrumentedList 
    67def has_value(item): 
    78    if item is not None: 
     
    2021def _convertCollectionToList(tupleToHash, processedItems = []):  
    2122    toHash = [] 
     23    if tupleToHash is not None and type(tupleToHash) != tuple and type(tupleToHash) != list \ 
     24        and type(tupleToHash) != InstrumentedList and type(tupleToHash) != dict: 
     25        processedItems.append(tupleToHash) 
     26        toHash.append(tupleToHash) 
     27        return toHash 
     28     
    2229    for item in tupleToHash: 
    2330        if item in processedItems: 
    2431            continue 
    2532        processedItems.append(item) 
    26         if type(item) == tuple or type(item) == list: 
     33        if type(item) == tuple or type(item) == list or type(item) == InstrumentedList: 
    2734            for innerItem in item: 
    2835                toHash.extend(_convertCollectionToList(innerItem, processedItems)) 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8201 r8202  
    274274    return _returnNotNoneText(contributors) 
    275275 
     276def findPublishedDate(resourceMigration): 
     277    resourceXML = getAtomDocumentByMO(resourceMigration) 
     278    publishedDate = resourceXML.find('%spublished' % (atomNS)) 
     279    return _returnNotNoneText(publishedDate) 
     280 
     281def findUpdatedDate(resourceMigration): 
     282    resourceXML = getAtomDocumentByMO(resourceMigration) 
     283    publishedDate = resourceXML.find('%supdated' % (atomNS)) 
     284    return _returnNotNoneText(publishedDate) 
     285 
    276286def findID(dataEntXML): 
    277287    ent_id = dataEntXML.find('%sid' % (atomNS)) 
     
    458468    ''' 
    459469        Creates a new Date instance. 
    460         @param date: a datetime.date instance  
     470        @param date: a datetime.datetime instance  
    461471    ''' 
    462472    idate = Date() 
     
    640650        Creates a new CI_Date 
    641651        @param dateType: a CI_DateTypeCode value 
    642         @param date: a timestamp 
     652        @param date: a DateTime instance 
    643653    """ 
    644654    ci_date = CI_Date() 
     
    652662        Creates a new CI_Citation 
    653663        @param titile: the CI_Citation title 
    654         @param date: a CI_Date instance 
     664        @param date: an array of CI_Date instances 
    655665    """     
    656666    ci_citation = CI_Citation() 
    657667    ci_citation.title = title 
    658     if date: 
    659         ci_citation.date = date  
     668    if date and type(date) == list: 
     669        ci_citation.date = date 
    660670    return ci_citation 
    661671 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/dataEntity.py

    r8198 r8202  
    1313from libs.migration.processor.commons import findDeploymentsInDE,\ 
    1414    createMD_Identifier, extractContent, MD_CODE_MOLES2_CITATION,\ 
    15     hasAtomDocumentSameHash 
     15    hasAtomDocumentSameHash, createCI_Citation, createCI_Date, findPublishedDate,\ 
     16    isoDateTimeStringToTimeDate, findUpdatedDate, createDate, createDateTime 
    1617from libs.migration.processor.deployment import DeploymentProcessor 
    1718from ea_model.moles3_4.utilities.mo_publicationstatevalue import MO_PublicationStateValue 
     
    1920import logging 
    2021from libs.migration.processor.check.check import moles3Append 
     22from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 
    2123 
    2224class DataEntityProcessor(object): 
     
    4547                                         + " has not associated cedacat:citation") 
    4648        else: 
    47             newIdentifier = createMD_Identifier(code = contentDict['citation']) 
     49            ci_dates = [] 
     50            doc_date = findPublishedDate(self._dataEntityMigration)             
     51            if doc_date: 
     52                i_date = createDate(isoDateTimeStringToTimeDate(doc_date))            
     53                ci_dates.append(createCI_Date(CI_DateTypeCode.cl_publication, date = i_date)) 
     54 
     55            doc_date = findUpdatedDate(self._dataEntityMigration)             
     56            if doc_date: 
     57                i_date = createDate(isoDateTimeStringToTimeDate(doc_date))                 
     58                ci_dates.append(createCI_Date(CI_DateTypeCode.cl_revision, date = i_date)) 
     59                 
     60            i_citation = createCI_Citation(title = 'ceda_moles2_citation', date=ci_dates) 
     61            newIdentifier = createMD_Identifier(code = contentDict['citation'], authority=i_citation) 
    4862            moles3Append(ceda_observationCollection, 'identifier', newIdentifier) 
    4963     
Note: See TracChangeset for help on using the changeset viewer.