oldaplib 0.4.0__py3-none-any.whl → 0.4.2__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.
@@ -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
- if self._attributes.get(HasPropertyAttr.MIN_COUNT, None) is not None:
229
- sparql += f' ;\n{blank:{indent * indent_inc}}sh:minCount {self._attributes[HasPropertyAttr.MIN_COUNT].toRdf}'
230
- if self._attributes.get(HasPropertyAttr.MAX_COUNT, None) is not None:
231
- sparql += f' ;\n{blank:{indent * indent_inc}}sh:maxCount {self._attributes[HasPropertyAttr.MAX_COUNT].toRdf}'
232
- if self._attributes.get(HasPropertyAttr.ORDER, None) is not None:
233
- sparql += f' ;\n{blank:{indent * indent_inc}}sh:order {self._attributes[HasPropertyAttr.ORDER].toRdf}'
234
- if self._attributes.get(HasPropertyAttr.GROUP, None) is not None:
235
- sparql += f' ;\n{blank:{indent * indent_inc}}sh:group {self._attributes[HasPropertyAttr.GROUP].toRdf}'
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:
@@ -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'),
@@ -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
- del self._attributes[attr]
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)
@@ -127,6 +127,7 @@ class ResourceInstance:
127
127
  # we have an attachedToRole property given in the constructor...
128
128
  #
129
129
  value = kwargs[str(prop_iri)] if kwargs.get(str(prop_iri)) else kwargs[prop_iri.fragment]
130
+ value = {Xsd_QName(role): dperm if isinstance(dperm, DataPermission) else DataPermission.from_string(dperm) for role, dperm in value.items()}
130
131
  if not isinstance(value, dict):
131
132
  raise OldapErrorValue(f'{self.name}: Property {prop_iri} with attachedToRole must be a dict')
132
133
  self._attached_roles = ObservableDict(value, on_change=self.__attachedToRole_cb)
@@ -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:
@@ -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/user.py CHANGED
@@ -892,49 +892,55 @@ class User(Model):
892
892
  # oldap:hasDefaultDataPermission has changed!
893
893
  #
894
894
  rdfstar = False
895
- sparql = f'{blank:{indent * indent_inc}}# RDF*Star <<.. oldap:hasRole ...>> oldap:hasDefaultDataPermission ...\n'
896
- sparql += f'{blank:{indent * indent_inc}}WITH oldap:admin\n'
895
+ sparql = ''
896
+ if removed or changed:
897
+ sparql += f'{blank:{indent * indent_inc}}# RDF*Star DELETE: <<.. oldap:hasRole ...>> oldap:hasDefaultDataPermission ...\n'
898
+ sparql += f'{blank:{indent * indent_inc}}DELETE DATA {{\n'
899
+ sparql += f'{blank:{(indent + 1) * indent_inc}}GRAPH oldap:admin {{\n'
900
+ rdfstar = True
897
901
  if removed:
898
902
  tmp = [role for role, dperm in removed.items() if dperm] # check if we have roles with dterm not None
899
903
  if tmp:
900
- sparql += f'{blank:{indent * indent_inc}}DELETE {{\n'
901
904
  for role, dperm in removed.items():
902
905
  if dperm:
903
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm} .\n'
904
- sparql += f'{blank:{indent * indent_inc}}}}\n'
905
- rdfstar = True
906
+ sparql += f'{blank:{(indent + 2) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm.toRdf} .\n'
906
907
  if changed: # remove RDF*Star triples of the roles that have changed
907
908
  tmp = [role for role, dperm in changed.items() if dperm['old']]
908
909
  if tmp:
909
- sparql += f'{blank:{indent * indent_inc}}DELETE {{\n'
910
910
  for role, changes in changed.items():
911
911
  if changes['old']:
