Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/RecordManager/Finna/Record/AuthoritySupportTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ function ($id) use ($type) {
$ns = $this->getAuthorityNamespace($type);
$result = [];
foreach ($ids as $id) {
// Normalize ISNI URIs to match ISNI identifiers in authority sources
if (preg_match('/^https:\/\/isni\.org\/isni\/(.*)/', $id, $matches)) {
$result[] = '(isni)' . $matches[1];
continue;
}
// Never prefix other http(s) url's
if (preg_match('/^https?:/', $id)) {
// Never prefix http(s) url's
$result[] = $id;
continue;
}
Expand Down
31 changes: 29 additions & 2 deletions src/RecordManager/Finna/Record/Lido.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ public function toSolrArray(?Database $db = null)
'author'
);
$data['author2_id_role_str_mv'] = $this->addNamespaceToAuthorityIds($this->getAllAuthorIdsAndRoles(), 'author');
// Add values with namespaces also to allfields
$data['allfields'] = [
...$data['allfields'],
...$data['topic_id_str_mv'],
...$data['geographic_id_str_mv'],
...$data['author2_id_str_mv'],
];
$data['language'] = $this->getLanguages();
// do not index online urls as they display extra information in Finna
$onlineUrls = $this->getOnlineUrls();
Expand Down Expand Up @@ -473,7 +480,7 @@ public function getMainAuthor()
*/
public function getRawTopicIds(): array
{
return parent::getTopicIDs();
return array_filter(array_unique([...parent::getTopicIDs(), ...$this->getSubjectActorIds()]));
}

/**
Expand Down Expand Up @@ -585,6 +592,26 @@ protected function getAllAuthorIdsAndRoles(): array
return $results;
}

/**
* Get subject actor ids
*
* @return array<int, string>
*/
protected function getSubjectActorIds(): array
{
$result = [];
foreach ($this->getSubjectNodes() as $subject) {
foreach ($subject->subjectActor as $subjectActor) {
foreach ($subjectActor->actor->actorID ?? [] as $actorID) {
if ($id = trim((string)$actorID)) {
$result[] = $id;
}
}
}
}
return array_values(array_unique($result));
}

/**
* Process an array of placeID elements
*
Expand Down Expand Up @@ -922,7 +949,7 @@ protected function getUsageRights()
*/
protected function getTopicIDs($exclude = ['iconclass']): array
{
$result = parent::getTopicIDs($exclude);
$result = [...parent::getTopicIDs($exclude), ...$this->getSubjectActorIds()];
return $this->addNamespaceToAuthorityIds($result, 'topic');
}

Expand Down
10 changes: 10 additions & 0 deletions tests/RecordManagerTest/Finna/Record/LidoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ public function testMusketti2()
'author2' => [],
'author2_id_str_mv' => [
'http://urn.fi/URN:NBN:fi:au:finaf:000173713',
'(isni)0000000073500621',
],
'author2_id_role_str_mv' => [
'http://urn.fi/URN:NBN:fi:au:finaf:000173713###kuvaaja',
'http://urn.fi/URN:NBN:fi:au:finaf:000173713###kehittäjä',
'(isni)0000000073500621###kuvaaja',
'(isni)0000000073500621###kehittäjä',
],
'topic_facet' => [],
'topic' => [],
Expand Down Expand Up @@ -217,6 +220,7 @@ public function testMusketti2()
'Helsinki',
'valmistus',
'http://urn.fi/URN:NBN:fi:au:finaf:000173713',
'https://isni.org/isni/0000000073500621',
'Hintze Harry',
'1897',
'1897',
Expand All @@ -240,6 +244,12 @@ public function testMusketti2()
'Museovirasto/MV',
'Kansatieteen kuvakokoelma',
'Museovirasto/MV',
'(prt)Prt',
'(prt)Prt 2',
'(kiinteistötunnus)Kiinteistötunnus',
'http://www.yso.fi/onto/yso/p94413',
'http://urn.fi/URN:NBN:fi:au:finaf:000173713',
'(isni)0000000073500621',
],
'identifier' => '4878:1',
'measurements' => [
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/Finna/record/musketti2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<actorInRole>
<actor>
<actorID type="URI" source="finaf">http://urn.fi/URN:NBN:fi:au:finaf:000173713</actorID>
<actorID type="URI" source="ISNI">https://isni.org/isni/0000000073500621</actorID>
<nameActorSet>
<appellationValue>Hintze Harry</appellationValue>
</nameActorSet>
Expand Down