oldaplib 0.4.1__py3-none-any.whl → 0.4.3__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/standard/dcterms.ttl +868 -0
- oldaplib/ontologies/standard/schemaorg.ttl +20715 -0
- oldaplib/ontologies/standard/skos.ttl +288 -0
- oldaplib/ontologies/standard/skos.xml +468 -0
- oldaplib/src/connection.py +2 -0
- oldaplib/src/enums/XXXeditor.py +78 -0
- oldaplib/src/enums/attributeclass.py +18 -1
- oldaplib/src/enums/haspropertyattr.py +5 -3
- oldaplib/src/enums/projectattr.py +2 -0
- oldaplib/src/hasproperty.py +13 -9
- oldaplib/src/helpers/context.py +2 -0
- oldaplib/src/helpers/langstring.py +7 -0
- oldaplib/src/helpers/serializer.py +4 -3
- oldaplib/src/model.py +2 -1
- oldaplib/src/objectfactory.py +3 -6
- oldaplib/src/propertyclass.py +9 -2
- oldaplib/src/resourceclass.py +7 -4
- oldaplib/src/version.py +1 -1
- oldaplib/test/test_context.py +2 -0
- oldaplib/test/test_datamodel.py +23 -1
- oldaplib/test/test_hasproperty.py +64 -21
- oldaplib/test/test_objectfactory.py +147 -1
- oldaplib/test/xxxx_fasnacht.py +32 -0
- {oldaplib-0.4.1.dist-info → oldaplib-0.4.3.dist-info}/METADATA +5 -4
- {oldaplib-0.4.1.dist-info → oldaplib-0.4.3.dist-info}/RECORD +26 -21
- oldaplib/test/XXX_test_fasnacht.py +0 -17
- {oldaplib-0.4.1.dist-info → oldaplib-0.4.3.dist-info}/WHEEL +0 -0
oldaplib/src/hasproperty.py
CHANGED
|
@@ -206,7 +206,8 @@ class HasProperty(Model, Notify):
|
|
|
206
206
|
return HasPropertyData(minCount=self._attributes.get(HasPropertyAttr.MIN_COUNT, None),
|
|
207
207
|
maxCount=self._attributes.get(HasPropertyAttr.MAX_COUNT, None),
|
|
208
208
|
order=self._attributes.get(HasPropertyAttr.ORDER, None),
|
|
209
|
-
group=self._attributes.get(HasPropertyAttr.GROUP, None)
|
|
209
|
+
group=self._attributes.get(HasPropertyAttr.GROUP, None),
|
|
210
|
+
editor=self._attributes.get(HasPropertyAttr.EDITOR, None))
|
|
210
211
|
|
|
211
212
|
def clear_changeset(self) -> None:
|
|
212
213
|
if hasattr(self._prop, 'clear_changeset'):
|
|
@@ -225,14 +226,17 @@ class HasProperty(Model, Notify):
|
|
|
225
226
|
def create_shacl(self, indent: int = 0, indent_inc: int = 4) -> str:
|
|
226
227
|
blank = ''
|
|
227
228
|
sparql = ''
|
|
228
|
-
|
|
229
|
-
sparql += f' ;\n{blank:{indent * indent_inc}}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
229
|
+
for attr, val in self._attributes.items():
|
|
230
|
+
sparql += f' ;\n{blank:{indent * indent_inc}}{attr.value} {val.toRdf} ;\n'
|
|
231
|
+
|
|
232
|
+
# if self._attributes.get(HasPropertyAttr.MIN_COUNT, None) is not None:
|
|
233
|
+
# sparql += f' ;\n{blank:{indent * indent_inc}}sh:minCount {self._attributes[HasPropertyAttr.MIN_COUNT].toRdf}'
|
|
234
|
+
# if self._attributes.get(HasPropertyAttr.MAX_COUNT, None) is not None:
|
|
235
|
+
# sparql += f' ;\n{blank:{indent * indent_inc}}sh:maxCount {self._attributes[HasPropertyAttr.MAX_COUNT].toRdf}'
|
|
236
|
+
# if self._attributes.get(HasPropertyAttr.ORDER, None) is not None:
|
|
237
|
+
# sparql += f' ;\n{blank:{indent * indent_inc}}sh:order {self._attributes[HasPropertyAttr.ORDER].toRdf}'
|
|
238
|
+
# if self._attributes.get(HasPropertyAttr.GROUP, None) is not None:
|
|
239
|
+
# sparql += f' ;\n{blank:{indent * indent_inc}}sh:group {self._attributes[HasPropertyAttr.GROUP].toRdf}'
|
|
236
240
|
return sparql
|
|
237
241
|
|
|
238
242
|
def create_owl(self, indent: int = 0, indent_inc: int = 4) -> str:
|
oldaplib/src/helpers/context.py
CHANGED
|
@@ -49,6 +49,7 @@ class ContextSingleton(type):
|
|
|
49
49
|
#Xsd_NCName('dc'): NamespaceIRI('http://purl.org/dc/elements/1.1/'),
|
|
50
50
|
Xsd_NCName('dcterms'): NamespaceIRI('http://purl.org/dc/terms/'),
|
|
51
51
|
Xsd_NCName('dcmitype'): NamespaceIRI('http://purl.org/dc/dcmitype/'),
|
|
52
|
+
Xsd_NCName('dash'): NamespaceIRI('http://datashapes.org/dash#'),
|
|
52
53
|
#Xsd_NCName('foaf'): NamespaceIRI('http://xmlns.com/foaf/0.1/'),
|
|
53
54
|
Xsd_NCName('oldap'): NamespaceIRI('http://oldap.org/base#'),
|
|
54
55
|
Xsd_NCName('shared'): NamespaceIRI('http://oldap.org/shared#')
|
|
@@ -65,6 +66,7 @@ class ContextSingleton(type):
|
|
|
65
66
|
#NamespaceIRI('http://purl.org/dc/elements/1.1/'): Xsd_NCName('dc'),
|
|
66
67
|
NamespaceIRI('http://purl.org/dc/terms/'): Xsd_NCName('dcterms'),
|
|
67
68
|
NamespaceIRI('http://purl.org/dc/dcmitype/'): Xsd_NCName('dcmitype'),
|
|
69
|
+
NamespaceIRI('http://datashapes.org/dash#'): Xsd_NCName('dash'),
|
|
68
70
|
#NamespaceIRI('http://xmlns.com/foaf/0.1/'): Xsd_NCName('foaf'),
|
|
69
71
|
NamespaceIRI('http://oldap.org/base#'): Xsd_NCName('oldap'),
|
|
70
72
|
NamespaceIRI('http://oldap.org/shared#'): Xsd_NCName('shared'),
|
|
@@ -418,6 +418,13 @@ class LangString(Notify):
|
|
|
418
418
|
f'LangString parameter has wrong datatype: {type(langstring).__name__}, must be "str | Xsd_string | List[str] | Dict[Language | str, str] | LangString"')
|
|
419
419
|
self.notify()
|
|
420
420
|
|
|
421
|
+
def remove(self, lang: Language | str):
|
|
422
|
+
self.__delitem__(lang)
|
|
423
|
+
|
|
424
|
+
def discard(self, lang: Language | str):
|
|
425
|
+
if self.get(lang) is not None:
|
|
426
|
+
self.__delitem__(lang)
|
|
427
|
+
|
|
421
428
|
def undo(self) -> None:
|
|
422
429
|
"""
|
|
423
430
|
Undo all changes made since last update/creation/read
|
|
@@ -53,8 +53,8 @@ class _Serializer:
|
|
|
53
53
|
if isinstance(obj, UUID):
|
|
54
54
|
return {self._key: 'UUID', '__value__': str(obj)}
|
|
55
55
|
if isinstance(obj, Enum):
|
|
56
|
-
if hasattr(obj, '_value'):
|
|
57
|
-
# It's a "complex" enum
|
|
56
|
+
if hasattr(obj, '_value') and hasattr(obj, 'numeric'):
|
|
57
|
+
# It's a "complex" enum like DataPermission
|
|
58
58
|
return {self._key: obj.__class__.__name__, '__value__': [obj.value, obj.numeric]}
|
|
59
59
|
else:
|
|
60
60
|
return {self._key: obj.__class__.__name__, '__value__': obj.value}
|
|
@@ -95,7 +95,8 @@ class _Serializer:
|
|
|
95
95
|
# for bytes datatype
|
|
96
96
|
#
|
|
97
97
|
return b85decode(d['__value__'].encode(encoding='UTF-8'))
|
|
98
|
-
if type(self._classes[classname]) == type(Enum):
|
|
98
|
+
#if type(self._classes[classname]) == type(Enum):
|
|
99
|
+
if isinstance(self._classes[classname], type) and issubclass(self._classes[classname], Enum):
|
|
99
100
|
#
|
|
100
101
|
# for Enums and subclasses
|
|
101
102
|
#
|
oldaplib/src/model.py
CHANGED
|
@@ -218,7 +218,8 @@ class Model:
|
|
|
218
218
|
if self._changeset.get(attr) is None:
|
|
219
219
|
self._changeset[attr] = AttributeChange(deepcopy(self._attributes[attr]), Action.REPLACE)
|
|
220
220
|
if value is None:
|
|
221
|
-
|
|
221
|
+
if self._attributes.get(attr) is not None:
|
|
222
|
+
del self._attributes[attr]
|
|
222
223
|
else:
|
|
223
224
|
if not isinstance(value, attr.datatype):
|
|
224
225
|
self._attributes[attr] = attr.datatype(value, validate=True)
|
oldaplib/src/objectfactory.py
CHANGED
|
@@ -212,16 +212,13 @@ class ResourceInstance:
|
|
|
212
212
|
self.clear_changeset()
|
|
213
213
|
|
|
214
214
|
def __setitem__(self, key: Xsd_QName, value: ValueType | Xsd | None):
|
|
215
|
-
|
|
216
|
-
self.__set_value(value, key)
|
|
217
|
-
else:
|
|
218
|
-
raise OldapErrorValue(f'{self.name}: Property {key} does not exist.')
|
|
215
|
+
self.__set_value(value, key)
|
|
219
216
|
|
|
220
217
|
def __getitem__(self, key: Xsd_QName) -> ValueType | Xsd | None:
|
|
221
218
|
if self._values.get(key):
|
|
222
219
|
return self.__get_value(key)
|
|
223
220
|
else:
|
|
224
|
-
raise OldapErrorValue(f'{self.name}: Property {key} does not exist.')
|
|
221
|
+
raise OldapErrorValue(f'{self.name}: __getitem__: Property {key} does not exist.')
|
|
225
222
|
|
|
226
223
|
def __delitem__(self, key: Xsd_QName):
|
|
227
224
|
if self._values.get(key):
|
|
@@ -465,7 +462,7 @@ class ResourceInstance:
|
|
|
465
462
|
self.validate_value(value, hasprop.prop)
|
|
466
463
|
else:
|
|
467
464
|
if isinstance(value, (list, tuple, set, ObservableSet)):
|
|
468
|
-
for val in
|
|
465
|
+
for val in value:
|
|
469
466
|
self.validate_value(val, hasprop.prop)
|
|
470
467
|
else:
|
|
471
468
|
self.validate_value(value, hasprop.prop)
|
oldaplib/src/propertyclass.py
CHANGED
|
@@ -71,6 +71,7 @@ class HasPropertyData:
|
|
|
71
71
|
maxCount: Xsd_integer | None = None
|
|
72
72
|
order: Xsd_decimal | None = None
|
|
73
73
|
group: Xsd_QName | None = None
|
|
74
|
+
editor: Xsd_QName | None = None
|
|
74
75
|
|
|
75
76
|
def create_shacl(self, indent: int = 0, indent_inc: int = 4):
|
|
76
77
|
blank = ''
|
|
@@ -83,6 +84,8 @@ class HasPropertyData:
|
|
|
83
84
|
sparql += f' ;\n{blank:{indent * indent_inc}}sh:order {self.order.toRdf}'
|
|
84
85
|
if self.group is not None:
|
|
85
86
|
sparql += f' ;\n{blank:{indent * indent_inc}}sh:group {self.group.toRdf}'
|
|
87
|
+
if self.editor is not None:
|
|
88
|
+
sparql += f' ;\n{blank:{indent * indent_inc}}dash:editor {self.editor.toRdf}'
|
|
86
89
|
return sparql
|
|
87
90
|
|
|
88
91
|
def create_owl(self, indent: int = 0, indent_inc: int = 4):
|
|
@@ -800,6 +803,7 @@ class PropertyClass(Model, Notify):
|
|
|
800
803
|
maxCount: Xsd_integer | None = None
|
|
801
804
|
order: Xsd_decimal | None = None
|
|
802
805
|
group: Xsd_QName | None = None
|
|
806
|
+
editor: Xsd_QName | None = None
|
|
803
807
|
nodeKind: Xsd_QName | None = None
|
|
804
808
|
propkeys = {Xsd_QName(x.value) for x in PropClassAttr}
|
|
805
809
|
for key, val in attributes.items():
|
|
@@ -863,6 +867,8 @@ class PropertyClass(Model, Notify):
|
|
|
863
867
|
order = val
|
|
864
868
|
elif key == 'sh:group':
|
|
865
869
|
group = val
|
|
870
|
+
elif key == 'dash:editor':
|
|
871
|
+
editor = val
|
|
866
872
|
elif key in propkeys:
|
|
867
873
|
attr = PropClassAttr.from_value(key)
|
|
868
874
|
if not attr.in_shacl:
|
|
@@ -879,7 +885,8 @@ class PropertyClass(Model, Notify):
|
|
|
879
885
|
minCount=minCount,
|
|
880
886
|
maxCount=maxCount,
|
|
881
887
|
order=order,
|
|
882
|
-
group=group
|
|
888
|
+
group=group,
|
|
889
|
+
editor=editor)
|
|
883
890
|
|
|
884
891
|
if self._attributes.get(PropClassAttr.CLASS) is not None:
|
|
885
892
|
self._attributes[PropClassAttr.TYPE].add(OwlPropertyType.OwlObjectProperty)
|
|
@@ -897,7 +904,7 @@ class PropertyClass(Model, Notify):
|
|
|
897
904
|
self.update_notifier()
|
|
898
905
|
|
|
899
906
|
self.__from_triplestore = True
|
|
900
|
-
return HasPropertyData(refprop, minCount, maxCount, order, group)
|
|
907
|
+
return HasPropertyData(refprop, minCount, maxCount, order, group, editor)
|
|
901
908
|
|
|
902
909
|
def read_owl(self) -> None:
|
|
903
910
|
if self._externalOntology:
|
oldaplib/src/resourceclass.py
CHANGED
|
@@ -942,7 +942,8 @@ class ResourceClass(Model, Notify):
|
|
|
942
942
|
minCount=attributes.get(Xsd_QName('sh:minCount')),
|
|
943
943
|
maxCount=attributes.get(Xsd_QName('sh:maxCount')),
|
|
944
944
|
order=attributes.get(Xsd_QName('sh:order')),
|
|
945
|
-
group=attributes.get(Xsd_QName('sh:group'))
|
|
945
|
+
group=attributes.get(Xsd_QName('sh:group')),
|
|
946
|
+
editor=attributes.get(Xsd_QName('dash:editor'))))
|
|
946
947
|
else:
|
|
947
948
|
prop = PropertyClass(con=con, project=project)
|
|
948
949
|
haspropdata = prop.parse_shacl(attributes=attributes)
|
|
@@ -957,7 +958,8 @@ class ResourceClass(Model, Notify):
|
|
|
957
958
|
minCount=haspropdata.minCount,
|
|
958
959
|
maxCount=haspropdata.maxCount,
|
|
959
960
|
order=haspropdata.order,
|
|
960
|
-
group=haspropdata.group
|
|
961
|
+
group=haspropdata.group,
|
|
962
|
+
editor=haspropdata.editor))
|
|
961
963
|
else:
|
|
962
964
|
#
|
|
963
965
|
# Case C, external property
|
|
@@ -971,7 +973,8 @@ class ResourceClass(Model, Notify):
|
|
|
971
973
|
minCount=haspropdata.minCount,
|
|
972
974
|
maxCount=haspropdata.maxCount,
|
|
973
975
|
order=haspropdata.order,
|
|
974
|
-
group=haspropdata.group
|
|
976
|
+
group=haspropdata.group,
|
|
977
|
+
editor=haspropdata.editor))
|
|
975
978
|
return proplist
|
|
976
979
|
|
|
977
980
|
def __read_owl(self) -> None:
|
|
@@ -1178,7 +1181,7 @@ class ResourceClass(Model, Notify):
|
|
|
1178
1181
|
|
|
1179
1182
|
for iri, hp in self._properties.items():
|
|
1180
1183
|
if hp.type == PropType.STANDALONE:
|
|
1181
|
-
if hp.minCount or hp.maxCount or hp.order or hp.group:
|
|
1184
|
+
if hp.minCount or hp.maxCount or hp.order or hp.group or hp.editor:
|
|
1182
1185
|
sparql += f' ;\n{blank:{(indent + 2) * indent_inc}}sh:property {iri}Shape, ['
|
|
1183
1186
|
sparql += f'\n{blank:{(indent + 3) * indent_inc}}sh:path {iri.toRdf}'
|
|
1184
1187
|
sparql += hp.create_shacl(indent=2)
|
oldaplib/src/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.4.
|
|
1
|
+
__version__ = "0.4.3"
|
oldaplib/test/test_context.py
CHANGED
|
@@ -80,6 +80,7 @@ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
|
80
80
|
PREFIX schema: <http://schema.org/>
|
|
81
81
|
PREFIX dcterms: <http://purl.org/dc/terms/>
|
|
82
82
|
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
|
|
83
|
+
PREFIX dash: <http://datashapes.org/dash#>
|
|
83
84
|
PREFIX oldap: <http://oldap.org/base#>
|
|
84
85
|
PREFIX shared: <http://oldap.org/shared#>
|
|
85
86
|
PREFIX test: <http://www.test.org/gaga#>
|
|
@@ -99,6 +100,7 @@ PREFIX test: <http://www.test.org/gaga#>
|
|
|
99
100
|
@prefix schema: <http://schema.org/> .
|
|
100
101
|
@prefix dcterms: <http://purl.org/dc/terms/> .
|
|
101
102
|
@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
|
|
103
|
+
@prefix dash: <http://datashapes.org/dash#> .
|
|
102
104
|
@prefix oldap: <http://oldap.org/base#> .
|
|
103
105
|
@prefix shared: <http://oldap.org/shared#> .
|
|
104
106
|
@prefix test: <http://www.test.org/gaga#> .
|
oldaplib/test/test_datamodel.py
CHANGED
|
@@ -1105,7 +1105,7 @@ class TestDataModel(unittest.TestCase):
|
|
|
1105
1105
|
resclasses=[page, book, person])
|
|
1106
1106
|
dm.write_as_trig('gaga.trig')
|
|
1107
1107
|
|
|
1108
|
-
unittest.skip('Only during development....')
|
|
1108
|
+
@unittest.skip('Only during development....')
|
|
1109
1109
|
def test_cache(self):
|
|
1110
1110
|
project_root = find_project_root(__file__)
|
|
1111
1111
|
self._connection.clear_graph(Xsd_QName('test:shacl'))
|
|
@@ -1123,3 +1123,25 @@ class TestDataModel(unittest.TestCase):
|
|
|
1123
1123
|
|
|
1124
1124
|
pass
|
|
1125
1125
|
|
|
1126
|
+
@unittest.skip('Only during development....')
|
|
1127
|
+
def test_datamodel_read_fasnacht(self):
|
|
1128
|
+
connection = Connection(userId="rosenth",
|
|
1129
|
+
credentials="RioGrande",
|
|
1130
|
+
context_name="DEFAULT")
|
|
1131
|
+
|
|
1132
|
+
fasnacht = Project.read(connection, "fasnacht")
|
|
1133
|
+
|
|
1134
|
+
model = DataModel.read(connection, fasnacht, ignore_cache=True)
|
|
1135
|
+
print(model)
|
|
1136
|
+
|
|
1137
|
+
@unittest.skip('Only during development....')
|
|
1138
|
+
def test_datamodel_read_shared(self):
|
|
1139
|
+
connection = Connection(userId="rosenth",
|
|
1140
|
+
credentials="RioGrande",
|
|
1141
|
+
context_name="DEFAULT")
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
model = DataModel.read(connection, 'oldap')
|
|
1145
|
+
model = DataModel.read(connection, 'shared')
|
|
1146
|
+
print(model.get_propclasses())
|
|
1147
|
+
|
|
@@ -60,15 +60,28 @@ class TestHasProperty(unittest.TestCase):
|
|
|
60
60
|
#cls._connection.clear_graph(QName('test:onto'))
|
|
61
61
|
pass
|
|
62
62
|
|
|
63
|
-
def
|
|
63
|
+
def test_creation_A(self):
|
|
64
64
|
p1 = PropertyClass(con=self._connection,
|
|
65
65
|
project=self._project,
|
|
66
66
|
property_class_iri=Xsd_QName('test:hasprop_test_A'),
|
|
67
67
|
datatype=XsdDatatypes.string,
|
|
68
68
|
name=LangString(["HasPropTest A"]))
|
|
69
69
|
hasproperties: list[HasProperty] = [
|
|
70
|
-
HasProperty(con=self._connection,
|
|
71
|
-
|
|
70
|
+
HasProperty(con=self._connection,
|
|
71
|
+
project=self._project,
|
|
72
|
+
prop=p1,
|
|
73
|
+
minCount=1,
|
|
74
|
+
maxCount=1,
|
|
75
|
+
group=Xsd_QName('test:group'),
|
|
76
|
+
order=1,
|
|
77
|
+
editor=Xsd_QName("dash:TextAreaEditor")),
|
|
78
|
+
HasProperty(con=self._connection,
|
|
79
|
+
project=self._project,
|
|
80
|
+
prop=Xsd_QName("test:comment"),
|
|
81
|
+
maxCount=1,
|
|
82
|
+
group=Xsd_QName('test:group'),
|
|
83
|
+
order=2,
|
|
84
|
+
editor=Xsd_QName("dash:TextFieldEditor")),
|
|
72
85
|
]
|
|
73
86
|
r1 = ResourceClass(con=self._connection,
|
|
74
87
|
project=self._project,
|
|
@@ -87,21 +100,26 @@ class TestHasProperty(unittest.TestCase):
|
|
|
87
100
|
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].maxCount, Xsd_integer(1))
|
|
88
101
|
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].order, Xsd_decimal(1))
|
|
89
102
|
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].group, Xsd_QName('test:group'))
|
|
103
|
+
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].editor, Xsd_QName("dash:TextAreaEditor"))
|
|
90
104
|
|
|
91
105
|
self.assertIsNone(r1[Xsd_QName("test:comment")].minCount)
|
|
92
106
|
self.assertEqual(r1[Xsd_QName("test:comment")].maxCount, Xsd_integer(1))
|
|
93
107
|
self.assertEqual(r1[Xsd_QName("test:comment")].order, Xsd_decimal(2))
|
|
94
108
|
self.assertEqual(r1[Xsd_QName("test:comment")].group, Xsd_QName('test:group'))
|
|
109
|
+
self.assertEqual(r1[Xsd_QName('test:comment')].editor, Xsd_QName("dash:TextFieldEditor"))
|
|
95
110
|
|
|
96
|
-
def
|
|
111
|
+
def test_creation_B(self):
|
|
97
112
|
p1 = PropertyClass(con=self._connection,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
project=self._project,
|
|
114
|
+
property_class_iri=Xsd_QName('test:hasprop_test_B'),
|
|
115
|
+
datatype=XsdDatatypes.string,
|
|
116
|
+
name=LangString(["HasPropTest B"]))
|
|
102
117
|
hasproperties: list[HasProperty] = [
|
|
103
|
-
HasProperty(con=self._connection, project=self._project, prop=p1,
|
|
104
|
-
|
|
118
|
+
HasProperty(con=self._connection, project=self._project, prop=p1,
|
|
119
|
+
minCount=1, maxCount=1, group=Xsd_QName('test:group'),
|
|
120
|
+
order=1, editor=Xsd_QName("dash:TextAreaEditor")),
|
|
121
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"),
|
|
122
|
+
maxCount=1, group=Xsd_QName('test:group'), order=2, editor=Xsd_QName("dash:TextFieldEditor")),
|
|
105
123
|
]
|
|
106
124
|
r1 = ResourceClass(con=self._connection,
|
|
107
125
|
project=self._project,
|
|
@@ -119,10 +137,12 @@ class TestHasProperty(unittest.TestCase):
|
|
|
119
137
|
r1[Xsd_QName('test:hasprop_test_B')].maxCount = Xsd_integer(2)
|
|
120
138
|
r1[Xsd_QName('test:hasprop_test_B')].order = Xsd_decimal(2)
|
|
121
139
|
r1[Xsd_QName('test:hasprop_test_B')].group = Xsd_QName('test:groupB')
|
|
140
|
+
r1[Xsd_QName('test:hasprop_test_B')].editor = Xsd_QName("dash:TextFieldEditor")
|
|
122
141
|
|
|
123
142
|
r1[Xsd_QName('test:comment')].maxCount = Xsd_integer(2)
|
|
124
143
|
r1[Xsd_QName('test:comment')].order = Xsd_decimal(1)
|
|
125
144
|
r1[Xsd_QName('test:comment')].group = Xsd_QName('test:groupB')
|
|
145
|
+
r1[Xsd_QName('test:comment')].editor = Xsd_QName("dash:TextAreaEditor")
|
|
126
146
|
|
|
127
147
|
r1.update()
|
|
128
148
|
r1 = ResourceClass.read(con=self._connection,
|
|
@@ -131,10 +151,11 @@ class TestHasProperty(unittest.TestCase):
|
|
|
131
151
|
self.assertEqual(Xsd_integer(2), r1[Xsd_QName('test:hasprop_test_B')].maxCount)
|
|
132
152
|
self.assertEqual(Xsd_decimal(2), r1[Xsd_QName('test:hasprop_test_B')].order)
|
|
133
153
|
self.assertEqual(Xsd_QName('test:groupB'), r1[Xsd_QName('test:hasprop_test_B')].group)
|
|
154
|
+
self.assertEqual(Xsd_QName("dash:TextFieldEditor"), r1[Xsd_QName('test:hasprop_test_B')].editor)
|
|
134
155
|
|
|
135
156
|
self.assertEqual(Xsd_integer(2), r1[Xsd_QName('test:comment')].maxCount)
|
|
136
157
|
self.assertEqual(Xsd_decimal(1), r1[Xsd_QName('test:comment')].order)
|
|
137
|
-
self.assertEqual(Xsd_QName(
|
|
158
|
+
self.assertEqual(Xsd_QName("dash:TextAreaEditor"), r1[Xsd_QName('test:comment')].editor)
|
|
138
159
|
|
|
139
160
|
def test_modification_add(self):
|
|
140
161
|
p1 = PropertyClass(con=self._connection,
|
|
@@ -143,8 +164,17 @@ class TestHasProperty(unittest.TestCase):
|
|
|
143
164
|
datatype=XsdDatatypes.string,
|
|
144
165
|
name=LangString(["HasPropTest C"]))
|
|
145
166
|
hasproperties: list[HasProperty] = [
|
|
146
|
-
HasProperty(con=self._connection,
|
|
147
|
-
|
|
167
|
+
HasProperty(con=self._connection,
|
|
168
|
+
project=self._project,
|
|
169
|
+
prop=p1,
|
|
170
|
+
minCount=1,
|
|
171
|
+
order=1,
|
|
172
|
+
editor=Xsd_QName("dash:TextAreaEditor")),
|
|
173
|
+
HasProperty(con=self._connection,
|
|
174
|
+
project=self._project,
|
|
175
|
+
prop=Xsd_QName("test:comment"),
|
|
176
|
+
maxCount=1,
|
|
177
|
+
group=Xsd_QName('test:group')),
|
|
148
178
|
]
|
|
149
179
|
r1 = ResourceClass(con=self._connection,
|
|
150
180
|
project=self._project,
|
|
@@ -160,17 +190,22 @@ class TestHasProperty(unittest.TestCase):
|
|
|
160
190
|
project=self._project,
|
|
161
191
|
owl_class_iri=Xsd_QName("test:HasPropertyTest_C"))
|
|
162
192
|
r1[Xsd_QName('test:hasprop_test_C')].maxCount = Xsd_integer(10)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
193
|
+
r1[Xsd_QName('test:hasprop_test_C')].group = Xsd_QName('test:group')
|
|
194
|
+
r1[Xsd_QName('test:hasprop_test_C')].editor = None
|
|
195
|
+
r1[Xsd_QName("test:comment")].minCount = Xsd_integer(1)
|
|
196
|
+
r1[Xsd_QName("test:comment")].order = Xsd_decimal(1)
|
|
197
|
+
r1[Xsd_QName("test:comment")].editor = Xsd_QName("dash:TextFieldEditor")
|
|
198
|
+
|
|
166
199
|
r1.update()
|
|
167
200
|
r1 = ResourceClass.read(con=self._connection,
|
|
168
201
|
project=self._project,
|
|
169
202
|
owl_class_iri=Xsd_QName("test:HasPropertyTest_C"))
|
|
170
203
|
self.assertEqual(Xsd_integer(10), r1[Xsd_QName('test:hasprop_test_C')].maxCount)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
204
|
+
self.assertEqual(Xsd_QName('test:group'), r1[Xsd_QName('test:hasprop_test_C')].group)
|
|
205
|
+
self.assertIsNone(r1[Xsd_QName('test:hasprop_test_C')].editor)
|
|
206
|
+
self.assertEqual(Xsd_integer(1), r1[Xsd_QName("test:comment")].minCount)
|
|
207
|
+
self.assertEqual(Xsd_decimal(1), r1[Xsd_QName("test:comment")].order)
|
|
208
|
+
self.assertEqual(Xsd_QName("dash:TextFieldEditor"), r1[Xsd_QName("test:comment")].editor)
|
|
174
209
|
|
|
175
210
|
def test_modification_delete(self):
|
|
176
211
|
p1 = PropertyClass(con=self._connection,
|
|
@@ -179,8 +214,12 @@ class TestHasProperty(unittest.TestCase):
|
|
|
179
214
|
datatype=XsdDatatypes.string,
|
|
180
215
|
name=LangString(["HasPropTest D"]))
|
|
181
216
|
hasproperties: list[HasProperty] = [
|
|
182
|
-
HasProperty(con=self._connection, project=self._project, prop=p1,
|
|
183
|
-
|
|
217
|
+
HasProperty(con=self._connection, project=self._project, prop=p1,
|
|
218
|
+
minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1,
|
|
219
|
+
editor=Xsd_QName("dash:TextFieldEditor")),
|
|
220
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"),
|
|
221
|
+
maxCount=1, group=Xsd_QName('test:group'), order=2,
|
|
222
|
+
editor=Xsd_QName("dash:TextAreaEditor")),
|
|
184
223
|
]
|
|
185
224
|
r1 = ResourceClass(con=self._connection,
|
|
186
225
|
project=self._project,
|
|
@@ -197,9 +236,11 @@ class TestHasProperty(unittest.TestCase):
|
|
|
197
236
|
owl_class_iri=Xsd_QName("test:HasPropertyTest_D"))
|
|
198
237
|
del r1[Xsd_QName('test:hasprop_test_D')].maxCount
|
|
199
238
|
del r1[Xsd_QName('test:hasprop_test_D')].order
|
|
239
|
+
del r1[Xsd_QName('test:hasprop_test_D')].editor
|
|
200
240
|
del r1[Xsd_QName('test:comment')].maxCount
|
|
201
241
|
del r1[Xsd_QName('test:comment')].group
|
|
202
242
|
del r1[Xsd_QName('test:comment')].order
|
|
243
|
+
del r1[Xsd_QName('test:comment')].editor
|
|
203
244
|
r1.update()
|
|
204
245
|
|
|
205
246
|
r1 = ResourceClass.read(con=self._connection,
|
|
@@ -207,9 +248,11 @@ class TestHasProperty(unittest.TestCase):
|
|
|
207
248
|
owl_class_iri=Xsd_QName("test:HasPropertyTest_D"))
|
|
208
249
|
self.assertIsNone(r1[Xsd_QName('test:hasprop_test_D')].maxCount)
|
|
209
250
|
self.assertIsNone(r1[Xsd_QName('test:hasprop_test_D')].order)
|
|
251
|
+
self.assertIsNone(r1[Xsd_QName('test:hasprop_test_D')].editor)
|
|
210
252
|
self.assertIsNone(r1[Xsd_QName('test:comment')].maxCount)
|
|
211
253
|
self.assertIsNone(r1[Xsd_QName('test:comment')].group)
|
|
212
254
|
self.assertIsNone(r1[Xsd_QName('test:comment')].order)
|
|
255
|
+
self.assertIsNone(r1[Xsd_QName('test:comment')].editor)
|
|
213
256
|
|
|
214
257
|
|
|
215
258
|
|
|
@@ -18,7 +18,8 @@ from oldaplib.src.enums.language import Language
|
|
|
18
18
|
from oldaplib.src.helpers.attributechange import AttributeChange
|
|
19
19
|
from oldaplib.src.helpers.context import Context
|
|
20
20
|
from oldaplib.src.helpers.langstring import LangString
|
|
21
|
-
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorValue, OldapErrorNoPermission,
|
|
21
|
+
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorValue, OldapErrorNoPermission, \
|
|
22
|
+
OldapErrorInUse, OldapErrorKey
|
|
22
23
|
from oldaplib.src.role import Role
|
|
23
24
|
from oldaplib.src.project import Project
|
|
24
25
|
from oldaplib.src.user import User
|
|
@@ -480,6 +481,28 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
480
481
|
|
|
481
482
|
bb.delete()
|
|
482
483
|
|
|
484
|
+
def test_read_D(self):
|
|
485
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
486
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
487
|
+
b = SetterTester(stringSetter="This is a test string",
|
|
488
|
+
langStringSetter=["C'est un string de test@fr", "Dies ist eine Testzeichenkette@de"],
|
|
489
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
490
|
+
integerSetter={20200, 30300},
|
|
491
|
+
attachedToRole={Xsd_QName('oldap:Unknown'): DataPermission.DATA_VIEW})
|
|
492
|
+
b.create()
|
|
493
|
+
bb = SetterTester.read(con=self._connection, iri=b.iri)
|
|
494
|
+
self.assertEqual(bb.name, "test:SetterTester")
|
|
495
|
+
self.assertEqual(bb.stringSetter, {Xsd_string("This is a test string")})
|
|
496
|
+
print(type(bb.langStringSetter).__name__)
|
|
497
|
+
print(bb.langStringSetter)
|
|
498
|
+
# self.assertEqual(bb.author, {Iri("test:TuomasHolopainen")})
|
|
499
|
+
# jsonobj = bb.toJsonObject()
|
|
500
|
+
# self.assertEqual(jsonobj['test:author'], ['test:TuomasHolopainen'])
|
|
501
|
+
# self.assertEqual(jsonobj['test:pubDate'], ['2001-01-01'])
|
|
502
|
+
# self.assertEqual(jsonobj['test:title'], ['The Life and Times of Scrooge'])
|
|
503
|
+
|
|
504
|
+
bb.delete()
|
|
505
|
+
|
|
483
506
|
def test_value_setter(self):
|
|
484
507
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
485
508
|
SetterTester = factory.createObjectInstance('SetterTester')
|
|
@@ -591,6 +614,129 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
591
614
|
|
|
592
615
|
obj1.delete()
|
|
593
616
|
|
|
617
|
+
def test_value_modifier_C(self):
|
|
618
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
619
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
620
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
621
|
+
langStringSetter=LangString("C'est un teste@fr", "Dies ist eine Test-Zeichenkette@de"),
|
|
622
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
623
|
+
booleanSetter=True,
|
|
624
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
625
|
+
obj1.create()
|
|
626
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
627
|
+
obj1[Xsd_QName('test:integerSetter')] = [1]
|
|
628
|
+
obj1.update()
|
|
629
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
630
|
+
self.assertEqual(obj1.integerSetter, {Xsd_int(1)})
|
|
631
|
+
|
|
632
|
+
def test_value_modifier_add_lang(self):
|
|
633
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
634
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
635
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
636
|
+
langStringSetter=LangString("C'est un teste@fr"),
|
|
637
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
638
|
+
booleanSetter=True,
|
|
639
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
640
|
+
obj1.create()
|
|
641
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
642
|
+
obj1[Xsd_QName('test:langStringSetter')].add("Dies ist eine Test-Zeichenkette@de")
|
|
643
|
+
obj1.update()
|
|
644
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
645
|
+
self.assertEqual(obj1.langStringSetter, LangString("C'est un teste@fr", "Dies ist eine Test-Zeichenkette@de"))
|
|
646
|
+
|
|
647
|
+
def test_value_modifier_remove_lang_A(self):
|
|
648
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
649
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
650
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
651
|
+
langStringSetter=LangString("Waseliwas@de", "C'est un teste@fr"),
|
|
652
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
653
|
+
booleanSetter=True,
|
|
654
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
655
|
+
obj1.create()
|
|
656
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
657
|
+
del obj1[Xsd_QName('test:langStringSetter')]['de']
|
|
658
|
+
obj1.update()
|
|
659
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
660
|
+
self.assertEqual(obj1.langStringSetter, LangString("C'est un teste@fr"))
|
|
661
|
+
|
|
662
|
+
def test_value_modifier_remove_lang_B(self):
|
|
663
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
664
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
665
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
666
|
+
langStringSetter=LangString("Waseliwas@de", "C'est un teste@fr"),
|
|
667
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
668
|
+
booleanSetter=True,
|
|
669
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
670
|
+
obj1.create()
|
|
671
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
672
|
+
obj1[Xsd_QName('test:langStringSetter')].remove(Language.DE)
|
|
673
|
+
obj1.update()
|
|
674
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
675
|
+
self.assertEqual(obj1.langStringSetter, LangString("C'est un teste@fr"))
|
|
676
|
+
|
|
677
|
+
def test_value_modifier_remove_lang_D(self):
|
|
678
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
679
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
680
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
681
|
+
langStringSetter=LangString("Waseliwas@de", "C'est un teste@fr"),
|
|
682
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
683
|
+
booleanSetter=True,
|
|
684
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
685
|
+
obj1.create()
|
|
686
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
687
|
+
obj1[Xsd_QName('test:langStringSetter')].discard(Language.EN)
|
|
688
|
+
obj1.update()
|
|
689
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
690
|
+
self.assertEqual(obj1.langStringSetter, LangString("Waseliwas@de", "C'est un teste@fr"))
|
|
691
|
+
|
|
692
|
+
with self.assertRaises(OldapErrorKey):
|
|
693
|
+
obj1[Xsd_QName('test:langStringSetter')].remove(Language.EN)
|
|
694
|
+
|
|
695
|
+
def test_value_modifier_replace(self):
|
|
696
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
697
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
698
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
699
|
+
langStringSetter=LangString("C'est un teste@fr"),
|
|
700
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
701
|
+
booleanSetter=True,
|
|
702
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
703
|
+
obj1.create()
|
|
704
|
+
obj1[Xsd_QName('test:langStringSetter')] = LangString("FRANCAIS@fr", "DEUTSCH@de")
|
|
705
|
+
obj1.update()
|
|
706
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
707
|
+
self.assertEqual(obj1.langStringSetter, LangString("FRANCAIS@fr", "DEUTSCH@de"))
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def test_value_modifier_delete_A(self):
|
|
711
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
712
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
713
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
714
|
+
langStringSetter=LangString("C'est un teste@fr"),
|
|
715
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
716
|
+
booleanSetter=True,
|
|
717
|
+
integerSetter={20200, 30300},
|
|
718
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
719
|
+
obj1.create()
|
|
720
|
+
obj1[Xsd_QName('test:integerSetter')] = None
|
|
721
|
+
obj1.update()
|
|
722
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
723
|
+
self.assertIsNone(obj1.integerSetter)
|
|
724
|
+
|
|
725
|
+
def test_value_modifier_delete_B(self):
|
|
726
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
727
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
728
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
729
|
+
langStringSetter=LangString("C'est un teste@fr"),
|
|
730
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
731
|
+
booleanSetter=True,
|
|
732
|
+
integerSetter={20200, 30300},
|
|
733
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
734
|
+
obj1.create()
|
|
735
|
+
del obj1[Xsd_QName('test:integerSetter')]
|
|
736
|
+
obj1.update()
|
|
737
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
738
|
+
self.assertIsNone(obj1.integerSetter)
|
|
739
|
+
|
|
594
740
|
def test_value_maxcount_mincount(self):
|
|
595
741
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
596
742
|
Person = factory.createObjectInstance('Person')
|