912
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["old"]} .\n'
913
- sparql += f'{blank:{indent * indent_inc}}}}\n'
914
- rdfstar = True
912
+ sparql += f'{blank:{(indent + 1) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["old"].toRdf} .\n'
913
+
914
+ if rdfstar:
915
+ sparql += f'{blank:{(indent + 1) * indent_inc}}}}\n'
916
+ sparql += f'{blank:{indent * indent_inc}}}}\n'
917
+ if added or changed:
918
+ if rdfstar:
919
+ sparql += f'{blank:{indent * indent_inc}};\n'
920
+ sparql += f'{blank:{indent * indent_inc}}# RDF*Star INSERT: <<.. oldap:hasRole ...>> oldap:hasDefaultDataPermission ...\n'
921
+ sparql += f'{blank:{indent * indent_inc}}INSERT DATA {{\n'
922
+ sparql += f'{blank:{(indent + 1) * indent_inc}}GRAPH oldap:admin {{\n'
923
+ rdfstar = True
924
+ else:
925
+ rdfstar = False
915
926
  if added:
916
927
  tmp = [role for role, dperm in added.items() if dperm] # check if we have roles with dterm not None
917
928
  if tmp:
918
- sparql += f'{blank:{indent * indent_inc}}INSERT {{\n'
919
929
  for role, dperm in added.items():
920
930
  if dperm:
921
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm} .\n'
922
- sparql += f'{blank:{indent * indent_inc}}}}\n'
931
+ sparql += f'{blank:{(indent + 2) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm.toRdf} .\n'
923
932
  rdfstar = True
924
933
  if changed: # add the RDF*Star triples of the roles that have changed
925
934
  tmp = [role for role, dperm in changed.items() if dperm['new']]
926
935
  if tmp:
927
- sparql += f'{blank:{indent * indent_inc}}INSERT {{\n'
928
936
  for role, changes in changed.items():
929
937
  if changes['new']:
930
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["new"]} .\n'
931
- sparql += f'{blank:{indent * indent_inc}}}}\n'
938
+ sparql += f'{blank:{(indent + 1) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["new"].toRdf} .\n'
932
939
  rdfstar = True
933
- sparql += f'{blank:{indent * indent_inc}}WHERE {{\n'
934
- sparql += f'{blank:{(indent + 1) * indent_inc}}BIND({self.userIri.toRdf} as ?user)\n'
935
- sparql += f'{blank:{(indent + 1) * indent_inc}}?user a oldap:User .\n'
936
- sparql += f'{blank:{indent * indent_inc}}}}'
937
940
  if rdfstar:
941
+ sparql += f'{blank:{(indent + 1) * indent_inc}}}}\n'
942
+ sparql += f'{blank:{indent * indent_inc}}}}\n'
943
+ if sparql:
938
944
  sparql_list.append(sparql)
939
945
 
940
946
  #
@@ -1115,6 +1121,7 @@ class User(Model):
1115
1121
  self.set_modified_by_iri(Xsd_QName('oldap:admin'), self.userIri, self.modified, timestamp)
1116
1122
  modtime = self.get_modified_by_iri(Xsd_QName('oldap:admin'), self.userIri)
1117
1123
  except OldapError:
1124
+ print(sparql)
1118
1125
  self._con.transaction_abort()
1119
1126
  raise
1120
1127
  if timestamp != modtime:
oldaplib/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.0"
1
+ __version__ = "0.4.2"
@@ -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#> .
@@ -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 test_creation(self):
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, project=self._project, prop=p1, minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1),
71
- HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group'), order=2),
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 test_modification_replace(self):
111
+ def test_creation_B(self):
97
112
  p1 = PropertyClass(con=self._connection,
98
- project=self._project,
99
- property_class_iri=Xsd_QName('test:hasprop_test_B'),
100
- datatype=XsdDatatypes.string,
101
- name=LangString(["HasPropTest B"]))
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, minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1),
104
- HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group'), order=2),
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('test:groupB'), r1[Xsd_QName('test:comment')].group)
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, project=self._project, prop=p1, minCount=1, order=1),
147
- HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group')),
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
- #r1[Xsd_QName('test:hasprop_test_C')].group = Xsd_QName('test:group')
164
- #r1[Xsd_QName("test:comment")].minCount = Xsd_integer(1)
165
- #r1[Xsd_QName("test:comment")].order = Xsd_decimal(1)
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
- #self.assertEqual(Xsd_QName('test:group'), r1[Xsd_QName('test:hasprop_test_C')].group)
172
- #self.assertEqual(Xsd_integer(1), r1[Xsd_QName("test:comment")].minCount)
173
- #self.assertEqual(Xsd_decimal(1), r1[Xsd_QName("test:comment")].order)
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, minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1),
183
- HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group'), order=2),
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
 
