Changeset 8016


Ignore:
Timestamp:
14/12/11 08:40:01 (8 years ago)
Author:
mnagni
Message:
 
Location:
mauRepo/MolesManager/trunk/src
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src

    • Property svn:ignore set to
      sqlite.db
  • mauRepo/MolesManager/trunk/src/MolesManager/static/templates/cedaObservation.html

    r8015 r8016  
     1 
     2 
     3 
     4 
     5 
     6 
     7 
    18<form action="." method="post">{% csrf_token %} 
     9<div class="fieldWrapper"> 
     10        <label for="id_obj_id">ID</label> 
     11        {{ objId.obj_id }} 
     12</div>   
     13<input type="submit" value="Submit" /> 
    214 
    3 {{ coObs.dataLineage }} 
    415 
    5 {{ form.as_p }} 
    6 <!--    
    7 <input type="submit" value="Submit" /> 
    8 --> 
     16 
     17<div class="fieldWrapper"> 
     18        <label for="id_dataLineage">dataLineage</label> 
     19        {{ coObs.dataLineage }} 
     20         
     21        <label for="id_relatedParty">relatedParty</label> 
     22        {{ coObs.relatedParty }} 
     23</div> 
    924</form> 
  • mauRepo/MolesManager/trunk/src/MolesManager/views/cedaObservationView.py

    r8015 r8016  
    88from django.shortcuts import render_to_response 
    99from django.core.context_processors import csrf 
     10from MolesManager.forms.commons import ObjectById 
     11from ea_model.ceda_moles.ceda_observation.ceda_observation import CEDA_Observation 
    1012 
    1113 
    12 def __getSample(request): 
     14def __getSample(request, objectId): 
     15    ''' 
     16    @param request: an HttpRequest 
     17    @param objectId: an istance of ObjectById   
     18    ''' 
    1319    ''' 
    1420    sampleForm = createForm(request.POST or None) 
     
    1723        sampleForm = createForm(dp[0]) 
    1824    return sampleForm 
    19     ''' 
    20     dp = getCEDA_ObservationById(1) 
    21     return createForm(dp[0]) 
     25    '''     
     26    #dp = getCEDA_ObservationById(objectId.cleaned_data['id']) 
     27    co = createForm(CEDA_Observation) 
     28    coObj = co(request.POST or None) 
     29 
     30    if objectId.is_valid() and coObj.is_valid(): 
     31        return coObj 
     32 
     33    if objectId.is_valid(): 
     34        id = objectId.cleaned_data['obj_id'] 
     35        dp = getCEDA_ObservationById(objectId.cleaned_data['obj_id']) 
     36        return createForm(dp[0]) 
     37    return None 
    2238def coView(request): 
    2339    c = {} 
    24     form = __getSample(request) 
     40    objectId = ObjectById(request.POST or None) 
     41    form = __getSample(request, objectId)  
    2542    c['coObs'] = form 
     43    c['objId'] = objectId 
    2644     
    2745    c.update(csrf(request)) 
  • mauRepo/MolesManager/trunk/src/libs/migration/client.py

    r8015 r8016  
    55''' 
    66from libs.migration.db.dbConnection import MOLES3DB, \ 
    7     getObservationCollectionMigrationOrderByDate 
     7    getObservationCollectionMigrationOrderByDate, _buildFilter 
    88from libs.migration.processor.dataEntity import DataEntityProcessor 
    99from libs.migration.processor.loadResources import LoadResources 
     10from ea_model.ceda_moles.ceda_observation.ceda_observation import CEDA_Observation 
     11from ea_model.moles3_4.utilities.mo_responsiblepartyinfo import MO_ResponsiblePartyInfo 
     12from ea_model.moles3_4.utilities.mo_rolevalue import MO_RoleValue 
     13from ea_model.upcomingiso.ci_party import CI_Party 
     14from libs.commons_db import doInsertOrUpdate 
    1015 
    1116''' 
     
    2429''' 
    2530 
     31 
     32 
    2633''' 
     34ceda_observation = CEDA_Observation() 
     35ceda_observation.dataLineage = 'mauData' 
     36ceda_observation.relatedParty = [] 
     37rp = MO_ResponsiblePartyInfo() 
     38rp.role = MO_RoleValue.cl_author 
     39rp.party = [] 
     40party = CI_Party() 
     41party.name = 'Mau' 
     42rp.party.append(party) 
     43ceda_observation.relatedParty.append(rp) 
     44doInsertOrUpdate([ceda_observation], session, update = False) 
     45session.commit() 
     46 
     47 
     48res = session.query(CEDA_Observation).filter(*[_buildFilter('ceda_observation_id', 2)]) 
     49rp = res[0].relatedParty[0] 
     50print rp 
     51''' 
     52 
     53 
    2754lr = LoadResources(session) 
    2855lr.process() 
    29 ''' 
    3056 
    3157sorted_data_ents = getObservationCollectionMigrationOrderByDate(session) 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/commons.py

    r8015 r8016  
    6464    return _returnNotNoneText(id) 
    6565 
     66def extractLinks(dataEntXML, markers): 
     67    linksDict = {} 
     68    links = dataEntXML.findall('%slink' % (atomNS)) 
     69    for link in links: 
     70        for marker in markers: 
     71            _updateLinksDict(linksDict, link, marker)         
     72    return linksDict 
     73 
     74def extractDataEntityLinks(dataEntXML): 
     75    markers = ['Deployment', 'DOWNLOAD', 'DOCUMENTATION', 'ACCESS', 'LOGO'] 
     76    return extractLinks(dataEntXML, markers) 
     77 
     78def extractDeploymentLinks(dataEntXML): 
     79    markers = ['ACTIVITY', 'DPT', 'OBS'] 
     80    return extractLinks(dataEntXML, markers) 
     81 
     82def _updateLinksDict(linksDict, link, linkMarker): 
     83    rel = link.get('rel') 
     84    if rel and rel.endswith('/' + linkMarker): 
     85        if not linksDict.has_key(linkMarker): 
     86            linksDict[linkMarker] = [] 
     87        linksDict[linkMarker].append(link.get('href')) 
     88 
    6689def findDeploymentsInDE(dataEntXML): 
    67     hrefs = dataEntXML.findall('%slink' % (atomNS)) 
     90    linksDict = extractDataEntityLinks(dataEntXML) 
    6891    depls = [] 
    69     for href in hrefs: 
    70         rel = href.get('rel') 
    71         if rel and rel.endswith('/Deployment'): 
     92    if linksDict.has_key('Deployment'): 
     93        for link in linksDict['Deployment']: 
    7294            try: 
    73                 link = href.get('href').split('/')[-1] 
    74                 linkName = link.rsplit('__ATOM__')[1] 
     95                linkLongName = link.split('/')[-1] 
     96                linkName = linkLongName.rsplit('__ATOM__')[1] 
    7597                depls.append(linkName) 
    7698            except Exception as ex: 
     
    78100    return depls 
    79101 
    80 def getResourceRefs(resourceRefs): 
     102def getResourceRefs(deploymentRefs): 
    81103    ''' 
    82104        Returns a list of Elements representing the inner resource reference items 
    83         @param ownerBaseDeployments: the name of the eXist collection name below the 'deployments' one 
     105        @param resourceRefs: the name of the eXist collection name below the 'deployments' one 
    84106    '''   
    85     deployment = getDocument(resourceRefs) 
    86     XMLDepl = XML(deployment) 
     107    XMLDepl = getXMLDocument(deploymentRefs) 
    87108    return XMLDepl.findall('%scollection/%sresource' % (existNS, existNS)) 
    88109 
    89 def getCollectionRefs(base): 
     110def getCollectionRefs(publishedRefs): 
    90111    ''' 
    91112        Returns a list of Elements representing the inner deployment reference items 
    92113        @param basePublished: the name of the eXist collection name below the 'published' one 
    93114    '''   
    94     collection = getDocument(base) 
    95     XMLPubl = XML(collection) 
     115    XMLPubl = getXMLDocument(publishedRefs) 
    96116    return XMLPubl.findall('%scollection/%scollection' % (existNS, existNS)) 
    97117 
     
    100120    resourceDoc = getDocument(resourceSource) 
    101121    return XML(resourceDoc) 
    102  
    103122 
    104123 
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/deployment.py

    r8015 r8016  
    5151         
    5252        parsedParties = [] 
    53         if (len(set(authors) & set(['badc.nerc.ac.uk', 'neodc.rl.ac.uk'])) > 0): 
     53        if (len(set(authors) & set(['badc.nerc.ac.uk', 'neodc.nerc.ac.uk'])) > 0): 
    5454            parsedParties.append(self._createResponsibleParty('Centre for Environmental Data Archive', MO_RoleValue.cl_curator)) 
    5555            authorsCSV = findAuthorInResource(self._deProcessor.dataEntity) 
     
    7272        ''' 
    7373        return createMO_ResponsiblePartyInfoAsCI_Organization(name, role) 
    74  
    75     def _assignName(self, relatedPartyInfos): 
    76         ''' 
    77             @param relatedPartyInfos: a MO_ResponsiblePartyInfo list 
    78         '''         
    79         authorCSV = findAuthorInResource(self._deployment) 
    80         if (not authorCSV): 
    81             return 
    82         newResponsiblePartyInfos = self._extractResponsiblePartyInfo(authorCSV.split(',')) 
    83         #This methods check prepare the insert/update of the responsiblePartyInfos 
    84         self._checkResponsiblePartyExist(relatedPartyInfos, newResponsiblePartyInfos) 
    85         for newResponsiblePartyInfo in newResponsiblePartyInfos: 
    86             self._addResponsiblePartyInfo(relatedPartyInfos, newResponsiblePartyInfo) 
    87          
    88         ''' 
    89         if not self._existsCEDAasPublisher(): 
    90             rp = self._ceda_observation.relatedParty 
    91             rp.append(createMO_ResponsiblePartyInfoAsCI_Organization(MO_RoleValue.cl_publisher, DeploymentProcessor.publisherName)) 
    92         ''' 
    9374 
    9475    def _addResponsiblePartyInfo(self, oldResponsiblePartyInfos, newResponsiblePartyInfo): 
     
    131112            oldPartyInfo.remove(oldParty)  
    132113 
     114    def _assignName(self, relatedPartyInfos): 
     115        ''' 
     116            @param relatedPartyInfos: a MO_ResponsiblePartyInfo list 
     117        '''         
     118        authorCSV = findAuthorInResource(self._deployment) 
     119        if (not authorCSV): 
     120            return 
     121        newResponsiblePartyInfos = self._extractResponsiblePartyInfo(authorCSV.split(',')) 
     122        #This methods check prepare the insert/update of the responsiblePartyInfos 
     123        self._checkResponsiblePartyExist(relatedPartyInfos, newResponsiblePartyInfos) 
     124        for newResponsiblePartyInfo in newResponsiblePartyInfos: 
     125            self._addResponsiblePartyInfo(relatedPartyInfos, newResponsiblePartyInfo) 
     126         
     127        ''' 
     128        if not self._existsCEDAasPublisher(): 
     129            rp = self._ceda_observation.relatedParty 
     130            rp.append(createMO_ResponsiblePartyInfoAsCI_Organization(MO_RoleValue.cl_publisher, DeploymentProcessor.publisherName)) 
     131        ''' 
     132 
    133133    def _assignLineage(self): 
    134134        self._ceda_observation.dataLineage = findMolesLineage(self._deProcessor.dataEntity) 
     
    136136            raise NoDataLineage(self._de_path) 
    137137         
     138    def _assignTitle(self): 
     139        pass  
    138140         
    139141    def _processObj(self, cedaObservation): 
     
    143145        self._assignName(cedaObservation.relatedParty) 
    144146        self._assignLineage() 
     147        self._assignTitle() 
    145148         
    146149         
  • mauRepo/MolesManager/trunk/src/libs/migration/processor/loadResources.py

    r8015 r8016  
    66from libs.migration.processor.commons import docStatus, base, getCollectionRefs,\ 
    77    getResource, findMolesCreationDate, findID, stringToTimestamp,\ 
    8     getResourceRefs 
     8    getResourceRefs, getXMLDocument 
    99from libs.migration.db.classes import ObservationCollectionMigration,\ 
    1010    ObservationMigration 
     
    4040        for ref in refs: 
    4141            deName = ref.get('name') 
    42             res = getResource(baseOwner, deName) 
    43             exist_path = '%s/%s' % (baseOwner, deName) 
     42            resourceSource = '%s/%s' % (baseOwner, deName) 
     43            res = getXMLDocument(resourceSource) 
     44            
    4445             
    4546            try: 
    4647                deCreationDate = findMolesCreationDate(res)             
    4748                if deCreationDate is None: 
    48                     raise NoCreationDate(exist_path) 
     49                    raise NoCreationDate(resourceSource) 
    4950            except NoCreationDate as ex: 
    5051                print ex 
     
    5354            deID = findID(res)  
    5455            if deID is None: 
    55                 print (exist_path) 
     56                print (resourceSource) 
    5657 
    5758                                  
     
    7475        for ref in refs: 
    7576            deName = ref.get('name') 
    76             res = getResource(baseOwner, deName)  
    77             exist_path = '%s/%s' % (baseOwner, deName)  
     77            resourceSource = '%s/%s' % (baseOwner, deName) 
     78            res = getXMLDocument(resourceSource)  
    7879             
    7980            try: 
    8081                deCreationDate = findMolesCreationDate(res)             
    8182                if deCreationDate is None: 
    82                     raise NoCreationDate(exist_path) 
     83                    raise NoCreationDate(resourceSource) 
    8384            except NoCreationDate as ex: 
    8485                print ex 
     
    8788            deID = findID(res) 
    8889            if deID is None: 
    89                 print (exist_path) 
     90                print (resourceSource) 
    9091 
    9192                       
Note: See TracChangeset for help on using the changeset viewer.