From 36e17600f211da4b1462145d348aeea201a01081 Mon Sep 17 00:00:00 2001 From: mshroom <32199029+mshroom@users.noreply.github.com> Date: Fri, 11 Sep 2026 13:34:27 +0300 Subject: [PATCH] Improve compatibility with FINNA LIDO profile v1.0 --- src/RecordManager/Finna/Record/Lido.php | 31 +++++++++++++------ .../Finna/Record/LidoTest.php | 8 +++-- tests/fixtures/Finna/record/musketti1.xml | 10 ++++++ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/RecordManager/Finna/Record/Lido.php b/src/RecordManager/Finna/Record/Lido.php index dc08897b..242d0569 100644 --- a/src/RecordManager/Finna/Record/Lido.php +++ b/src/RecordManager/Finna/Record/Lido.php @@ -119,7 +119,7 @@ class Lido extends \RecordManager\Base\Record\Lido * * @var array */ - protected $relatedISBNRelationTypes = ['is reproduced in', 'julkaisu']; + protected $relatedISBNRelationTypes = ['is reproduced in', 'on toisinnettu', 'julkaisu']; /** * Description types to exclude from title @@ -128,6 +128,13 @@ class Lido extends \RecordManager\Base\Record\Lido */ protected $descriptionTypesExcludedFromTitle = ['provenance', 'provenienssi']; + /** + * Subject conceptID types included in topic identifiers (all lowercase). + * + * @var array + */ + protected $subjectConceptIDTypes = ['uri', 'url', 'http://terminology.lido-schema.org/lido00099']; + /** * Title types for preferred titles. * @@ -996,10 +1003,8 @@ protected function getUsageRights() $result = []; $path = 'lido/administrativeMetadata/resourceWrap/resourceSet'; foreach ($this->xmlDoc->all(path: $path) as $set) { - if (null !== ($value = $this->xmlDoc->firstValue($set, 'rightsResource/rightsType/conceptID'))) { - $result[] = $value; - } else { - $result[] = 'restricted'; + foreach ($this->xmlDoc->all($set, path: 'rightsResource/rightsType') as $rightsType) { + $result[] = ('' !== $value = $this->getFirstConceptIdentifier($rightsType)) ? $value : 'restricted'; } } return $result; @@ -2112,8 +2117,7 @@ protected function getRelatedWorks($relatedWorkRelType) } /** - * Return the object measurements. Only the display element is used currently - * until processing more granular data is needed. + * Return the object measurements. * * @link http://www.lido-schema.org/schema/v1.0/lido-v1.0-schema-listing.html * #objectMeasurementsSetComplexType @@ -2125,17 +2129,24 @@ protected function getMeasurements() $path = 'lido/descriptiveMetadata/objectIdentificationWrap/objectMeasurementsWrap/objectMeasurementsSet'; foreach ($this->xmlDoc->all(path: $path) as $set) { $setResults = $this->xmlDoc->allValues($set, 'displayObjectMeasurements'); - // Use measurementsSet if there's no displayMeasurements: + // Use measurementsSet if there's no displayMeasurements. + // Support both simple text and term element in measurementType and measurementUnit. if (!$setResults) { foreach ($this->xmlDoc->all($set, 'objectMeasurements/measurementsSet') as $measurements) { $parts = []; - if ('' !== ($type = $this->xmlDoc->firstValue($measurements, 'measurementType') ?? '')) { + $type = $this->xmlDoc->firstValue($measurements, 'measurementType/term') + ?? $this->xmlDoc->firstValue($measurements, 'measurementType') + ?? ''; + if ('' !== $type) { $parts[] = $type; } if ('' !== ($val = $this->xmlDoc->firstValue($measurements, 'measurementValue') ?? '')) { $parts[] = $val; } - if ('' !== ($unit = $this->xmlDoc->firstValue($measurements, 'measurementUnit') ?? '')) { + $unit = $this->xmlDoc->firstValue($measurements, 'measurementUnit/term') + ?? $this->xmlDoc->firstValue($measurements, 'measurementUnit') + ?? ''; + if ('' !== $unit) { $parts[] = $unit; } if ($parts) { diff --git a/tests/RecordManagerTest/Finna/Record/LidoTest.php b/tests/RecordManagerTest/Finna/Record/LidoTest.php index 175b7069..39988cfd 100644 --- a/tests/RecordManagerTest/Finna/Record/LidoTest.php +++ b/tests/RecordManagerTest/Finna/Record/LidoTest.php @@ -85,6 +85,8 @@ public function testMusketti1() $this->assertContains('pannut', $fields['topic']); $this->assertContains('kahvipannut', $fields['topic']); $this->assertContains('Toimija, Toini', $fields['topic']); + $this->assertContains('http://www.yso.fi/onto/yso/p4847', $fields['topic_id_str_mv']); + $this->assertContains('http://www.yso.fi/onto/yso/p4277', $fields['topic_id_str_mv']); $this->assertEquals('kahvipannu', $fields['title']); @@ -120,6 +122,8 @@ public function testMusketti1() $this->assertContains('teollinen tuote', $fields['allfields']); $this->assertContains('Museovirasto/MV', $fields['allfields']); $this->assertEquals(['image/jpeg'], $fields['media_type_str_mv']); + $this->assertContains('Undefined rights', $fields['usage_rights_str_mv']); + $this->assertContains('https://rightsstatements.org/vocab/InC/1.0/', $fields['usage_rights_str_mv']); } /** @@ -317,10 +321,10 @@ public function testMusketti2() 'free_online_str_mv' => '__unit_test_no_source__', 'location_geo' => [], 'usage_rights_str_mv' => [ - '', + 'restricted', ], 'usage_rights_ext_str_mv' => [ - '', + 'restricted', ], 'author_facet' => [ 'Testaaja, Taavi', diff --git a/tests/fixtures/Finna/record/musketti1.xml b/tests/fixtures/Finna/record/musketti1.xml index 754e7642..f98bb48e 100644 --- a/tests/fixtures/Finna/record/musketti1.xml +++ b/tests/fixtures/Finna/record/musketti1.xml @@ -117,12 +117,15 @@ taloustarvikkeet + http://www.yso.fi/onto/yso/p4847 nautintoaineet + kahvi + 0000 suomalais-ugrilaiset kansat @@ -201,6 +204,13 @@ + + + + + + +