From 221442ecda9b5febde539287d6fa2e5fe85bffd0 Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Fri, 21 Oct 2022 09:28:06 +0200 Subject: [PATCH] Bug 28639: Embed see-from headings (from authorities) into bibliographic records at OAI repository level Test plan: 1. Create an authority with at least a 1XX$a and a 4XX$a, for instance: 100 $a Foo 400 $a Bar 2. Create a biblio and add a link to this authority using the cataloguing plugin 3. Enable OAI-PMH syspref and fill OAI-PMH:archiveID syspref with "oai:sandbox" 4. Go to OAI repository and display the previously created record (at /cgi-bin/koha/oai.pl?verb=GetRecord&metadataPrefix=marcxml&identifier=oai:sandbox:{biblionumber} 5. The record should not contain see-from headings 6. Run perl installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl 7. Enable OAI-PMH:EmbedSeeFromInBibRecord 8. Go again to the OAI record, you should see alternative forms at the end of the record --- Koha/OAI/Server/Repository.pm | 5 +++++ ...639-add_EmbedSeeFromInBibRecord_syspref.pl | 21 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/web_services.pref | 6 ++++++ 4 files changed, 33 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm index 0cd0df5dcf..061d5e1834 100644 --- a/Koha/OAI/Server/Repository.pm +++ b/Koha/OAI/Server/Repository.pm @@ -39,6 +39,7 @@ use C4::Context; use C4::Biblio qw( GetFrameworkCode ); use Koha::XSLT::Base; use Koha::Biblios; +use Koha::Filter::MARC::EmbedSeeFromHeadings; =head1 NAME @@ -172,6 +173,7 @@ sub get_biblio_marcxml { my ( $self, $biblionumber, $format ) = @_; my $with_items = 0; my $expanded_avs = 0; + my $embedseefromheadings = C4::Context->preference('OAI-PMH:EmbedSeeFromInBibRecord') || 0; if ( my $conf = $self->{conf} ) { $with_items = $conf->{format}->{$format}->{include_items }; $expanded_avs = $conf->{format}->{$format}->{expanded_avs}; @@ -179,6 +181,9 @@ sub get_biblio_marcxml { my $biblio = Koha::Biblios->find($biblionumber); my $record = $biblio->metadata->record({ embed_items => $with_items, opac => 1 }); + if ( $embedseefromheadings ) { + Koha::Filter::MARC::EmbedSeeFromHeadings->filter($record); + } if ( $expanded_avs ) { my $frameworkcode = GetFrameworkCode($biblionumber) || ''; my $record_processor = Koha::RecordProcessor->new( diff --git a/installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl b/installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl new file mode 100755 index 0000000000..75598d1025 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl @@ -0,0 +1,21 @@ +use Modern::Perl; + +return { + bug_number => "bug_28639", + description => "Add embed see-from headings for oai", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) + VALUES ( + 'EmbedSeeFromInBibRecord', '0', NULL, 'Add embed see-from headings for OAI', 'YesNo' + ) + } + ); + + say $out "Syspref EmbedSeeFromInBibRecord for OAI"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 68b6841c12..0074407246 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -407,6 +407,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OAI-PMH:AutoUpdateSetEmbedItemData', '0', '', 'Embed item information when automatically updating OAI sets. Requires OAI-PMH:AutoUpdateSets syspref to be enabled', 'YesNo'), ('OAI-PMH:ConfFile','',NULL,'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','File'), ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent), might be deleted (transient), or will never have any data in it (no)','transient|persistent|no','Choice'), +('OAI-PMH:EmbedSeeFromInBibRecord','0','','Embed see-from headings in bibliographic records exposed through OAI repository.','YesNo'), ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), ('OPACAcquisitionDetails','0','','Show the acquisition details at the OPAC','YesNo'), ('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index 1fb5c99916..69e87780e4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -80,6 +80,12 @@ Web services: transient: might be emptied or truncated at some point (transient) no: will never have any data in it (no) - "." + - + - pref: "OAI-PMH:EmbedSeeFromInBibRecord" + choices: + 1: Enable + 0: "Don't enabled" + - "Embed see from (non-preferred form) headings in bibliographic records exposed through OAI repository." ILS-DI: - - pref: ILS-DI -- 2.25.1