diff --git a/src/RecordManager/Finna/Record/Ead3.php b/src/RecordManager/Finna/Record/Ead3.php
index ec13e9f3..fddff610 100644
--- a/src/RecordManager/Finna/Record/Ead3.php
+++ b/src/RecordManager/Finna/Record/Ead3.php
@@ -197,7 +197,6 @@ public function toSolrArray(?Database $db = null)
}
$data['author_variant'] = $this->getAuthorVariants();
- $data['author2'] = $this->getSecondaryAuthors();
$data['author_facet'] = $this->createAuthorFacetArray($data);
$data['author2_id_str_mv']
@@ -394,6 +393,95 @@ public function getCorporateAuthorIds(): array
return array_values(array_unique($results));
}
+ /**
+ * Return record title in English
+ *
+ * @return string
+ */
+ protected function getTitleEn(): string
+ {
+ return $this->getTitleByLanguage(false, 'en');
+ }
+
+ /**
+ * Return record title in Finnish
+ *
+ * @return string
+ */
+ protected function getTitleFi(): string
+ {
+ return $this->getTitleByLanguage(false, 'fi');
+ }
+
+ /**
+ * Return record title in Northern Sami
+ *
+ * @return string
+ */
+ protected function getTitleSe(): string
+ {
+ return $this->getTitleByLanguage(false, 'se');
+ }
+
+ /**
+ * Return record title in Swedish
+ *
+ * @return string
+ */
+ protected function getTitleSv(): string
+ {
+ return $this->getTitleByLanguage(false, 'sv');
+ }
+
+ /**
+ * Get alternate titles
+ *
+ * @return array
+ */
+ protected function getAltTitles()
+ {
+ return array_unique(
+ array_filter([$this->getTitleFi(), $this->getTitleSv(), $this->getTitleEn(), $this->getTitleSe()])
+ );
+ }
+
+ /**
+ * Add hierarchy titles.
+ *
+ * @param array $data Reference to the target array
+ * @param string $sequenceUnitId Id to be added
+ *
+ * @return void
+ */
+ protected function addHierarchyTitles(array &$data, string $sequenceUnitId): void
+ {
+ // Note: title_in_hierarchy is only needed if it differs from title.
+ if ($this->getDriverParam('addIdToHierarchyTitle', true)) {
+ $data['title_in_hierarchy'] = trim("$sequenceUnitId " . $data['title']);
+ foreach (['fi', 'sv', 'en', 'se'] as $language) {
+ if ('' !== ($langTitle = $data['title_' . $language . '_txt'] ?? '')) {
+ $data['title_in_hierarchy_' . $language . '_str'] = trim("$sequenceUnitId $langTitle");
+ }
+ }
+ }
+ }
+
+ /**
+ * Add additional titles.
+ *
+ * @param array $data Reference to the target array
+ *
+ * @return void
+ */
+ protected function addAdditionalTitles(array &$data): void
+ {
+ // Language specific title fields
+ $data['title_en_txt'] = $this->getTitleEn();
+ $data['title_fi_txt'] = $this->getTitleFi();
+ $data['title_se_txt'] = $this->getTitleSe();
+ $data['title_sv_txt'] = $this->getTitleSv();
+ }
+
/**
* Enrich titles with year ranges.
*
@@ -420,50 +508,65 @@ protected function enrichTitlesWithYearRanges(
'enrichTitleWithYearRange',
'no_match_exists'
);
- if ('never' === $type) {
+ if ('never' === $type || $unitDateRange['startDateUnknown']) {
return $data;
}
- if (!$unitDateRange['startDateUnknown']) {
- $range = $unitDateRange['date'];
- $startYear
- = $this->metadataUtils->extractYear($range[0]);
- $endYear = $this->metadataUtils->extractYear($range[1]);
- $yearRange[] = $startYear !== '-9999' ? $startYear : '';
- $yearRange[] = $endYear !== '9999' ? $endYear : '';
- $ndash = html_entity_decode('–', ENT_NOQUOTES, 'UTF-8');
- $yearRangeStr = trim(implode($ndash, array_unique($yearRange)));
- if (!$yearRangeStr) {
- return $data;
- }
- // Append with LTR mark first to ensure correct text direction
- $yearRangeStr = "\u{200E} ($yearRangeStr)";
- foreach (
- ['title_full', 'title_sort', 'title', 'title_short'] as $field
- ) {
- $yearsFound = $this->getYearsFromString($data[$field]);
- switch ($type) {
- case 'always':
- $data[$field] .= $yearRangeStr;
- break;
- case 'no_year_exists':
- if (!$yearsFound) {
- $data[$field] .= $yearRangeStr;
- }
- break;
- case 'no_match_exists':
- if (!array_intersect($yearRange, $yearsFound)) {
- $data[$field] .= $yearRangeStr;
- }
- break;
- case 'no_matches_exist':
- $yearRange = array_filter(array_unique($yearRange));
- if (array_intersect($yearRange, $yearsFound) !== $yearRange) {
- $data[$field] .= $yearRangeStr;
- }
- break;
+ $range = $unitDateRange['date'];
+ $startYear
+ = $this->metadataUtils->extractYear($range[0]);
+ $endYear = $this->metadataUtils->extractYear($range[1]);
+ $yearRange[] = $startYear !== '-9999' ? $startYear : '';
+ $yearRange[] = $endYear !== '9999' ? $endYear : '';
+ $ndash = html_entity_decode('–', ENT_NOQUOTES, 'UTF-8');
+ $yearRangeStr = trim(implode($ndash, array_unique($yearRange)));
+ if (!$yearRangeStr) {
+ return $data;
+ }
+ // Append with LTR mark first to ensure correct text direction
+ $yearRangeStr = "\u{200E} ($yearRangeStr)";
+
+ $appendYear = function (string $title) use ($type, $yearRangeStr, $yearRange): string {
+ if ('' === $title) {
+ return $title;
+ }
+ $yearsFound = $this->getYearsFromString($title);
+ if ($type === 'always') {
+ return $title .= $yearRangeStr;
+ } elseif ($type === 'no_year_exists') {
+ if (!$yearsFound) {
+ return $title .= $yearRangeStr;
+ }
+ } elseif ($type === 'no_match_exists') {
+ if (!array_intersect($yearRange, $yearsFound)) {
+ return $title .= $yearRangeStr;
+ }
+ } elseif ($type === 'no_matches_exist') {
+ $yearRange = array_filter(array_unique($yearRange));
+ if (array_intersect($yearRange, $yearsFound) !== $yearRange) {
+ return $title .= $yearRangeStr;
}
}
+ return $title;
+ };
+
+ foreach (
+ [
+ 'title_full',
+ 'title_sort',
+ 'title',
+ 'title_en_txt',
+ 'title_fi_txt',
+ 'title_se_txt',
+ 'title_sv_txt',
+ 'title_short',
+ ] as $field
+ ) {
+ $data[$field] = $data[$field] ? $appendYear($data[$field]) : '';
}
+ $data['title_alt'] = array_map(
+ $appendYear,
+ $data['title_alt'] ?? []
+ );
return $data;
}
diff --git a/src/RecordManager/Finna/Record/Lido.php b/src/RecordManager/Finna/Record/Lido.php
index c08767a7..0afa039a 100644
--- a/src/RecordManager/Finna/Record/Lido.php
+++ b/src/RecordManager/Finna/Record/Lido.php
@@ -165,6 +165,17 @@ class Lido extends \RecordManager\Base\Record\Lido
'kiinteistörekisteri' => 'kiinteistötunnus',
];
+ /**
+ * Hierarchy fields included in allfields.
+ *
+ * @var array
+ */
+ protected $hierarchyFieldsInAllFields = [
+ 'is_hierarchy_title', 'hierarchy_parent_title', 'hierarchy_top_title', 'title_in_hierarchy',
+ 'title_in_hierarchy_en_str_', 'title_in_hierarchy_fi_str', 'title_in_hierarchy_se_str',
+ 'title_in_hierarchy_sv_str',
+ ];
+
/**
* Constructor
*
@@ -555,6 +566,46 @@ public function getRelatedISBNs(): array
return array_unique($results);
}
+ /**
+ * Return record title in English
+ *
+ * @return string
+ */
+ protected function getTitleEn(): string
+ {
+ return $this->getTitles('en')['preferred'];
+ }
+
+ /**
+ * Return record title in Finnish
+ *
+ * @return string
+ */
+ protected function getTitleFi(): string
+ {
+ return $this->getTitles('fi')['preferred'];
+ }
+
+ /**
+ * Return record title in Northern Sami
+ *
+ * @return string
+ */
+ protected function getTitleSe(): string
+ {
+ return $this->getTitles('se')['preferred'];
+ }
+
+ /**
+ * Return record title in Swedish
+ *
+ * @return string
+ */
+ protected function getTitleSv(): string
+ {
+ return $this->getTitles('sv')['preferred'];
+ }
+
/**
* Get all author ids and roles
*
@@ -2197,6 +2248,7 @@ protected function getSecondaryAuthors(): array
*/
protected function addHierarchyFields(array &$data): void
{
+ parent::addHierarchyFields($data);
// Add additional related work titles
if ($furtherTitles = $this->getRelatedWorks($this->relatedWorkRelationTypesExtended)) {
// Check that number of indexed parent titles and ids match
@@ -2210,9 +2262,47 @@ protected function addHierarchyFields(array &$data): void
...(array)($data['hierarchy_parent_title'] ?? []),
...$furtherTitles,
];
+ $data['allfields'] = [
+ ...(array)($data['allfields'] ?? []),
+ ...$furtherTitles,
+ ];
}
+ }
- parent::addHierarchyFields($data);
+ /**
+ * Add hierarchy titles.
+ *
+ * @param array $data Reference to the target array
+ *
+ * @return void
+ */
+ protected function addHierarchyTitles(array &$data): void
+ {
+ // Note: title_in_hierarchy is only needed if it differs from title.
+ if ($this->getDriverParam('addIdToHierarchyTitle', true)) {
+ $data['title_in_hierarchy'] = trim($this->getIdentifier() . ' ' . $data['title']);
+ foreach (['fi', 'sv', 'en', 'se'] as $language) {
+ if ('' !== ($langTitle = $data['title_' . $language . '_txt'] ?? '')) {
+ $data['title_in_hierarchy_' . $language . '_str'] = trim($this->getIdentifier() . ' ' . $langTitle);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add additional titles.
+ *
+ * @param array $data Reference to the target array
+ *
+ * @return void
+ */
+ protected function addAdditionalTitles(array &$data): void
+ {
+ // Language specific title fields
+ $data['title_en_txt'] = $this->getTitleEn();
+ $data['title_fi_txt'] = $this->getTitleFi();
+ $data['title_se_txt'] = $this->getTitleSe();
+ $data['title_sv_txt'] = $this->getTitleSv();
}
/**
diff --git a/src/RecordManager/Finna/Record/Lrmi.php b/src/RecordManager/Finna/Record/Lrmi.php
index aca42957..03c656eb 100644
--- a/src/RecordManager/Finna/Record/Lrmi.php
+++ b/src/RecordManager/Finna/Record/Lrmi.php
@@ -179,18 +179,7 @@ public function getOnlineUrls(): array
*/
public function getTitle($forFiling = false)
{
- $doc = $this->doc;
- $title = (string)$doc->title;
- foreach ($doc->title as $t) {
- if ((string)$t->attributes()->lang === 'fi') {
- $title = (string)$t;
- break;
- }
- }
- if ($forFiling) {
- $title = $this->metadataUtils->createSortTitle($title);
- }
- return $title;
+ return $this->getTitleByLanguage($forFiling, 'fi') ?: $this->getTitleByLanguage($forFiling);
}
/**
diff --git a/src/RecordManager/Finna/Record/QdcRecordTrait.php b/src/RecordManager/Finna/Record/QdcRecordTrait.php
index 9dcd0f85..20c7c57e 100644
--- a/src/RecordManager/Finna/Record/QdcRecordTrait.php
+++ b/src/RecordManager/Finna/Record/QdcRecordTrait.php
@@ -159,7 +159,11 @@ public function toSolrArray(?Database $db = null)
...$originalIds,
];
}
-
+ // Language specific title fields
+ $data['title_en_txt'] = $this->getTitleEn();
+ $data['title_fi_txt'] = $this->getTitleFi();
+ $data['title_se_txt'] = $this->getTitleSe();
+ $data['title_sv_txt'] = $this->getTitleSv();
return $data;
}
@@ -183,6 +187,46 @@ public function getLocations(): array
];
}
+ /**
+ * Return record title in English
+ *
+ * @return string
+ */
+ protected function getTitleEn(): string
+ {
+ return $this->getTitleByLanguage(false, 'en');
+ }
+
+ /**
+ * Return record title in Finnish
+ *
+ * @return string
+ */
+ protected function getTitleFi(): string
+ {
+ return $this->getTitleByLanguage(false, 'fi');
+ }
+
+ /**
+ * Return record title in Northern Sami
+ *
+ * @return string
+ */
+ protected function getTitleSe(): string
+ {
+ return $this->getTitleByLanguage(false, 'se');
+ }
+
+ /**
+ * Return record title in Swedish
+ *
+ * @return string
+ */
+ protected function getTitleSv(): string
+ {
+ return $this->getTitleByLanguage(false, 'sv');
+ }
+
/**
* Get resource identifiers, used for identifier_txtP_mv and file_identifier_string_mv
*
diff --git a/src/RecordManager/Finna/Splitter/Ead3.php b/src/RecordManager/Finna/Splitter/Ead3.php
index aa8e677e..b836354e 100644
--- a/src/RecordManager/Finna/Splitter/Ead3.php
+++ b/src/RecordManager/Finna/Splitter/Ead3.php
@@ -154,4 +154,76 @@ protected function addAdditionalData(&$record, &$original): void
parent::addAdditionalData($record, $original);
$record->{'add-data'}->archive->addAttribute('type', $this->archiveType);
}
+
+ /**
+ * Add title attributes to the element
+ *
+ * @param \SimpleXMLElement $element Element
+ * @param array $titles Title values
+ *
+ * @return void
+ */
+ protected function addTitleAttributes(\SimpleXMLElement $element, array $titles): void
+ {
+ $element->addAttribute('title', $titles['title']);
+ foreach (['en', 'fi', 'se', 'sv'] as $lang) {
+ if ($titles['title_' . $lang] ?? '') {
+ $element->addAttribute('title_' . $lang, $titles['title_' . $lang]);
+ }
+ }
+ }
+
+ /**
+ * Get Parent titles as an array
+ *
+ * @param \SimpleXMLElement $parentDid Parent did element
+ * @param string $parentID Parent ID to use as fallback
+ *
+ * @return array
+ */
+ protected function getParentTitles(\SimpleXMLElement $parentDid, string $parentID): array
+ {
+ $parentTitle = '';
+ $langTitles = [];
+ foreach ($parentDid->unittitle ?? [] as $unittitle) {
+ $title = (string)$unittitle ?: ((string)($unittitle->attributes()->label ?? $parentID));
+ if ($this->prependParentTitleWithUnitId && ($pid = $this->getParentUnitId($parentDid))) {
+ $title = $pid . ' ' . $title;
+ }
+ $parentTitle = $parentTitle ?: $title;
+ if ($language = $this->metadataUtils->normalizeLanguageCode($unittitle->attributes()->lang ?? '')) {
+ $langTitles[$language] ??= $title;
+ }
+ }
+ $titles = ['title' => $parentTitle];
+ foreach (['en', 'fi', 'se', 'sv'] as $lang) {
+ if ($langTitles[$lang] ?? '') {
+ $titles['title_' . $lang] = $langTitles[$lang];
+ }
+ }
+ return $titles;
+ }
+
+ /**
+ * Get Archive titles as an array
+ *
+ * @return array
+ */
+ protected function getArchiveTitles(): array
+ {
+ $langTitles = [];
+ foreach ($this->doc->archdesc->did->unittitle ?? [] as $title) {
+ if ($language = $this->metadataUtils->normalizeLanguageCode($title->attributes()->lang ?? '')) {
+ $langTitles[$language] ??= (string)$title;
+ }
+ }
+
+ $titles = ['title' => $this->archiveTitle];
+ foreach (['en', 'fi', 'se', 'sv'] as $lang) {
+ if ($langTitles[$lang] ?? '') {
+ $titles['title_' . $lang] = $langTitles[$lang];
+ }
+ }
+ return $titles;
+ }
}
diff --git a/tests/RecordManagerTest/Finna/Record/Ead3Test.php b/tests/RecordManagerTest/Finna/Record/Ead3Test.php
index 187896bf..38d173d1 100644
--- a/tests/RecordManagerTest/Finna/Record/Ead3Test.php
+++ b/tests/RecordManagerTest/Finna/Record/Ead3Test.php
@@ -568,7 +568,11 @@ public static function sksProvider(): array
return [
'addIdToHierarchyTitle=true' => [
'true',
- '1 1 Sundvall Gustaf Edvard S 1:a) 1',
+ [
+ 'no_lang' => '1 1 Sundvall Gustaf Edvard S 1:a) 1',
+ 'fi' => '1 1 Sundvall Gustaf Edvard S 1:a) 1',
+ 'sv' => '1 1 Sundvall Gustaf Edvard S 1:a) 1 swe',
+ ],
],
'addIdToHierarchyTitle=false' => [
'false',
@@ -580,13 +584,13 @@ public static function sksProvider(): array
/**
* Test SKS EAD3 record handling
*
- * @param string $addIdToHierarchyTitle Value for addIdToHierarchyTitle driver param
- * @param ?string $expectedTitleInHierarchy Expected title_in_hierarchy field contents
+ * @param string $addIdToHierarchyTitle Value for addIdToHierarchyTitle driver param
+ * @param ?array $expectedTitleInHierarchy Expected title_in_hierarchy field contents
*
* @return void
*/
#[\PHPUnit\Framework\Attributes\DataProvider('sksProvider')]
- public function testSKS(string $addIdToHierarchyTitle, ?string $expectedTitleInHierarchy): void
+ public function testSKS(string $addIdToHierarchyTitle, ?array $expectedTitleInHierarchy): void
{
$fields = $this->createRecord(
Ead3::class,
@@ -598,7 +602,17 @@ public function testSKS(string $addIdToHierarchyTitle, ?string $expectedTitleInH
],
],
],
- 'Finna'
+ 'Finna',
+ [],
+ [
+ 'Metadata Language Code Mappings' => [
+ 'fin' => 'fi',
+ 'swe' => 'sv',
+ 'en-gb' => 'en',
+ 'eng' => 'en',
+ 'sme' => 'se',
+ ],
+ ],
)->toSolrArray();
unset($fields['fullrecord']);
$ltr = "\u{200E}";
@@ -613,6 +627,7 @@ public function testSKS(string $addIdToHierarchyTitle, ?string $expectedTitleInH
'242790397',
'xx.xx.1881-xx.xx.1881',
'Sundvall Gustaf Edvard S 1:a) 1',
+ 'Sundvall Gustaf Edvard S 1:a) 1 swe',
'1',
's/sundvall_gustaf_edvard/001/00001/00005',
'SKS KRA S Sundvall Gustaf Edvard 1: a) 1',
@@ -731,8 +746,16 @@ public function testSKS(string $addIdToHierarchyTitle, ?string $expectedTitleInH
'title_sub' => '1',
'title_short' => 'Sundvall Gustaf Edvard S 1:a) 1' . $ltr . ' (1881)',
'title' => '1 Sundvall Gustaf Edvard S 1:a) 1' . $ltr . ' (1881)',
+ 'title_en_txt' => '',
+ 'title_fi_txt' => '1 Sundvall Gustaf Edvard S 1:a) 1' . $ltr . ' (1881)',
+ 'title_se_txt' => '',
+ 'title_sv_txt' => '1 Sundvall Gustaf Edvard S 1:a) 1 swe' . $ltr . ' (1881)',
'title_sort' => '1 sundvall gustaf edvard s 1 a 1' . $ltr . ' (1881)',
'title_full' => '1 Sundvall Gustaf Edvard S 1:a) 1' . $ltr . ' (1881)',
+ 'title_alt' => [
+ '1 Sundvall Gustaf Edvard S 1:a) 1' . $ltr . ' (1881)',
+ '1 Sundvall Gustaf Edvard S 1:a) 1 swe' . $ltr . ' (1881)',
+ ],
'language' => [
'fin',
],
@@ -843,7 +866,9 @@ public function testSKS(string $addIdToHierarchyTitle, ?string $expectedTitleInH
'publishDateSort' => '',
];
if (null !== $expectedTitleInHierarchy) {
- $expected['title_in_hierarchy'] = $expectedTitleInHierarchy;
+ $expected['title_in_hierarchy'] = $expectedTitleInHierarchy['no_lang'];
+ $expected['title_in_hierarchy_fi_str'] = $expectedTitleInHierarchy['fi'];
+ $expected['title_in_hierarchy_sv_str'] = $expectedTitleInHierarchy['sv'];
}
$this->assertEquals(
diff --git a/tests/RecordManagerTest/Finna/Record/LidoTest.php b/tests/RecordManagerTest/Finna/Record/LidoTest.php
index 0a8164cc..6a40c49c 100644
--- a/tests/RecordManagerTest/Finna/Record/LidoTest.php
+++ b/tests/RecordManagerTest/Finna/Record/LidoTest.php
@@ -128,7 +128,22 @@ public function testMusketti1()
*/
public function testMusketti2()
{
- $fields = $this->createRecord(Lido::class, 'musketti2.xml', [], 'Finna')
+ $fields = $this->createRecord(
+ Lido::class,
+ 'musketti2.xml',
+ [],
+ 'Finna',
+ [],
+ [
+ 'Metadata Language Code Mappings' => [
+ 'fin' => 'fi',
+ 'swe' => 'sv',
+ 'en-gb' => 'en',
+ 'eng' => 'en',
+ 'sme' => 'se',
+ ],
+ ],
+ )
->toSolrArray();
unset($fields['fullrecord']);
@@ -137,8 +152,14 @@ public function testMusketti2()
'title_full' => 'Imatrankoski',
'title_short' => 'Imatrankoski',
'title' => 'Imatrankoski',
+ 'title_en_txt' => '',
+ 'title_fi_txt' => 'Imatrankoski',
+ 'title_se_txt' => '',
+ 'title_sv_txt' => 'Imatra fors',
'title_sort' => 'imatrankoski',
- 'title_alt' => [],
+ 'title_alt' => [
+ 'Imatra fors',
+ ],
'format' => 'kuva',
'institution' => 'Museoviraston kuva-arkisto/',
'author' => [
@@ -201,6 +222,7 @@ public function testMusketti2()
'sv',
'en',
'Imatrankoski',
+ 'Imatra fors',
'33,1.',
'Imatra. val. H.Hintze 1897 Antr.',
'33,1.',
@@ -563,6 +585,7 @@ public function testMeasurements()
'title_full' => 'lierihattu',
'title_short' => 'lierihattu',
'title' => 'lierihattu',
+ 'title_fi_txt' => 'lierihattu',
'title_sort' => 'lierihattu',
'allfields' => [
'M123',
@@ -676,4 +699,48 @@ public function testHierarchicalLocations(): void
];
$this->compareArray($expected, $result, 'RawGeographicTopicIds');
}
+
+ /**
+ * Test LIDO hierarchy handling
+ *
+ * @return void
+ */
+ public function testLidoHierarchies()
+ {
+ $record = $this->createRecord(
+ Lido::class,
+ 'lido_hierarchy.xml',
+ [
+ '__unit_test_no_source__' => [
+ 'driverParams' => [
+ 'indexHierarchies=true',
+ 'addIdToHierarchyTitle=true',
+ 'defaultDisplayLanguage=fi',
+ ],
+ ],
+ ],
+ 'Finna'
+ );
+ $fields = $record->toSolrArray();
+
+ $this->assertEquals('testit-200', $fields['hierarchy_top_id']);
+ $this->assertEquals('Yksikkötestikokoelma; Kaikki testit kautta aikojen', $fields['hierarchy_top_title']);
+ $this->assertEquals('testit-404', $fields['hierarchy_parent_id']);
+ $this->assertEquals(
+ [
+ 'Puuttuvien testien kokoelma',
+ 'Testiarkisto',
+ 'Yksikkötestikokoelma',
+ ],
+ $fields['hierarchy_parent_title']
+ );
+ $this->assertEquals('testi-000000418', $fields['hierarchy_sequence']);
+ $this->assertEquals('testi-418 Testi joka puuttui', $fields['title_in_hierarchy']);
+ $this->assertEquals('testi-418 Testi joka puuttui', $fields['title_in_hierarchy_fi_str']);
+ $this->assertEquals('testi-418 The test that was missing', $fields['title_in_hierarchy_en_str']);
+ $this->assertContains('Yksikkötestikokoelma; Kaikki testit kautta aikojen', $fields['allfields']);
+ $this->assertContains('Puuttuvien testien kokoelma', $fields['allfields']);
+ $this->assertContains('testi-418 Testi joka puuttui', $fields['allfields']);
+ $this->assertEquals('Testiarkisto', $fields['collection']);
+ }
}
diff --git a/tests/RecordManagerTest/Finna/Record/LrmiTest.php b/tests/RecordManagerTest/Finna/Record/LrmiTest.php
index 9dac3b5e..9f27c67f 100644
--- a/tests/RecordManagerTest/Finna/Record/LrmiTest.php
+++ b/tests/RecordManagerTest/Finna/Record/LrmiTest.php
@@ -68,4 +68,29 @@ public function testMediaTypes()
$fields['media_type_str_mv']
);
}
+
+ /**
+ * Test LRMI titles
+ *
+ * @return void
+ */
+ public function testTitles()
+ {
+ $record = $this->createRecord(
+ Lrmi::class,
+ 'lrmi1.xml',
+ [],
+ 'Finna',
+ [$this->createMock(\RecordManager\Base\Http\HttpService::class)]
+ );
+ $fields = $record->toSolrArray();
+ $this->assertEquals('Opetuksen ja oppimisen suunnittelu, Learning Design', $fields['title']);
+ $this->assertEquals('Opetuksen ja oppimisen suunnittelu, Learning Design', $fields['title_full']);
+ $this->assertEquals('Opetuksen ja oppimisen suunnittelu, Learning Design', $fields['title_short']);
+ $this->assertEquals('opetuksen ja oppimisen suunnittelu learning design', $fields['title_sort']);
+ $this->assertEquals('Designing Learning Processes', $fields['title_en_txt']);
+ $this->assertEquals('Opetuksen ja oppimisen suunnittelu, Learning Design', $fields['title_fi_txt']);
+ $this->assertEquals('', $fields['title_se_txt']);
+ $this->assertEquals('Planering av undevisning och lärande', $fields['title_sv_txt']);
+ }
}
diff --git a/tests/RecordManagerTest/Finna/Record/QdcTest.php b/tests/RecordManagerTest/Finna/Record/QdcTest.php
index 1116c81a..c292c442 100644
--- a/tests/RecordManagerTest/Finna/Record/QdcTest.php
+++ b/tests/RecordManagerTest/Finna/Record/QdcTest.php
@@ -42,6 +42,212 @@
*/
class QdcTest extends \RecordManagerTest\Base\Record\RecordTestBase
{
+ /**
+ * Test QDC record handling
+ *
+ * @return void
+ */
+ public function testQdc1()
+ {
+ $record = $this->createRecord(
+ Qdc::class,
+ 'qdc1.xml',
+ [],
+ 'Finna',
+ [$this->createMock(\RecordManager\Base\Http\HttpService::class)]
+ );
+ $fields = $record->toSolrArray();
+ unset($fields['fullrecord']);
+
+ $expected = [
+ 'record_format' => 'qdc',
+ 'ctrlnum' => [
+ '10138_331330',
+ ],
+ 'allfields' => [
+ 'Urine : The potential, value chain and its sustainable management',
+ 'Is that even a real title',
+ 'Ei',
+ 'Joo',
+ 'Viskari, Eeva-Liisa',
+ 'Lehtoranta, Suvi',
+ 'Malila, Riikka',
+ 'urine',
+ 'fertilizer',
+ 'value chain',
+ 'agriculture',
+ 'nutrient recovery',
+ 'virtsa',
+ 'lannoitteet',
+ 'ravinteet',
+ 'uudelleenkäyttö',
+ 'maatalous',
+ '2021-06-16T06:31:44Z',
+ '2021',
+ 'Article',
+ 'okm_type',
+ 'okm_type_2',
+ 'other_type',
+ 'Eeva-Liisa Viskari, Suvi Lehtoranta, Riikka Malila. Urine : The potential, value chain and its'
+ . ' sustainable management. Sanitation Value Chain (2021) 5, 1, pages 10-12. '
+ . 'https://doi.org/10.34416/svc.00029',
+ '2432-5058',
+ 'http://hdl.handle.net/10138/331330',
+ 'https://doi.org/10.34416/svc.00029',
+ 'en',
+ 'Sanitation Value Chain 5:1',
+ 'Sanitation Research Collection',
+ 'CC BY-NC-ND 4.0',
+ 'Sanitation Project, Research Institute for Humanity and Nature',
+ 'http://dx.doi.org/https://doi.org/10.34416/svc.00029',
+ '10138_331330',
+ ],
+ 'language' => [
+ 'en',
+ ],
+ 'format' => 'Article',
+ 'format_ext_str_mv' => 'Article',
+ 'author' => [
+ 'Viskari, Eeva-Liisa',
+ 'Lehtoranta, Suvi',
+ 'Malila, Riikka',
+ ],
+ 'author2' => [],
+ 'author_corporate' => [],
+ 'author_sort' => 'Viskari, Eeva-Liisa',
+ 'author_facet' => [
+ 'Viskari, Eeva-Liisa',
+ 'Lehtoranta, Suvi',
+ 'Malila, Riikka',
+ ],
+ 'hierarchy_parent_title' => [
+ 'Sanitation Research Collection',
+ ],
+ 'title_full' => 'Urine : The potential, value chain and its sustainable management',
+ 'title' => 'Urine : The potential, value chain and its sustainable management',
+ 'title_en_txt' => 'Urine : The potential, value chain and its sustainable management',
+ 'title_fi_txt' => 'Joo',
+ 'title_se_txt' => '',
+ 'title_sv_txt' => '',
+ 'title_short' => 'Urine',
+ 'title_sub' => 'The potential, value chain and its sustainable management',
+ 'title_sort' => 'urine the potential value chain and its sustainable management',
+ 'title_alt' => [
+ 'Is that even a real title',
+ 'Ei',
+ 'Joo',
+ ],
+ 'publisher' => [
+ 'Sanitation Project, Research Institute for Humanity and Nature',
+ ],
+ 'publishDate' => [
+ '2021',
+ ],
+ 'publishDateSort' => '2021',
+ 'publishDateRange' => [
+ '[2021-01-01 TO 2021-12-31]',
+ ],
+ 'main_date_str' => '2021',
+ 'main_date' => '2021-01-01T00:00:00Z',
+ 'publication_daterange' => '[2021-01-01 TO 2021-12-31]',
+ 'search_daterange_mv' => [
+ '[2021-01-01 TO 2021-12-31]',
+ ],
+ 'era' => [],
+ 'era_facet' => [],
+ 'geographic' => [],
+ 'geographic_facet' => [],
+ 'location_geo' => [],
+ 'usage_rights_str_mv' => [
+ 'CC BY-NC-ND 4.0',
+ ],
+ 'usage_rights_ext_str_mv' => [
+ 'CC BY-NC-ND 4.0',
+ ],
+ 'source_str_mv' => '__unit_test_no_source__',
+ 'datasource_str_mv' => '__unit_test_no_source__',
+ 'isbn' => [],
+ 'issn' => [
+ '2432-5058',
+ ],
+ 'doi_str_mv' => [
+ '10.34416/svc.00029',
+ ],
+ 'topic_facet' => [
+ 'urine',
+ 'fertilizer',
+ 'value chain',
+ 'agriculture',
+ 'nutrient recovery',
+ 'virtsa',
+ 'lannoitteet',
+ 'ravinteet',
+ 'uudelleenkäyttö',
+ 'maatalous',
+ ],
+ 'topic' => [
+ 'urine',
+ 'fertilizer',
+ 'value chain',
+ 'agriculture',
+ 'nutrient recovery',
+ 'virtsa',
+ 'lannoitteet',
+ 'ravinteet',
+ 'uudelleenkäyttö',
+ 'maatalous',
+ ],
+ 'url' => [
+ 'http://hdl.handle.net/10138/331330',
+ 'https://doi.org/10.34416/svc.00029',
+ 'http://dx.doi.org/https://doi.org/10.34416/svc.00029',
+ ],
+ 'online_urls_str_mv' => [],
+ 'media_type_str_mv' => [],
+ 'file_identifier_str_mv' => [],
+ 'thumbnail' => '',
+ 'contents' => [],
+ 'description' => '',
+ 'series' => [
+ 'Sanitation Value Chain 5:1',
+ ],
+ 'fulltext' => '',
+ ];
+
+ $this->compareArray($expected, $fields, 'toSolrArray');
+
+ $keys = $record->getWorkIdentificationData();
+
+ $expected = [
+ [
+ 'authors' => [
+ [
+ 'type' => 'author',
+ 'value' => 'Viskari, Eeva-Liisa',
+ ],
+ ],
+ 'authorsAltScript' => [
+ ],
+ 'titles' => [
+ [
+ 'type' => 'title',
+ 'value' => 'urine the potential value chain and its'
+ . ' sustainable management',
+ ],
+ [
+ 'type' => 'title',
+ 'value' => 'Urine : The potential, value chain and its'
+ . ' sustainable management',
+ ],
+ ],
+ 'titlesAltScript' => [
+ ],
+ ],
+ ];
+
+ $this->compareArray($expected, $keys, 'getWorkIdentificationData');
+ }
+
/**
* Test dateranges.
*
diff --git a/tests/fixtures/Finna/record/lido_hierarchy.xml b/tests/fixtures/Finna/record/lido_hierarchy.xml
new file mode 100644
index 00000000..688840a8
--- /dev/null
+++ b/tests/fixtures/Finna/record/lido_hierarchy.xml
@@ -0,0 +1,154 @@
+
+
+
+ knp-247394
+
+
+
+
+ Testi
+
+
+
+
+
+
+ Testi joka puuttui
+ The test that was missing
+
+
+
+
+
+
+
+ Test Institution
+
+
+ testi-418
+
+
+
+
+
+
+
+
+ yksikkötestit
+
+
+
+
+
+
+
+ Testit kautta aikojen
+
+
+ is reproduced in
+
+
+
+
+ Testiarkisto
+ Test Archive
+
+
+ Kokoelma
+
+
+
+
+ Yksikkötestikokoelma
+ Unit Test Collection
+
+
+ Alakokoelma
+
+
+
+
+ Yksikkötestikokoelma; Kaikki testit kautta aikojen
+
+
+
+
+ is part of
+
+
+
+
+ Puuttuvien testien kokoelma
+
+
+
+
+ is part of
+
+
+
+
+
+
+
+
+
+ creation
+
+
+
+
+
+
+ Anni M. Körnä
+
+
+
+ Kirjoittajat
+
+
+
+
+
+
+
+
+
+
+ M011-320623
+
+
+
+
+
+
+ Test Institution
+
+
+
+
+
+ 247394
+
+ Item
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/fixtures/Finna/record/lrmi1.xml b/tests/fixtures/Finna/record/lrmi1.xml
new file mode 100644
index 00000000..c9be1542
--- /dev/null
+++ b/tests/fixtures/Finna/record/lrmi1.xml
@@ -0,0 +1,7 @@
+
+
+ oai:aoe.fi:11
+ Designing Learning Processes
+ Opetuksen ja oppimisen suunnittelu, Learning Design
+ Planering av undevisning och lärande
+
diff --git a/tests/fixtures/Finna/record/musketti2.xml b/tests/fixtures/Finna/record/musketti2.xml
index 93880ff7..72ac8654 100644
--- a/tests/fixtures/Finna/record/musketti2.xml
+++ b/tests/fixtures/Finna/record/musketti2.xml
@@ -28,7 +28,8 @@
- Imatrankoski
+ Imatrankoski
+ Imatra fors
diff --git a/tests/fixtures/Finna/record/qdc1.xml b/tests/fixtures/Finna/record/qdc1.xml
new file mode 100644
index 00000000..19429153
--- /dev/null
+++ b/tests/fixtures/Finna/record/qdc1.xml
@@ -0,0 +1,37 @@
+
+
+ Urine : The potential, value chain and its sustainable management
+ Is that even a real title
+ Ei
+ Joo
+ Viskari, Eeva-Liisa
+ Lehtoranta, Suvi
+ Malila, Riikka
+ urine
+ fertilizer
+ value chain
+ agriculture
+ nutrient recovery
+ virtsa
+ lannoitteet
+ ravinteet
+ uudelleenkäyttö
+ maatalous
+ 2021-06-16T06:31:44Z
+ 2021
+ Article
+ okm_type
+ okm_type_2
+ other_type
+ Eeva-Liisa Viskari, Suvi Lehtoranta, Riikka Malila. Urine : The potential, value chain and its sustainable management. Sanitation Value Chain (2021) 5, 1, pages 10-12. https://doi.org/10.34416/svc.00029
+ 2432-5058
+ http://hdl.handle.net/10138/331330
+ https://doi.org/10.34416/svc.00029
+ en
+ Sanitation Value Chain 5:1
+ Sanitation Research Collection
+ CC BY-NC-ND 4.0
+ Sanitation Project, Research Institute for Humanity and Nature
+ http://dx.doi.org/https://doi.org/10.34416/svc.00029
+ 10138_331330
+
diff --git a/tests/fixtures/Finna/record/sks.xml b/tests/fixtures/Finna/record/sks.xml
index 414e7bc7..0c401bce 100644
--- a/tests/fixtures/Finna/record/sks.xml
+++ b/tests/fixtures/Finna/record/sks.xml
@@ -25,6 +25,7 @@
xx.xx.1881-xx.xx.1881
Sundvall Gustaf Edvard S 1:a) 1
+ Sundvall Gustaf Edvard S 1:a) 1 swe
1
s/sundvall_gustaf_edvard/001/00001/00005