Skip to content
Merged
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
28 changes: 28 additions & 0 deletions src/RecordManager/Finna/Record/Aipa.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
*/
class Aipa extends Qdc
{
use AuthoritySupportTrait;
use CreateRecordTrait;

/**
Expand Down Expand Up @@ -116,6 +117,7 @@ public function toSolrArray(?Database $db = null)

$data['record_format'] = 'aipa';
$data['educational_material_type_str_mv'] = $this->getFormat();
$data['topic_id_str_mv'] = $this->getTopicIDs();

// Merge fields from encapsulated records.
foreach ($this->doc->item as $item) {
Expand Down Expand Up @@ -154,6 +156,32 @@ public function getFormat()
return (string)($this->doc->type);
}

/**
* Get all topic identifiers (for enrichment)
*
* @return array
*/
public function getRawTopicIds(): array
{
$results = [];
foreach ($this->doc->subject ?? [] as $subject) {
if ($id = trim((string)($subject->attributes()->identifier))) {
$results[] = $id;
}
}
return array_unique($results);
}

/**
* Return subject identifiers associated with object.
*
* @return array
*/
protected function getTopicIDs(): array
{
return $this->addNamespaceToAuthorityIds($this->getRawTopicIDs(), 'topic');
}

/**
* Return URLs associated with object
*
Expand Down