source: mauRepo/MolesManager/trunk/src/libs/migration/client.py @ 8016

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/client.py@8016
Revision 8016, 1.7 KB checked in by mnagni, 8 years ago (diff)
Line 
1'''
2Created on 9 Nov 2011
3
4@author: mnagni
5'''
6from libs.migration.db.dbConnection import MOLES3DB, \
7    getObservationCollectionMigrationOrderByDate, _buildFilter
8from libs.migration.processor.dataEntity import DataEntityProcessor
9from 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
15
16'''
17exist/rest/atoms/published/data_entities/neodc.nerc.ac.uk
18'''
19
20
21session = MOLES3DB.getSession()
22
23'''
24So it works:
25Loads the eXist resources
26Loops over a docStatus
27Loops over the data_entities
28For each data_entity loop over its deployments
29'''
30
31
32
33'''
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
54lr = LoadResources(session)
55lr.process()
56
57sorted_data_ents = getObservationCollectionMigrationOrderByDate(session)
58exs = []
59#loops over the sorted data entities
60for de in sorted_data_ents:   
61    de_path = '%s/%s' % (de.exist_path, de.data_ent_name)
62    dep = DataEntityProcessor(de_path, session)
63    exs.append(dep.process())   
64    session.commit()
65print exs   
66
67
Note: See TracBrowser for help on using the repository browser.