oldaplib 0.3.12__py3-none-any.whl → 0.3.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oldaplib/ontologies/shared.trig +155 -6
- oldaplib/src/enums/haspropertyattr.py +2 -2
- oldaplib/src/hasproperty.py +12 -6
- oldaplib/src/objectfactory.py +21 -8
- oldaplib/src/propertyclass.py +14 -8
- oldaplib/src/resourceclass.py +4 -4
- oldaplib/src/version.py +1 -1
- oldaplib/test/test_objectfactory.py +21 -2
- {oldaplib-0.3.12.dist-info → oldaplib-0.3.14.dist-info}/METADATA +8 -1
- {oldaplib-0.3.12.dist-info → oldaplib-0.3.14.dist-info}/RECORD +11 -11
- {oldaplib-0.3.12.dist-info → oldaplib-0.3.14.dist-info}/WHEEL +0 -0
oldaplib/ontologies/shared.trig
CHANGED
|
@@ -41,7 +41,7 @@ shared:shacl {
|
|
|
41
41
|
dcterms:created "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
42
42
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
43
43
|
dcterms:modified "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
44
|
-
sh:maxCount "1"^^xsd:
|
|
44
|
+
sh:maxCount "1"^^xsd:nonNegativeInteger ;
|
|
45
45
|
sh:datatype xsd:decimal ;
|
|
46
46
|
] ;
|
|
47
47
|
sh:property [
|
|
@@ -50,7 +50,7 @@ shared:shacl {
|
|
|
50
50
|
dcterms:created "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
51
51
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
52
52
|
dcterms:modified "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
53
|
-
sh:maxCount "1"^^xsd:
|
|
53
|
+
sh:maxCount "1"^^xsd:nonNegativeInteger ;
|
|
54
54
|
sh:datatype xsd:string ;
|
|
55
55
|
sh:in ("GREGORIAN"^^xsd:string "JULIAN"^^xsd:string "HEBREW"^^xsd:string "ISLAMIC"^^xsd:string "PERSIAN"^^xsd:string) ;
|
|
56
56
|
] ;
|
|
@@ -60,7 +60,7 @@ shared:shacl {
|
|
|
60
60
|
dcterms:created "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
61
61
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
62
62
|
dcterms:modified "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
63
|
-
sh:maxCount "1"^^xsd:
|
|
63
|
+
sh:maxCount "1"^^xsd:nonNegativeInteger ;
|
|
64
64
|
sh:class oldap:ChronolgyStatement ;
|
|
65
65
|
] ;
|
|
66
66
|
sh:property [
|
|
@@ -69,7 +69,7 @@ shared:shacl {
|
|
|
69
69
|
dcterms:created "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
70
70
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
71
71
|
dcterms:modified "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
72
|
-
sh:maxCount "1"^^xsd:
|
|
72
|
+
sh:maxCount "1"^^xsd:nonNegativeInteger ;
|
|
73
73
|
sh:class oldap:ChronolgyStatement ;
|
|
74
74
|
] ;
|
|
75
75
|
sh:property [
|
|
@@ -78,7 +78,7 @@ shared:shacl {
|
|
|
78
78
|
dcterms:created "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
79
79
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
80
80
|
dcterms:modified "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
81
|
-
sh:maxCount "1"^^xsd:
|
|
81
|
+
sh:maxCount "1"^^xsd:nonNegativeInteger ;
|
|
82
82
|
sh:datatype xsd:decimal ;
|
|
83
83
|
] ;
|
|
84
84
|
sh:property [
|
|
@@ -87,11 +87,88 @@ shared:shacl {
|
|
|
87
87
|
dcterms:created "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
88
88
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
89
89
|
dcterms:modified "2023-11-04T12:00:00+00:00"^^xsd:dateTime ;
|
|
90
|
-
sh:maxCount "1"^^xsd:
|
|
90
|
+
sh:maxCount "1"^^xsd:nonNegativeInteger ;
|
|
91
91
|
sh:datatype xsd:decimal ;
|
|
92
92
|
] .
|
|
93
93
|
|
|
94
|
+
###############################################################################
|
|
95
|
+
# Media object
|
|
96
|
+
###############################################################################
|
|
94
97
|
|
|
98
|
+
shared:MediaObjectShape a sh:NodeShape ;
|
|
99
|
+
sh:targetClass shared:MediaObject ;
|
|
100
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
101
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
102
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
103
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
104
|
+
oldap:externalOntology "false"^^xsd:boolean ;
|
|
105
|
+
rdfs:label "MediaObject"@en, "Medienobjekt"@de, "MediaObject"@fr, "MediaObject"@it ;
|
|
106
|
+
rdfs:comment "Page of a book"@en, "Seite eines Buches"@de ;
|
|
107
|
+
sh:closed "true"^^xsd:boolean ;
|
|
108
|
+
sh:node oldap:ThingShape ;
|
|
109
|
+
sh:property [
|
|
110
|
+
sh:path rdf:type ;
|
|
111
|
+
] ;
|
|
112
|
+
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
113
|
+
sh:path shared:originalName ;
|
|
114
|
+
schema:version "0.1.0"^^xsd:string ;
|
|
115
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
116
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
117
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
118
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
119
|
+
oldap:statementProperty "false"^^xsd:boolean ;
|
|
120
|
+
oldap:externalOntology "false"^^xsd:boolean ;
|
|
121
|
+
sh:datatype xsd:string ;
|
|
122
|
+
sh:name "Original Filename"@en, "Originaler Dateiname"@de, "Nom orignal du fichier"@fr, "Nome documento originale"@it ;
|
|
123
|
+
sh:minCount "1"^^xsd:integer ;
|
|
124
|
+
sh:maxCount "1"^^xsd:integer ;
|
|
125
|
+
sh:order "1.0"^^xsd:decimal ;
|
|
126
|
+
] ;
|
|
127
|
+
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
128
|
+
sh:path shared:originalMimeType ;
|
|
129
|
+
schema:version "0.1.0"^^xsd:string ;
|
|
130
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
131
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
132
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
133
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
134
|
+
oldap:statementProperty "false"^^xsd:boolean ;
|
|
135
|
+
oldap:externalOntology "false"^^xsd:boolean ;
|
|
136
|
+
sh:datatype xsd:string ;
|
|
137
|
+
sh:name "Original mimetype"@en, "Originaler Mimetype"@de, "Mimetype original"@fr, "Mimetype originale"@it ;
|
|
138
|
+
sh:minCount "1"^^xsd:integer ;
|
|
139
|
+
sh:maxCount "1"^^xsd:integer ;
|
|
140
|
+
sh:order "2.0"^^xsd:decimal ;
|
|
141
|
+
] ;
|
|
142
|
+
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
143
|
+
sh:path shared:serverUrl ;
|
|
144
|
+
schema:version "0.1.0"^^xsd:string ;
|
|
145
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
146
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
147
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
148
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
149
|
+
oldap:statementProperty "false"^^xsd:boolean ;
|
|
150
|
+
oldap:externalOntology "false"^^xsd:boolean ;
|
|
151
|
+
sh:datatype xsd:anyURI ;
|
|
152
|
+
sh:name "Server URL"@en, "URL des servers"@de, "Server URL"@fr, "Server URL"@it ;
|
|
153
|
+
sh:minCount "1"^^xsd:integer ;
|
|
154
|
+
sh:maxCount "1"^^xsd:integer ;
|
|
155
|
+
sh:order "3.0"^^xsd:decimal ;
|
|
156
|
+
] ;
|
|
157
|
+
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
158
|
+
sh:path shared:imageId ;
|
|
159
|
+
schema:version "0.1.0"^^xsd:string ;
|
|
160
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
161
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
162
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
163
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
164
|
+
oldap:statementProperty "false"^^xsd:boolean ;
|
|
165
|
+
oldap:externalOntology "false"^^xsd:boolean ;
|
|
166
|
+
sh:datatype xsd:string ;
|
|
167
|
+
sh:name "Image ID"@en, "ID des Bilder"@de, "ID de l\'image"@fr, "ID de l\'immagine"@it ;
|
|
168
|
+
sh:minCount "1"^^xsd:integer ;
|
|
169
|
+
sh:maxCount "1"^^xsd:integer ;
|
|
170
|
+
sh:order "3.0"^^xsd:decimal ;
|
|
171
|
+
] .
|
|
95
172
|
}
|
|
96
173
|
|
|
97
174
|
shared:onto {
|
|
@@ -161,6 +238,7 @@ shared:onto {
|
|
|
161
238
|
###########################################################################
|
|
162
239
|
# Chronology Date Resource
|
|
163
240
|
###########################################################################
|
|
241
|
+
|
|
164
242
|
oldap:ChronolgyStatement rdf:type owl:Class ;
|
|
165
243
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
166
244
|
dcterms:created "2023-11-04T12:00:00Z"^^xsd:dateTime ;
|
|
@@ -210,5 +288,76 @@ shared:onto {
|
|
|
210
288
|
owl:onDataRange xsd:decimal
|
|
211
289
|
] .
|
|
212
290
|
|
|
291
|
+
###########################################################################
|
|
292
|
+
# Media object
|
|
293
|
+
###########################################################################
|
|
294
|
+
|
|
295
|
+
shared:originalName rdf:type owl:DatatypeProperty ;
|
|
296
|
+
rdfs:domain shared:MediaObject ;
|
|
297
|
+
rdfs:range xsd:string ;
|
|
298
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
299
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
300
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
301
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
302
|
+
|
|
303
|
+
shared:originalMimeType rdf:type owl:DatatypeProperty ;
|
|
304
|
+
rdfs:domain shared:MediaObject ;
|
|
305
|
+
rdfs:range xsd:string ;
|
|
306
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
307
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
308
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
309
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
310
|
+
|
|
311
|
+
shared:serverUrl rdf:type owl:DatatypeProperty ;
|
|
312
|
+
rdfs:domain shared:MediaObject ;
|
|
313
|
+
rdfs:range xsd:anyURI ;
|
|
314
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
315
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
316
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
317
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
318
|
+
|
|
319
|
+
shared:imageId rdf:type owl:DatatypeProperty ;
|
|
320
|
+
rdfs:domain shared:MediaObject ;
|
|
321
|
+
rdfs:range xsd:string ;
|
|
322
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
323
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
324
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
325
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
326
|
+
|
|
327
|
+
shared:MediaObject rdf:type owl:Class ;
|
|
328
|
+
schema:version "0.1.0"^^xsd:string ;
|
|
329
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
330
|
+
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
331
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
332
|
+
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
333
|
+
rdfs:label "MediaObject"@en, "Medienobjekt"@de, "MediaObject"@fr, "MediaObject"@it ;
|
|
334
|
+
rdfs:comment "Page of a book"@en, "Seite eines Buches"@de ;
|
|
335
|
+
rdfs:subClassOf oldap:Thing ,
|
|
336
|
+
[
|
|
337
|
+
rdf:type owl:Restriction ;
|
|
338
|
+
owl:onProperty shared:originalName ;
|
|
339
|
+
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
340
|
+
owl:onDataRange xsd:string ;
|
|
341
|
+
] ,
|
|
342
|
+
[
|
|
343
|
+
rdf:type owl:Restriction ;
|
|
344
|
+
owl:onProperty shared:originalMimeType ;
|
|
345
|
+
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
346
|
+
owl:onDataRange xsd:string ;
|
|
347
|
+
] ,
|
|
348
|
+
[
|
|
349
|
+
rdf:type owl:Restriction ;
|
|
350
|
+
owl:onProperty shared:serverUrl ;
|
|
351
|
+
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
352
|
+
owl:onDataRange xsd:anyURI ;
|
|
353
|
+
] ,
|
|
354
|
+
[
|
|
355
|
+
rdf:type owl:Restriction ;
|
|
356
|
+
owl:onProperty shared:imageId ;
|
|
357
|
+
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
358
|
+
owl:onDataRange xsd:string ;
|
|
359
|
+
] .
|
|
360
|
+
|
|
361
|
+
|
|
213
362
|
}
|
|
214
363
|
|
|
@@ -12,7 +12,7 @@ from oldaplib.src.xsd.xsd_qname import Xsd_QName
|
|
|
12
12
|
@unique
|
|
13
13
|
class HasPropertyAttr(AttributeClass):
|
|
14
14
|
# order: (QName, mandatory, immutable, datatype)
|
|
15
|
-
MIN_COUNT = ('sh:minCount', False, False,
|
|
16
|
-
MAX_COUNT = ('sh:maxCount', False, False,
|
|
15
|
+
MIN_COUNT = ('sh:minCount', False, False, Xsd_integer)
|
|
16
|
+
MAX_COUNT = ('sh:maxCount', False, False, Xsd_integer)
|
|
17
17
|
ORDER = ('sh:order', False, False, Xsd_decimal)
|
|
18
18
|
GROUP = ('sh:group', False, False, Xsd_QName)
|
oldaplib/src/hasproperty.py
CHANGED
|
@@ -222,12 +222,15 @@ class HasProperty(Model, Notify):
|
|
|
222
222
|
max_count = Xsd_nonNegativeInteger(int(self._attributes[HasPropertyAttr.MAX_COUNT])) if self._attributes.get(HasPropertyAttr.MAX_COUNT) else None
|
|
223
223
|
|
|
224
224
|
if min_count and max_count and min_count == max_count:
|
|
225
|
-
|
|
225
|
+
tmp = Xsd_nonNegativeInteger(min_count)
|
|
226
|
+
sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}owl:qualifiedCardinality {tmp.toRdf}'
|
|
226
227
|
else:
|
|
227
228
|
if min_count:
|
|
228
|
-
|
|
229
|
+
tmp = Xsd_nonNegativeInteger(min_count)
|
|
230
|
+
sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}owl:minQualifiedCardinality {tmp.toRdf}'
|
|
229
231
|
if max_count:
|
|
230
|
-
|
|
232
|
+
tmp = Xsd_nonNegativeInteger(max_count)
|
|
233
|
+
sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}owl:maxQualifiedCardinality {tmp.toRdf}'
|
|
231
234
|
return sparql
|
|
232
235
|
|
|
233
236
|
def update_shacl(self,
|
|
@@ -287,12 +290,15 @@ class HasProperty(Model, Notify):
|
|
|
287
290
|
if min_count or max_count:
|
|
288
291
|
sparql += f'{blank:{indent * indent_inc}}INSERT {{\n'
|
|
289
292
|
if min_count and max_count and min_count == max_count:
|
|
290
|
-
|
|
293
|
+
tmp = Xsd_nonNegativeInteger(min_count)
|
|
294
|
+
sparql += f'{blank:{(indent + 1) * indent_inc}}?prop owl:qualifiedCardinality {tmp.toRdf} .\n'
|
|
291
295
|
else:
|
|
292
296
|
if min_count:
|
|
293
|
-
|
|
297
|
+
tmp = Xsd_nonNegativeInteger(min_count)
|
|
298
|
+
sparql += f'{blank:{(indent + 1) * indent_inc}}?prop owl:minQualifiedCardinality {tmp.toRdf} .\n'
|
|
294
299
|
if max_count:
|
|
295
|
-
|
|
300
|
+
tmp = Xsd_nonNegativeInteger(max_count)
|
|
301
|
+
sparql += f'{blank:{(indent + 1) * indent_inc}}?prop owl:maxQualifiedCardinality {tmp.toRdf} .\n'
|
|
296
302
|
sparql += f'{blank:{indent * indent_inc}}}}\n'
|
|
297
303
|
|
|
298
304
|
sparql += f'{blank:{indent * indent_inc}}WHERE {{\n'
|
oldaplib/src/objectfactory.py
CHANGED
|
@@ -495,7 +495,7 @@ class ResourceInstance:
|
|
|
495
495
|
raise OldapErrorNoPermission(message)
|
|
496
496
|
|
|
497
497
|
timestamp = Xsd_dateTimeStamp()
|
|
498
|
-
if self.name
|
|
498
|
+
if self.name in ("Thing", "oldap:Thing"):
|
|
499
499
|
self._values[Xsd_QName('oldap:createdBy', validate=False)] = ObservableSet({self._con.userIri})
|
|
500
500
|
self._values[Xsd_QName('oldap:creationDate', validate=False)] = ObservableSet({timestamp})
|
|
501
501
|
self._values[Xsd_QName('oldap:lastModifiedBy', validate=False)] = ObservableSet({self._con.userIri})
|
|
@@ -517,7 +517,7 @@ class ResourceInstance:
|
|
|
517
517
|
sparql += f'{blank:{indent * indent_inc}}INSERT DATA {{'
|
|
518
518
|
sparql += f'\n{blank:{(indent + 1) * indent_inc}}GRAPH {self._graph}:data {{'
|
|
519
519
|
|
|
520
|
-
sparql += f'\n{blank:{(indent + 2) * indent_inc}}{self._iri.toRdf} a {self.
|
|
520
|
+
sparql += f'\n{blank:{(indent + 2) * indent_inc}}{self._iri.toRdf} a {self.name}'
|
|
521
521
|
|
|
522
522
|
for prop_iri, values in self._values.items():
|
|
523
523
|
if self.properties.get(prop_iri) and self.properties[prop_iri].prop.datatype == XsdDatatypes.QName:
|
|
@@ -537,6 +537,7 @@ class ResourceInstance:
|
|
|
537
537
|
raise OldapErrorAlreadyExists(f'Resource with IRI {self._iri} already exists.')
|
|
538
538
|
self._con.transaction_update(sparql)
|
|
539
539
|
except OldapError as e:
|
|
540
|
+
print(sparql)
|
|
540
541
|
self._con.transaction_abort()
|
|
541
542
|
raise
|
|
542
543
|
self._con.transaction_commit()
|
|
@@ -1172,7 +1173,9 @@ class ResourceInstanceFactory:
|
|
|
1172
1173
|
"""
|
|
1173
1174
|
_con: IConnection
|
|
1174
1175
|
_project: Project
|
|
1176
|
+
_sharedProject: Project
|
|
1175
1177
|
_datamodel: DataModel
|
|
1178
|
+
_sharedModel: DataModel
|
|
1176
1179
|
|
|
1177
1180
|
def __init__(self,
|
|
1178
1181
|
con: IConnection,
|
|
@@ -1182,20 +1185,30 @@ class ResourceInstanceFactory:
|
|
|
1182
1185
|
self._project = project
|
|
1183
1186
|
else:
|
|
1184
1187
|
self._project = Project.read(self._con, project)
|
|
1188
|
+
self._sharedProject = Project.read(self._con, "oldap:SharedProject")
|
|
1185
1189
|
|
|
1186
|
-
self._datamodel = DataModel.read(con=self._con, project=self._project
|
|
1190
|
+
self._datamodel = DataModel.read(con=self._con, project=self._project)
|
|
1191
|
+
self._sharedModel = DataModel.read(con=self._con, project=self._sharedProject)
|
|
1187
1192
|
|
|
1188
|
-
def createObjectInstance(self, name: Xsd_NCName | str) -> Type: ## ToDo: Get name automatically from IRI
|
|
1189
|
-
|
|
1193
|
+
def createObjectInstance(self, name: Xsd_NCName | Xsd_QName | str) -> Type: ## ToDo: Get name automatically from IRI
|
|
1194
|
+
if isinstance(name, Xsd_QName):
|
|
1195
|
+
classiri = name
|
|
1196
|
+
else:
|
|
1197
|
+
try:
|
|
1198
|
+
classiri = Xsd_QName(name, validate=True)
|
|
1199
|
+
except (ValueError, OldapErrorValue):
|
|
1200
|
+
if not isinstance(name, Xsd_NCName):
|
|
1201
|
+
name = Xsd_NCName(name, validate=True)
|
|
1202
|
+
classiri = Xsd_QName(self._project.projectShortName, name)
|
|
1190
1203
|
resclass = self._datamodel.get(classiri)
|
|
1191
|
-
if not
|
|
1192
|
-
|
|
1204
|
+
if not resclass:
|
|
1205
|
+
resclass = self._sharedModel.get(classiri)
|
|
1193
1206
|
if resclass is None:
|
|
1194
1207
|
raise OldapErrorNotFound(f'Given Resource Class "{classiri}" not found.')
|
|
1195
1208
|
return type(str(name), (ResourceInstance,), {
|
|
1196
1209
|
'_con': self._con,
|
|
1197
1210
|
'project': self._project,
|
|
1198
|
-
'name':
|
|
1211
|
+
'name': resclass.owl_class_iri,
|
|
1199
1212
|
'factory': self,
|
|
1200
1213
|
'properties': resclass.properties,
|
|
1201
1214
|
'superclass': resclass.superclass})
|
oldaplib/src/propertyclass.py
CHANGED
|
@@ -67,8 +67,8 @@ Attributes = dict[Xsd_QName, PropTypes]
|
|
|
67
67
|
@serializer
|
|
68
68
|
class HasPropertyData:
|
|
69
69
|
refprop: Xsd_QName | None = None
|
|
70
|
-
minCount:
|
|
71
|
-
maxCount:
|
|
70
|
+
minCount: Xsd_integer | None = None
|
|
71
|
+
maxCount: Xsd_integer | None = None
|
|
72
72
|
order: Xsd_decimal | None = None
|
|
73
73
|
group: Xsd_QName | None = None
|
|
74
74
|
|
|
@@ -91,12 +91,15 @@ class HasPropertyData:
|
|
|
91
91
|
sparql = ''
|
|
92
92
|
|
|
93
93
|
if self.minCount and self.maxCount and self.minCount == self.maxCount:
|
|
94
|
-
|
|
94
|
+
tmp = Xsd_nonNegativeInteger(self.minCount) # Convert to nonNegativeInteger
|
|
95
|
+
sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}owl:qualifiedCardinality {tmp.toRdf}'
|
|
95
96
|
else:
|
|
96
97
|
if self.minCount:
|
|
97
|
-
|
|
98
|
+
tmp = Xsd_nonNegativeInteger(self.minCount)
|
|
99
|
+
sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}owl:minQualifiedCardinality {tmp.toRdf}'
|
|
98
100
|
if self.maxCount:
|
|
99
|
-
|
|
101
|
+
tmp = Xsd_nonNegativeInteger(self.maxCount)
|
|
102
|
+
sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}owl:maxQualifiedCardinality {tmp.toRdf}'
|
|
100
103
|
return sparql
|
|
101
104
|
|
|
102
105
|
#@strict
|
|
@@ -1135,12 +1138,15 @@ class PropertyClass(Model, Notify):
|
|
|
1135
1138
|
sparql += f'{blank:{(indent + 1) * indent_inc}}owl:onProperty {self._property_class_iri.toRdf}'
|
|
1136
1139
|
|
|
1137
1140
|
if haspropdata.minCount and haspropdata.maxCount and haspropdata.minCount == haspropdata.maxCount:
|
|
1138
|
-
|
|
1141
|
+
tmp = Xsd_nonNegativeInteger(haspropdata.minCount)
|
|
1142
|
+
sparql += f' ;\n{blank:{(indent + 1)*indent_inc}}owl:qualifiedCardinality {tmp.toRdf}'
|
|
1139
1143
|
else:
|
|
1140
1144
|
if haspropdata.minCount:
|
|
1141
|
-
|
|
1145
|
+
tmp = Xsd_nonNegativeInteger(haspropdata.minCount)
|
|
1146
|
+
sparql += f' ;\n{blank:{(indent + 1)*indent_inc}}owl:minQualifiedCardinality {tmp.toRdf}'
|
|
1142
1147
|
if haspropdata.maxCount:
|
|
1143
|
-
|
|
1148
|
+
tmp = Xsd_nonNegativeInteger(haspropdata.maxCount)
|
|
1149
|
+
sparql += f' ;\n{blank:{(indent + 1)*indent_inc}}owl:maxQualifiedCardinality {tmp.toRdf}'
|
|
1144
1150
|
#
|
|
1145
1151
|
# (NOTE: owl:onClass and owl:onDataRange can be used only in a restriction and are "local" to the use
|
|
1146
1152
|
# of the property within the given resource. However, rdfs:range is "global" for all use of this property!
|
oldaplib/src/resourceclass.py
CHANGED
|
@@ -983,12 +983,12 @@ class ResourceClass(Model, Notify):
|
|
|
983
983
|
elif p == 'owl:onClass':
|
|
984
984
|
propdict[bnode_id]['to_node_iri'] = r['o']
|
|
985
985
|
elif p == 'owl:minQualifiedCardinality':
|
|
986
|
-
propdict[bnode_id]['min_count'] = r['o']
|
|
986
|
+
propdict[bnode_id]['min_count'] = Xsd_integer(r['o'])
|
|
987
987
|
elif p == 'owl:maxQualifiedCardinality':
|
|
988
|
-
propdict[bnode_id]['max_count'] = r['o']
|
|
988
|
+
propdict[bnode_id]['max_count'] = Xsd_integer(r['o'])
|
|
989
989
|
elif p == 'owl:qualifiedCardinality':
|
|
990
|
-
propdict[bnode_id]['min_count'] = r['o']
|
|
991
|
-
propdict[bnode_id]['max_count'] = r['o']
|
|
990
|
+
propdict[bnode_id]['min_count'] = Xsd_integer(r['o'])
|
|
991
|
+
propdict[bnode_id]['max_count'] = Xsd_integer(r['o'])
|
|
992
992
|
elif p == 'owl:onDataRange':
|
|
993
993
|
propdict[bnode_id]['datatype'] = r['o']
|
|
994
994
|
else:
|
oldaplib/src/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.14"
|
|
@@ -357,6 +357,25 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
357
357
|
mycat = Cat(name="Fluffy", subName="Fluffy the Cat")
|
|
358
358
|
mycat.create()
|
|
359
359
|
|
|
360
|
+
def test_create_from_shared(self):
|
|
361
|
+
dm = DataModel.read(con=self._connection, project='test')
|
|
362
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
363
|
+
MO = factory.createObjectInstance('shared:MediaObject')
|
|
364
|
+
mo = MO(originalName='Cat.tif',
|
|
365
|
+
originalMimeType='image/tiff',
|
|
366
|
+
serverUrl='http://iiif.oldap.org/iiif/3/',
|
|
367
|
+
imageId='cat.tif',
|
|
368
|
+
grantsPermission=Iri('oldap:GenericView'))
|
|
369
|
+
mo.create()
|
|
370
|
+
data = ResourceInstance.read_data(con=self._connection, iri=mo.iri, projectShortName='test')
|
|
371
|
+
print(data)
|
|
372
|
+
self.assertEqual(data[Xsd_QName("oldap:grantsPermission")], ['oldap:GenericView'])
|
|
373
|
+
self.assertEqual(data[Xsd_QName("shared:originalName")], ['Cat.tif'])
|
|
374
|
+
self.assertEqual(data[Xsd_QName("shared:originalMimeType")], ['image/tiff'])
|
|
375
|
+
self.assertEqual(data[Xsd_QName("shared:serverUrl")], ['http://iiif.oldap.org/iiif/3/'])
|
|
376
|
+
self.assertEqual(data[Xsd_QName("shared:imageId")], ['cat.tif'])
|
|
377
|
+
mo.delete()
|
|
378
|
+
|
|
360
379
|
def test_read_A(self):
|
|
361
380
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
362
381
|
Book = factory.createObjectInstance('Book')
|
|
@@ -381,7 +400,7 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
381
400
|
grantsPermission=Iri('oldap:GenericView'))
|
|
382
401
|
b.create()
|
|
383
402
|
bb = factory.read(iri=b.iri)
|
|
384
|
-
self.assertEqual(bb.name, "Book")
|
|
403
|
+
self.assertEqual(bb.name, "test:Book")
|
|
385
404
|
self.assertEqual(bb.title, {Xsd_string("The Life and Times of Scrooge")})
|
|
386
405
|
self.assertEqual(bb.author, {Iri("test:TuomasHolopainen")})
|
|
387
406
|
jsonobj = bb.toJsonObject()
|
|
@@ -398,7 +417,7 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
398
417
|
grantsPermission=Iri('oldap:GenericView'))
|
|
399
418
|
b.create()
|
|
400
419
|
bb = Book.read(con=self._connection, iri=b.iri)
|
|
401
|
-
self.assertEqual(bb.name, "Book")
|
|
420
|
+
self.assertEqual(bb.name, "test:Book")
|
|
402
421
|
self.assertEqual(bb.title, {Xsd_string("The Life and Times of Scrooge")})
|
|
403
422
|
self.assertEqual(bb.author, {Iri("test:TuomasHolopainen")})
|
|
404
423
|
jsonobj = bb.toJsonObject()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: oldaplib
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.14
|
|
4
4
|
Summary: Open Media Access Server Library (Linked Open Data middleware/RESTApi)
|
|
5
5
|
License: GNU Affero General Public License version 3
|
|
6
6
|
Author: Lukas Rosenthaler
|
|
@@ -79,4 +79,11 @@ http://oldap.org/<location>/<project>/data#
|
|
|
79
79
|
The project name must be unique to the location and is of
|
|
80
80
|
type [NCName](https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName).
|
|
81
81
|
|
|
82
|
+
## Media object
|
|
83
|
+
|
|
84
|
+
- originalName: `<http://purl.org/dc/terms/originalName>`
|
|
85
|
+
- originalMimeType: `<http://purl.org/dc/terms/format>`
|
|
86
|
+
- mediaserverUri: xsd:anyURI
|
|
87
|
+
- project: `<http://oldap.org/base#project>`
|
|
88
|
+
|
|
82
89
|
|
|
@@ -5,7 +5,7 @@ oldaplib/ontologies/admin.trig,sha256=S53TALvsBvbkV_Put4bUlwk8ZcD-Fj-K6LlsKkiuB9
|
|
|
5
5
|
oldaplib/ontologies/example.trig,sha256=MdRrFBZZ1L6aUDiT6aX4cnXiy-RoZHczF3Exn7aBSmU,1518
|
|
6
6
|
oldaplib/ontologies/oldap.trig,sha256=i2XanqKlhWSIdD17fLu5g0Luq2GORQCcyIfLn9Kummk,60241
|
|
7
7
|
oldaplib/ontologies/oldap.ttl,sha256=qdA0uiSjzVhkc1d5IN2y5ioK1QMzwl-TTnn3M_D1Kh8,29446
|
|
8
|
-
oldaplib/ontologies/shared.trig,sha256=
|
|
8
|
+
oldaplib/ontologies/shared.trig,sha256=BPocpJFbHIEq1XEd1P3yjMg7q-vSYyIVDCa97RILuMI,18045
|
|
9
9
|
oldaplib/ontologies/standard/.gitsave,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
oldaplib/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
oldaplib/src/cachesingleton.py,sha256=WGhuFER-mTnOJmwaN17fXPAg7zn7GJBm-XadShNUBBk,3687
|
|
@@ -23,7 +23,7 @@ oldaplib/src/enums/adminpermissions.py,sha256=v8Rc83NPSG_s7830-I7CbmKIhOioN2YkSH
|
|
|
23
23
|
oldaplib/src/enums/attributeclass.py,sha256=Lc7OnMMl9vjXj0SuL0l30iEjwC3oWDv_C8PFeTavDGc,3006
|
|
24
24
|
oldaplib/src/enums/datapermissions.py,sha256=0KiDjrPeSpGDAui8Z74sFBdDm64stzcMJx_dVEa2-bo,3437
|
|
25
25
|
oldaplib/src/enums/externalontologyattr.py,sha256=H7SrWrhe1Dkz_t1OFCWZVh3_14lJDltYGh3dOFr1Z6w,807
|
|
26
|
-
oldaplib/src/enums/haspropertyattr.py,sha256=
|
|
26
|
+
oldaplib/src/enums/haspropertyattr.py,sha256=Pwi-520nxue3s1fku9x4FNFBOOKSbYVI9MTVGD5jaeU,726
|
|
27
27
|
oldaplib/src/enums/language.py,sha256=OfQsFpIBj8lGBbZEqVCR_1F-bimPM48vqBl4EKBgggY,4623
|
|
28
28
|
oldaplib/src/enums/oldaplistattr.py,sha256=xuOU3oP35-PFFmlI-jlN28yqdk5lp_OzScKCC1O4IDI,620
|
|
29
29
|
oldaplib/src/enums/oldaplistnodeattr.py,sha256=qokSxE-0FLyWNipjjY3gZJC2bBEt1qS1Z2SFg-gb0kc,722
|
|
@@ -37,7 +37,7 @@ oldaplib/src/enums/userattr.py,sha256=ZRBGGLP5NMvyAER893TzRjfkhZk4jOtS9RsSkYsQM-
|
|
|
37
37
|
oldaplib/src/enums/xsd_datatypes.py,sha256=TGpy2TEaYfmCsSCClSyK76ixNP_hR7nEdJvCT6l-Txk,6253
|
|
38
38
|
oldaplib/src/externalontology.py,sha256=VaQvVlq5muzmQ466c1gKrldXn9Wx_WfOR7pUCjw_cYw,23888
|
|
39
39
|
oldaplib/src/globalconfig.py,sha256=zAJmAMQnojbhj8SZFUaPj7DIHN5g3wUwQQhWPMxjDUg,1306
|
|
40
|
-
oldaplib/src/hasproperty.py,sha256=
|
|
40
|
+
oldaplib/src/hasproperty.py,sha256=VnjLa6VBIH---mwh1mJ_drisDqjPu7By1RhFAVZaT7k,15814
|
|
41
41
|
oldaplib/src/helpers/Notify.py,sha256=9zzO93F4V4lj-xF6b3hpRg1QkI4TR_GYEh3ptsohlfQ,2008
|
|
42
42
|
oldaplib/src/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
43
|
oldaplib/src/helpers/attributechange.py,sha256=aQ5Q9s6U3bVd1WSNQcBpkr5UQVxeP4z_uz0K5_31ZVc,256
|
|
@@ -59,18 +59,18 @@ oldaplib/src/helpers/tools.py,sha256=sNbiOLucTGNFzZmiWwPLFOb80VTXQH0Zd9uCGubhzAk
|
|
|
59
59
|
oldaplib/src/iconnection.py,sha256=XlOc2Kh4tK_UOHydLQwlWjUFLUze-Aq_vEZpf9KS1-s,3677
|
|
60
60
|
oldaplib/src/in_project.py,sha256=2KuhHPj8DNveFRBeImrRfxlCOYhBK-mcxXYUp6s--j8,10672
|
|
61
61
|
oldaplib/src/model.py,sha256=VACR3T6zJYFaE5J1PFFdP0OSwhbu4sahoLMWg6_L_rE,19267
|
|
62
|
-
oldaplib/src/objectfactory.py,sha256=
|
|
62
|
+
oldaplib/src/objectfactory.py,sha256=pZ_5D3LpwfsvMVr6Rftwa3AlV84wNQcDDPs5USFNn0k,64306
|
|
63
63
|
oldaplib/src/oldaplist.py,sha256=sGAvEEJukRCjM70G0NFaR-L9YPleQTOtdWGExj3oYL8,42933
|
|
64
64
|
oldaplib/src/oldaplist_helpers.py,sha256=1Gur0nS1PCKb9iUtCKPUFDOYjw6vvAwYpe-G3DdxlEc,14213
|
|
65
65
|
oldaplib/src/oldaplistnode.py,sha256=NnC2juEGTtEkDO6OlB9PjSw_zTF-wSsRUgEk-6VV9DA,87344
|
|
66
66
|
oldaplib/src/oldaplogging.py,sha256=IDSOylms9OSTInYPC4Y2QrTTEzRL0T5I2QssCevOhTU,1242
|
|
67
67
|
oldaplib/src/permissionset.py,sha256=bzzVuZ7O_yVMujziwo32GEJIZYGG3g5gTds4HjLmGtU,31874
|
|
68
68
|
oldaplib/src/project.py,sha256=DNwViRg19zkE1F0zuWqQFK008uTVehVAu7xNbyessig,34207
|
|
69
|
-
oldaplib/src/propertyclass.py,sha256=
|
|
70
|
-
oldaplib/src/resourceclass.py,sha256=
|
|
69
|
+
oldaplib/src/propertyclass.py,sha256=WcRz-yzNOenyTWsYHkh48vaJDFO_0AgH9AMFq-HsiVo,93777
|
|
70
|
+
oldaplib/src/resourceclass.py,sha256=I6m93JhfCh4XAUFgmb6v0fD798DfU7-ImTKrUJk4g-o,102098
|
|
71
71
|
oldaplib/src/user.py,sha256=Z4GXPRkaHXx3glUpPXQdFqYMxQPOuqayDwkTAE5RGjU,48820
|
|
72
72
|
oldaplib/src/userdataclass.py,sha256=FbZkcRt0pKbOeqsZ7HbpwoKE-XPWH2AqpHG1GcsrBPo,12364
|
|
73
|
-
oldaplib/src/version.py,sha256
|
|
73
|
+
oldaplib/src/version.py,sha256=-T6106A_Mf7BT-0-rzDMc_1EaoZP74bXWfYSnwUgJCg,22
|
|
74
74
|
oldaplib/src/xsd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
75
|
oldaplib/src/xsd/floatingpoint.py,sha256=rDReKqh0mXyc4F5wslgTUxbeGf3-PGERyughj5_62YI,8852
|
|
76
76
|
oldaplib/src/xsd/iri.py,sha256=w1Dr0z-REi7yPe3GPGnyzGrLVMvLY03kEeK-AmZ9sxw,8383
|
|
@@ -126,7 +126,7 @@ oldaplib/test/test_hasproperty.py,sha256=r991g8kBTfv1CGs9Hf0fli-AUp7Ob7rOHWYD74h
|
|
|
126
126
|
oldaplib/test/test_in_project.py,sha256=DYT-guwRQ9crnfEt7cQZxoEMxThin7QeymNce3jaZx4,7779
|
|
127
127
|
oldaplib/test/test_langstring.py,sha256=37BeKiQzj63G-SyS_paK_SEG7ulRbGrE89Mz40UB_bE,15146
|
|
128
128
|
oldaplib/test/test_language_in.py,sha256=ELqHO-YIsZSCPF3E3rWde4J7rERL7En7sV_pzQ00zgs,8826
|
|
129
|
-
oldaplib/test/test_objectfactory.py,sha256=
|
|
129
|
+
oldaplib/test/test_objectfactory.py,sha256=jYNCaGkGXGoIo0mVsMPen3pWFx1xVbHq-nGgzDisf9w,36572
|
|
130
130
|
oldaplib/test/test_observable_dict.py,sha256=GxD0sM0nsVfVRBu92SFGkJ6--YXq4ibBWI4IpjZZzDU,1396
|
|
131
131
|
oldaplib/test/test_observable_set.py,sha256=JWZSoAsr8XIEBXPVgSVJjQQEEc8uSAme5IrFYLYVVXw,6313
|
|
132
132
|
oldaplib/test/test_oldaplist.py,sha256=9wo3tEOHt5bIuXyvSSyTzjhtdKrQHiiAA6EfVBuq4wI,20114
|
|
@@ -158,6 +158,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
|
|
|
158
158
|
oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
|
|
159
159
|
oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
|
|
160
160
|
oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
|
|
161
|
-
oldaplib-0.3.
|
|
162
|
-
oldaplib-0.3.
|
|
163
|
-
oldaplib-0.3.
|
|
161
|
+
oldaplib-0.3.14.dist-info/METADATA,sha256=UJPy5L_UvfLyY8TbVdWFTXKTHHdPdDNuVwUEG7ElRCo,3061
|
|
162
|
+
oldaplib-0.3.14.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
163
|
+
oldaplib-0.3.14.dist-info/RECORD,,
|
|
File without changes
|