From a0556b5bc7cedb7b6d0ccd83b44f89df2a2d9fe5 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 Signed-off-by: Chris Cormack Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer (cherry picked from commit fd70ee6a9411d9f320c6f609415d74dd38a0116f) Signed-off-by: Fridolin Somers --- 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 49c86c8c42..974689eb92 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 051657aa76..1ec3bd8d0f 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); @@ -266,6 +268,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, } ); } @@ -395,6 +398,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.39.5