oldaplib 0.3.26__py3-none-any.whl → 0.3.28__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/project.py CHANGED
@@ -426,6 +426,21 @@ class Project(Model):
426
426
  projects.append(ProjectSearchResult(r['project'], r['shortname']))
427
427
  return projects
428
428
 
429
+
430
+ def trig_to_str(self, created: Xsd_dateTime, modified: Xsd_dateTime,indent: int = 0, indent_inc: int = 4):
431
+ blank = ''
432
+ sparql = ''
433
+ sparql += f'\n{blank:{indent * indent_inc}}{self.projectIri.toRdf} a oldap:Project'
434
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:creator {self._con.userIri.toRdf}'
435
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:created {created.toRdf}'
436
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:contributor {self._con.userIri.toRdf}'
437
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:modified {modified.toRdf}'
438
+ for attr, value in self._attributes.items():
439
+ if not value:
440
+ continue
441
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}{attr.value.toRdf} {value.toRdf}'
442
+ return sparql
443
+
429
444
  def create(self, indent: int = 0, indent_inc: int = 4) -> None:
430
445
  """
431
446
  Creates a new project in the triple store. The function starts by
@@ -459,11 +474,14 @@ class Project(Model):
459
474
  raise OldapErrorNoPermission(message)
460
475
 
461
476
  timestamp = Xsd_dateTime.now()
462
- indent: int = 0
463
- indent_inc: int = 4
477
+ #indent: int = 0
478
+ #indent_inc: int = 4
464
479
 
465
480
  context = Context(name=self._con.context_name)
466
481
 
482
+ #
483
+ # SPARQL to check if project with the given projectShortName already exists
484
+ #
467
485
  sparql0 = context.sparql_context
468
486
  sparql0 += f"""
469
487
  ASK {{
@@ -475,15 +493,9 @@ class Project(Model):
475
493
  }}
476
494
  """
477
495
 
478
- sparql1 = context.sparql_context
479
- sparql1 += f"""
480
- SELECT ?project
481
- FROM oldap:admin
482
- WHERE {{
483
- ?project a oldap:Project .
484
- FILTER(?project = {self.projectIri.toRdf})
485
- }}
486
- """
496
+ #
497
+ # SPARQL to check if the given namespaceIri is already used by another project
498
+ #
487
499
  sparql1a = context.sparql_context
488
500
  sparql1a += f"""
489
501
  ASK {{
@@ -493,6 +505,9 @@ class Project(Model):
493
505
  }}
494
506
  """
495
507
 
508
+ #
509
+ # SPARQL to check if project with the given projectIri already exists
510
+ #
496
511
  sparql1b = context.sparql_context
497
512
  sparql1b += f"""