@@ -480,6 +480,28 @@ class TestObjectFactory(unittest.TestCase):
480
480
 
481
481
  bb.delete()
482
482
 
483
+ def test_read_D(self):
484
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
485
+ SetterTester = factory.createObjectInstance('SetterTester')
486
+ b = SetterTester(stringSetter="This is a test string",
487
+ langStringSetter=["C'est un string de test@fr", "Dies ist eine Testzeichenkette@de"],
488
+ decimalSetter=Xsd_decimal(3.14),
489
+ integerSetter={20200, 30300},
490
+ attachedToRole={Xsd_QName('oldap:Unknown'): DataPermission.DATA_VIEW})
491
+ b.create()
492
+ bb = SetterTester.read(con=self._connection, iri=b.iri)
493
+ self.assertEqual(bb.name, "test:SetterTester")
494
+ self.assertEqual(bb.stringSetter, {Xsd_string("This is a test string")})
495
+ print(type(bb.langStringSetter).__name__)
496
+ print(bb.langStringSetter)
497
+ # self.assertEqual(bb.author, {Iri("test:TuomasHolopainen")})
498
+ # jsonobj = bb.toJsonObject()
499
+ # self.assertEqual(jsonobj['test:author'], ['test:TuomasHolopainen'])
500
+ # self.assertEqual(jsonobj['test:pubDate'], ['2001-01-01'])
501
+ # self.assertEqual(jsonobj['test:title'], ['The Life and Times of Scrooge'])
502
+
503
+ bb.delete()
504
+
483
505
  def test_value_setter(self):
484
506
  factory = ResourceInstanceFactory(con=self._connection, project='test')
485
507
  SetterTester = factory.createObjectInstance('SetterTester')
@@ -699,6 +699,7 @@ class TestUser(unittest.TestCase):
699
699
  AdminPermission.ADMIN_CREATE}},
700
700
  hasRole={Iri('oldap:Unknown'): DataPermission.DATA_RESTRICTED})
701
701
  user.create()
702
+
702
703
  user2 = User.read(con=self._connection, userId="edison", ignore_cache=True)
703
704
  user2.userId = "aedison"
704
705
  user2.familyName = "Edison et al."
@@ -0,0 +1,32 @@
1
+ from pprint import pprint
2
+
3
+ from oldaplib.src.connection import Connection
4
+ import unittest
5
+
6
+ from oldaplib.src.datamodel import DataModel
7
+ from oldaplib.src.project import Project
8
+
9
+ class TestDataModel(unittest.TestCase):
10
+
11
+ #@unittest.skip('Work in progress')
12
+ def test_fasnacht(self):
13
+ connection = Connection(userId="rosenth",
14
+ credentials="RioGrande",
15
+ context_name="DEFAULT")
16
+
17
+ dm = DataModel.read(connection, "fasnacht", ignore_cache=False)
18
+ pass
19
+
20
+ def test_datamodel_read_shared(self):
21
+ connection = Connection(userId="rosenth",
22
+ credentials="RioGrande",
23
+ context_name="DEFAULT")
24
+
25
+ model = DataModel.read(connection, 'shared')
26
+ pp = model.get_propclasses()
27
+ for p in pp:
28
+ print(model[p])
29
+ model = DataModel.read(connection, 'shared', ignore_cache=True)
30
+ pp = model.get_propclasses()
31
+ for p in pp:
32
+ print(model[p])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oldaplib
3
- Version: 0.4.0
3
+ Version: 0.4.2
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