From 17cf78c323e1c03846fbfed8025c0151818ba9fa Mon Sep 17 00:00:00 2001 From: Jon Knight Date: Wed, 10 May 2017 16:10:53 +0100 Subject: [PATCH] Changed to allow MARC Modifications Templates to be used with the bulk importer. This patch does NOT change the white space formatting in the areas of this script that the changes do not touch. --- misc/migration_tools/bulkmarcimport.pl | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index dc2cae4..b6472a5 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -3,6 +3,7 @@ use strict; use warnings; +use Modern::Perl; #use diagnostics; BEGIN { # find Koha's Perl modules @@ -24,6 +25,8 @@ use C4::Koha; use C4::Debug; use C4::Charset; use C4::Items; +use C4::MarcModificationTemplates; + use YAML; use Unicode::Normalize; use Time::HiRes qw(gettimeofday); @@ -43,6 +46,8 @@ my $cleanisbn = 1; my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode); my $framework = ''; my $localcust; +my $marc_mod_template = ''; +my $marc_mod_template_id = -1; $|=1; @@ -79,6 +84,7 @@ GetOptions( 'dedupbarcode' => \$dedup_barcode, 'framework=s' => \$framework, 'custom:s' => \$localcust, + 'marcmodtemplate:s' => \$marc_mod_template, ); $biblios ||= !$authorities; $insert ||= !$update; @@ -114,6 +120,19 @@ if(defined $localcust) { #local customize module $localcust=\&customize if $localcust; } +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"; + } +} + my $dbh = C4::Context->dbh; my $heading_fields=get_heading_fields(); @@ -263,6 +282,10 @@ RECORD: while ( ) { } } SetUTF8Flag($record); + if($marc_mod_template_id > 0) { + print "Modifying MARC\n"; + ModifyRecordWithTemplate( $marc_mod_template_id, $record ); + } &$localcust($record) if $localcust; my $isbn; # remove trailing - in isbn (only for biblios, of course) -- 1.7.1