oldaplib 0.3.14__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.
@@ -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
- EQUIVALEND_PROPERTY = ('owl:equivalentProperty', False, False, Xsd_QName, Target.OWL)
60
+ EQUIVALENT_PROPERTY = ('owl:equivalentProperty', False, False, Xsd_QName, Target.OWL)
61
61
 
62
62
 
63
63
  @classmethod
@@ -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),
@@ -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.14"
1
+ __version__ = "0.3.15"
@@ -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 test_propertyclass_inconsistent_constructor(self):
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:testprop5'),
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 test_propertyclass_invalid_constructor(self):
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",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: oldaplib
3
- Version: 0.3.14
3
+ Version: 0.3.15
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
@@ -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=92R_rVdG-xAWLsRqFknuyKIwLXI-g8gTszL_x9cGNVk,4263
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=VnjLa6VBIH---mwh1mJ_drisDqjPu7By1RhFAVZaT7k,15814
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
@@ -66,11 +66,11 @@ oldaplib/src/oldaplistnode.py,sha256=NnC2juEGTtEkDO6OlB9PjSw_zTF-wSsRUgEk-6VV9DA
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=WcRz-yzNOenyTWsYHkh48vaJDFO_0AgH9AMFq-HsiVo,93777
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=-T6106A_Mf7BT-0-rzDMc_1EaoZP74bXWfYSnwUgJCg,22
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
@@ -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=67Kw5cDlPzRNm20bqz1QB-8PXFpV5iQy8Jza1epLXxk,53293
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.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,,
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,,