In [1]:
%load_ext autoreload
%autoreload 2
In [2]:
from prov.model import ProvDocument
d1 = ProvDocument()
Model is along the concept described in https://www.w3.org/TR/prov-primer/
In [3]:
from IPython.display import display, Image
Image(filename='key-concepts.png')
Out[3]:
In [7]:
import sys
#sys.path.append('/home/stephan/Repos/ENES-EUDAT/submission_forms')
sys.path.append('C:\\Users\\Stephan Kindermann\\Documents\\GitHub\\submission_forms')
from dkrz_forms import form_handler
from dkrz_forms.config import *
name_space = project_config.NAME_SPACES
cordex_dict = project_config.PROJECT_DICT['test']
# add namespaces for submission provenance capture
for key,value in name_space.iteritems():
d1.add_namespace(key,value)
#d1.add_namespace()
# to do: look into some predefined vocabs, e.g. dublin core, iso19139,foaf etc.
d1.add_namespace("enes_entity",'http://www.enes.org/enes_entitiy#')
d1.add_namespace('enes_agent','http://www.enes.org/enes_agent#')
d1.add_namespace('data_collection','http://www.enes.org/enes_entity/file_collection')
d1.add_namespace('data_manager','http://www.enes.org/enes_agent/data_manager')
d1.add_namespace('data_provider','http://www.enes.org/enes_agent/data_provider')
d1.add_namespace('subm','http://www.enes.org/enes_entity/data_submsission')
d1.add_namespace('foaf','http://xmlns.com/foaf/0.1/')
Out[7]:
(from DOI: 10.3390/ijgi5030038 , mehr unter https://github.com/tsunagun/vocab/blob/master/all_20130125.csv)
owl Web Ontology Language http://www.w3.org/2002/07/owl#
dctype DCMI Type Vocabulary http://purl.org/dc/dcmitype/
dco DCO Ontology http://info.deepcarbon.net/schema#
prov PROV Ontology http://www.w3.org/ns/prov#
skos Simple Knowledge
Organization System http://www.w3.org/2004/02/skos/core#
foaf FOAF Ontology http://xmlns.com/foaf/0.1/
vivo VIVO Ontology http://vivoweb.org/ontology/core#
bibo Bibliographic Ontology http://purl.org/ontology/bibo/
xsd XML Schema Datatype http://www.w3.org/2001/XMLSchema#
rdf Resource Description
Framework http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs Resource Description
Framework Schema http://www.w3.org/2000/01/rdf-schema#
In [10]:
# later: organize things in bundles
data_manager_ats = {'foaf:givenName':'Peter','foaf:mbox':'lenzen@dkzr.de'}
d1.entity('sub:empty')
def add_stage(agent,activity,in_state,out_state):
# in_stage exists, out_stage is generated
d1.agent(agent, data_manager_ats)
d1.activity(activity)
d1.entity(out_state)
d1.wasGeneratedBy(out_state,activity)
d1.used(activity,in_state)
d1.wasAssociatedWith(activity,agent)
d1.wasDerivedFrom(out_state,in_state)
In [11]:
import json
form_file = open('/home/stephan/tmp/Repos/submission_forms_repo/test/test_ki_sk1.json',"r")
json_info = form_file.read()
#json_info["__type__"] = "sf",
form_file.close()
sf_dict = json.loads(json_info)
In [22]:
form_handler.FForm(sf_dict)
Out[22]:
In [13]:
sf = form_handler.FForm(sf_dict)
In [14]:
print sf.__dict__
In [15]:
print sf.sub
In [16]:
data_provider = sf.sub['first_name']+'_'+sf.sub['last_name']
submission_manager = sf.sub['responsible_person']
ingest_manager = sf.ing['responsible_person']
qa_manager = sf.ing['responsible_person']
publication_manager = sf.pub['responsible_person']
add_stage(agent='data_provider:test_user_id',activity='subm:submit',in_state="subm:empty",out_state='subm:out1_sub')
add_stage(agent='data_manager:peter_lenzen_id',activity='subm:review',in_state="subm:out1_sub",out_state='subm:out1_rev')
add_stage(agent='data_manager:peter_lenzen_id',activity='subm:ingest',in_state="subm:out1_rev",out_state='subm:out1_ing')
add_stage(agent='data_manager:hdh_id',activity='subm:check',in_state="subm:out1_ing",out_state='subm:out1_che')
add_stage(agent='data_manager:katharina_b_id',activity='subm:publish',in_state="subm:out1_che",out_state='subm:out1_pub')
add_stage(agent='data_manager:lta_id',activity='subm:archive',in_state="subm:out1_pub",out_state='subm:out1_arch')
In [23]:
mylist = [a]
a = {'1':'2'}
In [8]:
%matplotlib inline
d1.plot()
In [44]:
d1.serialize()
Out[44]:
In [47]:
import json
ingest_prov_file = open('ingest_prov_1.json','w')
prov_data = d1.serialize()
prov_data_json = json.dumps(prov_data)
ingest_prov_file.write(prov_data)
ingest_prov_file.close()
#d1.wasAttributedTo(data_submission,'????')
In [18]:
#d1.get_records()
submission = d1.get_record('subm:out1_sub')[0]
review = d1.get_record('subm:out1_rev')[0]
ingest = d1.get_record('subm:out1_ing')[0]
check = d1.get_record('subm:out1_che')[0]
publication = d1.get_record('subm:out1_pub')[0]
lta = d1.get_record('subm:out1_arch')[0]
In [19]:
res = form_handler.prefix_dict(sf.sub,'sub',sf.sub.keys())
res['sub:status']="fertig"
print res
ing = form_handler.prefix_dict(sf.ing,'ing',sf.ing.keys())
qua = form_handler.prefix_dict(sf.qua,'qua',sf.qua.keys())
pub = form_handler.prefix_dict(sf.pub,'pub',sf.pub.keys())
In [20]:
submission.add_attributes(res)
ingest.add_attributes(ing)
check.add_attributes(qua)
publication.add_attributes(pub)
In [29]:
che_act = d1.get_record('subm:check')
tst = che_act[0]
test_dict = {'subm:test':'test'}
tst.add_attributes(test_dict)
In [32]:
print tst
tst.FORMAL_ATTRIBUTES
tst.
Out[32]:
In [ ]:
che_act = d1.get_record('subm:check')
#tst.formal_attributes
#tst.FORMAL_ATTRIBUTES
tst.add_attributes({'foaf:name':'tst'})
print tst.attributes
#for i in tst:
# print i
#tst.insert([('subm:givenName','sk')])
In [ ]:
import sys
sys.path.append('/home/stephan/Repos/ENES-EUDAT/submission_forms')
from dkrz_forms import form_handler
sf,repo = form_handler.init_form("CORDEX")
init_dict = sf.__dict__
sub_form = form_handler.prefix(sf,'subm',sf.__dict__.keys())
sub_dict = sub_form.__dict__
#init_state = d1.get_record('subm:empty')[0]
#init_state.add_attributes(init_dict)
sub_state = d1.get_record('subm:out1_sub')[0]
init_state.add_attributes(sub_dict)
In [ ]:
tst_dict = {'test1':'val1','test2':'val2'}
tst = form_handler.submission_form(tst_dict)
print tst.__dict__
In [ ]:
print result.__dict__
In [ ]:
dict_from_class(sf)
In [ ]: