oldaplib 0.3.13__py3-none-any.whl → 0.3.15__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 +40 -42
- oldaplib/src/enums/propertyclassattr.py +1 -1
- oldaplib/src/hasproperty.py +21 -1
- oldaplib/src/objectfactory.py +21 -8
- oldaplib/src/propertyclass.py +5 -1
- oldaplib/src/version.py +1 -1
- oldaplib/test/test_objectfactory.py +21 -2
- oldaplib/test/test_propertyclass.py +52 -3
- {oldaplib-0.3.13.dist-info → oldaplib-0.3.15.dist-info}/METADATA +1 -1
- {oldaplib-0.3.13.dist-info → oldaplib-0.3.15.dist-info}/RECORD +11 -11
- {oldaplib-0.3.13.dist-info → oldaplib-0.3.15.dist-info}/WHEEL +0 -0
oldaplib/ontologies/shared.trig
CHANGED
|
@@ -95,26 +95,27 @@ shared:shacl {
|
|
|
95
95
|
# Media object
|
|
96
96
|
###############################################################################
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
sh:targetClass
|
|
100
|
-
dcterms:created "2025-11-
|
|
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
101
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
102
|
-
dcterms:modified "2025-11-
|
|
102
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
103
103
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
104
104
|
oldap:externalOntology "false"^^xsd:boolean ;
|
|
105
105
|
rdfs:label "MediaObject"@en, "Medienobjekt"@de, "MediaObject"@fr, "MediaObject"@it ;
|
|
106
106
|
rdfs:comment "Page of a book"@en, "Seite eines Buches"@de ;
|
|
107
107
|
sh:closed "true"^^xsd:boolean ;
|
|
108
|
+
sh:node oldap:ThingShape ;
|
|
108
109
|
sh:property [
|
|
109
110
|
sh:path rdf:type ;
|
|
110
111
|
] ;
|
|
111
112
|
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
112
|
-
sh:path
|
|
113
|
+
sh:path shared:originalName ;
|
|
113
114
|
schema:version "0.1.0"^^xsd:string ;
|
|
114
115
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
115
|
-
dcterms:created "2025-11-
|
|
116
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
116
117
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
117
|
-
dcterms:modified "2025-11-
|
|
118
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
118
119
|
oldap:statementProperty "false"^^xsd:boolean ;
|
|
119
120
|
oldap:externalOntology "false"^^xsd:boolean ;
|
|
120
121
|
sh:datatype xsd:string ;
|
|
@@ -124,12 +125,12 @@ shared:shacl {
|
|
|
124
125
|
sh:order "1.0"^^xsd:decimal ;
|
|
125
126
|
] ;
|
|
126
127
|
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
127
|
-
sh:path
|
|
128
|
+
sh:path shared:originalMimeType ;
|
|
128
129
|
schema:version "0.1.0"^^xsd:string ;
|
|
129
130
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
130
|
-
dcterms:created "2025-11-
|
|
131
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
131
132
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
132
|
-
dcterms:modified "2025-11-
|
|
133
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
133
134
|
oldap:statementProperty "false"^^xsd:boolean ;
|
|
134
135
|
oldap:externalOntology "false"^^xsd:boolean ;
|
|
135
136
|
sh:datatype xsd:string ;
|
|
@@ -139,12 +140,12 @@ shared:shacl {
|
|
|
139
140
|
sh:order "2.0"^^xsd:decimal ;
|
|
140
141
|
] ;
|
|
141
142
|
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
142
|
-
sh:path
|
|
143
|
+
sh:path shared:serverUrl ;
|
|
143
144
|
schema:version "0.1.0"^^xsd:string ;
|
|
144
145
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
145
|
-
dcterms:created "2025-11-
|
|
146
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
146
147
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
147
|
-
dcterms:modified "2025-11-
|
|
148
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
148
149
|
oldap:statementProperty "false"^^xsd:boolean ;
|
|
149
150
|
oldap:externalOntology "false"^^xsd:boolean ;
|
|
150
151
|
sh:datatype xsd:anyURI ;
|
|
@@ -154,12 +155,12 @@ shared:shacl {
|
|
|
154
155
|
sh:order "3.0"^^xsd:decimal ;
|
|
155
156
|
] ;
|
|
156
157
|
sh:property [ # >>PropertyClass.property_node_shacl()
|
|
157
|
-
sh:path
|
|
158
|
+
sh:path shared:imageId ;
|
|
158
159
|
schema:version "0.1.0"^^xsd:string ;
|
|
159
160
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
160
|
-
dcterms:created "2025-11-
|
|
161
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
161
162
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
162
|
-
dcterms:modified "2025-11-
|
|
163
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
163
164
|
oldap:statementProperty "false"^^xsd:boolean ;
|
|
164
165
|
oldap:externalOntology "false"^^xsd:boolean ;
|
|
165
166
|
sh:datatype xsd:string ;
|
|
@@ -168,9 +169,6 @@ shared:shacl {
|
|
|
168
169
|
sh:maxCount "1"^^xsd:integer ;
|
|
169
170
|
sh:order "3.0"^^xsd:decimal ;
|
|
170
171
|
] .
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
shared:onto {
|
|
@@ -294,68 +292,68 @@ shared:onto {
|
|
|
294
292
|
# Media object
|
|
295
293
|
###########################################################################
|
|
296
294
|
|
|
297
|
-
|
|
298
|
-
rdfs:domain
|
|
295
|
+
shared:originalName rdf:type owl:DatatypeProperty ;
|
|
296
|
+
rdfs:domain shared:MediaObject ;
|
|
299
297
|
rdfs:range xsd:string ;
|
|
300
298
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
301
|
-
dcterms:created "2025-11-
|
|
299
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
302
300
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
303
|
-
dcterms:modified "2025-11-
|
|
301
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
304
302
|
|
|
305
|
-
|
|
306
|
-
rdfs:domain
|
|
303
|
+
shared:originalMimeType rdf:type owl:DatatypeProperty ;
|
|
304
|
+
rdfs:domain shared:MediaObject ;
|
|
307
305
|
rdfs:range xsd:string ;
|
|
308
306
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
309
|
-
dcterms:created "2025-11-
|
|
307
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
310
308
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
311
|
-
dcterms:modified "2025-11-
|
|
309
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
312
310
|
|
|
313
|
-
|
|
314
|
-
rdfs:domain
|
|
311
|
+
shared:serverUrl rdf:type owl:DatatypeProperty ;
|
|
312
|
+
rdfs:domain shared:MediaObject ;
|
|
315
313
|
rdfs:range xsd:anyURI ;
|
|
316
314
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
317
|
-
dcterms:created "2025-11-
|
|
315
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
318
316
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
319
|
-
dcterms:modified "2025-11-
|
|
317
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
320
318
|
|
|
321
|
-
|
|
322
|
-
rdfs:domain
|
|
319
|
+
shared:imageId rdf:type owl:DatatypeProperty ;
|
|
320
|
+
rdfs:domain shared:MediaObject ;
|
|
323
321
|
rdfs:range xsd:string ;
|
|
324
322
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
325
|
-
dcterms:created "2025-11-
|
|
323
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
326
324
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
327
|
-
dcterms:modified "2025-11-
|
|
325
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime .
|
|
328
326
|
|
|
329
|
-
|
|
327
|
+
shared:MediaObject rdf:type owl:Class ;
|
|
330
328
|
schema:version "0.1.0"^^xsd:string ;
|
|
331
|
-
dcterms:created "2025-11-
|
|
329
|
+
dcterms:created "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
332
330
|
dcterms:creator <https://orcid.org/0000-0003-1681-4036> ;
|
|
333
|
-
dcterms:modified "2025-11-
|
|
331
|
+
dcterms:modified "2025-11-21T00:15:09.037880+01:00"^^xsd:dateTime ;
|
|
334
332
|
dcterms:contributor <https://orcid.org/0000-0003-1681-4036> ;
|
|
335
333
|
rdfs:label "MediaObject"@en, "Medienobjekt"@de, "MediaObject"@fr, "MediaObject"@it ;
|
|
336
334
|
rdfs:comment "Page of a book"@en, "Seite eines Buches"@de ;
|
|
337
335
|
rdfs:subClassOf oldap:Thing ,
|
|
338
336
|
[
|
|
339
337
|
rdf:type owl:Restriction ;
|
|
340
|
-
owl:onProperty
|
|
338
|
+
owl:onProperty shared:originalName ;
|
|
341
339
|
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
342
340
|
owl:onDataRange xsd:string ;
|
|
343
341
|
] ,
|
|
344
342
|
[
|
|
345
343
|
rdf:type owl:Restriction ;
|
|
346
|
-
owl:onProperty
|
|
344
|
+
owl:onProperty shared:originalMimeType ;
|
|
347
345
|
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
348
346
|
owl:onDataRange xsd:string ;
|
|
349
347
|
] ,
|
|
350
348
|
[
|
|
351
349
|
rdf:type owl:Restriction ;
|
|
352
|
-
owl:onProperty
|
|
350
|
+
owl:onProperty shared:serverUrl ;
|
|
353
351
|
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
354
352
|
owl:onDataRange xsd:anyURI ;
|
|
355
353
|
] ,
|
|
356
354
|
[
|
|
357
355
|
rdf:type owl:Restriction ;
|
|
358
|
-
owl:onProperty
|
|
356
|
+
owl:onProperty shared:imageId ;
|
|
359
357
|
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
|
|
360
358
|
owl:onDataRange xsd:string ;
|
|
361
359
|
] .
|
|
@@ -57,7 +57,7 @@ class PropClassAttr(AttributeClass):
|
|
|
57
57
|
LESS_THAN = ('sh:lessThan', False, False, Iri, Target.SHACL)
|
|
58
58
|
LESS_THAN_OR_EQUALS = ('sh:lessThanOrEquals', False, False, Iri, Target.SHACL)
|
|
59
59
|
INVERSE_OF = ('owl:inverseOf', False, False, Xsd_QName, Target.OWL)
|
|
60
|
-
|
|
60
|
+
EQUIVALENT_PROPERTY = ('owl:equivalentProperty', False, False, Xsd_QName, Target.OWL)
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
@classmethod
|
oldaplib/src/hasproperty.py
CHANGED
|
@@ -6,9 +6,10 @@ from typing import Callable, Self, Any
|
|
|
6
6
|
from oldaplib.src.enums.action import Action
|
|
7
7
|
from oldaplib.src.enums.attributeclass import AttributeClass
|
|
8
8
|
from oldaplib.src.enums.haspropertyattr import HasPropertyAttr
|
|
9
|
+
from oldaplib.src.enums.owlpropertytype import OwlPropertyType
|
|
9
10
|
from oldaplib.src.helpers.Notify import Notify
|
|
10
11
|
from oldaplib.src.helpers.irincname import IriOrNCName
|
|
11
|
-
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound
|
|
12
|
+
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorInconsistency
|
|
12
13
|
from oldaplib.src.helpers.serializer import serializer
|
|
13
14
|
from oldaplib.src.iconnection import IConnection
|
|
14
15
|
from oldaplib.src.model import Model
|
|
@@ -117,6 +118,25 @@ class HasProperty(Model, Notify):
|
|
|
117
118
|
self._type = PropType.INTERNAL
|
|
118
119
|
self.set_attributes(kwargs, HasPropertyAttr)
|
|
119
120
|
|
|
121
|
+
#
|
|
122
|
+
# Check consistency for owl:FunctionalProperty. It must have a maxCount=1
|
|
123
|
+
#
|
|
124
|
+
if isinstance(self._prop, PropertyClass) and OwlPropertyType.FunctionalProperty in self._prop.type:
|
|
125
|
+
if not self._attributes.get(HasPropertyAttr.MAX_COUNT):
|
|
126
|
+
raise OldapErrorInconsistency(f'FunctionalProperty {self._prop.property_class_iri} must have maxCount=1')
|
|
127
|
+
if self._attributes[HasPropertyAttr.MAX_COUNT] != 1:
|
|
128
|
+
raise OldapErrorInconsistency(f'FunctionalProperty {self._prop.property_class_iri} must have maxCount=1')
|
|
129
|
+
|
|
130
|
+
#
|
|
131
|
+
# Check consistency for owl:InverseFunctionalProperty. It must have a cardinality of 1..1
|
|
132
|
+
#
|
|
133
|
+
if isinstance(self._prop, PropertyClass) and OwlPropertyType.InverseFunctionalProperty in self._prop.type:
|
|
134
|
+
if not self._attributes.get(HasPropertyAttr.MIN_COUNT) or not self._attributes.get(HasPropertyAttr.MAX_COUNT):
|
|
135
|
+
raise OldapErrorInconsistency(f'InverseFunctionalProperty {self._prop.property_class_iri} must have cardinality=1..1')
|
|
136
|
+
if self._attributes[HasPropertyAttr.MIN_COUNT] != 1 or self._attributes[HasPropertyAttr.MAX_COUNT] != 1:
|
|
137
|
+
raise OldapErrorInconsistency(f'InverseFunctionalProperty {self._prop.property_class_iri} must have cardinality=1..1')
|
|
138
|
+
|
|
139
|
+
|
|
120
140
|
for attr in HasPropertyAttr:
|
|
121
141
|
setattr(HasProperty, attr.value.fragment, property(
|
|
122
142
|
partial(HasProperty._get_value, attr=attr),
|
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
|
@@ -184,7 +184,7 @@ class PropertyClass(Model, Notify):
|
|
|
184
184
|
__slots__ = ('subPropertyOf', 'type', 'toClass', 'datatype', 'name', 'description', 'languageIn', 'uniqueLang',
|
|
185
185
|
'inSet', 'minCount', 'maxCount', 'pattern',
|
|
186
186
|
'minExclusive', 'maxExclusive', 'minInclusive', 'maxInclusive', 'minLength', 'maxLength',
|
|
187
|
-
'lessThan', 'lessThanOrEqual')
|
|
187
|
+
'lessThan', 'lessThanOrEqual', 'inverseOf', 'equivalentProperty')
|
|
188
188
|
|
|
189
189
|
|
|
190
190
|
def __init__(self, *,
|
|
@@ -321,10 +321,14 @@ class PropertyClass(Model, Notify):
|
|
|
321
321
|
if self._statementProperty:
|
|
322
322
|
self._attributes[PropClassAttr.TYPE].add(OwlPropertyType.StatementProperty)
|
|
323
323
|
if self._attributes.get(PropClassAttr.CLASS) is not None:
|
|
324
|
+
if OwlPropertyType.OwlDataProperty in self._attributes[PropClassAttr.TYPE]:
|
|
325
|
+
raise OldapErrorInconsistency(f'Property {self._property_class_iri} cannot be both a link property and a data property.')
|
|
324
326
|
self._attributes[PropClassAttr.TYPE].add(OwlPropertyType.OwlObjectProperty)
|
|
325
327
|
if self._attributes.get(PropClassAttr.DATATYPE) is not None:
|
|
326
328
|
raise OldapError(f'Datatype "{self._attributes.get(PropClassAttr.DATATYPE)}" not possible for OwlObjectProperty')
|
|
327
329
|
elif self._attributes.get(PropClassAttr.DATATYPE) is not None:
|
|
330
|
+
if OwlPropertyType.OwlObjectProperty in self._attributes[PropClassAttr.TYPE]:
|
|
331
|
+
raise OldapErrorInconsistency(f'Property {self._property_class_iri} cannot be both a link property and a data property.')
|
|
328
332
|
self._attributes[PropClassAttr.TYPE].add(OwlPropertyType.OwlDataProperty)
|
|
329
333
|
|
|
330
334
|
#
|
oldaplib/src/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.15"
|
|
@@ -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()
|
|
@@ -14,6 +14,7 @@ from oldaplib.src.enums.action import Action
|
|
|
14
14
|
from oldaplib.src.enums.language import Language
|
|
15
15
|
from oldaplib.src.enums.propertyclassattr import PropClassAttr
|
|
16
16
|
from oldaplib.src.enums.xsd_datatypes import XsdDatatypes
|
|
17
|
+
from oldaplib.src.hasproperty import HasProperty
|
|
17
18
|
from oldaplib.src.helpers.context import Context
|
|
18
19
|
from oldaplib.src.helpers.langstring import LangString, LangStringChange
|
|
19
20
|
from oldaplib.src.helpers.observable_set import ObservableSet
|
|
@@ -252,15 +253,31 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
252
253
|
p4.update()
|
|
253
254
|
self.assertEqual(p4.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.TransitiveProperty, OwlPropertyType.OwlDataProperty})
|
|
254
255
|
|
|
255
|
-
def
|
|
256
|
+
def test_propertyclass_inconsistent_constructor_A(self):
|
|
256
257
|
with self.assertRaises(OldapErrorValue):
|
|
257
258
|
p5 = PropertyClass(con=self._connection,
|
|
258
259
|
project=self._project,
|
|
259
|
-
property_class_iri=Xsd_QName('test:
|
|
260
|
+
property_class_iri=Xsd_QName('test:testprop5a'),
|
|
260
261
|
datatype=XsdDatatypes.string,
|
|
261
262
|
languageIn=LanguageIn(Language.EN, Language.DE, Language.FR))
|
|
262
263
|
|
|
263
|
-
def
|
|
264
|
+
def test_propertyclass_inconsistent_constructor_B(self):
|
|
265
|
+
with self.assertRaises(OldapErrorInconsistency):
|
|
266
|
+
p5 = PropertyClass(con=self._connection,
|
|
267
|
+
project=self._project,
|
|
268
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.OwlObjectProperty},
|
|
269
|
+
property_class_iri=Xsd_QName('test:testprop5b'),
|
|
270
|
+
datatype=XsdDatatypes.string)
|
|
271
|
+
|
|
272
|
+
def test_propertyclass_inconsistent_constructor_C(self):
|
|
273
|
+
with self.assertRaises(OldapErrorInconsistency):
|
|
274
|
+
p5 = PropertyClass(con=self._connection,
|
|
275
|
+
project=self._project,
|
|
276
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.OwlDataProperty},
|
|
277
|
+
property_class_iri=Xsd_QName('test:testprop5c'),
|
|
278
|
+
toClass=Xsd_QName('test:comment'))
|
|
279
|
+
|
|
280
|
+
def test_propertyclass_invalid_constructor_A(self):
|
|
264
281
|
with self.assertRaises(OldapErrorInconsistency):
|
|
265
282
|
px = PropertyClass(con=self._connection,
|
|
266
283
|
project=self._project,
|
|
@@ -268,6 +285,38 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
268
285
|
toClass=Xsd_QName('test:comment'),
|
|
269
286
|
minLength=42)
|
|
270
287
|
|
|
288
|
+
def test_propertyclass_invalid_constructor_B(self):
|
|
289
|
+
px = PropertyClass(con=self._connection,
|
|
290
|
+
project=self._project,
|
|
291
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.FunctionalProperty},
|
|
292
|
+
property_class_iri=Xsd_QName('test:testpropBa'),
|
|
293
|
+
toClass=Xsd_QName('test:comment'))
|
|
294
|
+
hp = HasProperty(con=self._connection, project=self._project, prop=px, maxCount=1)
|
|
295
|
+
|
|
296
|
+
with self.assertRaises(OldapErrorInconsistency):
|
|
297
|
+
px = PropertyClass(con=self._connection,
|
|
298
|
+
project=self._project,
|
|
299
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.FunctionalProperty},
|
|
300
|
+
property_class_iri=Xsd_QName('test:testpropBb'),
|
|
301
|
+
toClass=Xsd_QName('test:comment'))
|
|
302
|
+
hp = HasProperty(con=self._connection, project=self._project, prop=px)
|
|
303
|
+
|
|
304
|
+
def test_propertyclass_invalid_constructor_C(self):
|
|
305
|
+
px = PropertyClass(con=self._connection,
|
|
306
|
+
project=self._project,
|
|
307
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.InverseFunctionalProperty},
|
|
308
|
+
property_class_iri=Xsd_QName('test:testpropC'),
|
|
309
|
+
toClass=Xsd_QName('test:comment'))
|
|
310
|
+
hp = HasProperty(con=self._connection, project=self._project, prop=px, minCount=1, maxCount=1)
|
|
311
|
+
|
|
312
|
+
with self.assertRaises(OldapErrorInconsistency):
|
|
313
|
+
px = PropertyClass(con=self._connection,
|
|
314
|
+
project=self._project,
|
|
315
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.InverseFunctionalProperty},
|
|
316
|
+
property_class_iri=Xsd_QName('test:testpropC'),
|
|
317
|
+
toClass=Xsd_QName('test:comment'))
|
|
318
|
+
hp = HasProperty(con=self._connection, project=self._project, prop=px)
|
|
319
|
+
|
|
271
320
|
def test_propertyclass_projectsn_constructor(self):
|
|
272
321
|
p6 = PropertyClass(con=self._connection,
|
|
273
322
|
project="test",
|
|
@@ -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
|
|
@@ -30,14 +30,14 @@ oldaplib/src/enums/oldaplistnodeattr.py,sha256=qokSxE-0FLyWNipjjY3gZJC2bBEt1qS1Z
|
|
|
30
30
|
oldaplib/src/enums/owlpropertytype.py,sha256=R7DaCV4vtkGeuDhslN3q7719J1sLKUL-x0o91Te7Qk8,989
|
|
31
31
|
oldaplib/src/enums/permissionsetattr.py,sha256=og4jPvbY86ABr_I9qIvhvg4iIiQCFMcv9-_0D2gfzz8,839
|
|
32
32
|
oldaplib/src/enums/projectattr.py,sha256=A_iayrT3Sd1L_guhHtCKSlUaVf9JqikRXqML-GHkJ3o,1173
|
|
33
|
-
oldaplib/src/enums/propertyclassattr.py,sha256
|
|
33
|
+
oldaplib/src/enums/propertyclassattr.py,sha256=-F5Pjqj1AAnCrC01en-gGD4M-QoIYbi5QAWL0jQmNVQ,4263
|
|
34
34
|
oldaplib/src/enums/resourceclassattr.py,sha256=g8tc5JDr4wLCteBNnhHMVE4cRZOhlSQqs-qFnRB3_N0,709
|
|
35
35
|
oldaplib/src/enums/sparql_result_format.py,sha256=MLBHKY25o96mswSWioR-rS__zP6kPzYGNIWLZCr9784,636
|
|
36
36
|
oldaplib/src/enums/userattr.py,sha256=ZRBGGLP5NMvyAER893TzRjfkhZk4jOtS9RsSkYsQM-c,1628
|
|
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=w2rNuhqyWdJYAXnGROFLZUyafCpznPv-h_XuQSFWbqs,17235
|
|
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=
|
|
69
|
+
oldaplib/src/propertyclass.py,sha256=feWze8I0FxIgXGCn0jlBMVu69xULj43KIceP8GL0J9s,94266
|
|
70
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=gfCyWXKIm8Pcp9T835VgQrEZyolnHdfkmrdCNFY3zyg,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
|
|
@@ -134,7 +134,7 @@ oldaplib/test/test_oldaplist_helpers.py,sha256=vJkA_Txhdk4oIwo2YK566yOte2Z6MQksh
|
|
|
134
134
|
oldaplib/test/test_oldaplistnode.py,sha256=bWoCmDmHvOnNNviSCvhWo7LA2CskA_5IRDxNUufTKj4,149434
|
|
135
135
|
oldaplib/test/test_permissionset.py,sha256=YOCirqm_oFE1Emz9fYsnDeawwI6zHN9xBv9vOZnKst0,23368
|
|
136
136
|
oldaplib/test/test_project.py,sha256=fwkfaCxEskd27xinxDDr74dMWs7S0YcGr84mUOw20x4,25290
|
|
137
|
-
oldaplib/test/test_propertyclass.py,sha256=
|
|
137
|
+
oldaplib/test/test_propertyclass.py,sha256=pOXTnJphYU3stlqXgGJK5Z3mUJ26C27X_FRc00Aj4qY,56310
|
|
138
138
|
oldaplib/test/test_resourceclass.py,sha256=WQGyns2S8O6vDH8oXBQjcww_VcjIONovuNdKm0coO-c,96621
|
|
139
139
|
oldaplib/test/test_semantic_version.py,sha256=OSJYHWDpKBqk-HsxJ2nFpSr14a4OEZTFCogzEni8mcE,3392
|
|
140
140
|
oldaplib/test/test_user.py,sha256=gLTcQ0ymi9pYPPpq9BOY_3YS07EJXtnJKFCHe4Rj0mQ,72133
|
|
@@ -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.15.dist-info/METADATA,sha256=XhFAj7WMCjQDXGb-d-a1l2oWZNqu5TX49cn_fHW1ZAI,3061
|
|
162
|
+
oldaplib-0.3.15.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
163
|
+
oldaplib-0.3.15.dist-info/RECORD,,
|
|
File without changes
|