Skip to content

Commit

Permalink
[FINNA-2143] Sierra: Add an option to keep existing 852 fields in har…
Browse files Browse the repository at this point in the history
…vested records.
  • Loading branch information
EreMaijala committed Apr 24, 2024
1 parent f8e638a commit 801af58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf/datasources.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
;; unsuppressed to suppressed won't be detected.
;;suppressedRecords = false
;suppressedBibCode3 = 'c,d,n'
;keepExisting852Fields = false
;institution = SierraLib
;format = marc
;dedup = true
Expand Down
16 changes: 14 additions & 2 deletions src/RecordManager/Base/Harvest/SierraApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ class SierraApi extends AbstractBase
*/
protected $suppressedBibCode3 = [];

/**
* Whether to keep existing 852 fields in the MARC records before adding new ones
* for the item locations.
*
* @var bool
*/
protected $keepExisting852Fields = false;

/**
* HTTP client options
*
Expand Down Expand Up @@ -154,7 +162,8 @@ public function init(string $source, bool $verbose, bool $reharvest): void
',',
$settings['suppressedBibCode3'] ?? ''
);
$this->apiVersion = 'v' . ($settings['sierraApiVersion'] ?? '5');
$this->apiVersion = 'v' . ($settings['sierraApiVersion'] ?? '6');
$this->keepExisting852Fields = $settings['keepExisting852Fields'] ?? false;
}

/**
Expand Down Expand Up @@ -540,7 +549,10 @@ protected function convertRecordToMarcArray($record)
$marc['leader'] = $varField['content'];
continue;
}
if (!isset($varField['marcTag']) || $varField['marcTag'] == '852') {
if (
!isset($varField['marcTag'])
|| (!$this->keepExisting852Fields && $varField['marcTag'] == '852')
) {
continue;
}
// Make sure the tag has three characters
Expand Down

0 comments on commit 801af58

Please sign in to comment.