498
513
  ASK {{
@@ -506,15 +521,16 @@ class Project(Model):
506
521
  sparql2 = context.sparql_context
507
522
  sparql2 += f'{blank:{indent * indent_inc}}INSERT DATA {{'
508
523
  sparql2 += f'\n{blank:{(indent + 1) * indent_inc}}GRAPH oldap:admin {{'
509
- sparql2 += f'\n{blank:{(indent + 2) * indent_inc}}{self.projectIri.toRdf} a oldap:Project'
510
- sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:creator {self._con.userIri.toRdf}'
511
- sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:created {timestamp.toRdf}'
512
- sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:contributor {self._con.userIri.toRdf}'
513
- sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:modified {timestamp.toRdf}'
514
- for attr, value in self._attributes.items():
515
- if not value:
516
- continue
517
- sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}{attr.value.toRdf} {value.toRdf}'
524
+ sparql2 += self.trig_to_str(created=timestamp, modified=timestamp, indent=indent + 2, indent_inc=indent_inc)
525
+ # sparql2 += f'\n{blank:{(indent + 2) * indent_inc}}{self.projectIri.toRdf} a oldap:Project'
526
+ # sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:creator {self._con.userIri.toRdf}'
527
+ # sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:created {timestamp.toRdf}'
528
+ # sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:contributor {self._con.userIri.toRdf}'
529
+ # sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:modified {timestamp.toRdf}'
530
+ # for attr, value in self._attributes.items():
531
+ # if not value:
532
+ # continue
533
+ # sparql2 += f' ;\n{blank:{(indent + 3) * indent_inc}}{attr.value.toRdf} {value.toRdf}'
518
534
  sparql2 += f' .\n{blank:{(indent + 1) * indent_inc}}}}\n'
519
535
  sparql2 += f'{blank:{indent * indent_inc}}}}\n'
520
536
 
@@ -799,6 +799,10 @@ class ResourceClass(Model, Notify):
799
799
  conf = GlobalConfig(self._con)
800
800
  sysproj = conf.sysproject
801
801
  superclass = ResourceClass.read(self._con, sysproj, owliri)
802
+ elif owliri.prefix == 'shared':
803
+ conf = GlobalConfig(self._con)
804
+ sharedproj = conf.sharedproject
805
+ superclass = ResourceClass.read(self._con, sharedproj, owliri)
802
806
  else:
803
807
  superclass = ResourceClass.read(self._con, self._project, owliri)
804
808
  self._attributes[ResClassAttribute.SUPERCLASS][owliri] = superclass
oldaplib/src/user.py CHANGED
@@ -363,7 +363,43 @@ class User(Model):
363
363
  self._changeset[UserAttr.IN_PROJECT] = AttributeChange(self._attributes[UserAttr.IN_PROJECT], Action.MODIFY)
364
364
  self._attributes[UserAttr.IN_PROJECT][project].remove(permission)
365
365
 
366
- def create(self, indent: int = 0, indent_inc: int = 4) -> None:
366
+ def trig_to_str(self,
367
+ creator: Iri,
368
+ created: Xsd_dateTime,
369
+ contributor: Iri,
370
+ modified: Xsd_dateTime,
371
+ indent: int = 0, indent_inc: int = 4):
372
+ blank = ''
373
+ sparql = ''
374
+ sparql += f'{blank:{indent * indent_inc}}{self.userIri.toRdf} a oldap:User'
375
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:creator {creator.toRdf}'
376
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:created {created.toRdf}'
377
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:contributor {contributor.toRdf}'
378
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}dcterms:modified {modified.toRdf}'
379
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}oldap:userId {self.userId.toRdf}'
380
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}schema:familyName {self.familyName.toRdf}'
381
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}schema:givenName {self.givenName.toRdf}'
382
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}schema:email {self.email.toRdf}'
383
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}oldap:credentials {self.credentials.toRdf}'
384
+ activeval = "true" if self.isActive else "false"
385
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}oldap:isActive {activeval}'
386
+ star = ''
387
+ if self.inProject:
388
+ project = [p.toRdf for p in self.inProject.keys()]
389
+ rdfstr = ", ".join(project)
390
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}oldap:inProject {rdfstr}'
391
+ for p in self.inProject.keys():
392
+ for admin_p in self.inProject[p]: # TODO: May be use .get() instead of [] !!!!!!!!!!!!!!!!!!!!!!!!!
393
+ star += f'{blank:{indent * indent_inc}}<<{self.userIri.toRdf} oldap:inProject {p.toRdf}>> oldap:hasAdminPermission {admin_p.value} .\n'
394
+ if self.hasPermissions:
395
+ rdfstr = ", ".join([str(x) for x in self.hasPermissions])
396
+ sparql += f' ;\n{blank:{(indent + 1) * indent_inc}}oldap:hasPermissions {rdfstr}'
397
+ sparql += " .\n\n"
398
+ sparql += star
399
+ return sparql
400
+
401
+
402
+ def create(self, indent: int = 0, indent_inc: int = 4, keep_dates: bool = False) -> None:
367
403
  """
368
404
  Creates a user in the triple store with the provided details. Before proceeding with the
369
405
  creation, it verifies the uniqueness of the `userId` and `userIri`. The user is created
@@ -444,31 +480,43 @@ class User(Model):
444
480
  sparql += f'{blank:{indent * indent_inc}}INSERT DATA {{\n'
445
481
  sparql += f'{blank:{(indent + 1) * indent_inc}}GRAPH oldap:admin {{\n'
446
482
 
447
- sparql += f'{blank:{(indent + 2) * indent_inc}}{self.userIri.toRdf} a oldap:User'
448
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:creator {self._con.userIri.toRdf}'
449
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:created {timestamp.toRdf}'
450
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:contributor {self._con.userIri.toRdf}'
451
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:modified {timestamp.toRdf}'
452
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:userId {self.userId.toRdf}'
453
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}schema:familyName {self.familyName.toRdf}'
454
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}schema:givenName {self.givenName.toRdf}'
455
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}schema:email {self.email.toRdf}'
456
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:credentials {self.credentials.toRdf}'
457
- activeval = "true" if self.isActive else "false"
458
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:isActive {activeval}'
459
- star = ''
460
- if self.inProject:
461
- project = [p.toRdf for p in self.inProject.keys()]
462
- rdfstr = ", ".join(project)
463
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:inProject {rdfstr}'
464
- for p in self.inProject.keys():
465
- for admin_p in self.inProject[p]: # TODO: May be use .get() instead of [] !!!!!!!!!!!!!!!!!!!!!!!!!
466
- star += f'{blank:{(indent + 2) * indent_inc}}<<{self.userIri.toRdf} oldap:inProject {p.toRdf}>> oldap:hasAdminPermission {admin_p.value} .\n'
467
- if self.hasPermissions:
468
- rdfstr = ", ".join([str(x) for x in self.hasPermissions])
469
- sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:hasPermissions {rdfstr}'
470
- sparql += " .\n\n"
471
- sparql += star
483
+ if keep_dates:
484
+ sparql += self.trig_to_str(creator=self.creator,
485
+ created=self.created,
486
+ contributor=self.contributor,
487
+ modified=self.modified,
488
+ indent=indent + 2, indent_inc=indent_inc)
489
+ else:
490
+ sparql += self.trig_to_str(creator=self._con.userIri,
491
+ created=timestamp,
492
+ contributor=self._con.userIri,
493
+ modified=timestamp,
494
+ indent=indent + 2, indent_inc=indent_inc)
495
+ # sparql += f'{blank:{(indent + 2) * indent_inc}}{self.userIri.toRdf} a oldap:User'
496
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:creator {self._con.userIri.toRdf}'
497
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:created {timestamp.toRdf}'
498
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:contributor {self._con.userIri.toRdf}'
499
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}dcterms:modified {timestamp.toRdf}'
500
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:userId {self.userId.toRdf}'
501
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}schema:familyName {self.familyName.toRdf}'
502
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}schema:givenName {self.givenName.toRdf}'
503
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}schema:email {self.email.toRdf}'
504
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:credentials {self.credentials.toRdf}'
505
+ # activeval = "true" if self.isActive else "false"
506
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:isActive {activeval}'
507
+ # star = ''
508
+ # if self.inProject:
509
+ # project = [p.toRdf for p in self.inProject.keys()]
510
+ # rdfstr = ", ".join(project)
511
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:inProject {rdfstr}'
512
+ # for p in self.inProject.keys():
513
+ # for admin_p in self.inProject[p]: # TODO: May be use .get() instead of [] !!!!!!!!!!!!!!!!!!!!!!!!!
514
+ # star += f'{blank:{(indent + 2) * indent_inc}}<<{self.userIri.toRdf} oldap:inProject {p.toRdf}>> oldap:hasAdminPermission {admin_p.value} .\n'
515
+ # if self.hasPermissions:
516
+ # rdfstr = ", ".join([str(x) for x in self.hasPermissions])
517
+ # sparql += f' ;\n{blank:{(indent + 3) * indent_inc}}oldap:hasPermissions {rdfstr}'
518
+ # sparql += " .\n\n"
519
+ # sparql += star
472
520
  sparql += f'{blank:{(indent + 1) * indent_inc}}}}\n'
473
521
  sparql += f'{blank:{indent * indent_inc}}}}\n'
474
522
 
oldaplib/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.3.26"
1
+ __version__ = "0.3.28"
@@ -69,15 +69,15 @@ class Xsd_anyURI(Xsd):
69
69
  raise OldapErrorValue(f'Invalid URN format for "{value}".')
70
70
  elif value.startswith("http"):
71
71
  if not re.match(self._uri_pattern, str(value)):
72
- raise OldapErrorValue(f'Invalid string "{value}" for xsd:anyURI.')
72
+ raise OldapErrorValue(f'Invalid string "{value}" for xsd:anyURI (regexp).')
73
73
  if validate:
74
74
  if not XsdValidator.validate(XsdDatatypes.anyURI, str(value)):
75
- raise OldapErrorValue(f'Invalid string "{value}" for anyURI')
75
+ raise OldapErrorValue(f'Invalid string "{value}" for xsd:anyURI (validator)')
76
76
  else:
77
77
  if not url(str(value)):
78
- raise OldapErrorValue(f'Invalid string "{value}" for xsd:anyURI.')
78
+ raise OldapErrorValue(f'Invalid string "{value}" for xsd:anyURI (url()).')
79
79
  else:
80
- raise OldapErrorValue(f'Invalid string "{value}" for anyURI')
80
+ raise OldapErrorValue(f'Invalid string "{value}" for anyURI (no urn:/http:)')
81
81
  self._value = str(value)
82
82
  self._append_allowed = self._value[-1] == '/' or self._value[-1] == '#'
83
83
 
@@ -0,0 +1,17 @@
1
+ from oldaplib.src.connection import Connection
2
+ import unittest
3
+
4
+ from oldaplib.src.datamodel import DataModel
5
+ from oldaplib.src.project import Project
6
+
7
+ class TestDataModel(unittest.TestCase):
8
+
9
+ # @unittest.skip('Work in progress')
10
+ def test_fasnacht(self):
11
+ connection = Connection(userId="rosenth",
12
+ credentials="RioGrande",
13
+ context_name="DEFAULT")
14
+
15
+ project = Project.read(connection, "fasnacht")
16
+ dm = DataModel.read(connection, project, ignore_cache=False)
17
+ pass
@@ -52,7 +52,6 @@ class TestBasicConnection(unittest.TestCase):
52
52
  cls._connection.clear_graph(Xsd_QName('test:onto'))
53
53
  file = project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
54
54
  cls._connection.upload_turtle(file)
55
- sleep(1) # upload may take a while...
56
55
 
57
56
  @classmethod
58
57
  def tearDownClass(cls):
@@ -55,14 +55,14 @@ class TestContext(unittest.TestCase):
55
55
  self.assertIsNone(qn)
56
56
  with self.assertRaises(OldapError) as ex:
57
57
  qn = context.iri2qname('waseliwas/soll')
58
- self.assertEqual(str(ex.exception), 'Invalid string "waseliwas/soll" for anyURI')
58
+ self.assertEqual(str(ex.exception), 'Invalid string "waseliwas/soll" for anyURI (no urn:/http:)')
59
59
 
60
60
  def test_context_qname2iri(self):
61
61
  context = Context(name='qname2iri')
62
62
  self.assertEqual(context.qname2iri(Xsd_QName('skos:gaga')), 'http://www.w3.org/2004/02/skos/core#gaga')
63
63
  with self.assertRaises(OldapError) as ex:
64
64
  qn = context.iri2qname('gaga')
65
- self.assertEqual(str(ex.exception), 'Invalid string "gaga" for anyURI')
65
+ self.assertEqual(str(ex.exception), 'Invalid string "gaga" for anyURI (no urn:/http:)')
66
66
  self.assertIsNone(context.iri2qname('abc:def'))
67
67
  t = Xsd_QName('xml:integer')
68
68
  self.assertEqual(context.qname2iri(t), 'http://www.w3.org/XML/1998/namespace#integer')
@@ -79,6 +79,7 @@ PREFIX sh: <http://www.w3.org/ns/shacl#>
79
79
  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
+ PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
82
83
  PREFIX oldap: <http://oldap.org/base#>
83
84
  PREFIX shared: <http://oldap.org/shared#>
84
85
  PREFIX test: <http://www.test.org/gaga#>
@@ -97,6 +98,7 @@ PREFIX test: <http://www.test.org/gaga#>
97
98
  @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
98
99
  @prefix schema: <http://schema.org/> .
99
100
  @prefix dcterms: <http://purl.org/dc/terms/> .
101
+ @prefix dcmitype: <http://purl.org/dc/dcmitype/> .
100
102
  @prefix oldap: <http://oldap.org/base#> .
101
103
  @prefix shared: <http://oldap.org/shared#> .
102
104
  @prefix test: <http://www.test.org/gaga#> .
@@ -102,9 +102,6 @@ class TestDataModel(unittest.TestCase):
102
102
  file = project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
103
103
  cls._connection.upload_turtle(file)
104
104
 
105
-
106
- sleep(1) # upload may take a while...
107
-
108
105
  cls._project = Project.read(cls._connection, "test", ignore_cache=True)
109
106
  cls._dmproject = Project.read(cls._connection, "dmtest", ignore_cache=True)
110
107
  cls._dmprojectA = Project.read(cls._connection, "dmtestA", ignore_cache=True)
@@ -390,6 +387,7 @@ class TestDataModel(unittest.TestCase):
390
387
 
391
388
  def test_datamodel_read_shared(self):
392
389
  model = DataModel.read(self._connection, self._sharedproject, ignore_cache=True)
390
+ pass
393
391
 
394
392
  def test_datamodel_read_system(self):
395
393
  model = DataModel.read(self._connection, self._sysproject, ignore_cache=True)
@@ -1114,8 +1112,6 @@ class TestDataModel(unittest.TestCase):
1114
1112
  file = project_root / 'oldaplib' / 'testdata' / 'objectfactory_test.trig'
1115
1113
  self._connection.upload_turtle(file)
1116
1114
 
1117
- sleep(1) # upload may take a while...
1118
-
1119
1115
  cache = CacheSingletonRedis()
1120
1116
  cache.clear()
1121
1117
  dm1 = DataModel.read(self._connection, self._project, ignore_cache=False)
@@ -1123,3 +1119,4 @@ class TestDataModel(unittest.TestCase):
1123
1119
  dm2 = DataModel.read(self._connection, self._project, ignore_cache=False)
1124
1120
 
1125
1121
  pass
1122
+
@@ -51,7 +51,6 @@ class TestexternalOntologies(unittest.TestCase):
51
51
  cls._connection.upload_turtle(file)
52
52
  file = project_root / 'oldaplib' / 'ontologies' / 'admin-testing.trig'
53
53
  cls._connection.upload_turtle(file)
54
- sleep(1) # upload may take a while...
55
54
 
56
55
  project = Project(con=cls._connection,
57
56
  projectIri=Iri("http://extonto.test.org/test"),
@@ -52,7 +52,6 @@ class TestHasProperty(unittest.TestCase):
52
52
 
53
53
  file = project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
54
54
  cls._connection.upload_turtle(file)
55
- sleep(1) # upload may take a while...
56
55
  cls._project = Project.read(cls._connection, "test")
57
56
 
58
57
  @classmethod
@@ -108,8 +108,6 @@ class TestObjectFactory(unittest.TestCase):
108
108
  file = project_root / 'oldaplib' / 'testdata' / 'instances_test.trig'
109
109
  cls._connection.upload_turtle(file)
110
110
 
111
- sleep(1) # upload may take a while...
112
-
113
111
  user = User.read(cls._connection, "rosenth")
114
112
  user.hasPermissions.add(Iri('oldap:GenericUpdate')) # TODO: SHOULD WORK WITH Xsd_QName
115
113
  user.update()
@@ -362,9 +360,12 @@ class TestObjectFactory(unittest.TestCase):
362
360
  factory = ResourceInstanceFactory(con=self._connection, project='test')
363
361
  MO = factory.createObjectInstance('shared:MediaObject')
364
362
  mo = MO(originalName='Cat.tif',
363
+ type='dcmitype:StillImage',
365
364
  originalMimeType='image/tiff',
366
365
  serverUrl='http://iiif.oldap.org/iiif/3/',
367
366
  imageId='cat.tif',
367
+ path='test',
368
+ protocol='iiif',
368
369
  grantsPermission=Iri('oldap:GenericView'))
369
370
  mo.create()
370
371
  data = ResourceInstance.read_data(con=self._connection, iri=mo.iri, projectShortName='test')
@@ -545,7 +546,7 @@ class TestObjectFactory(unittest.TestCase):
545
546
  givenName="Max",
546
547
  grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
547
548
  p.create()
548
- sleep(1)
549
+
549
550
  obj1 = Person.read(con=self._connection,
550
551
  iri=p.iri)
551
552
  with self.assertRaises(OldapErrorValue):
@@ -700,10 +701,49 @@ class TestObjectFactory(unittest.TestCase):
700
701
  resClass='test:Page')
701
702
  self.assertEqual(len(res), 8)
702
703
 
703
- @unittest.skip('Work in progress')
704
- def test_media_object(self):
705
- res = ResourceInstance.get_media_object_by_id(con=self._connection,mediaObjectId='Nn3Epw1LMTNS.tif')
706
- print(res)
704
+ #@unittest.skip('Work in progress')
705
+ def test_read_media_object(self):
706
+ res = ResourceInstance.get_media_object_by_id(con=self._connection,mediaObjectId='x_34db.tif')
707
+ self.assertEqual(res['iri'], Iri("urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b901"))
708
+ self.assertEqual(res['shared:originalName'], Xsd_string("testfile.tif"))
709
+ self.assertEqual(res['shared:originalMimeType'], Xsd_string("image/tiff"))
710
+ self.assertEqual(res['shared:serverUrl'], Xsd_string("https://iiif.oldap.org"))
711
+ self.assertEqual(res['shared:protocol'], Xsd_string("iiif"))
712
+ self.assertEqual(res['graph'], Xsd_QName("test:data"))
713
+ self.assertEqual(res['shared:path'], Xsd_string("test/subtest"))
714
+ self.assertEqual(res['oldap:permissionValue'], Xsd_integer(2))
715
+
716
+ def test_create_media_object(self):
717
+ dm = DataModel.read(con=self._connection, project='test')
718
+ factory = ResourceInstanceFactory(con=self._connection, project='test')
719
+ MLE = factory.createObjectInstance('test:MediaLibraryEntry')
720
+ mle = MLE(originalName='MyCarnivalImagetif',
721
+ type='dcmitype:StillImage',
722
+ originalMimeType='image/tiff',
723
+ imageId='x_34dbY4.tif',
724
+ serverUrl='http://iiif.oldap.org/iiif/3/',
725
+ path='test/subtest',
726
+ protocol='iiif',
727
+ caption='My Carnival Image of 1968 with the Bohrerhof-Clique',
728
+ grantsPermission=Iri('oldap:GenericView'))
729
+ mle.create()
730
+ data = ResourceInstance.read_data(con=self._connection, iri=mle.iri, projectShortName='test')
731
+ self.assertEqual(data['shared:originalName'], ["MyCarnivalImagetif"])
732
+ self.assertEqual(data['shared:originalMimeType'], ['image/tiff'])
733
+ self.assertEqual(data['shared:serverUrl'], ['http://iiif.oldap.org/iiif/3/'])
734
+ self.assertEqual(data['shared:imageId'], ['x_34dbY4.tif'])
735
+ self.assertEqual(data['shared:protocol'], ['iiif'])
736
+ self.assertEqual(data['shared:path'], ['test/subtest'])
737
+ self.assertEqual(data['test:caption'], ['My Carnival Image of 1968 with the Bohrerhof-Clique'])
738
+
739
+
740
+ data2 = ResourceInstance.get_media_object_by_id(con=self._connection, mediaObjectId='x_34dbY4.tif')
741
+ self.assertEqual(data2['shared:originalName'], "MyCarnivalImagetif")
742
+ self.assertEqual(data2['shared:originalMimeType'], 'image/tiff')
743
+ self.assertEqual(data2['shared:serverUrl'], 'http://iiif.oldap.org/iiif/3/')
744
+ self.assertEqual(data2['shared:protocol'], 'iiif')
745
+ self.assertEqual(data2['shared:path'], 'test/subtest')
746
+ mle.delete()
707
747
 
708
748
  if __name__ == '__main__':
709
749
  unittest.main()
@@ -80,7 +80,7 @@ class TestOldapList(unittest.TestCase):
80
80
 
81
81
  file = cls._project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
82
82
  cls._connection.upload_turtle(file)
83
- sleep(1)
83
+
84
84
  cls._project = Project.read(cls._connection, "test")
85
85
  LangString.defaultLanguage = Language.EN
86
86
 
@@ -66,7 +66,7 @@ class OldapListHelperTestCase(unittest.TestCase):
66
66
  cls._connection.clear_graph(Xsd_QName('hyha:data'))
67
67
  file = project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
68
68
  cls._connection.upload_turtle(file)
69
- sleep(1)
69
+
70
70
  cls._project = Project.read(cls._connection, "test")
71
71
  LangString.defaultLanguage = Language.EN
72
72
 
@@ -84,7 +84,6 @@ class TestOldapListNode(unittest.TestCase):
84
84
 
85
85
  file = cls._project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
86
86
  cls._connection.upload_turtle(file)
87
- sleep(1)
88
87
 
89
88
  cls._project = Project.read(cls._connection, "test")
90
89
  cls._dmproject = Project.read(cls._connection, "dmtest", ignore_cache=True)
@@ -78,7 +78,7 @@ class TestPermissionSet(unittest.TestCase):
78
78
  cls._connection.clear_graph(Xsd_QName('test:data'))
79
79
  file = cls._project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
80
80
  cls._connection.upload_turtle(file)
81
- sleep(1)
81
+
82
82
  cls._project = Project.read(cls._connection, "test")
83
83
  LangString.defaultLanguage = Language.EN
84
84
 
@@ -347,6 +347,7 @@ class TestPermissionSet(unittest.TestCase):
347
347
  ps.update()
348
348
  ps = PermissionSet.read(con=self._connection, permissionSetId=psId, definedByProject=Iri('oldap:SystemProject'))
349
349
  self.assertEqual(ps.givesPermission, DataPermission.DATA_VIEW)
350
+ self.assertEqual(ps.givesPermission, DataPermission.DATA_VIEW)
350
351
  self.assertEqual(ps.label, LangString("testUpdatePerm@en", "testVerändernPerm@de", "testeModificationPerm@fr"))
351
352
  del ps.comment
352
353
  ps.update()
@@ -56,7 +56,6 @@ class Testproject(unittest.TestCase):
56
56
  cls._connection.upload_turtle(file)
57
57
  file = project_root / 'oldaplib' / 'ontologies' / 'admin-testing.trig'
58
58
  cls._connection.upload_turtle(file)
59
- sleep(1) # upload may take a while...
60
59
 
61
60
  @classmethod
62
61
  def tearDownClass(cls):
@@ -70,7 +70,6 @@ class TestPropertyClass(unittest.TestCase):
70
70
  cls._connection.clear_graph(Xsd_QName('test:onto'))
71
71
  file = project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
72
72
  cls._connection.upload_turtle(file)
73
- sleep(1) # upload may take a while...
74
73
  cls._project = Project.read(cls._connection, "test")
75
74
  cls._sysproject = Project.read(cls._connection, "oldap")
76
75
 
@@ -137,7 +137,7 @@ class TestResourceClass(unittest.TestCase):
137
137
 
138
138
  file = project_root / 'oldaplib' / 'testdata' / 'connection_test.trig'
139
139
  cls._connection.upload_turtle(file)
140
- sleep(1) # upload may take a while...
140
+
141
141
  cls._project = Project.read(cls._connection, "test")
142
142
  cls._sysproject = Project.read(cls._connection, "oldap", ignore_cache=True)
143
143
 
@@ -61,7 +61,6 @@ class TestUser(unittest.TestCase):
61
61
  cls._connection.upload_turtle(file)
62
62
  file = project_root / 'oldaplib' / 'ontologies' / 'admin-testing.trig'
63
63
  cls._connection.upload_turtle(file)
64
- sleep(1) # upload may take a while...
65
64
 
66
65
  def tearDown(self):
67
66
  pass
@@ -281,7 +281,7 @@ class TestXsdDatatypes(unittest.TestCase):
281
281
  self.assertEqual(hash(val1), hash(val2))
282
282
  with self.assertRaises(OldapErrorValue) as ex:
283
283
  val = Xsd_anyURI('waseliwas', validate=True)
284
- self.assertEqual(str(ex.exception), 'Invalid string "waseliwas" for anyURI')
284
+ self.assertEqual(str(ex.exception), 'Invalid string "waseliwas" for anyURI (no urn:/http:)')
285
285
 
286
286
  def test_xsd_base64binary(self):
287
287
  data = base64.b64encode(b'Waseliwas soll den das sein?')
@@ -1,6 +1,8 @@
1
+ @prefix http: <http://www.w3.org/2011/http#> .
1
2
  @prefix : <http://oldap.org/base#> .
2
3
  @prefix test: <http://oldap.org/test#> .
3
4
  @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
5
+ @prefix shared: <http://oldap.org/shared#> .
4
6
 
5
7
  test:data {
6
8
  <urn:uuid:7a1de6d7-de75-4875-ab24-74819057703f> a test:Book;
@@ -116,4 +118,20 @@ test:data {
116
118
  test:pageDescription "Description for page 4"@en;
117
119
  test:pageContent "Waseliwas for page 4\\n9pB6yFsJs7zcCkyF9j9flbGUcNczytEsw1nSUYCBLIN3P63wePvVQnWDX5dgUDXyeEwUwoBycRPcrp6kG2wsknVjfajQI30lZ73E";
118
120
  test:pageInBook <urn:uuid:9bf6ae23-bf2f-4466-abe3-65efe6afe589> .
121
+
122
+ <urn:uuid:1b8e3f42-6d7a-4c9b-a3f8-93c2e5d7b901> a shared:MediaObject;
123
+ :createdBy <https://orcid.org/0000-0003-1681-4036>;
124
+ :creationDate "2025-11-13T16:43:28.861171+01:00"^^xsd:dateTimeStamp;
125
+ :lastModifiedBy <https://orcid.org/0000-0003-1681-4036>;
126
+ :lastModificationDate "2025-11-13T16:43:28.861171+01:00"^^xsd:dateTimeStamp;
127
+ :grantsPermission :GenericView;
128
+ shared:originalName 'testfile.tif';
129
+ shared:originalMimeType 'image/tiff';
130
+ shared:serverUrl 'https://iiif.oldap.org';
131
+ shared:imageId 'x_34db.tif';
132
+ shared:protocol 'iiif';
133
+ shared:path 'test/subtest' .
134
+
135
+
136
+
119
137
  }