oldaplib 0.3.6__py3-none-any.whl → 0.3.7__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/src/objectfactory.py +41 -10
- oldaplib/src/version.py +1 -1
- oldaplib/test/test_objectfactory.py +14 -0
- {oldaplib-0.3.6.dist-info → oldaplib-0.3.7.dist-info}/METADATA +1 -1
- {oldaplib-0.3.6.dist-info → oldaplib-0.3.7.dist-info}/RECORD +6 -6
- {oldaplib-0.3.6.dist-info → oldaplib-0.3.7.dist-info}/WHEEL +0 -0
oldaplib/src/objectfactory.py
CHANGED
|
@@ -508,11 +508,6 @@ class ResourceInstance:
|
|
|
508
508
|
sparql = context.sparql_context
|
|
509
509
|
sparql += f'''
|
|
510
510
|
SELECT ?predicate ?value
|
|
511
|
-
FROM oldap:onto
|
|
512
|
-
FROM shared:onto
|
|
513
|
-
FROM {graph}:onto
|
|
514
|
-
FROM NAMED oldap:admin
|
|
515
|
-
FROM NAMED {graph}:data
|
|
516
511
|
WHERE {{
|
|
517
512
|
BIND({iri.toRdf} as ?iri)
|
|
518
513
|
GRAPH {graph}:data {{
|
|
@@ -791,6 +786,47 @@ class ResourceInstanceFactory:
|
|
|
791
786
|
'properties': resclass.properties,
|
|
792
787
|
'superclass': resclass.superclass})
|
|
793
788
|
|
|
789
|
+
@staticmethod
|
|
790
|
+
def read_data(con: IConnection, projectShortName: Xsd_NCName | str, iri: Iri | str) -> dict[Xsd_QName, Any]:
|
|
791
|
+
if not isinstance(iri, Iri):
|
|
792
|
+
iri = Iri(iri, validate=True)
|
|
793
|
+
if not isinstance(projectShortName, Xsd_NCName):
|
|
794
|
+
graph = Xsd_NCName(projectShortName)
|
|
795
|
+
else:
|
|
796
|
+
graph = projectShortName
|
|
797
|
+
|
|
798
|
+
context = Context(name=con.context_name)
|
|
799
|
+
sparql = context.sparql_context
|
|
800
|
+
sparql += f'''
|
|
801
|
+
SELECT ?predicate ?value
|
|
802
|
+
WHERE {{
|
|
803
|
+
GRAPH {graph}:data {{
|
|
804
|
+
{iri.toRdf} ?predicate ?value .
|
|
805
|
+
{iri.toRdf} oldap:grantsPermission ?permset .
|
|
806
|
+
}}
|
|
807
|
+
GRAPH oldap:admin {{
|
|
808
|
+
{con.userIri.toRdf} oldap:hasPermissions ?permset .
|
|
809
|
+
?permset oldap:givesPermission ?DataPermission .
|
|
810
|
+
?DataPermission oldap:permissionValue ?permval .
|
|
811
|
+
}}
|
|
812
|
+
FILTER(?permval >= {DataPermission.DATA_VIEW.numeric.toRdf})
|
|
813
|
+
}}
|
|
814
|
+
'''
|
|
815
|
+
jsonres = con.query(sparql)
|
|
816
|
+
res = QueryProcessor(context, jsonres)
|
|
817
|
+
data = {}
|
|
818
|
+
for r in res:
|
|
819
|
+
if r['predicate'].is_qname:
|
|
820
|
+
if not data.get(r['predicate'].as_qname):
|
|
821
|
+
data[r['predicate'].as_qname] = []
|
|
822
|
+
data[str(r['predicate'].as_qname)].append(str(r['value']))
|
|
823
|
+
else:
|
|
824
|
+
raise OldapErrorInconsistency(f"Expected QName as predicate, got {r['predicate']}")
|
|
825
|
+
if not data.get('rdf:type'):
|
|
826
|
+
raise OldapErrorNotFound(f'Resource with iri <{iri}> not found.')
|
|
827
|
+
return data
|
|
828
|
+
|
|
829
|
+
|
|
794
830
|
def read(self, iri: Iri | str) -> ResourceInstance:
|
|
795
831
|
if not isinstance(iri, Iri):
|
|
796
832
|
iri = Iri(iri, validate=True)
|
|
@@ -799,11 +835,6 @@ class ResourceInstanceFactory:
|
|
|
799
835
|
sparql = context.sparql_context
|
|
800
836
|
sparql += f'''
|
|
801
837
|
SELECT ?predicate ?value
|
|
802
|
-
FROM oldap:onto
|
|
803
|
-
FROM shared:onto
|
|
804
|
-
FROM {graph}:onto
|
|
805
|
-
FROM NAMED oldap:admin
|
|
806
|
-
FROM NAMED {graph}:data
|
|
807
838
|
WHERE {{
|
|
808
839
|
BIND({iri.toRdf} as ?iri)
|
|
809
840
|
GRAPH {graph}:data {{
|
oldaplib/src/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.7"
|
|
@@ -350,6 +350,19 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
350
350
|
mycat.create()
|
|
351
351
|
|
|
352
352
|
def test_read_A(self):
|
|
353
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
354
|
+
Book = factory.createObjectInstance('Book')
|
|
355
|
+
b = Book(title="The Life and Times of Scrooge",
|
|
356
|
+
author="test:TuomasHolopainen",
|
|
357
|
+
pubDate="2001-01-01",
|
|
358
|
+
grantsPermission=Iri('oldap:GenericView'))
|
|
359
|
+
b.create()
|
|
360
|
+
data = factory.read_data(con=self._connection, iri=b.iri, projectShortName='test')
|
|
361
|
+
self.assertEqual(data['rdf:type'], ['test:Book'])
|
|
362
|
+
self.assertEqual(data['test:title'], ['The Life and Times of Scrooge'])
|
|
363
|
+
self.assertEqual(data['test:author'], ['test:TuomasHolopainen'])
|
|
364
|
+
|
|
365
|
+
def test_read_B(self):
|
|
353
366
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
354
367
|
Book = factory.createObjectInstance('Book')
|
|
355
368
|
b = Book(title="The Life and Times of Scrooge",
|
|
@@ -366,6 +379,7 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
366
379
|
self.assertEqual(jsonobj['test:pubDate'], ['2001-01-01'])
|
|
367
380
|
self.assertEqual(jsonobj['test:title'], ['The Life and Times of Scrooge'])
|
|
368
381
|
|
|
382
|
+
|
|
369
383
|
def test_value_setter(self):
|
|
370
384
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
371
385
|
SetterTester = factory.createObjectInstance('SetterTester')
|
|
@@ -59,7 +59,7 @@ 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=kUdrwa0BBco-HWWQbG3_Tpkwar6GLbdNfkcWbvze30M,19218
|
|
62
|
-
oldaplib/src/objectfactory.py,sha256=
|
|
62
|
+
oldaplib/src/objectfactory.py,sha256=a2afDGUlh52xGaP5V2Po9Sr6om4DXiRdhsJ0IT9IPjA,46502
|
|
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
|
|
@@ -70,7 +70,7 @@ oldaplib/src/propertyclass.py,sha256=pnaDsmyGKQnJaaOHXA0XyLcp4zn1b1vC9sLbjXls4lM
|
|
|
70
70
|
oldaplib/src/resourceclass.py,sha256=EIxyd7Z_w59wDxWLXCaLvhhvh5SjLEUWb8gqmZz8LLM,102046
|
|
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=Jl3PXrkK7-Eox4dKIMxhOA7uVtSB0CC7qOf4NAQqa_s,21
|
|
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=gMhZ18jeuM5lv_zeamDKhk9xoPrVi_uXyOaYjuS4Tgg,31943
|
|
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
|
|
@@ -157,6 +157,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
|
|
|
157
157
|
oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
|
|
158
158
|
oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
|
|
159
159
|
oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
|
|
160
|
-
oldaplib-0.3.
|
|
161
|
-
oldaplib-0.3.
|
|
162
|
-
oldaplib-0.3.
|
|
160
|
+
oldaplib-0.3.7.dist-info/METADATA,sha256=sTq_7C3AnzAxZj55_5f1XmG1_70eXUeJQKhKm4gnglY,2854
|
|
161
|
+
oldaplib-0.3.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
162
|
+
oldaplib-0.3.7.dist-info/RECORD,,
|
|
File without changes
|