source: mauRepo/MolesManager/trunk/src/libs/migration/processor/check/check.py @ 8091

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/processor/check/check.py@8091
Revision 8091, 2.2 KB checked in by mnagni, 8 years ago (diff)

The migration process now includes
1) deployment_data files
2) XML document hash
3) full Dojo support


Line 
1'''
2Created on 2 Feb 2012
3
4@author: mnagni
5'''
6def _updateParty(oldParty, newParty):
7    pass
8
9def _checkParty(oldParties, newParties): 
10    for oldParty in oldParties:
11        for newParty in newParties:
12            if oldParty.name == newParty.name:
13                #here shoud update the oldParty (CI_Individual or CI_Organization)
14                _updateParty(oldParty, newParty)
15                newParties.remove(newParty)
16
17def checkResponsiblePartyInfos(oldPartyInfos, newPartyInfos):   
18    for newPartyInfo in newPartyInfos:
19        if not newPartyInfo in oldPartyInfos:
20            oldPartyInfos.append(newPartyInfo)
21        else:       
22            for oldPartyInfo in oldPartyInfos:
23                if oldPartyInfo.role == newPartyInfo.role:
24                    _checkParty(oldPartyInfo.party, newPartyInfo.party)
25           
26def observationHasTitle(mo_observation, title):
27    for identifier in mo_observation.identifier:
28        if identifier.authority and identifier.authority.title == title:
29            return True
30    return False
31
32def observationHasQuality(mo_observation, quality):
33    for rq in mo_observation.resultQuality:
34        for res in rq.result:
35            if hasattr(res, 'explaination') and res.explaination == quality:
36                return True
37    return False
38           
39def checkLineage(ceda_observation, newLineage):
40    if ceda_observation.dataLineage != newLineage:
41        ceda_observation.dataLineage = newLineage
42
43def checkObservation(old_ceda_observation, ceda_observation):
44    if old_ceda_observation == ceda_observation:
45        return old_ceda_observation
46    else:
47        return ceda_observation
48       
49def checkObservationCollection(ceda_observationCollection, ceda_observation):
50    if hasattr(ceda_observation, 'id'):
51        for old_ceda_observation in ceda_observationCollection.member:
52            if old_ceda_observation.id == ceda_observation.id:
53                #if here the relation already exists
54                return
55
56        #if here the relation has to be created
57        assign = []
58        assign = ceda_observationCollection.member
59        assign.append(ceda_observation)
60        ceda_observationCollection.member = assign
61                     
62               
63 
64               
Note: See TracBrowser for help on using the repository browser.