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
4 changes: 2 additions & 2 deletions conf/datasources.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
; authority[<type>] Map to authority index sources where <type> is authority record type
; (corporateBody, person) or * for any;
; authority_id_regex[<type>] Regex for filtering allowed authority ids
; (used when indexing authority ids and when enriching biblio records with MarcAuthEnrichment)
; (used when indexing authority ids and when enriching biblio records with AuthEnrichment)
; fullTextXPaths XPath expression denoting full text fields
; fullTextUrlXPaths XPath expression denoting fields that contain URLs to full text content (plain text only at the moment)

Expand Down Expand Up @@ -173,7 +173,7 @@
;driverParams[] = "idIn999=true"
;driverParams[] = "003InLinkingID=true"
;driverParams[] = "kohaNormalization=true"
;enrichments[] = MarcAuthEnrichment,final
;enrichments[] = AuthEnrichment,final

; Sample DSpace configuration
;[dspace]
Expand Down
47 changes: 46 additions & 1 deletion src/RecordManager/Base/Enrichment/AuthEnrichment.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://github.com/NatLibFi/RecordManager
*/
abstract class AuthEnrichment extends AbstractEnrichment
class AuthEnrichment extends AbstractEnrichment
{
use \RecordManager\Base\Record\CreateRecordTrait;

Expand All @@ -63,6 +63,21 @@ abstract class AuthEnrichment extends AbstractEnrichment
*/
protected $authorityDb;

/**
* Enrichment specifications. Key is the array in solrArray and value contains following:
* - pref, preferred field in solr
* - check, check field for existing values
*
* @var array<string, array>
*/
protected array $enrichmentSpecs = [
'author2_id_str_mv' => [
'pref' => 'author_variant',
'check' => 'author_variant',
'includeInAllFields' => true,
],
];

/**
* Constructor
*
Expand Down Expand Up @@ -95,6 +110,36 @@ public function __construct(
$this->authorityDb = $authorityDb;
}

/**
* Enrich the record and return any additions in solrArray
*
* @param string $sourceId Source ID
* @param object $record Metadata Record
* @param array $solrArray Metadata to be sent to Solr
*
* @throws \Exception
* @return void
*/
public function enrich($sourceId, $record, &$solrArray)
{
foreach ($this->enrichmentSpecs as $key => $specs) {
if (empty($solrArray[$key])) {
continue;
}
foreach ($solrArray[$key] as $id) {
$this->enrichField(
$sourceId,
$record,
$solrArray,
$id,
$specs['pref'],
$specs['check'],
$specs['includeInAllFields'] ?? false
);
}
}
}

/**
* Enrich the record and return any additions in solrArray
*
Expand Down
97 changes: 0 additions & 97 deletions src/RecordManager/Base/Enrichment/Ead3SkosmosEnrichment.php

This file was deleted.

61 changes: 0 additions & 61 deletions src/RecordManager/Base/Enrichment/EadSkosmosEnrichment.php

This file was deleted.

92 changes: 0 additions & 92 deletions src/RecordManager/Base/Enrichment/LidoSkosmosEnrichment.php

This file was deleted.

Loading