From 9f115c93fd8963464dc4280ecb839fb56980e3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Thu, 28 Mar 2024 08:57:06 +0200 Subject: [PATCH 1/4] Repository locations collected with more filtering and added elements. --- src/RecordManager/Base/Record/Lido.php | 35 ++++++++++++++++++- .../Base/Record/LidoTest.php | 32 ++++++++++++++--- tests/fixtures/Base/record/lido1.xml | 20 +++++++++++ 3 files changed, 82 insertions(+), 5 deletions(-) diff --git a/src/RecordManager/Base/Record/Lido.php b/src/RecordManager/Base/Record/Lido.php index 1f2ea175b..6945ee7c2 100644 --- a/src/RecordManager/Base/Record/Lido.php +++ b/src/RecordManager/Base/Record/Lido.php @@ -108,6 +108,20 @@ class Lido extends AbstractRecord */ protected $subjectConceptIDTypes = ['uri', 'url']; + /** + * Repository location types to be filtered. + * + * @var array + */ + protected $repositoryLocationTypes = ['Current location']; + + /** + * Excluded appellationValue labels. + * + * @var array + */ + protected $excludedAppellationValueLabels = ['tarkempi paikka']; + /** * Return record ID (local) * @@ -1320,9 +1334,28 @@ protected function getRepositoryLocations(): array $this->doc->lido->descriptiveMetadata->objectIdentificationWrap->repositoryWrap->repositorySet ?? [] as $set ) { + $type = (string)($set->attributes()->type ?? ''); + if (!in_array($type, $this->repositoryLocationTypes)) { + continue; + } foreach ($set->repositoryLocation->namePlaceSet ?? [] as $nameSet) { foreach ($nameSet->appellationValue ?? [] as $place) { - $result[] = (string)$place; + if ( + $place + && !in_array((string)$place->attributes()->label, $this->excludedAppellationValueLabels) + ) { + $result[] = trim((string)$place); + } + } + } + foreach ($set->repositoryLocation ?? [] as $location) { + foreach ($location->partOfPlace ?? [] as $part) { + while ($part->namePlaceSet ?? false) { + if ($partName = $part->namePlaceSet->appellationValue ?? '') { + $result[] = trim((string)$partName); + } + $part = $part->partOfPlace; + } } } } diff --git a/tests/RecordManagerTest/Base/Record/LidoTest.php b/tests/RecordManagerTest/Base/Record/LidoTest.php index 0dfb9dd68..ef386a46b 100644 --- a/tests/RecordManagerTest/Base/Record/LidoTest.php +++ b/tests/RecordManagerTest/Base/Record/LidoTest.php @@ -81,8 +81,16 @@ public function testLido1() 'ulkoilu', ], 'material_str_mv' => [], - 'geographic_facet' => [], - 'geographic' => [], + 'geographic_facet' => [ + 'Kalasatama', + 'Capellanranta 1 ja 3 välillä', + 'Helsinki', + ], + 'geographic' => [ + 'Kalasatama', + 'Capellanranta 1 ja 3 välillä', + 'Helsinki', + ], 'era' => [], 'era_facet' => [], 'collection' => '', @@ -108,6 +116,10 @@ public function testLido1() '9789518593731', '9789518593732', '0357-5284', + 'Tarkempi paikka veden äärellä', + 'Kalasatama', + 'Capellanranta 1 ja 3 välillä', + 'Helsinki', 'retkeily', 'ulkoilu', 'Luhtanen, Raimo', @@ -196,8 +208,16 @@ public function testLido1NonMergedTitle() 'ulkoilu', ], 'material_str_mv' => [], - 'geographic_facet' => [], - 'geographic' => [], + 'geographic_facet' => [ + 'Kalasatama', + 'Capellanranta 1 ja 3 välillä', + 'Helsinki', + ], + 'geographic' => [ + 'Kalasatama', + 'Capellanranta 1 ja 3 välillä', + 'Helsinki', + ], 'era' => [], 'era_facet' => [], 'collection' => '', @@ -223,6 +243,10 @@ public function testLido1NonMergedTitle() '9789518593731', '9789518593732', '0357-5284', + 'Tarkempi paikka veden äärellä', + 'Kalasatama', + 'Capellanranta 1 ja 3 välillä', + 'Helsinki', 'retkeily', 'ulkoilu', 'Luhtanen, Raimo', diff --git a/tests/fixtures/Base/record/lido1.xml b/tests/fixtures/Base/record/lido1.xml index 1538e5e6c..318c10f21 100644 --- a/tests/fixtures/Base/record/lido1.xml +++ b/tests/fixtures/Base/record/lido1.xml @@ -37,6 +37,26 @@ 0357-5284 + + + + Tarkempi paikka veden äärellä + + + Kalasatama + + + + Capellanranta 1 ja 3 välillä + + + + Helsinki + + + + + From b6a7a18dae6904288380aee683f750c089243a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Thu, 28 Mar 2024 09:21:45 +0200 Subject: [PATCH 2/4] Part of places also checked for excluded labels --- src/RecordManager/Base/Record/Lido.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/RecordManager/Base/Record/Lido.php b/src/RecordManager/Base/Record/Lido.php index 6945ee7c2..f94457e6c 100644 --- a/src/RecordManager/Base/Record/Lido.php +++ b/src/RecordManager/Base/Record/Lido.php @@ -1352,7 +1352,11 @@ protected function getRepositoryLocations(): array foreach ($location->partOfPlace ?? [] as $part) { while ($part->namePlaceSet ?? false) { if ($partName = $part->namePlaceSet->appellationValue ?? '') { - $result[] = trim((string)$partName); + if ( + !in_array((string)$partName->attributes()->label, $this->excludedAppellationValueLabels) + ) { + $result[] = trim((string)$partName); + } } $part = $part->partOfPlace; } From 3fc7f2c7f7e4d0fbf6c8f2ef6226126ae520f082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 5 Apr 2024 14:18:53 +0300 Subject: [PATCH 3/4] Variable arrays defined in subclass and tests moved as well. --- src/RecordManager/Base/Record/Lido.php | 17 ++++++---- .../Base/Record/LidoTest.php | 32 +++---------------- tests/fixtures/Base/record/lido1.xml | 20 ------------ 3 files changed, 14 insertions(+), 55 deletions(-) diff --git a/src/RecordManager/Base/Record/Lido.php b/src/RecordManager/Base/Record/Lido.php index f94457e6c..61ba94e3c 100644 --- a/src/RecordManager/Base/Record/Lido.php +++ b/src/RecordManager/Base/Record/Lido.php @@ -109,18 +109,18 @@ class Lido extends AbstractRecord protected $subjectConceptIDTypes = ['uri', 'url']; /** - * Repository location types to be filtered. + * Repository location types to be included. * * @var array */ - protected $repositoryLocationTypes = ['Current location']; + protected $repositoryLocationTypes = []; /** - * Excluded appellationValue labels. + * Excluded location appellationValue labels. * * @var array */ - protected $excludedAppellationValueLabels = ['tarkempi paikka']; + protected $excludedLocationAppellationValueLabels = []; /** * Return record ID (local) @@ -1335,14 +1335,14 @@ protected function getRepositoryLocations(): array ?? [] as $set ) { $type = (string)($set->attributes()->type ?? ''); - if (!in_array($type, $this->repositoryLocationTypes)) { + if (!empty($this->repositoryLocationTypes) && !in_array($type, $this->repositoryLocationTypes)) { continue; } foreach ($set->repositoryLocation->namePlaceSet ?? [] as $nameSet) { foreach ($nameSet->appellationValue ?? [] as $place) { if ( $place - && !in_array((string)$place->attributes()->label, $this->excludedAppellationValueLabels) + && !in_array((string)$place->attributes()->label, $this->excludedLocationAppellationValueLabels) ) { $result[] = trim((string)$place); } @@ -1353,7 +1353,10 @@ protected function getRepositoryLocations(): array while ($part->namePlaceSet ?? false) { if ($partName = $part->namePlaceSet->appellationValue ?? '') { if ( - !in_array((string)$partName->attributes()->label, $this->excludedAppellationValueLabels) + !in_array( + (string)$partName->attributes()->label, + $this->excludedLocationAppellationValueLabels + ) ) { $result[] = trim((string)$partName); } diff --git a/tests/RecordManagerTest/Base/Record/LidoTest.php b/tests/RecordManagerTest/Base/Record/LidoTest.php index ef386a46b..0dfb9dd68 100644 --- a/tests/RecordManagerTest/Base/Record/LidoTest.php +++ b/tests/RecordManagerTest/Base/Record/LidoTest.php @@ -81,16 +81,8 @@ public function testLido1() 'ulkoilu', ], 'material_str_mv' => [], - 'geographic_facet' => [ - 'Kalasatama', - 'Capellanranta 1 ja 3 välillä', - 'Helsinki', - ], - 'geographic' => [ - 'Kalasatama', - 'Capellanranta 1 ja 3 välillä', - 'Helsinki', - ], + 'geographic_facet' => [], + 'geographic' => [], 'era' => [], 'era_facet' => [], 'collection' => '', @@ -116,10 +108,6 @@ public function testLido1() '9789518593731', '9789518593732', '0357-5284', - 'Tarkempi paikka veden äärellä', - 'Kalasatama', - 'Capellanranta 1 ja 3 välillä', - 'Helsinki', 'retkeily', 'ulkoilu', 'Luhtanen, Raimo', @@ -208,16 +196,8 @@ public function testLido1NonMergedTitle() 'ulkoilu', ], 'material_str_mv' => [], - 'geographic_facet' => [ - 'Kalasatama', - 'Capellanranta 1 ja 3 välillä', - 'Helsinki', - ], - 'geographic' => [ - 'Kalasatama', - 'Capellanranta 1 ja 3 välillä', - 'Helsinki', - ], + 'geographic_facet' => [], + 'geographic' => [], 'era' => [], 'era_facet' => [], 'collection' => '', @@ -243,10 +223,6 @@ public function testLido1NonMergedTitle() '9789518593731', '9789518593732', '0357-5284', - 'Tarkempi paikka veden äärellä', - 'Kalasatama', - 'Capellanranta 1 ja 3 välillä', - 'Helsinki', 'retkeily', 'ulkoilu', 'Luhtanen, Raimo', diff --git a/tests/fixtures/Base/record/lido1.xml b/tests/fixtures/Base/record/lido1.xml index 318c10f21..1538e5e6c 100644 --- a/tests/fixtures/Base/record/lido1.xml +++ b/tests/fixtures/Base/record/lido1.xml @@ -37,26 +37,6 @@ 0357-5284 - - - - Tarkempi paikka veden äärellä - - - Kalasatama - - - - Capellanranta 1 ja 3 välillä - - - - Helsinki - - - - - From 252d7e61261d881d52f7d01ad39b452c5da5446a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Mon, 15 Apr 2024 08:19:23 +0300 Subject: [PATCH 4/4] Tweaks to conditions. --- src/RecordManager/Base/Record/Lido.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/RecordManager/Base/Record/Lido.php b/src/RecordManager/Base/Record/Lido.php index 61ba94e3c..c0bf5a350 100644 --- a/src/RecordManager/Base/Record/Lido.php +++ b/src/RecordManager/Base/Record/Lido.php @@ -1335,7 +1335,7 @@ protected function getRepositoryLocations(): array ?? [] as $set ) { $type = (string)($set->attributes()->type ?? ''); - if (!empty($this->repositoryLocationTypes) && !in_array($type, $this->repositoryLocationTypes)) { + if ($this->repositoryLocationTypes && !in_array($type, $this->repositoryLocationTypes)) { continue; } foreach ($set->repositoryLocation->namePlaceSet ?? [] as $nameSet) { @@ -1350,8 +1350,8 @@ protected function getRepositoryLocations(): array } foreach ($set->repositoryLocation ?? [] as $location) { foreach ($location->partOfPlace ?? [] as $part) { - while ($part->namePlaceSet ?? false) { - if ($partName = $part->namePlaceSet->appellationValue ?? '') { + while ($part->namePlaceSet) { + if ($partName = $part->namePlaceSet->appellationValue ?? null) { if ( !in_array( (string)$partName->attributes()->label,