-
Notifications
You must be signed in to change notification settings - Fork 0
/
atos-2016_3dcap-metadata.py
5197 lines (4591 loc) · 211 KB
/
atos-2016_3dcap-metadata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#
# GOM-Script-Version: 2016
# Anja Cramer / RGZM
# Timo Homburg / i3mainz
# Laura Raddatz / i3mainz
# 2020/2021
#import gom
import json, math, time
import xml, time, os, random
import datetime
production=True
#production=False
## Indicates if only properties for which a URI has been defined in the JSON dict should be considered for the TTL export .
#includeonlypropswithuri=False
includeonlypropswithuri=True
# python script version
script_name = "atos-2016_3dcap_metadata.py"
script_label = "ATOS 2016 3DCAP Metadata Script"
github_release = "0.1.2"
####################### TTL Export #############################
## Mapping of datatypes present in the JSON dictionary to datatypes present in the TTL file .
datatypes={"float":"xsd:float","double":"xsd:double","str":"xsd:string","date":"xsd:date","int":"xsd:integer","bool":"xsd:boolean","NoneType":"xsd:string", "dateTime":"xsd:dateTime", "list":"xsd:list"}
## Namespace for classes defined in the resulting ontology model .
ontologynamespace="http://objects.mainzed.org/ont#"
## Prefix name for the data namespace .
dataprefix="ex"
# variable python script
script_uri=str(dataprefix)+":"+script_name
## Prefix name for the class namespace .
ontologyprefix="giga"
toolnamespace="http://objects.mainzed.org/tool/"
toolpropnamespace="http://objects.mainzed.org/tool/atos/62/"
## Namespace for instances defined in the TTL export .
datanamespace="http://objects.mainzed.org/data/"
## Prefix name for the exif namespace .
exifnamespace="http://www.w3.org/2003/12/exif/"
## Prefix name for the exif namespace .
om="http://www.ontology-of-units-of-measure.org/resource/om-2/"
## Prefix name for the rdfs namespace .
rdfs='http://www.w3.org/2000/01/rdf-schema#'
##Prefix name for the gigamesh namespace
giganamespace="http://www.gigamesh.eu/ont#"
# Prefix name for prov-o namespace .
provnamespace = "http://www.w3.org/ns/prov#"
#atos 2016
referencepointid="reference_point_id"
globalreferencepointid="point_id"
## Provenance dictionary: Might be used to change the provenance vocabulary .
provenancedict_prov_o={
"entity":"prov:Entity",
"activity":"prov:Activity",
"agent":"prov:Agent",
"used":"prov:used",
"person":"foaf:Person"
}
## Provenance dictionary cidoc crm: Might be used to change the provenance vocabulary .
provenancedict_crmdig={
"entity":"http://www.cidoc-crm.org/cidoc-crm/D1",
"activity":"http://www.cidoc-crm.org/cidoc-crm/D11",
"agent":"prov:Agent",
"used":"prov:used",
"person":"http://www.cidoc-crm.org/cidoc-crm/D21"
}
sensorTypeToClass={
"ATOS III Rev.01": str(ontologyprefix)+":StructuredLightScanner",
"ATOS Core": str(ontologyprefix)+":StructuredLightScanner",
"ATOS II (first generation)": str(ontologyprefix)+":StructuredLightScanner",
"ATOS III Rev.02": str(ontologyprefix)+":StructuredLightScanner",
}
provenancedict=provenancedict_prov_o
## Key for the german label as present in the JSON dictionary .
germanlabel="key_deu"
## Key for the english label as present in the JSON dictionary .
englishlabel="key_eng"
artifactURI=None
## Header for the TTL export which includes all necessary namespaces.
ttlstringhead="@prefix "+str(ontologyprefix)+": <"+str(ontologynamespace)+"> .\n@prefix geo: <http://www.opengis.net/ont/geosparql#> .\n@prefix "+str(dataprefix)+": <"+str(datanamespace)+"> .\n@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n@prefix prov: <http://www.w3.org/ns/prov-o/> .\n@prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n@prefix om:<http://www.ontology-of-units-of-measure.org/resource/om-2/> .\n@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#> . \n@prefix owl:<http://www.w3.org/2002/07/owl#> . \n@prefix i3atos:<http://www.i3mainz.de/metadata/atos#> . \n@prefix dc:<http://purl.org/dc/terms/> .\n@prefix i3data:<http://www.i3mainz.de/data/grabbauten/> . \n@prefix i3:<http://www.i3mainz.de/ont#> . \n@prefix xsd:<http://www.w3.org/2001/XMLSchema#> . \n"
## Generates a UUID.
def generate_uuid():
random_string = ''
random_str_seq = "0123456789abcdef"
uuid_format = [8, 4, 4, 4, 12]
for n in uuid_format:
for i in range(0,n):
random_string += str(random_str_seq[random.randint(0, len(random_str_seq) - 1)])
if i != n:
random_string += '-'
return random_string[:-1]
## Turns the first character of a String to lowercase .
# @param s The string to modify .
# @return a String with the first character to lowercase
def first_upper(s):
if len(s) == 0:
return s
else:
return s[0].upper() + s[1:]
## Turns the first character of a String to lowercase .
# @param s The string to modify .
# @return a String with the first character to lowercase
def first_lower(s):
if len(s) == 0:
return s
else:
return s[0].lower() + s[1:]
## Reads a TTL file, splits its header and body and merges it to the internal TTL set .
# @param filepath The filepath of the TTL file to read .
# @param ttlstring The set of triples to append to .
def readInputTTL(filepath,ttlstring):
file1 = open(filepath, 'r')
Lines = file1.readlines()
count = 0
for line in Lines:
if line.startswith("@"):
ttlstringhead+=line+"\n"
else:
ttlstring.add(line)
file1.close()
## Extracts the ID of a previously created object to extend its provenance hierarchy .
# @param ttlstring The set of triples to append to .
# @param filterclass The class to use for filtering .
# @return a set of filtered triples
def filterLastId(ttlstring,filterclass):
concernedtriples=set()
for triple in ttlstring:
for filt in filterclass:
if filt in triple:
concernedtriples.add(triple)
if len(concernedtriples)==0:
return None
if len(concernedtriples)==1 and concernedtriples[0].contains("rdf:type"):
return concernedtriples.split(" ")[0];
## Reads an artifact description given in a text file and converts its information to TLL .
# @param filepath the path of the text file to process
# @param ttlstring the set of triples to store the result in
def readInputTXTForArtifactDescription(filepath,ttlstring):
file1 = open(filepath, 'r')
firstline = file1.readline()
if ";" in firstline:
entities=firstline.split(";")
if len(entities)>2:
if entities[0].startswith("http") and entities[2].startswith("http"):
ttlstring.add("<"+entities[0]+"> rdf:type <"+entities[2]+"> .\n")
ttlstring.add("<"+entities[0]+"> rdfs:label \""+entities[1]+" Artifact\"@en .\n")
ttlstring.add("<"+entities[2]+"> rdf:type owl:Class .\n")
ttlstring.add("<"+entities[2]+"> rdfs:subClassOf prov:Entity .\n")
elif entities[0].startswith("http") and not entities[2].startswith("http"):
ttlstring.add("<"+entities[0]+"> rdf:type "+entities[2]+" .\n")
ttlstring.add("<"+entities[0]+"> rdfs:label \""+entities[1]+" Artifact\"@en .\n")
ttlstring.add(entities[2]+" rdf:type owl:Class .\n")
ttlstring.add(entities[2]+" rdfs:subClassOf prov:Entity .\n")
elif not entities[0].startswith("http") and not entities[2].startswith("http"):
ttlstring.add("<"+datanamespace+entities[0]+"> rdf:type "+entities[2]+" .\n")
ttlstring.add("<"+datanamespace+entities[0]+"> rdfs:label \""+entities[1]+" Artifact\"@en .\n")
ttlstring.add(entities[2]+" rdf:type owl:Class .\n")
ttlstring.add(entities[2]+" rdfs:subClassOf prov:Entity .\n")
else:
ttlstring.add("<"+datanamespace+entities[0]+"> rdf:type <"+entities[2]+"> .\n")
ttlstring.add("<"+datanamespace+entities[0]+"> rdfs:label \""+entities[1]+" Artifact\"@en .\n")
ttlstring.add("<"+entities[2]+"> rdf:type owl:Class .\n")
ttlstring.add("<"+entities[2]+"> rdfs:subClassOf prov:Entity .\n")
else:
if entities[0].startswith("http"):
ttlstring.add("<"+entities[0]+"> rdf:type giga:Artifact .\n")
else:
ttlstring.add("<"+datanamespace+entities[0]+"> rdf:type giga:Artifact .\n")
if entities[0].startswith("http"):
artifactURI=entities[0]
else:
artifactURI=datanamespace+entities[0]
file1.close()
## Reads an instance present in a JSON representation and appends its TTL representation to the triple set .
# @param jsonobj The JSON object to process
# @param id The id of the current instance
# @param classs The class of the current instance
# @param labelprefix A string prefix to be prepended to a rdfs:label expression
# @param ttlstring The set of triples to append to
def exportInformationFromIndAsTTL(jsonobj,id,classs,labelprefix,ttlstring):
for info in jsonobj:
#print(classs)
#print(jsonobj[info])
if not info in jsonobj or not "value" in jsonobj[info] or jsonobj[info]["value"]==None or jsonobj[info]["value"]=="":
continue
propuri=str(ontologyprefix)+":"+first_lower(str(info)).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","").replace("[","_").replace("]","")
if "uri" in jsonobj[info]:
#print(jsonobj[info]["uri"])
if jsonobj[info]["uri"].startswith("http"):
propuri="<"+str(jsonobj[info]["uri"][0:jsonobj[info]["uri"].rfind("#")]+"#"+first_lower(jsonobj[info]["uri"][jsonobj[info]["uri"].rfind("#")+1:]))+">"
elif ":" in jsonobj[info]["uri"]:
propuri=str(jsonobj[info]["uri"][0:jsonobj[info]["uri"].rfind(":")]+":"+first_lower(jsonobj[info]["uri"][jsonobj[info]["uri"].rfind(":")+1:]))
else:
propuri=str(ontologyprefix)+":"+first_lower(str(info)).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","").replace("[","_").replace("]","")
ttlstring.add(str(propuri)+" rdfs:isDefinedBy <"+str(toolpropnamespace)+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","").replace("[","_").replace("]","")+"> .\n")
#print("Propuri: "+propuri)
#print(jsonobj[info]["value"])
#print(isinstance(jsonobj[info]["value"],list))
if isinstance(jsonobj[info]["value"],list):
for val in jsonobj[info]["value"]:
ttlstring=handleProperty(jsonobj,info,id,labelprefix,propuri,classs,ttlstring,val,str(ontologyprefix)+":"+first_upper(str(info)).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","").replace("[","_").replace("]",""))
else:
ttlstring=handleProperty(jsonobj,info,id,labelprefix,propuri,classs,ttlstring,jsonobj[info]["value"],str(ontologyprefix)+":"+first_upper(str(info)).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","").replace("[","_").replace("]",""))
#print ("ttlstring")
return ttlstring
## Processes a given property depending on its type .
def handleProperty(jsonobj,info,id,labelprefix,propuri,classs,ttlstring,inputvalue,propclass):
if "unit" in jsonobj[info] and jsonobj[info]["unit"]!=None and jsonobj[info]["unit"]!="":
ttlstring.add(str(propuri)+" rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(propuri)+" rdfs:domain "+str(classs)+" .\n")
ttlstring.add(str(propuri)+" rdfs:range om:Measure .\n")
if englishlabel in jsonobj[info] and jsonobj[info][englishlabel]!=None and str(jsonobj[info][englishlabel])!="" and str(jsonobj[info][englishlabel]).strip()!="...":
ttlstring.add(str(propuri)+" rdfs:label \""+str(jsonobj[info][englishlabel]).replace("\"","'")+"\"@en .\n")
if labelprefix=="":
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" rdfs:label \""+str(jsonobj[info][englishlabel]).replace("\"","'")+" \"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value rdfs:label \""+str(jsonobj[info][englishlabel]).replace("\"","'")+" Measurement Value \"@en .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" rdfs:label \""+str(jsonobj[info][englishlabel]).replace("\"","'")+" ("+str(labelprefix)+")\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value rdfs:label \""+str(jsonobj[info][englishlabel]).replace("\"","'")+" Measurement Value ("+str(labelprefix)+")\"@en .\n")
if germanlabel in jsonobj[info] and jsonobj[info][germanlabel]!=None and str(jsonobj[info][germanlabel])!="" and str(jsonobj[info][germanlabel])!="...":
ttlstring.add(str(propuri)+" rdfs:label \""+str(jsonobj[info][germanlabel]).replace("\"","'")+"\"@de .\n")
if labelprefix=="":
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" rdfs:label \""+str(jsonobj[info][germanlabel]).replace("\"","'")+" \"@de .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value rdfs:label \""+str(jsonobj[info][germanlabel]).replace("\"","'")+" Messwert \"@de .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" rdfs:label \""+str(jsonobj[info][germanlabel]).replace("\"","'")+" ("+str(labelprefix)+")\"@de .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value rdfs:label \""+str(jsonobj[info][germanlabel]).replace("\"","'")+" Messwert ("+str(labelprefix)+")\"@de .\n")
if "measurementclass" in jsonobj[info] and jsonobj[info]["measurementclass"]!=None and str(jsonobj[info]["measurementclass"])!="":
if ":" in jsonobj[info]["measurementclass"]:
if jsonobj[info]["measurementclass"].startswith("http"):
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdf:type owl:Class .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdfs:label \""+jsonobj[info]["measurementclass"].replace("\"","'")+"\"@en .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdfs:subClassOf om:Quantity .\n")
else:
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" rdfs:label \""+jsonobj[info]["measurementclass"].replace("\"","'")+"\"@en .\n")
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" rdfs:subClassOf om:Quantity .\n")
else:
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdf:type owl:Class .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdfs:label \""+jsonobj[info]["measurementclass"].replace("\"","'")+"\"@en .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdfs:subClassOf om:Quantity .\n")
else:
ttlstring.add(propclass+" rdf:type owl:Class .\n")
ttlstring.add(propclass+" rdfs:label \""+propclass.replace("_"," ").replace(ontologyprefix+":","")+"\"@en .\n")
ttlstring.add(propclass+" rdfs:subClassOf om:Quantity .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" rdf:type "+propclass+" .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value rdf:type om:Measure .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" om:hasValue "+str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value .\n")
#print(jsonobj[info]["unit"])
if jsonobj[info]["unit"].startswith("http"):
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value om:hasUnit <"+str(jsonobj[info]["unit"])+"> .\n")
ttlstring.add("<"+str(jsonobj[info]["unit"])+"> rdf:type om:UnitOfMeasure .\n")
ttlstring.add("<"+str(jsonobj[info]["unit"])+"> rdfs:label \""+jsonobj[info]["unit"].replace("\"","'")+"\"@en .\n")
elif ":" in jsonobj[info]["unit"]:
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value om:hasUnit "+str(jsonobj[info]["unit"].replace(" ",""))+" .\n")
ttlstring.add(str(jsonobj[info]["unit"].replace(" ",""))+" rdf:type om:UnitOfMeasure .\n")
ttlstring.add(str(jsonobj[info]["unit"].replace(" ",""))+" rdfs:label \""+jsonobj[info]["unit"].replace("\"","'")+"\" .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value om:hasUnit \""+str(jsonobj[info]["unit"])+"\" .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+"_value om:hasNumericalValue \""+str(inputvalue).replace("\\","\\\\")+"\"^^"+str(datatypes[jsonobj[info]["value_type"]])+" .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+" "+str(propuri)+" "+str(dataprefix)+":"+str(id)+"_"+str(info).replace(" ","").replace("[","_").replace("]","").replace("(","").replace(")","")+" .\n")
elif "value_type" in jsonobj[info] and jsonobj[info]["value_type"]=="enumeration":
ttlstring.add(str(propuri)+" rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(propuri)+" rdfs:domain "+str(classs)+" .\n")
if "measurementclass" in jsonobj[info] and jsonobj[info]["measurementclass"]!=None and str(jsonobj[info]["measurementclass"])!="":
if ":" in jsonobj[info]["measurementclass"]:
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" rdfs:label \""+jsonobj[info]["measurementclass"].replace("\"","'")+"\"@en .\n")
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" rdfs:subClassOf "+str(ontologyprefix)+":Enumeration .\n")
ttlstring.add(str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+"_"+inputvalue+" rdf:type "+str(ontologyprefix)+":"+jsonobj[info]["measurementclass"].replace(" ","")+" .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+" "+str(propuri)+" "+str(ontologyprefix)+":"+jsonobj[info]["measurementclass"]+"_"+str(inputvalue)+" .\n")
else:
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdf:type owl:Class .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdfs:label \""+jsonobj[info]["measurementclass"].replace("\"","'")++"\"@en .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"> rdfs:subClassOf "+str(ontologyprefix)+":Enumeration .\n")
ttlstring.add("<"+jsonobj[info]["measurementclass"].replace(" ","")+"_"+inputvalue+"> rdf:type <"+jsonobj[info]["measurementclass"].replace(" ","")+"> .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+" "+str(propuri)+" <"+jsonobj[info]["measurementclass"].replace(" ","")+"_"+str(inputvalue).replace(" ","")+"> .\n")
else:
classuri=str(ontologyprefix)+":"+str(propuri).replace(str(ontologyprefix),"").capitalize()
ttlstring.add(classuri+" rdf:type owl:Class .\n")
ttlstring.add(classuri+" rdfs:subClassOf "+str(ontologyprefix)+":Enumeration .\n")
ttlstring.add(classuri+"_"+str(inputvalue)+" rdf:type "+classuri+" .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+" "+str(propuri)+" "+classuri+"_"+str(inputvalue)+" .\n")
else:
if propuri=="http://www.w3.org/2000/01/rdf-schema#label" or propuri=="rdfs:label" or propuri=="http://www.w3.org/2000/01/rdf-schema#comment" or propuri=="rdfs:comment":
ttlstring.add(str(propuri)+" rdf:type owl:AnnotationProperty .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+" "+str(propuri)+" \""+str(inputvalue)+"\" .\n")
else:
ttlstring.add(str(propuri)+" rdf:type owl:DatatypeProperty .\n")
ttlstring.add(str(propuri)+" rdfs:domain "+str(classs)+" .\n")
if englishlabel in jsonobj[info] and jsonobj[info][englishlabel]!=None and str(jsonobj[info][englishlabel])!="" and str(jsonobj[info][englishlabel])!="...":
ttlstring.add(str(propuri)+" rdfs:label \""+str(jsonobj[info][englishlabel]).replace("\"","'")+"\"@en .\n")
if germanlabel in jsonobj[info] and jsonobj[info][germanlabel]!=None and str(jsonobj[info][germanlabel])!="" and str(jsonobj[info][germanlabel])!="...":
ttlstring.add(str(propuri)+" rdfs:label \""+str(jsonobj[info][germanlabel]).replace("\"","'")+"\"@de .\n")
ttlstring.add(str(propuri)+" rdfs:range "+str(datatypes[jsonobj[info]["value_type"]])+" .\n")
ttlstring.add(str(dataprefix)+":"+str(id)+" "+str(propuri)+" \""+str(inputvalue).replace("\\","\\\\")+"\"^^"+str(datatypes[jsonobj[info]["value_type"]])+" .\n")
#print("handled Property")
return ttlstring
## Converts a preformatted dictionary to a set of triples .
# @param dict the dictionary to export from
# @param measurementToExport indicates whether to export measurements
def exportToTTL(dict,measurementToExport,ttlstring):
###print ("drin in exportToTTL")
projectid=str(generate_uuid())
userid=str(generate_uuid())
projlabelkey="prj_n"
projects="projects"
projkey="measurement_series"
userkey="user_keywords"
mesheskey="meshes"
meshprocessingkey="processing"
calibkey="calibration"
sensorskey="sensors"
sensorinformationkey="calibration"
meshinfokey="mesh_information"
globalrefpointkey="global_referencepoints"
refpointkey="referencepoints"
globalrefpointinfo="global_referencepoints_information"
projinfokey="project_information"
measurmentserieskey = "measurement_series_information"
measurementskey="measurements"
measurementinformation="measurement_properties"
messungkey="messung"
applicationkey="applications"
capturingdevice="capturing_device"
mssetup="measurement_setup"
calsetup="cal_setup"
calobject="cal_object"
calproperties="cal_properties"
mscheck="measurement_check"
softwareid="ATOS2016"
labelprefix=""
projectname=""
if ttlstring==None:
ttlstring=set()
ttlstring.add(str(ontologyprefix)+":Mesh rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Mesh rdfs:subClassOf geo:Geometry .\n")
ttlstring.add(str(ontologyprefix)+":Mesh rdfs:label \"Mesh\"@en .\n")
ttlstring.add(str(ontologyprefix)+":IntermediateMeshResult rdfs:subClassOf "+str(ontologyprefix)+":Mesh .\n")
ttlstring.add(str(ontologyprefix)+":IntermediateMeshResult rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":IntermediateMeshResult rdfs:label \"Intermediate Mesh Result\"@en .\n")
ttlstring.add("rdfs:label rdf:type owl:AnnotationProperty .\n")
ttlstring.add(str(ontologyprefix)+":Tool rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Tool rdfs:label \"Tool\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Tool rdfs:subClassOf "+provenancedict.get("entity")+" .\n")
ttlstring.add(str(ontologyprefix)+":CapturingDevice rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":CapturingDevice rdfs:label \"capturing device\"@en .\n")
ttlstring.add(str(ontologyprefix)+":CapturingDevice rdfs:subClassOf "+str(ontologyprefix)+":Tool .\n")
ttlstring.add(str(ontologyprefix)+":Scanner rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Scanner rdfs:label \"scanner\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Scanner rdfs:subClassOf "+str(ontologyprefix)+":CapturingDevice .\n")
ttlstring.add(str(ontologyprefix)+":Sensor rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Sensor rdfs:label \"Sensor\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Software rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Software rdfs:label \"software\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Software rdfs:subClassOf "+provenancedict.get("entity")+" .\n")
ttlstring.add(str(ontologyprefix)+":Verification rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Verification rdfs:label \"verification\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Verification rdfs:subClassOf "+provenancedict.get("entity")+" .\n")
ttlstring.add(str(ontologyprefix)+":Setup rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Setup rdfs:label \"setup\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Setup rdfs:subClassOf "+provenancedict.get("entity")+" .\n")
ttlstring.add(str(ontologyprefix)+":StructuredLightScanner rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":StructuredLightScanner rdfs:label \"structured light scanner\"@en .\n")
ttlstring.add(str(ontologyprefix)+":StructuredLightScanner rdfs:subClassOf "+str(ontologyprefix)+":Scanner .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationObject rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationObject rdfs:label \"calibration object\"@en .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationObject rdfs:subClassOf "+str(ontologyprefix)+":Tool .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementSetup rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementSetup rdfs:label \"measurement setup\"@en .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementSetup rdfs:subClassOf "+str(ontologyprefix)+":Setup .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationSetup rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationSetup rdfs:label \"calibration setup\"@en .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationSetup rdfs:subClassOf "+str(ontologyprefix)+":Setup .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementCheck rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementCheck rdfs:label \"measurement check\"@en .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementCheck rdfs:subClassOf "+str(ontologyprefix)+":Verification .\n")
ttlstring.add(str(ontologyprefix)+":Algorithm rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Algorithm rdfs:label \"Algorithm\"@en .\n")
ttlstring.add(str(ontologyprefix)+":Algorithm rdfs:subClassOf "+provenancedict.get("agent")+" .\n")
ttlstring.add(provenancedict.get("entity")+" rdf:type owl:Class .\n")
ttlstring.add(provenancedict.get("person")+" rdf:type owl:Class .\n")
ttlstring.add(provenancedict.get("person")+" rdfs:label \"Person\".\n")
ttlstring.add(provenancedict.get("person")+" rdfs:subClassOf "+provenancedict.get("agent")+" .\n")
ttlstring.add(provenancedict.get("entity")+" rdfs:subClassOf owl:Thing .\n")
ttlstring.add("owl:Thing rdf:type owl:Class .\n")
ttlstring.add("owl:Thing rdfs:label \"Thing\" .\n")
ttlstring.add(provenancedict.get("entity")+" rdfs:label \"Entity\".\n")
ttlstring.add(provenancedict.get("agent")+" rdf:type owl:Class .\n")
ttlstring.add(provenancedict.get("agent")+" rdfs:label \"Agent\".\n")
ttlstring.add(provenancedict.get("agent")+" rdfs:subClassOf owl:Thing .\n")
ttlstring.add(provenancedict.get("activity")+" rdf:type owl:Class .\n")
ttlstring.add(provenancedict.get("activity")+" rdfs:label \"Activity\".\n")
ttlstring.add(provenancedict.get("activity")+" rdfs:subClassOf owl:Thing .\n")
ttlstring.add("dc:creator rdf:type owl:ObjectProperty .\n")
ttlstring.add("dc:creator rdfs:domain "+str(ontologyprefix)+":Mesh .\n")
ttlstring.add("dc:creator rdfs:range foaf:Person .\n")
ttlstring.add("prov:wasDerivedFrom rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:wasDerivedFrom rdfs:range "+provenancedict.get("entity")+" .\n")
ttlstring.add("prov:wasDerivedFrom rdfs:domain "+provenancedict.get("entity")+" .\n")
ttlstring.add("prov:wasInformedBy rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:wasInformedBy rdfs:range "+provenancedict.get("activity")+" .\n")
ttlstring.add("prov:wasInformedBy rdfs:domain "+provenancedict.get("activity")+" .\n")
ttlstring.add("prov:wasInvalidatedBy rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:wasInvalidatedBy rdfs:range "+provenancedict.get("activity")+" .\n")
ttlstring.add("prov:wasInvalidatedBy rdfs:domain "+provenancedict.get("activity")+" .\n")
ttlstring.add("prov:wasGeneratedBy rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:wasGeneratedBy rdfs:range "+provenancedict.get("activity")+" .\n")
ttlstring.add("prov:wasGeneratedBy rdfs:domain "+provenancedict.get("entity")+" .\n")
ttlstring.add("prov:actedOnBehalfOf rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:actedOnBehalfOf rdfs:range "+provenancedict.get("agent")+" .\n")
ttlstring.add("prov:actedOnBehalfOf rdfs:domain "+provenancedict.get("agent")+" .\n")
ttlstring.add("prov:wasAttributedTo rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:wasAttributedTo rdfs:range "+provenancedict.get("agent")+" .\n")
ttlstring.add("prov:wasAttributedTo rdfs:domain "+provenancedict.get("entity")+" .\n")
ttlstring.add("prov:used rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:used rdfs:range "+provenancedict.get("entity")+" .\n")
ttlstring.add("prov:used rdfs:domain "+provenancedict.get("activity")+" .\n")
ttlstring.add("prov:wasAssociatedWith rdf:type owl:ObjectProperty .\n")
ttlstring.add("prov:wasAssociatedWith rdfs:range "+provenancedict.get("agent")+" .\n")
ttlstring.add("prov:wasAssociatedWith rdfs:domain "+provenancedict.get("entity")+" .\n")
ttlstring.add("om:hasNumericalValue rdf:type owl:DatatypeProperty .\n")
ttlstring.add("om:hasNumericalValue rdfs:range xsd:integer .\n")
ttlstring.add("om:hasNumericalValue rdfs:domain om:Measure .\n")
ttlstring.add("om:hasNumericalValue rdfs:label \"has numerical value\"@en .\n")
ttlstring.add("om:hasValue rdf:type owl:ObjectProperty .\n")
ttlstring.add("om:hasValue rdfs:label \"has value\"@en .\n")
ttlstring.add("om:hasUnit rdf:type owl:ObjectProperty .\n")
ttlstring.add("om:hasUnit rdfs:label \"has unit\"@en .\n")
ttlstring.add("om:hasUnit rdfs:domain om:Measure .\n")
ttlstring.add("om:hasUnit rdfs:range om:UnitOfMeasure .\n")
ttlstring.add("geo:asWKT rdf:type owl:DatatypeProperty .\n")
ttlstring.add("geo:asWKT rdfs:label \"asWKT\"@en .\n")
ttlstring.add("om:Quantity rdf:type owl:Class .\n")
ttlstring.add("om:Quantity rdfs:label \"Quantity\".\n")
ttlstring.add("om:Quantity rdfs:subClassOf owl:Thing .\n")
ttlstring.add("om:Measure rdf:type owl:Class .\n")
ttlstring.add("om:Measure rdfs:label \"Measure\".\n")
ttlstring.add("om:Measure rdfs:subClassOf owl:Thing .\n")
ttlstring.add("om:UnitOfMeasure rdf:type owl:Class .\n")
ttlstring.add("om:UnitOfMeasure rdfs:label \"Unit Of Measure\".\n")
ttlstring.add("om:UnitOfMeasure rdfs:subClassOf owl:Thing .\n")
ttlstring.add(str(ontologyprefix)+":calibration rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":calibration rdfs:range "+str(ontologyprefix)+":Calibration .\n")
ttlstring.add(str(ontologyprefix)+":calibration rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":sensor rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":sensor rdfs:range "+str(ontologyprefix)+":Sensor .\n")
ttlstring.add(str(ontologyprefix)+":sensor rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":calibrationsetup rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":calibrationsetup rdfs:range "+str(ontologyprefix)+":Setup .\n")
ttlstring.add(str(ontologyprefix)+":calibrationsetup rdfs:domain "+str(ontologyprefix)+":Calibration .\n")
ttlstring.add(str(ontologyprefix)+":calibrationobject rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":calibrationobject rdfs:range "+str(ontologyprefix)+":CalibrationObject .\n")
ttlstring.add(str(ontologyprefix)+":calibrationobject rdfs:domain "+str(ontologyprefix)+":Calibration .\n")
ttlstring.add(str(ontologyprefix)+":capturingdevice rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":capturingdevice rdfs:range "+str(ontologyprefix)+":Tool .\n")
ttlstring.add(str(ontologyprefix)+":capturingdevice rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":globalReferencePoint rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":globalReferencePoint rdfs:range "+str(ontologyprefix)+":GRP .\n")
ttlstring.add(str(ontologyprefix)+":globalReferencePoint rdfs:domain "+str(ontologyprefix)+":MeasurementSeries .\n")
ttlstring.add(str(ontologyprefix)+":referencePoint rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":referencePoint rdfs:range "+str(ontologyprefix)+":ReferencePoint .\n")
ttlstring.add(str(ontologyprefix)+":referencePoint rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":partOf rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":partOf rdfs:range "+str(ontologyprefix)+":MeasurementCheck.\n")
ttlstring.add(str(ontologyprefix)+":partOf rdfs:range "+str(ontologyprefix)+":MeasurementSetup.\n")
ttlstring.add(str(ontologyprefix)+":partOf rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":usedBy rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":usedBy rdfs:range "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":usedBy rdfs:domain "+str(ontologyprefix)+":CapturingDevice .\n")
ttlstring.add(str(ontologyprefix)+":setup rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":setup rdfs:range "+str(ontologyprefix)+":MeasurementSetup .\n")
ttlstring.add(str(ontologyprefix)+":setup rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":verification rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":verification rdfs:range "+str(ontologyprefix)+":MeasurementCheck .\n")
ttlstring.add(str(ontologyprefix)+":verification rdfs:domain "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":measurementSeries rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":measurementSeries rdfs:range "+str(ontologyprefix)+":MeasurementSeries .\n")
ttlstring.add(str(ontologyprefix)+":measurementSeries rdfs:domain "+str(ontologyprefix)+":MeasurementProject .\n")
ttlstring.add(str(ontologyprefix)+":measurement rdf:type owl:ObjectProperty .\n")
ttlstring.add(str(ontologyprefix)+":measurement rdfs:range "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(ontologyprefix)+":measurement rdfs:domain "+str(ontologyprefix)+":MeasurementSeries .\n")
ttlstring.add(str(ontologyprefix)+":Calibration rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":CalibrationObject rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Measurement rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":Measurement rdfs:label \"Measurement\".\n")
ttlstring.add(str(ontologyprefix)+":Measurement rdfs:subClassOf prov:Entity .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementSeries rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementSeries rdfs:label \"Measurement Series\".\n")
ttlstring.add(str(ontologyprefix)+":MeasurementSeries rdfs:subClassOf prov:Entity .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementProjectMetadata rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementProjectMetadata rdfs:label \"Measurement Project Metadata\".\n")
ttlstring.add(str(ontologyprefix)+":MeasurementProjectMetadata rdfs:subClassOf prov:Entity .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementProject rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":MeasurementProject rdfs:label \"Measurement Project\".\n")
ttlstring.add(str(ontologyprefix)+":MeasurementProject rdfs:subClassOf prov:Entity .\n")
ttlstring.add(str(ontologyprefix)+":ReferencePoint rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":ReferencePoint rdfs:label \"reference point\".\n")
ttlstring.add(str(ontologyprefix)+":ReferencePoint rdfs:subClassOf geo:Point . geo:Point rdfs:subClassOf geo:Geometry . geo:Geometry rdfs:subClassOf prov:Entity .\n")
ttlstring.add(str(ontologyprefix)+":GRP rdf:type owl:Class .\n")
ttlstring.add(str(ontologyprefix)+":GRP rdfs:label \"global reference point\".\n")
ttlstring.add(str(ontologyprefix)+":GRP rdfs:subClassOf "+str(ontologyprefix)+":ReferencePoint .\n")
ttlstring.add(str(ontologyprefix)+":Calibration rdfs:subClassOf prov:Entity .\n")
ttlstring.add(str(ontologyprefix)+":Calibration rdfs:label \"Calibration\".\n")
ttlstring.add(str(dataprefix)+":metadata_calculation_activity rdf:type "+provenancedict.get("activity")+" . \n")
ttlstring.add(str(ontologyprefix)+":GRP_calculation_algorithm rdf:type "+str(ontologyprefix)+":Algorithm . \n")
for pro in dict[projects]:
#print(projkey)
#print (pro[projinfokey])
if projinfokey in pro:
if "prj_n" in pro[projinfokey]:
labelprefix=pro[projinfokey]["prj_n"]["value"]
projectname=pro[projinfokey]["prj_n"]["value"]
ttlstring.add(str(dataprefix)+":"+str(projectid)+" rdf:type "+str(ontologyprefix)+":MeasurementProject .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_metadata rdf:type "+str(ontologyprefix)+":MeasurementProjectMetadata .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_metadata prov:wasGeneratedBy "+str(dataprefix)+":metadata_calculation_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_metadata prov:wasAttributedTo "+str(dataprefix)+":"+script_name+".\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+" "+str(dataprefix)+":metadata "+str(dataprefix)+":"+str(projectid)+"_metadata .\n")
#print(pro[projinfokey])
ttlstring=exportInformationFromIndAsTTL(pro[projinfokey],projectid,str(ontologyprefix)+":MeasurementProject",labelprefix,ttlstring)
ttlstring.add(str(dataprefix)+":"+str(userid)+" rdf:type foaf:Person, "+provenancedict.get("agent")+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+" dc:creator "+str(dataprefix)+":"+str(userid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(userid)+" rdfs:label \"Creator of "+str(labelprefix)+"\" .\n")
#print(pro[applicationkey])
if applicationkey in pro:
for appl in pro[applicationkey]:
if "script_name" in appl and "value" in appl["script_name"] and appl["script_name"]["value"]==script_name:
ttlstring.add(str(dataprefix)+":"+script_name+" rdf:type "+str(ontologyprefix)+":Software .\n")
ttlstring.add(str(dataprefix)+":"+script_name+" rdfs:label \""+str(script_label)+"\"@en .\n")
ttlstring=exportInformationFromIndAsTTL(appl,script_name,str(ontologyprefix)+":Software",labelprefix,ttlstring)
else:
if "PROJECT.TYPE" in appl and "PROJECT.VERSION" in appl:
softwareid=str(appl["PROJECT.TYPE"]["value"]).strip().replace(" ","_")+"_"+str(appl["PROJECT.VERSION"]["value"]).strip().replace(" ","_").replace(".","_").replace("-","_")
elif "application_name" in appl and "application_build_information.version" in appl:
softwareid=str(appl["application_name"]["value"]).strip().replace(" ","_")+"_"+str(appl["application_build_information.version"]["value"]).strip().replace(" ","_").replace(".","_").replace("-","_")
else:
softwareid="ATOS2016"
ttlstring.add(str(dataprefix)+":"+softwareid+" rdf:type "+str(ontologyprefix)+":Software .\n")
ttlstring.add(str(dataprefix)+":"+softwareid+" rdfs:label \""+str(softwareid).replace("_"," ")+"\"@en .\n")
ttlstring=exportInformationFromIndAsTTL(appl,softwareid,str(ontologyprefix)+":Software",labelprefix,ttlstring)
if projkey in pro:
for msindex, project in enumerate(pro[projkey]):
#print(project)
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" rdf:type "+str(ontologyprefix)+":MeasurementSeries .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+" "+str(ontologyprefix)+":measurementSeries "+str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" rdfs:label \"Measurement Series "+str(msindex)+" for "+str(labelprefix)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" prov:wasAttributedTo "+str(dataprefix)+":"+str(userid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_activity prov:wasAssociatedWith "+str(dataprefix)+":"+str(userid)+" .\n")
if artifactURI!=None:
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_activity prov:used "+artifactURI+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_activity rdf:type prov:Activity .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_activity rdfs:label \"MS "+str(msindex)+" Activity ("+str(labelprefix)+")\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_activity rdfs:label \" Messreihe "+str(msindex)+" ("+str(labelprefix)+")\"@de .\n")
if measurmentserieskey in project:
#print(project[measurmentserieskey])
ttlstring=exportInformationFromIndAsTTL(project[measurmentserieskey],str(projectid)+"_ms_"+str(msindex),str(ontologyprefix)+":MeasurementSeries",labelprefix,ttlstring)
if measurementToExport==None:
#print ("measurementToExport==None:")
if projkey in project:
#print (project[projinfokey])
if projinfokey in project:
if "prj_n" in project[projinfokey]:
labelprefix=project[projinfokey]["prj_n"]["value"]+"Measurement Series "+str(msindex)
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" rdf:type "+str(ontologyprefix)+":MeasurementSeries, prov:Entity .\n")
#print(project[projinfokey])
ttlstring=exportInformationFromIndAsTTL(project[measurmentserieskey],projectid+"_ms_"+str(msindex),str(ontologyprefix)+":MeasurementSeries",labelprefix,ttlstring)
ttlstring.add(str(dataprefix)+":"+str(userid)+" rdf:type foaf:Person, "+provenancedict.get("agent")+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+" dc:creator "+str(dataprefix)+":"+str(userid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(userid)+" rdfs:label \"Creator of "+str(labelprefix)+"\" .\n")
#print(ttlstring)
if userkey in project:
ttlstring=exportInformationFromIndAsTTL(project[userkey],userid,"foaf:Person",labelprefix,ttlstring)
#print(ttlstring)
#print(project[globalrefpointkey])
if globalrefpointkey in project and refpointkey in project[globalrefpointkey]:
for index, grp in enumerate(project[globalrefpointkey][refpointkey]):
if "point_id" in grp:
index = grp["point_id"]["value"]
#print (index)
elif "r_id" in grp:
index = grp["r_id"]["value"]
#print (index)
grpid=str(projectid)+"_ms_"+str(msindex)+"_grp"+str(index)
#print (grpid)
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" "+str(ontologyprefix)+":globalReferencePoint "+str(dataprefix)+":"+str(grpid)+" . \n")
ttlstring.add(str(dataprefix)+":"+str(grpid)+" rdf:type "+str(ontologyprefix)+":GRP .\n")
ttlstring.add(str(dataprefix)+":"+str(grpid)+" rdfs:label \"GRP"+str(index)+" ( Measurement Series "+str(msindex)+")\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(grpid)+" rdfs:label \"GRP"+str(index)+" ( Messreihe "+str(msindex)+")\"@de .\n")
ttlstring.add(str(dataprefix)+":"+str(grpid)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity prov:wasAssociatedWith "+str(ontologyprefix)+":GRP_calculation_algorithm. \n")
ttlstring.add(str(ontologyprefix)+":GRP_calculation_algorithm prov:actedOnBehalfOf "+str(dataprefix)+":"+str(userid)+" . \n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity rdf:type "+provenancedict.get("activity")+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity rdfs:label \"GRP Calculation Activity\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity rdfs:label \"GRP Berechnung\"@de .\n")
#print("265:"+str(project[globalrefpointkey]))
#print("266: "+str(grp))
ttlstring=exportInformationFromIndAsTTL(grp,grpid,str(ontologyprefix)+":GRP",labelprefix+" MS "+str(msindex)+" GRP"+str(index),ttlstring)
if "r_x" in grp and "r_y" in grp and "r_z" in grp:
ttlstring.add(str(dataprefix)+":"+str(grpid)+" geo:asWKT \"POINT("+str(grp["r_x"]["value"])+" "+str(grp["r_y"]["value"])+" "+str(grp["r_z"]["value"])+")\"^^geo:wktLiteral .\n")
elif "coordinate.x" in grp and "coordinate.y" in grp and "coordinate.z" in grp:
ttlstring.add(str(dataprefix)+":"+str(grpid)+" geo:asWKT \"POINT("+str(grp["coordinate.x"]["value"])+" "+str(grp["coordinate.y"]["value"])+" "+str(grp["coordinate.z"]["value"])+")\"^^geo:wktLiteral .\n")
if sensorskey in project:
for seindex, sensor in enumerate(project[sensorskey]):
sensorid=str(projectid)+"_sensor_"+str(seindex)
calibid=str(sensorid)+"_calibration"
mscheckid=str(sensorid)+"_mscheck"
capturedevid=str(sensorid)+"_capturingdevice"
ttlstring.add(str(dataprefix)+":"+str(sensorid)+" rdf:type "+str(ontologyprefix)+":Sensor, "+provenancedict.get("entity")+" .\n")
ttlstring.add(str(dataprefix)+":"+str(sensorid)+" rdfs:label \"Sensor "+str(seindex)+" from "+str(projectname)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(sensorid)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(projectid)+" .\n")
if capturingdevice in sensor:
if "sensor_type" in sensor[capturingdevice] and sensor[capturingdevice]["sensor_type"]["value"] in sensorTypeToClass:
ttlstring.add(str(dataprefix)+":"+str(capturedevid)+" rdf:type "+str(sensorTypeToClass[sensor[capturingdevice]["sensor_type"]["value"]])+" .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(capturedevid)+" rdf:type "+str(ontologyprefix)+":CapturingDevice .\n")
ttlstring.add(str(dataprefix)+":"+str(sensorid)+" "+str(ontologyprefix)+":capturingdevice "+str(dataprefix)+":"+str(capturedevid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(mscheckid)+" "+str(ontologyprefix)+":partOf "+str(dataprefix)+":"+str(sensorid)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(capturedevid)+" rdfs:label \""+labelprefix+"Sensor "+str(seindex)+" Capturing Device\"@en .\n")
ttlstring=exportInformationFromIndAsTTL(sensor[capturingdevice],capturedevid,str(ontologyprefix)+":CapturingDevice",labelprefix+" Sensor "+str(seindex)+" Caturing Device",ttlstring)
if calibkey in sensor:
ttlstring.add(str(dataprefix)+":"+str(sensorid)+" "+str(ontologyprefix)+":calibration "+str(dataprefix)+":"+str(calibid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+" rdfs:label \"Sensor "+str(seindex)+" Calibration\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+" rdf:type "+str(ontologyprefix)+":Calibration .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity rdf:type prov:Activity .\n")
if labelprefix=="":
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity rdfs:label \"MS "+str(seindex)+" Measurement "+str(msindex)+" Calibration Activity \"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity rdfs:label \"Sensor "+str(seindex)+" Messvorgang "+str(msindex)+" Kalibrierung \"@de .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity rdfs:label \"MS "+str(seindex)+" Measurement "+str(msindex)+" Calibration Activity ("+str(labelprefix)+")\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity rdfs:label \"Sensor "+str(seindex)+" Messvorgang "+str(msindex)+" Kalibrierung ("+str(labelprefix)+")\"@de .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity prov:wasAssociatedWith "+str(dataprefix)+":"+str(userid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+" rdf:type "+str(ontologyprefix)+":Calibration .\n")
if calobject in sensor[calibkey]:
calobjid=""
calobjname=""
if "calibration_object_name" in sensor[calibkey][calobject]:
#print(messung[calibkey][calobject])
calobjid=str(sensor[calibkey][calobject]["calibration_object_name"]["value"]).replace(" ","")+"_calibration_object"
calobjname=str(sensor[calibkey][calobject]["calibration_object_name"]["value"])
else:
calobjid=str(sensorid)+"_calibration_object"
ttlstring.add(str(dataprefix)+":"+str(calibid)+" "+str(ontologyprefix)+":calibrationobject "+str(dataprefix)+":"+str(calobjid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(calobjid)+" rdfs:label \""+labelprefix+" Sensor "+str(seindex)+" Calibration Object"+"\" .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+"_activity prov:used "+str(dataprefix)+":"+str(calobjid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(calobjid)+" rdf:type "+str(ontologyprefix)+":CalibrationObject .\n")
ttlstring=exportInformationFromIndAsTTL(sensor[calibkey][calobject],calobjid,str(ontologyprefix)+":CalibrationObject",calobjname+" Calibration Object",ttlstring)
if calsetup in sensor[calibkey]:
calsetupid=str(sensorid)+"_calibration_setup"
ttlstring.add(str(dataprefix)+":"+str(calsetupid)+" rdf:type "+str(ontologyprefix)+":CalibrationSetup .\n")
ttlstring.add(str(dataprefix)+":"+str(calsetupid)+" rdfs:label \""+labelprefix+" Sensor "+str(seindex)+" Calibration Setup"+"\" .\n")
ttlstring.add(str(dataprefix)+":"+str(calibid)+" "+str(ontologyprefix)+":calibrationsetup "+str(dataprefix)+":"+str(calsetupid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(calsetupid)+" "+str(ontologyprefix)+":partOf "+str(dataprefix)+":"+str(calibid)+"_activity .\n")
ttlstring=exportInformationFromIndAsTTL(sensor[calibkey][calsetup],calsetupid,str(ontologyprefix)+":CalibrationSetup",labelprefix+" Sensor "+str(seindex)+" Calibration Setup",ttlstring)
if calproperties in sensor[calibkey]:
ttlstring=exportInformationFromIndAsTTL(sensor[calibkey][calproperties],calibid,str(ontologyprefix)+":Calibration",labelprefix+" Sensor "+str(seindex)+" Calibration",ttlstring)
ttlstring=exportInformationFromIndAsTTL(sensor[calibkey],calibid,str(ontologyprefix)+":Calibration",labelprefix+" Sensor "+str(seindex)+" Calibration",ttlstring)
#print(ttlstring)
if measurementskey in project:
for index, messung in enumerate(project[measurementskey]):
#print(index)
if measurementToExport==None or measurementToExport==index:
messungid=str(projectid)+"_ms_"+str(msindex)+"_measurement"+str(index)
calibid=str(messungid)+"_calibration"
capturedevid=str(messungid)+"_capturingdevice"
mssetupid=str(messungid)+"_mssetup"
mscheckid=str(messungid)+"_mscheck"
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" "+str(ontologyprefix)+":measurement "+str(dataprefix)+":"+str(messungid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(messungid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+" rdf:type "+str(ontologyprefix)+":Measurement .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+" rdfs:label \"MS "+str(msindex)+" Measurement "+str(index)+" for "+str(labelprefix)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+" prov:wasAttributedTo "+str(dataprefix)+":"+str(userid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(messungid)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity prov:wasAssociatedWith "+str(dataprefix)+":"+str(userid)+" .\n")
if artifactURI!=None:
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity prov:used "+artifactURI+" .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity rdf:type prov:Activity .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity prov:used "+str(dataprefix)+":"+softwareid+" .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity rdfs:label \"MS "+str(msindex)+" Measurement "+str(index)+" Activity ("+str(labelprefix)+")\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity rdfs:label \"Messreihe "+str(msindex)+" Messvorgang "+str(index)+" ("+str(labelprefix)+")\"@de .\n")
if measurementinformation in messung and "sensor_id" in messung[measurementinformation] and "value" in messung[measurementinformation]["sensor_id"]:
ttlstring.add(str(dataprefix)+":"+str(messungid)+" "+str(ontologyprefix)+":sensor "+str(dataprefix)+":"+str(projectid)+"_sensor_"+str(messung[measurementinformation]["sensor_id"]["value"])+" .\n")
if mssetup in messung:
ttlstring.add(str(dataprefix)+":"+str(mssetupid)+" rdf:type "+str(ontologyprefix)+":MeasurementSetup .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+" "+str(ontologyprefix)+":setup "+str(dataprefix)+":"+str(mssetupid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(mssetupid)+" "+str(ontologyprefix)+":partOf "+str(dataprefix)+":"+str(messungid)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(mssetupid)+" rdfs:label \""+labelprefix+" MS "+str(msindex)+" Measurement "+str(index)+" Setup\"@en .\n")
ttlstring=exportInformationFromIndAsTTL(messung[mssetup],mssetupid,str(ontologyprefix)+":MeasurementSetup",labelprefix+" MS "+str(msindex)+" Measurement "+str(index)+" Setup",ttlstring)
if mscheck in messung:
ttlstring.add(str(dataprefix)+":"+str(mscheckid)+" rdf:type "+str(ontologyprefix)+":MeasurementCheck .\n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+" "+str(ontologyprefix)+":verification "+str(dataprefix)+":"+str(mscheckid)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(mscheckid)+" prov:used "+str(dataprefix)+":"+str(messungid)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(mscheckid)+" rdfs:label \""+labelprefix+" MS "+str(msindex)+" Measurement "+str(index)+" Measurement Check\"@en .\n")
ttlstring=exportInformationFromIndAsTTL(messung[mscheck],mscheckid,str(ontologyprefix)+":MeasurementCheck",labelprefix+" MS "+str(msindex)+" Measurement "+str(index)+" Measurement Check",ttlstring)
ttlstring=exportInformationFromIndAsTTL(messung[measurementinformation],messungid,str(ontologyprefix)+":Measurement",labelprefix+" MS "+str(msindex)+" Measurement "+str(index),ttlstring)
#print(messung)
index2=0
index2oid = 0
messungindex=index
if refpointkey in messung:
for index,rp in enumerate(messung[refpointkey]):
if "r_id" in rp:
index2 = rp["r_id"]["value"]
elif "reference_point_id" in rp:
index2 = rp["reference_point_id"]["value"]
else:
index2 = "_noid_" + str(index2oid)
index2oid+=1
#print("aaa:"+str(rp))
rpuri=str(messungid)+"_rp"+str(index2)
ttlstring.add(str(dataprefix)+":"+str(messungid)+" "+str(ontologyprefix)+":referencePoint "+str(dataprefix)+":"+str(rpuri)+" . \n")
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" rdf:type "+str(ontologyprefix)+":ReferencePoint .\n")
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" rdfs:label \"RP"+str(index2)+" ("+str(labelprefix)+" MS "+str(msindex)+" Measurement "+str(messungindex)+")\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" rdfs:label \"RP"+str(index2)+" ("+str(labelprefix)+" Messreihe "+str(msindex)+" Messung "+str(messungindex)+")\"@de .\n")
ttlstring=exportInformationFromIndAsTTL(rp,rpuri,str(ontologyprefix)+":ReferencePoint",labelprefix+" MS "+str(msindex)+" Measurement "+str(index)+" RP"+str(index2),ttlstring)
if "r_x" in rp and "r_y" in rp and "r_z" in rp:
### atos v6.2
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" geo:asWKT \"POINT("+str(rp["r_x"]["value"])+" "+str(rp["r_y"]["value"])+" "+str(rp["r_z"]["value"])+")\"^^geo:wktLiteral .\n")
###atos 2016
elif "reference_point_coordinate.x" in rp and "reference_point_coordinate.y" in rp and "reference_point_coordinate.z" in rp:
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" geo:asWKT \"POINT("+str(rp["reference_point_coordinate.x"]["value"])+" "+str(rp["reference_point_coordinate.y"]["value"])+" "+str(rp["reference_point_coordinate.z"]["value"])+")\"^^geo:wktLiteral .\n")
#print(rp)
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(messungid)+"_activity . \n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_activity rdfs:label \"MS "+str(msindex)+" Measurement "+str(index)+" Activity\"@en. \n")
ttlstring.add(str(dataprefix)+":"+str(rpuri)+" prov:wasAttributedTo "+str(dataprefix)+":"+str(messungid)+"_algorithm . \n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_algorithm rdfs:label \"MS "+str(msindex)+" Measurement "+str(index)+" Algorithm\"@en. \n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_algorithm rdf:type "+str(ontologyprefix)+":Algorithm . \n")
ttlstring.add(str(dataprefix)+":"+str(messungid)+"_algorithm prov:actedOnBehalfOf "+str(dataprefix)+":"+str(userid)+" . \n")
#print(rpuri)
if measurementToExport==None and index2!=None:
#print("grp loop")
if globalrefpointkey in project:
if refpointkey in project[globalrefpointkey]:
for index, point in enumerate(project[globalrefpointkey][refpointkey]):
if referencepointid in rp and globalreferencepointid in point and rp[referencepointid]["value"]==point[globalreferencepointid]["value"]:
if "point_id" in point:
index = point["point_id"]["value"]
#print (index)
elif "r_id" in point:
index = point["r_id"]["value"]
#print (index)
#print(str(rp[referencepointid]["value"])+" - "+str(point[globalreferencepointid]["value"]))
#print(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp"+str(index)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(rpuri)+" . \n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp"+str(index)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(rpuri)+" . \n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity rdf:type prov:Activity . \n")
ttlstring.add(str(dataprefix)+":"+str(projectid)+"_ms_"+str(msindex)+"_grp_calculation_activity prov:used "+str(dataprefix)+":"+str(rpuri)+" . \n")
#print("next")
if mesheskey in pro:
for index, mesh in enumerate(pro[mesheskey]):
meshid=str(projectid)+"_mesh_"+str(index)
ttlstring.add(str(dataprefix)+":"+str(meshid)+" rdf:type "+str(ontologyprefix)+":Mesh, "+provenancedict.get("entity")+" .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+" rdfs:label \"Mesh "+str(meshid)+" from "+str(projectname)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(projectid)+" .\n")
lastprocid=""
if meshprocessingkey in mesh:
#print(mesh[meshprocessingkey])
for indexprocstep, procstep in enumerate(mesh[meshprocessingkey]):
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(0)+"_activity rdf:type prov:Activity .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(0)+"_activity rdfs:label \"Mesh Creation Activity "+str(0)+": "+str(procstep["processname"]["value"])+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(0)+"_activity rdfs:label \"Mesherstellungsschritt "+str(0)+": ("+str(procstep["processname"]["value"])+")\"@de .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(0)+"_activity prov:used "+str(dataprefix)+":"+str(projectid)+" .\n")
if "setup" in procstep:
ttlstring=exportInformationFromIndAsTTL(procstep["setup"],str(meshid)+"_creation_"+str(0)+"_activity","prov:Activity","Mesh Creation Activity "+procstep["processname"]["value"],ttlstring)
if "postprocessing" in procstep:
for indexpostproc, postproc in enumerate(procstep["postprocessing"]):
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity rdf:type prov:Activity .\n")
if "processname" in postproc and "value" in postproc["processname"]:
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity rdfs:label \"Mesh Creation Activity "+str(indexpostproc+1)+": "+str(postproc["processname"]["value"])+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity rdfs:label \"Mesherstellungsschritt "+str(indexpostproc+1)+": "+str(postproc["processname"]["value"])+"\"@de .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity rdfs:label \"Mesh Creation Activity "+str(indexpostproc+1)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity rdfs:label \"Mesherstellungsschritt "+str(indexpostproc+1)+"\"@de .\n")
if indexpostproc==0:
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity prov:wasInformedBy "+str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc)+"_activity .\n")
if indexpostproc!=0:
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity .\n")
else:
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity prov:wasInformedBy "+str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc)+"_activity .\n")
if indexpostproc!=0:
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" prov:wasDerivedFrom "+str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc)+" prov:wasInvalidatedBy "+str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity prov:used "+str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc)+" .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" rdfs:label \"Mesh "+str(meshid)+" Intermediate Result "+str(indexpostproc)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" rdfs:label \"Mesh "+str(meshid)+" Zwischenergebnis "+str(indexpostproc)+"\"@en .\n")
ttlstring.add(str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)+" rdf:type "+str(ontologyprefix)+":IntermediateMeshResult .\n")
lastprocid=str(dataprefix)+":"+str(meshid)+"_intermediate_"+str(indexpostproc+1)
if "processname" in postproc and "value" in postproc["processname"]:
ttlstring=exportInformationFromIndAsTTL(postproc,str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity","prov:Activity","Mesh Creation Activity "+str(indexpostproc)+": "+str(postproc["processname"]["value"])+" ",ttlstring)
else:
ttlstring=exportInformationFromIndAsTTL(postproc,str(meshid)+"_creation_"+str(indexpostproc+1)+"_activity","prov:Activity","Mesh Creation Activity "+str(indexpostproc)+" ",ttlstring)
else:
ttlstring.add(str(dataprefix)+":"+str(meshid)+" prov:wasGeneratedBy "+str(dataprefix)+":"+str(meshid)+"_creation_"+str(0)+"_activity .\n")
if lastprocid!="":
ttlstring.add(str(dataprefix)+":"+str(meshid)+" owl:sameAs "+str(lastprocid)+" .\n")
ttlstring=exportInformationFromIndAsTTL(mesh[meshinfokey],meshid,str(ontologyprefix)+":Mesh",labelprefix+" Mesh Attribute ",ttlstring)
return ttlstring
#####################################################################################################
## Method for collecting metadata of the measurement series, measurements and networks
## An externally created dictionary with user information can be given
def createMetaDic(dic_user): # befor exportjson(), now createMetaDic()
dic_dig = {}
dic_dig_app={}
list_app=[]
list_project_info=[]
project = {}
project_info ={}
sensor_id = 0
list_app.append(dic_dig_app)
# add script version infos
list_app.append(script_version())
# import userkey / general information
if "projects" in dic_user:
for e in dic_user["projects"]:
if 'general' in e:
project['general'] = e['general']
def infos_app (keyword,beschreibung,unit,description,uri,measurementclass, value, from_application):
dir = {}
dir.clear()
dir["value"] = gom.app.get(keyword)
dir["key_deu"] = beschreibung
if description!=None:
dir["key_eng"] = description
if uri!=None:
dir["uri"] = uri
if measurementclass!=None:
dir["measurementclass"] = measurementclass
dir["value_type"] = type(gom.app.get(keyword)).__name__
if unit!=None:
dir["unit"] = unit
if from_application!=None:
dir["from_application"] = from_application
if keyword == 'PROJECT.DATE':
value_new = dir["value"]
if keyword == "application_build_information.date":
dir["value_type"]="date"
if dir["value"] != None:
if len(str(dir["value"])) != 0:
dic_dig_app[keyword] = {}
dic_dig_app[keyword] = dir
# Applikationsname
keyword= 'application_name'
beschreibung = "Applikationsname"
unit= None
description="application name"
uri= None
measurementclass=None
value= gom.app.get ('application_name')
from_application= "true"
infos_app(keyword,beschreibung,unit,description,uri,measurementclass, value, from_application)
# Applilationsbuild-Informationen / Version
keyword= 'application_build_information.version'
beschreibung = "Applikationsbuild-Informationen / Version"
unit= None
description='application build information / version'
uri= None
measurementclass=None
value= gom.app.get(keyword)
from_application= "true"
infos_app(keyword,beschreibung,unit,description,uri,measurementclass, value, from_application)
# Applilationsbuild-Informationen / Revision
keyword= 'application_build_information.revision'
beschreibung = "Applikationsbuild-Informationen / Revision"
unit= None
description='application build information / Revision'
uri= None
measurementclass=None
value= gom.app.get(keyword)
from_application= "true"
infos_app(keyword,beschreibung,unit,description,uri,measurementclass, value, from_application)
# Applilationsbuild-Informationen / Datum
keyword= 'application_build_information.date'
beschreibung = "Applikationsbuild-Informationen / Datum"
unit= None
description='application build information / date'
uri= None
measurementclass=None
value= gom.app.get(keyword)
from_application= "true"
infos_app(keyword,beschreibung,unit,description,uri,measurementclass, value, from_application)
#project
def infos_p (keyword, beschreibung,unit=None,description=None, uri=None, measurementclass=None, value=None, from_application="true"):
dir = {}
if value== None:
dir["value"] = gom.app.project.get(keyword)
else:
dir["value"]= value
dir["key_deu"] = beschreibung
if description != None:
dir["key_eng"] = description
if uri != None:
dir["uri"] = uri
if unit != None:
dir["unit"] = unit
if measurementclass!=None:
dir["measurementclass"] = measurementclass
dir["from_application"]=from_application
try:
dir["value_type"] = type(gom.app.project.get(keyword)).__name__
except:
dir["value_type"] = type(dir["value"]).__name__
if dir["value"] != None:
if len(str(dir["value"])) != 0:
if includeonlypropswithuri and "uri" in dir:
project_info[keyword] = {}
project_info[keyword] = dir
if not includeonlypropswithuri:
project_info[keyword] ={}
project_info[keyword] = dir
### Projektinformationen
anz_messungen = 0
##Benutzerdefinierte Keywords
# Abteilung
keyword= 'user_department'
beschreibung = "Abteilung"
unit= None
description="department"
uri= None
measurementclass=None
infos_p(keyword,beschreibung,unit,description,uri,measurementclass)
# Bauteil
keyword= 'user_part'
beschreibung = "Bauteil"
unit= None
description="Part"
uri= None
measurementclass=None