Skip to content

Commit

Permalink
Doorkeeper::checkPropertyRangeUri(): if an object value can be resolv…
Browse files Browse the repository at this point in the history
…ed, assure it is normalized
  • Loading branch information
zozlak committed Jun 28, 2024
1 parent 688b9a3 commit f2d7523
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/acdhOeaw/arche/doorkeeper/Doorkeeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ static private function checkPropertyRangeUri(DatasetNodeInterface $meta,
try {
$norm->resolve((string) $obj);
RC::$log->debug("\t\t$prop value $obj resolved successfully");

$objNorm = $norm->normalize((string) $obj);
if ($objNorm !== (string) $obj) {
$objNorm = DF::namedNode($objNorm);
$meta->forEach(fn($q) => $q->withObject($objNorm), new PT($prop, $obj));
}
} catch (UriNormalizerException $ex) {
throw new DoorkeeperException($ex->getMessage(), $ex->getCode(), $ex);
}
Expand Down
18 changes: 18 additions & 0 deletions tests/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use termTemplates\NamedNodeTemplate as NNT;
use acdhOeaw\arche\lib\RepoResource;
use acdhOeaw\arche\lib\BinaryPayload;
use acdhOeaw\arche\lib\exception\NotFound;

/**
* Description of DoorkeeperTest
Expand Down Expand Up @@ -964,6 +965,23 @@ public function testTechnicalProperty(): void {
}
self::$repo->rollback();
}

public function testNormalizeObjectValue(): void {
$prop = 'https://vocabs.acdh.oeaw.ac.at/schema#hasActor';
$value = 'https://orcid.org/0000-0001-5853-2534/';
$class = DF::namedNode('https://vocabs.acdh.oeaw.ac.at/schema#Collection');
$meta = self::createMetadata([$prop => $value], $class);
self::$repo->begin();
$res = self::$repo->createResource($meta);
$ref = self::$repo->getResourceById(substr($value, 0, -1)); // normalized form
try {
self::$repo->getResourceById($value);
$this->assertTrue(false);
} catch (NotFound $ex) {
$this->assertTrue(true);
}
self::$repo->rollback();
}
// public function testRangeUri(): void {
// \acdhOeaw\arche\lib\ingest\MetadataCollection::$debug = true;
// $graph = new \acdhOeaw\arche\lib\ingest\MetadataCollection(self::$repo, __DIR__ . '/kraus_processed.nt');
Expand Down

0 comments on commit f2d7523

Please sign in to comment.