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
31 changes: 21 additions & 10 deletions src/RecordManager/Finna/Record/Lido.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions tests/RecordManagerTest/Finna/Record/LidoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down Expand Up @@ -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']);
}

/**
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/Finna/record/musketti1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@
<term label="Museoalan asiasanasto">taloustarvikkeet </term>
</subjectConcept>
<subjectConcept>
<conceptID type="http://terminology.lido-schema.org/lido00099" source="yso">http://www.yso.fi/onto/yso/p4847</conceptID>
<term label="Yleinen suomalainen asiasanasto"> nautintoaineet</term>
</subjectConcept>
<subjectConcept>
<Concept about="http://www.yso.fi/onto/yso/p4277"/>
<term label="Yleinen suomalainen asiasanasto">kahvi <!-- test --></term>
</subjectConcept>
<subjectConcept>
<conceptID type="notsupported">0000</conceptID>
<term label="Museoalan asiasanasto">suomalais-ugrilaiset kansat</term>
</subjectConcept>
<subjectConcept>
Expand Down Expand Up @@ -201,6 +204,13 @@
<creditLine />
</rightsResource>
</resourceSet>
<resourceSet>
<rightsResource>
<rightsType>
<Concept about="https://rightsstatements.org/vocab/InC/1.0/"/>
</rightsType>
</rightsResource>
</resourceSet>
</resourceWrap>
</administrativeMetadata>
</lido>
Expand Down
Loading