From 12e7f49b1d90da37a5b3b860627e87f349d3b98e Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 2 Aug 2022 15:17:25 -1000 Subject: [PATCH] Bug 31286: Embed see-from headings into bibliographic records export In misc/export_records.pl add an option to add see-from headings (from authorities 4xx) into bibliographic records export. Like it is done during record indexing. Test plan : 1) Choose a biblio record having a field (for example 650) linked to an authority with a see-form. 2) Export this record without see-from headings : misc/export_records.pl --starting_biblionumber=X --ending_biblionumber=X --filename /tmp/record_without.xml --format xml 3) Export this record with see-from headings : misc/export_records.pl --starting_biblionumber=X --ending_biblionumber=X --filename /tmp/record_with.xml --format xml --embed_see_from_headings 4) Compare /tmp/record_without.xml and /tmp/record_with.xml => you should see two 650, one with main heading and one with see-from heading --- Koha/Exporter/Record.pm | 7 +++++++ misc/export_records.pl | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm index e678c36ee1..c2dfc38c2f 100644 --- a/Koha/Exporter/Record.pm +++ b/Koha/Exporter/Record.pm @@ -10,6 +10,7 @@ use C4::Record; use Koha::Biblios; use Koha::CsvProfiles; use Koha::Logger; +use Koha::RecordProcessor; use List::Util qw( all any ); sub _get_record_for_export { @@ -120,12 +121,18 @@ sub _get_biblio_for_export { my $itemnumbers = $params->{itemnumbers}; my $export_items = $params->{export_items} // 1; my $only_export_items_for_branches = $params->{only_export_items_for_branches}; + my $embed_see_from_headings = $params->{embed_see_from_headings}; my $biblio = Koha::Biblios->find($biblionumber); my $record = eval { $biblio->metadata->record }; return if $@ or not defined $record; + if ($embed_see_from_headings) { + my $record_processor = Koha::RecordProcessor->new( { filters => 'EmbedSeeFromHeadings' } ); + $record_processor->process($record); + } + if ($export_items) { Koha::Biblio::Metadata->record( { diff --git a/misc/export_records.pl b/misc/export_records.pl index 32658cb8c8..08aba2d7e6 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -54,6 +54,7 @@ my ( $start_accession, $end_accession, $marc_conditions, + $embed_see_from_headings, $help ); @@ -78,6 +79,7 @@ GetOptions( 'start_accession=s' => \$start_accession, 'end_accession=s' => \$end_accession, 'marc_conditions=s' => \$marc_conditions, + 'embed_see_from_headings' => \$embed_see_from_headings, 'h|help|?' => \$help ) || pod2usage(1); @@ -256,6 +258,7 @@ else { csv_profile_id => $csv_profile_id, export_items => (not $dont_export_items), clean => $clean || 0, + embed_see_from_headings => $embed_see_from_headings || 0, } ); } @@ -385,6 +388,10 @@ Print a brief help message. "exists()" will include marc records where no exists. +=item B<--embed_see_from_headings> + + --embed_see_from_headings Embed see from (non-preferred form) headings in bibliographic record. + =back =head1 AUTHOR -- 2.35.4