Skip to content

Commit

Permalink
Adjusted comments in inis, changed to wait for upstream implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Dec 13, 2024
1 parent f796fdd commit efa4895
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 61 deletions.
6 changes: 4 additions & 2 deletions local/config/finna/SearchApiRecordFields.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,15 @@ urls:
$ref: '#/components/schemas/Url'
usageRights:
vufind.method: getUsageRights
description: Usage rights
description: Usage rights
(see [usage_rights_str_mv at https://www.kiwi.fi/display/Finna/Kenttien+mappaukset+eri+formaateista+Finnan+indeksiin]
(https://github.com/NatLibFi/RecordManager-Finna/blob/dev/mappings/usage_rights.map.sample))
type: array
items:
type: string
usageRightsExtended:
vufind.method: getUsageRightsExt
description: Usage rights extended
description: Extended usage rights (see https://github.com/NatLibFi/RecordManager-Finna/blob/dev/mappings/usage_rights_ext.map.sample)
type: array
items:
type: string
Expand Down
1 change: 1 addition & 0 deletions local/config/finna/config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ url = https://www.myendnoteweb.com/EndNoteWeb.html
;set_query['eod_ebooks'] = "format:eBook"
;vufind_api_format_fields = "id,authors,cleanIsbn,cleanIssn,formats,title"
;finna_api_format_fields = "id,authors,cleanIsbn,cleanIssn,formats,title,images,mediaTypes,ctrlnum,institutions,year,recordFormat,sectors,majorGenres,usageRights,usageRightsExtended,measurements,collections"

; Proxy Server is Optional.
[Proxy]
;host = your.proxy.server
Expand Down
69 changes: 10 additions & 59 deletions module/Finna/src/Finna/OAI/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace Finna\OAI;

use VuFind\SimpleXML;
use VuFind\RecordDriver\AbstractBase as AbstractRecordDriver;

/**
* OAI Server class
Expand Down Expand Up @@ -98,68 +98,19 @@ protected function initializeMetadataFormats()
}

/**
* Attach a non-deleted record to an XML document.
* Get record as a metadata presentation
*
* @param SimpleXMLElement $container XML container for new record
* @param object $record A record driver object
* @param string $format Metadata format to obtain (false for none)
* @param bool $headerOnly Only attach the header?
* @param string $set Currently active set
* @param AbstractRecordDriver $record A record driver object
* @param string $format Metadata format to obtain
*
* @return bool
* @return string|bool String on success or false if error occurs
*/
protected function attachNonDeleted(
$container,
$record,
$format,
$headerOnly = false,
$set = ''
) {
if ('oai_finna_json' !== $format || !$this->supportsFinnaMetadata()) {
return parent::attachNonDeleted($container, $record, $format, $headerOnly, $set);
}
$xml = $this->getFinnaMetadata($record);
// Headers should be returned only if the metadata format matching
// the supplied metadataPrefix is available.
// If RecordDriver returns nothing, skip this record.
if (empty($xml)) {
return true;
}

// Check for sets:
$fields = $record->getRawData();
if (null !== $this->setField && !empty($fields[$this->setField])) {
$sets = (array)$fields[$this->setField];
} else {
$sets = [];
}
if (!empty($set)) {
$sets = array_unique(array_merge($sets, [$set]));
}

// Get modification date:
$date = $record->getLastIndexed();
if (empty($date)) {
$date = $this->getUTCDateTime('now');
}

// Set up header (inside or outside a <record> container depending on
// preferences):
$recXml = $headerOnly ? $container : $container->addChild('record');
$this->attachRecordHeader(
$recXml,
$this->prefixID($record->getUniqueID()),
$date,
$sets
);

// Inject metadata if necessary:
if (!$headerOnly) {
$metadata = $recXml->addChild('metadata');
SimpleXML::appendElement($metadata, $xml);
protected function getRecordAsXML(AbstractRecordDriver $record, string $format): string|false
{
if ('oai_json_finna' === 'format' && $this->supportsFinnaMetadata()) {
return $this->getFinnaMetadata($record);
}

return true;
return parent::getRecordAsXml($record, $format);

Check failure on line 113 in module/Finna/src/Finna/OAI/Server.php

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Call to an undefined static method VuFind\OAI\Server::getRecordAsXml().

Check failure on line 113 in module/Finna/src/Finna/OAI/Server.php

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.3

Call to an undefined static method VuFind\OAI\Server::getRecordAsXml().
}

/**
Expand Down

0 comments on commit efa4895

Please sign in to comment.