oldaplib 0.3.28__tar.gz → 0.3.29__tar.gz
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-0.3.28 → oldaplib-0.3.29}/PKG-INFO +1 -1
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/objectfactory.py +126 -18
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/oldaplist_helpers.py +1 -1
- oldaplib-0.3.29/oldaplib/src/version.py +1 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_objectfactory.py +59 -3
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/instances_test.trig +14 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/pyproject.toml +1 -1
- oldaplib-0.3.28/oldaplib/src/version.py +0 -1
- {oldaplib-0.3.28 → oldaplib-0.3.29}/README.md +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/admin-testing.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/admin.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/example.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/oldap.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/oldap.ttl +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/shared.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/ontologies/standard/.gitsave +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/cachesingleton.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/connection.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/datamodel.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/dtypes/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/dtypes/bnode.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/dtypes/languagein.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/dtypes/namespaceiri.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/dtypes/rdfset.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/dtypes/xsdset.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/action.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/adminpermissions.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/attributeclass.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/datapermissions.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/externalontologyattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/haspropertyattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/language.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/oldaplistattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/oldaplistnodeattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/owlpropertytype.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/permissionsetattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/projectattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/propertyclassattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/resourceclassattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/sparql_result_format.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/userattr.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/enums/xsd_datatypes.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/externalontology.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/globalconfig.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/hasproperty.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/Notify.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/attributechange.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/context.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/convert2datatype.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/irincname.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/json_encoder.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/langstring.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/numeric.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/observable_dict.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/observable_set.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/oldaperror.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/query_processor.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/semantic_version.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/serializeableset.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/serializer.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/singletonmeta.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/helpers/tools.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/iconnection.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/in_project.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/model.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/oldaplist.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/oldaplistnode.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/oldaplogging.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/permissionset.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/project.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/propertyclass.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/resourceclass.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/user.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/userdataclass.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/floatingpoint.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/iri.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_anyuri.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_base64binary.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_boolean.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_byte.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_date.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_datetime.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_datetimestamp.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_decimal.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_double.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_duration.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_float.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_gday.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_gmonth.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_gmonthday.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_gyear.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_gyearmonth.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_hexbinary.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_id.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_idref.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_int.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_integer.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_language.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_long.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_name.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_ncname.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_negativeinteger.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_nmtoken.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_nonnegativeinteger.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_nonpositiveinteger.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_normalizedstring.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_positiveinteger.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_qname.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_short.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_string.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_time.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_token.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_unsignedbyte.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_unsignedint.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_unsignedlong.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/src/xsd/xsd_unsignedshort.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/XXX_test_fasnacht.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/__init__.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_cache.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_connection.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_context.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_datamodel.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_dtypes.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_externalontologies.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_hasproperty.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_in_project.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_langstring.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_language_in.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_observable_dict.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_observable_set.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_oldaplist.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_oldaplist_helpers.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_oldaplistnode.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_permissionset.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_project.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_propertyclass.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_resourceclass.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_semantic_version.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_user.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/test/test_xsd_datatypes.py +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/Gender.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/collections_type.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/connection_test.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/datamodel_test.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/event_type.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/hlist_schema.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/institution_or_building_type.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/language.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/location_type.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/means_of_transportation.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/objectfactory_test.trig +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/playground_list.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/role.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/source_type-1.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/source_type.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/test_move_left_of_toL.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testdata/testlist.yaml +0 -0
- {oldaplib-0.3.28 → oldaplib-0.3.29}/oldaplib/testit.http +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import jwt
|
|
3
|
+
|
|
4
|
+
from datetime import datetime, timedelta
|
|
2
5
|
from enum import Flag, auto
|
|
3
6
|
from functools import partial
|
|
4
7
|
from typing import Type, Any, Self, cast
|
|
@@ -1046,6 +1049,7 @@ class ResourceInstance:
|
|
|
1046
1049
|
limit: int = 100,
|
|
1047
1050
|
offset: int = 0,
|
|
1048
1051
|
indent: int = 0, indent_inc: int = 4) -> dict[Iri, dict[str, Xsd]]:
|
|
1052
|
+
# TODO: PROBLEM: does not work for properties which use MAX_COUNT > 1 !!!!!!!
|
|
1049
1053
|
"""
|
|
1050
1054
|
Retrieves all resources matching the specified parameters from a data store using a SPARQL query.
|
|
1051
1055
|
Depending on the `count_only` flag, it can return either a count of matching resources or detailed
|
|
@@ -1161,7 +1165,22 @@ class ResourceInstance:
|
|
|
1161
1165
|
return result
|
|
1162
1166
|
|
|
1163
1167
|
@staticmethod
|
|
1164
|
-
def get_media_object_by_id(con: IConnection, mediaObjectId: Xsd_string | str) -> dict[str, Xsd]
|
|
1168
|
+
def get_media_object_by_id(con: IConnection, mediaObjectId: Xsd_string | str) -> dict[str, Xsd]:
|
|
1169
|
+
"""
|
|
1170
|
+
Retrieves a media object by its ID from the system. This method queries a SPARQL endpoint
|
|
1171
|
+
to fetch details about the media object and constructs a resulting dictionary with the
|
|
1172
|
+
media object attributes and its associated metadata. Additionally, a signed JWT token
|
|
1173
|
+
is included in the result for security purposes.
|
|
1174
|
+
|
|
1175
|
+
:param con: A connection interface that provides access to the SPARQL endpoint and user context.
|
|
1176
|
+
:type con: IConnection
|
|
1177
|
+
:param mediaObjectId: The ID of the media object to be fetched, represented as an XSD string or a Python string.
|
|
1178
|
+
:type mediaObjectId: Xsd_string | str
|
|
1179
|
+
:return: A dictionary containing key-value pairs of media object attributes and metadata,
|
|
1180
|
+
with an additional JWT token for security. Returns None if the media object is not found.
|
|
1181
|
+
:rtype: dict[str, Xsd] | None
|
|
1182
|
+
:raises OldapErrorNotFound: Raised when the media object with the specified ID is not found.
|
|
1183
|
+
"""
|
|
1165
1184
|
if not isinstance(mediaObjectId, Xsd_string):
|
|
1166
1185
|
mediaObjectId = Xsd_string(mediaObjectId, validate=True)
|
|
1167
1186
|
blank = ''
|
|
@@ -1169,19 +1188,14 @@ class ResourceInstance:
|
|
|
1169
1188
|
sparql = context.sparql_context
|
|
1170
1189
|
|
|
1171
1190
|
sparql += f"""
|
|
1172
|
-
SELECT ?subject ?graph ?path ?
|
|
1191
|
+
SELECT ?subject ?graph ?path ?prop ?val ?permval
|
|
1173
1192
|
WHERE {{
|
|
1174
1193
|
VALUES ?inputImageId {{ {mediaObjectId.toRdf} }}
|
|
1175
|
-
|
|
1176
1194
|
?subject rdf:type shared:MediaObject .
|
|
1177
1195
|
GRAPH ?graph {{
|
|
1178
|
-
?subject shared:imageId ?inputImageId .
|
|
1179
|
-
?subject shared:originalName ?originalName .
|
|
1180
|
-
?subject shared:originalMimeType ?originalMimeType .
|
|
1181
|
-
?subject shared:serverUrl ?serverUrl .
|
|
1182
|
-
?subject shared:path ?path .
|
|
1183
|
-
?subject shared:protocol ?protocol .
|
|
1184
1196
|
?subject oldap:grantsPermission ?permset .
|
|
1197
|
+
?subject shared:imageId ?inputImageId .
|
|
1198
|
+
?subject ?prop ?val .
|
|
1185
1199
|
}}
|
|
1186
1200
|
GRAPH oldap:admin {{
|
|
1187
1201
|
{con.userIri.toRdf} oldap:hasPermissions ?permset .
|
|
@@ -1196,16 +1210,110 @@ class ResourceInstance:
|
|
|
1196
1210
|
print(sparql)
|
|
1197
1211
|
raise
|
|
1198
1212
|
res = QueryProcessor(context, jsonres)
|
|
1199
|
-
if len(res) == 0
|
|
1213
|
+
if len(res) == 0:
|
|
1200
1214
|
raise OldapErrorNotFound(f'Media object with id {mediaObjectId} not found.')
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1215
|
+
result: dict[str, Xsd] = {
|
|
1216
|
+
'iri': res[0].get('subject'),
|
|
1217
|
+
'graph': res[0].get('graph'),
|
|
1218
|
+
'permval': res[0].get('permval')
|
|
1219
|
+
}
|
|
1220
|
+
for r in res:
|
|
1221
|
+
if str(r['prop']) == 'rdf:type':
|
|
1222
|
+
continue
|
|
1223
|
+
if str(r['prop']) in {'oldap:createdBy', 'oldap:creationDate', 'oldap:lastModifiedBy', 'oldap:lastModificationDate',
|
|
1224
|
+
'shared:imageId', 'shared:originalName', 'shared:originalMimeType', 'shared:serverUrl', 'shared:path', 'shared:protocol'}:
|
|
1225
|
+
result[str(r['prop'])] = r['val']
|
|
1226
|
+
else:
|
|
1227
|
+
if result.get(str(r['prop'])) is None:
|
|
1228
|
+
result[str(r['prop'])] = []
|
|
1229
|
+
result[str(r['prop'])].append(r['val'])
|
|
1230
|
+
|
|
1231
|
+
expiration = datetime.now().astimezone() + timedelta(minutes=2)
|
|
1232
|
+
payload = {
|
|
1233
|
+
'userIri': str(con.userIri),
|
|
1234
|
+
'userid': str(con.userid),
|
|
1235
|
+
'id': str(mediaObjectId),
|
|
1236
|
+
'path': str(result.get('shared:path')),
|
|
1237
|
+
'permval': str(result.get('permval')),
|
|
1238
|
+
"exp": expiration.timestamp(),
|
|
1239
|
+
"iat": int(datetime.now().astimezone().timestamp()),
|
|
1240
|
+
"iss": "http://oldap.org"
|
|
1241
|
+
}
|
|
1242
|
+
token = jwt.encode(
|
|
1243
|
+
payload=payload,
|
|
1244
|
+
key=con.jwtkey,
|
|
1245
|
+
algorithm="HS256")
|
|
1246
|
+
result['token'] = token
|
|
1247
|
+
|
|
1248
|
+
return result
|
|
1249
|
+
|
|
1250
|
+
@staticmethod
|
|
1251
|
+
def get_media_object_by_iri(con: IConnection, mediaObjectIri: Iri | str) -> dict[str, Xsd] | None:
|
|
1252
|
+
if not isinstance(mediaObjectIri, Iri):
|
|
1253
|
+
mediaObjectIri = Iri(mediaObjectIri, validate=True)
|
|
1254
|
+
blank = ''
|
|
1255
|
+
context = Context(name=con.context_name)
|
|
1256
|
+
sparql = context.sparql_context
|
|
1257
|
+
|
|
1258
|
+
sparql += f"""
|
|
1259
|
+
SELECT ?graph ?prop ?val ?permval
|
|
1260
|
+
WHERE {{
|
|
1261
|
+
{mediaObjectIri.toRdf} rdf:type shared:MediaObject .
|
|
1262
|
+
GRAPH ?graph {{
|
|
1263
|
+
{mediaObjectIri.toRdf} oldap:grantsPermission ?permset .
|
|
1264
|
+
{mediaObjectIri.toRdf} shared:imageId ?inputImageId .
|
|
1265
|
+
{mediaObjectIri.toRdf} ?prop ?val .
|
|
1266
|
+
}}
|
|
1267
|
+
GRAPH oldap:admin {{
|
|
1268
|
+
{con.userIri.toRdf} oldap:hasPermissions ?permset .
|
|
1269
|
+
?permset oldap:givesPermission ?DataPermission .
|
|
1270
|
+
?DataPermission oldap:permissionValue ?permval .
|
|
1271
|
+
}}
|
|
1272
|
+
}}
|
|
1273
|
+
"""
|
|
1274
|
+
print(sparql)
|
|
1275
|
+
try:
|
|
1276
|
+
jsonres = con.query(sparql)
|
|
1277
|
+
except OldapError:
|
|
1278
|
+
print(sparql)
|
|
1279
|
+
raise
|
|
1280
|
+
res = QueryProcessor(context, jsonres)
|
|
1281
|
+
if len(res) == 0:
|
|
1282
|
+
raise OldapErrorNotFound(f'Media object with iri {mediaObjectIri} not found.')
|
|
1283
|
+
result: dict[str, Xsd] = {
|
|
1284
|
+
'iri': mediaObjectIri,
|
|
1285
|
+
'graph': res[0].get('graph'),
|
|
1286
|
+
'permval': res[0].get('permval')
|
|
1287
|
+
}
|
|
1288
|
+
for r in res:
|
|
1289
|
+
if str(r['prop']) == 'rdf:type':
|
|
1290
|
+
continue
|
|
1291
|
+
if str(r['prop']) in {'oldap:createdBy', 'oldap:creationDate', 'oldap:lastModifiedBy', 'oldap:lastModificationDate',
|
|
1292
|
+
'shared:imageId', 'shared:originalName', 'shared:originalMimeType', 'shared:serverUrl', 'shared:path', 'shared:protocol'}:
|
|
1293
|
+
result[str(r['prop'])] = r['val']
|
|
1294
|
+
else:
|
|
1295
|
+
if result.get(str(r['prop'])) is None:
|
|
1296
|
+
result[str(r['prop'])] = []
|
|
1297
|
+
result[str(r['prop'])].append(r['val'])
|
|
1298
|
+
|
|
1299
|
+
expiration = datetime.now().astimezone() + timedelta(minutes=2)
|
|
1300
|
+
payload = {
|
|
1301
|
+
'userIri': str(con.userIri),
|
|
1302
|
+
'userid': str(con.userid),
|
|
1303
|
+
'id': str(result.get('shared:imageId')),
|
|
1304
|
+
'path': str(result['shared:path']),
|
|
1305
|
+
'permval': str(result['permval']),
|
|
1306
|
+
"exp": expiration.timestamp(),
|
|
1307
|
+
"iat": int(datetime.now().astimezone().timestamp()),
|
|
1308
|
+
"iss": "http://oldap.org"
|
|
1309
|
+
}
|
|
1310
|
+
token = jwt.encode(
|
|
1311
|
+
payload=payload,
|
|
1312
|
+
key=con.jwtkey,
|
|
1313
|
+
algorithm="HS256")
|
|
1314
|
+
result['token'] = token
|
|
1315
|
+
|
|
1316
|
+
return result
|
|
1209
1317
|
|
|
1210
1318
|
|
|
1211
1319
|
def toJsonObject(self) -> dict[str, list[str] | str]:
|
|
@@ -150,7 +150,7 @@ def dump_list_to(con: IConnection,
|
|
|
150
150
|
make_dict(node, listdict[str(listnode.oldapListNodeId)]['nodes'])
|
|
151
151
|
|
|
152
152
|
#
|
|
153
|
-
# We need to get the OldapList IRI for
|
|
153
|
+
# We need to get the OldapList IRI for asking the cache...
|
|
154
154
|
#
|
|
155
155
|
if not isinstance(project, Project):
|
|
156
156
|
project = Project.read(con, project)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.29"
|
|
@@ -5,6 +5,7 @@ import unittest
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from pprint import pprint
|
|
7
7
|
from time import sleep
|
|
8
|
+
import jwt
|
|
8
9
|
|
|
9
10
|
from oldaplib.src.cachesingleton import CacheSingletonRedis
|
|
10
11
|
from oldaplib.src.datamodel import DataModel
|
|
@@ -702,16 +703,71 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
702
703
|
self.assertEqual(len(res), 8)
|
|
703
704
|
|
|
704
705
|
#@unittest.skip('Work in progress')
|
|
705
|
-
def
|
|
706
|
-
res = ResourceInstance.get_media_object_by_id(con=self._connection,mediaObjectId='x_34db.tif')
|
|
706
|
+
def test_read_media_object_by_id_A(self):
|
|
707
|
+
res = ResourceInstance.get_media_object_by_id(con=self._connection, mediaObjectId='x_34db.tif')
|
|
707
708
|
self.assertEqual(res['iri'], Iri("urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b901"))
|
|
709
|
+
self.assertEqual(res['permval'], Xsd_integer(2))
|
|
710
|
+
self.assertEqual(res['shared:imageId'], Xsd_string('x_34db.tif'))
|
|
708
711
|
self.assertEqual(res['shared:originalName'], Xsd_string("testfile.tif"))
|
|
709
712
|
self.assertEqual(res['shared:originalMimeType'], Xsd_string("image/tiff"))
|
|
710
713
|
self.assertEqual(res['shared:serverUrl'], Xsd_string("https://iiif.oldap.org"))
|
|
711
714
|
self.assertEqual(res['shared:protocol'], Xsd_string("iiif"))
|
|
712
715
|
self.assertEqual(res['graph'], Xsd_QName("test:data"))
|
|
713
716
|
self.assertEqual(res['shared:path'], Xsd_string("test/subtest"))
|
|
714
|
-
|
|
717
|
+
tinfo = jwt.decode(jwt=res['token'], key=self._connection.jwtkey, algorithms="HS256")
|
|
718
|
+
self.assertEqual(tinfo['id'], 'x_34db.tif')
|
|
719
|
+
self.assertEqual(tinfo['path'], 'test/subtest')
|
|
720
|
+
self.assertEqual(tinfo['permval'], '2')
|
|
721
|
+
|
|
722
|
+
def test_read_media_object_by_id_B(self):
|
|
723
|
+
res = ResourceInstance.get_media_object_by_id(con=self._connection, mediaObjectId='x_42db.jpg')
|
|
724
|
+
self.assertEqual(res['iri'], Iri("urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b999"))
|
|
725
|
+
self.assertEqual(res['permval'], Xsd_integer(2))
|
|
726
|
+
self.assertEqual(res['shared:imageId'], Xsd_string('x_42db.jpg'))
|
|
727
|
+
self.assertEqual(res['shared:originalName'], Xsd_string("testfile.jpg"))
|
|
728
|
+
self.assertEqual(res['shared:originalMimeType'], Xsd_string("image/jpeg"))
|
|
729
|
+
self.assertEqual(res['shared:serverUrl'], Xsd_string("https://iiif.oldap.org"))
|
|
730
|
+
self.assertEqual(res['shared:protocol'], Xsd_string("iiif"))
|
|
731
|
+
self.assertEqual(res['graph'], Xsd_QName("test:data"))
|
|
732
|
+
self.assertEqual(res['test:caption'], [Xsd_string("This is a non-real, non-existing image")])
|
|
733
|
+
self.assertEqual(res['shared:path'], Xsd_string("test/subtest"))
|
|
734
|
+
tinfo = jwt.decode(jwt=res['token'], key=self._connection.jwtkey, algorithms="HS256")
|
|
735
|
+
self.assertEqual(tinfo['id'], 'x_42db.jpg')
|
|
736
|
+
self.assertEqual(tinfo['path'], 'test/subtest')
|
|
737
|
+
self.assertEqual(tinfo['permval'], '2')
|
|
738
|
+
|
|
739
|
+
def test_read_media_object_by_iri_A(self):
|
|
740
|
+
res = ResourceInstance.get_media_object_by_iri(con=self._connection, mediaObjectIri='urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b901')
|
|
741
|
+
self.assertEqual(res['iri'], Iri("urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b901"))
|
|
742
|
+
self.assertEqual(res['permval'], Xsd_integer(2))
|
|
743
|
+
self.assertEqual(res['shared:imageId'], Xsd_string('x_34db.tif'))
|
|
744
|
+
self.assertEqual(res['shared:originalName'], Xsd_string("testfile.tif"))
|
|
745
|
+
self.assertEqual(res['shared:originalMimeType'], Xsd_string("image/tiff"))
|
|
746
|
+
self.assertEqual(res['shared:serverUrl'], Xsd_string("https://iiif.oldap.org"))
|
|
747
|
+
self.assertEqual(res['shared:protocol'], Xsd_string("iiif"))
|
|
748
|
+
self.assertEqual(res['graph'], Xsd_QName("test:data"))
|
|
749
|
+
self.assertEqual(res['shared:path'], Xsd_string("test/subtest"))
|
|
750
|
+
tinfo = jwt.decode(jwt=res['token'], key=self._connection.jwtkey, algorithms="HS256")
|
|
751
|
+
self.assertEqual(tinfo['id'], 'x_34db.tif')
|
|
752
|
+
self.assertEqual(tinfo['path'], 'test/subtest')
|
|
753
|
+
self.assertEqual(tinfo['permval'], '2')
|
|
754
|
+
|
|
755
|
+
def test_read_media_object_by_iri_B(self):
|
|
756
|
+
res = ResourceInstance.get_media_object_by_iri(con=self._connection, mediaObjectIri='urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b999')
|
|
757
|
+
self.assertEqual(res['iri'], Iri("urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b999"))
|
|
758
|
+
self.assertEqual(res['permval'], Xsd_integer(2))
|
|
759
|
+
self.assertEqual(res['shared:imageId'], Xsd_string('x_42db.jpg'))
|
|
760
|
+
self.assertEqual(res['shared:originalName'], Xsd_string("testfile.jpg"))
|
|
761
|
+
self.assertEqual(res['shared:originalMimeType'], Xsd_string("image/jpeg"))
|
|
762
|
+
self.assertEqual(res['shared:serverUrl'], Xsd_string("https://iiif.oldap.org"))
|
|
763
|
+
self.assertEqual(res['shared:protocol'], Xsd_string("iiif"))
|
|
764
|
+
self.assertEqual(res['graph'], Xsd_QName("test:data"))
|
|
765
|
+
self.assertEqual(res['test:caption'], [Xsd_string("This is a non-real, non-existing image")])
|
|
766
|
+
self.assertEqual(res['shared:path'], Xsd_string("test/subtest"))
|
|
767
|
+
tinfo = jwt.decode(jwt=res['token'], key=self._connection.jwtkey, algorithms="HS256")
|
|
768
|
+
self.assertEqual(tinfo['id'], 'x_42db.jpg')
|
|
769
|
+
self.assertEqual(tinfo['path'], 'test/subtest')
|
|
770
|
+
self.assertEqual(tinfo['permval'], '2')
|
|
715
771
|
|
|
716
772
|
def test_create_media_object(self):
|
|
717
773
|
dm = DataModel.read(con=self._connection, project='test')
|
|
@@ -132,6 +132,20 @@ test:data {
|
|
|
132
132
|
shared:protocol 'iiif';
|
|
133
133
|
shared:path 'test/subtest' .
|
|
134
134
|
|
|
135
|
+
<urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b999> a shared:MediaObject;
|
|
136
|
+
:createdBy <https://orcid.org/0000-0003-1681-4036>;
|
|
137
|
+
:creationDate "2025-11-13T16:43:28.861171+01:00"^^xsd:dateTimeStamp;
|
|
138
|
+
:lastModifiedBy <https://orcid.org/0000-0003-1681-4036>;
|
|
139
|
+
:lastModificationDate "2025-11-13T16:43:28.861171+01:00"^^xsd:dateTimeStamp;
|
|
140
|
+
:grantsPermission :GenericView;
|
|
141
|
+
shared:originalName 'testfile.jpg';
|
|
142
|
+
shared:originalMimeType 'image/jpeg';
|
|
143
|
+
shared:serverUrl 'https://iiif.oldap.org';
|
|
144
|
+
shared:imageId 'x_42db.jpg';
|
|
145
|
+
shared:protocol 'iiif';
|
|
146
|
+
shared:path 'test/subtest' ;
|
|
147
|
+
test:caption 'This is a non-real, non-existing image' .
|
|
148
|
+
|
|
135
149
|
|
|
136
150
|
|
|
137
151
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "oldaplib"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.29"
|
|
4
4
|
description = "Open Media Access Server Library (Linked Open Data middleware/RESTApi)"
|
|
5
5
|
authors = ["Lukas Rosenthaler <lukas.rosenthaler@unibas.ch>"]
|
|
6
6
|
license = "GNU Affero General Public License version 3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.28"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|