From a686d60b212b5e102346c662d9a9af2af6212ed8 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 20 Dec 2022 12:10:57 -1000 Subject: [PATCH] Bug 32509: Embed see-also-from headings into bibliographic records export In misc/export_records.pl add an option to add see-also-from headings (from authorities 5xx) into bibliographic records export. Like see-from. Test plan : 1) Choose a biblio record having a field (for example 650) linked to an authority with a see-also-from. 2) Export this record without see-also-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-also-from headings : misc/export_records.pl --starting_biblionumber=X --ending_biblionumber=X --filename /tmp/record_with.xml --format xml --embed_see_also_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-also-from heading Signed-off-by: David Nind --- Koha/Exporter/Record.pm | 15 +++++++-- misc/export_records.pl | 75 ++++++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm index e7d710be85..1348625358 100644 --- a/Koha/Exporter/Record.pm +++ b/Koha/Exporter/Record.pm @@ -120,14 +120,25 @@ sub _get_biblio_for_export { 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 $embed_see_also_from_headings = $params->{embed_see_also_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' } ); + if ( $embed_see_from_headings || $embed_see_also_from_headings ) { + my @other_headings; + push @other_headings, 'see_from' if $embed_see_from_headings; + push @other_headings, 'see_also_from' if $embed_see_also_from_headings; + my $record_processor = Koha::RecordProcessor->new( + { + filters => 'EmbedSeeFromHeadings', + options => { + other_headings => \@other_headings, + } + } + ); $record_processor->process($record); } diff --git a/misc/export_records.pl b/misc/export_records.pl index fefa166791..0e57432137 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -59,6 +59,7 @@ my ( $end_accession, $marc_conditions, $embed_see_from_headings, + $embed_see_also_from_headings, $report_id, @report_params, $report, @@ -70,32 +71,33 @@ my ( ); GetOptions( - 'format=s' => \$output_format, - 'date=s' => \$timestamp, - 'dont_export_items' => \$dont_export_items, - 'csv_profile_id=s' => \$csv_profile_id, - 'deleted_barcodes' => \$deleted_barcodes, - 'clean' => \$clean, - 'filename=s' => \$filename, - 'record-type=s' => \$record_type, - 'id_list_file=s' => \$id_list_file, - 'starting_authid=s' => \$starting_authid, - 'ending_authid=s' => \$ending_authid, - 'authtype=s' => \$authtype, - 'starting_biblionumber=s' => \$starting_biblionumber, - 'ending_biblionumber=s' => \$ending_biblionumber, - 'itemtype=s' => \$itemtype, - 'starting_callnumber=s' => \$starting_callnumber, - 'ending_callnumber=s' => \$ending_callnumber, - 'start_accession=s' => \$start_accession, - 'end_accession=s' => \$end_accession, - 'marc_conditions=s' => \$marc_conditions, - 'embed_see_from_headings' => \$embed_see_from_headings, - 'report_id=s' => \$report_id, - 'report_param=s' => \@report_params, - 'destination_server_id=s' => \$destination_server_id, - 'delete_local_after_run' => \$delete_local_after_run, - 'h|help|?' => \$help, + 'format=s' => \$output_format, + 'date=s' => \$timestamp, + 'dont_export_items' => \$dont_export_items, + 'csv_profile_id=s' => \$csv_profile_id, + 'deleted_barcodes' => \$deleted_barcodes, + 'clean' => \$clean, + 'filename=s' => \$filename, + 'record-type=s' => \$record_type, + 'id_list_file=s' => \$id_list_file, + 'starting_authid=s' => \$starting_authid, + 'ending_authid=s' => \$ending_authid, + 'authtype=s' => \$authtype, + 'starting_biblionumber=s' => \$starting_biblionumber, + 'ending_biblionumber=s' => \$ending_biblionumber, + 'itemtype=s' => \$itemtype, + 'starting_callnumber=s' => \$starting_callnumber, + 'ending_callnumber=s' => \$ending_callnumber, + 'start_accession=s' => \$start_accession, + 'end_accession=s' => \$end_accession, + 'marc_conditions=s' => \$marc_conditions, + 'embed_see_from_headings' => \$embed_see_from_headings, + 'embed_see_also_from_headings' => \$embed_see_also_from_headings, + 'report_id=s' => \$report_id, + 'report_param=s' => \@report_params, + 'destination_server_id=s' => \$destination_server_id, + 'delete_local_after_run' => \$delete_local_after_run, + 'h|help|?' => \$help, ) || pod2usage(1); if ($help) { @@ -348,14 +350,15 @@ if ($deleted_barcodes) { } else { Koha::Exporter::Record::export( { - record_type => $record_type, - record_ids => \@record_ids, - record_conditions => @marc_conditions ? \@marc_conditions : undef, - format => $output_format, - csv_profile_id => $csv_profile_id, - export_items => ( not $dont_export_items ), - clean => $clean || 0, - embed_see_from_headings => $embed_see_from_headings || 0, + record_type => $record_type, + record_ids => \@record_ids, + record_conditions => @marc_conditions ? \@marc_conditions : undef, + format => $output_format, + csv_profile_id => $csv_profile_id, + export_items => ( not $dont_export_items ), + clean => $clean || 0, + embed_see_from_headings => $embed_see_from_headings || 0, + embed_see_also_from_headings => $embed_see_also_from_headings || 0, } ); } @@ -536,6 +539,10 @@ Print a brief help message. --embed_see_from_headings Embed see from (non-preferred form) headings in bibliographic record. +=item B<--embed_see_also_from_headings> + + --embed_see_also_from_headings Embed see also from (non-preferred form) headings in bibliographic record. + =item B<--report_id> --report_id=ID Export biblionumbers or authids from a given saved report output. -- 2.39.5