From 8ca99e4d6fe06bb2e30b51118187740cab2e0d8a Mon Sep 17 00:00:00 2001 From: Jon Knight Date: Tue, 22 Aug 2017 15:57:13 +0000 Subject: [PATCH] First cut at some changes to misc/stage_file.pl script to provide for MARC modification template support. Not ready for QA yet. https://bugs.koha-community.org/show_bug.cgi?id=19164 --- misc/stage_file.pl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/misc/stage_file.pl b/misc/stage_file.pl index ad0b726..d613ca4 100755 --- a/misc/stage_file.pl +++ b/misc/stage_file.pl @@ -31,6 +31,7 @@ BEGIN { use C4::Context; use C4::ImportBatch; use C4::Matcher; +use C4::MarcModificationTemplates; use Getopt::Long; $| = 1; @@ -48,6 +49,8 @@ my $no_replace; my $format = 'ISO2709'; my $no_create; my $item_action = 'always_add'; +my $marc_mod_template = ''; +my $marc_mod_template_id = undef; my $result = GetOptions( 'encoding:s' => \$encoding, @@ -60,9 +63,23 @@ my $result = GetOptions( 'no-create' => \$no_create, 'comment:s' => \$batch_comment, 'authorities' => \$authorities, + 'marcmodtemplate:s' => \$marc_mod_template, 'h|help' => \$want_help ); +if($marc_mod_template ne '') { + my @templates = GetModificationTemplates(); + foreach my $this_template (@templates) { + if($this_template->{'name'} eq $marc_mod_template) { + $marc_mod_template_id = $this_template->{'template_id'}; + last; + } + } + if($marc_mod_template_id < 0) { + die "Can't located MARC modification template '$marc_mod_template'\n"; + } +} + $record_type = 'auth' if ($authorities); if (not $result or $input_file eq "" or $want_help) { @@ -92,6 +109,7 @@ process_batch({ no_replace => $no_replace, no_create => $no_create, item_action => $item_action, + marc_mod_template_id => $marc_mod_template_id, }); $dbh->commit(); @@ -116,7 +134,7 @@ sub process_batch { print "... staging MARC records -- please wait\n"; #FIXME: We should really allow the use of marc modification frameworks and to_marc plugins here if possible my ($batch_id, $num_valid_records, $num_items, @import_errors) = - BatchStageMarcRecords($record_type, $params->{encoding}, $marc_records, $params->{input_file}, undef, undef, $params->{batch_comment}, '', $params->{add_items}, 0, + BatchStageMarcRecords($record_type, $params->{encoding}, $marc_records, $params->{input_file}, $params->{'marc_mod_template_id'}, undef, $params->{batch_comment}, '', $params->{add_items}, 0, 100, \&print_progress_and_commit); print "... finished staging MARC records\n"; @@ -218,6 +236,14 @@ Parameters: the record batch; if the comment has spaces in it, surround the comment with quotation marks. + --marcmodtemplate