Bugzilla – Attachment 61907 Details for
Bug 18389
Allow using MARC modification templates in bulkmarcimport.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for bulkmarcimport.pl
bulkmarcimport.pl.patch (text/plain), 4.47 KB, created by
Jon Knight
on 2017-04-05 16:21:49 UTC
(
hide
)
Description:
Patch for bulkmarcimport.pl
Filename:
MIME Type:
Creator:
Jon Knight
Created:
2017-04-05 16:21:49 UTC
Size:
4.47 KB
patch
obsolete
>--- /var/koha/koha/misc/migration_tools/bulkmarcimport.pl 2017-03-03 11:34:37.474693412 +0000 >+++ bulkmarcimport.pl 2017-04-05 17:11:55.955277684 +0100 >@@ -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::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 ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode); > my $framework = ''; > my $localcust; >+my $marc_mod_template = ''; >+my $marc_mod_template_id = -1; > > $|=1; > >@@ -79,6 +84,7 @@ > 'dedupbarcode' => \$dedup_barcode, > 'framework=s' => \$framework, > 'custom:s' => \$localcust, >+ 'marcmodtemplate:s' => \$marc_mod_template, > ); > $biblios ||= !$authorities; > $insert ||= !$update; >@@ -114,6 +120,19 @@ > $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 @@ > } > } > 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) >@@ -404,18 +427,19 @@ > $sth_isbn->execute($isbn); > ($biblionumber,$biblioitemnumber) = $sth_isbn->fetchrow; > } >- if (defined $idmapfl) { >- if ($sourcetag < "010"){ >- if ($record->field($sourcetag)){ >- my $source = $record->field($sourcetag)->data(); >- printf(IDMAP "%s|%s\n",$source,$biblionumber); >- } >- } else { >- my $source=$record->subfield($sourcetag,$sourcesubfield); >- printf(IDMAP "%s|%s\n",$source,$biblionumber); >- } >- } >- # create biblio, unless we already have it ( either match or isbn ) >+ if (defined $idmapfl) { >+ if ($sourcetag < "010"){ >+ if ($record->field($sourcetag)){ >+ my $source = $record->field($sourcetag)->data(); >+ printf(IDMAP "%s|%s\n",$source,$biblionumber); >+ } >+ } else { >+ my $source=$record->subfield($sourcetag,$sourcesubfield); >+ printf(IDMAP "%s|%s\n",$source,$biblionumber); >+ } >+ } >+ >+ # create biblio, unless we already have it ( either match or isbn ) > if ($biblionumber) { > eval{$biblioitemnumber=GetBiblioData($biblionumber)->{biblioitemnumber};}; > if ($update) { >@@ -446,23 +470,24 @@ > } > eval { ( $itemnumbers_ref, $errors_ref ) = AddItemBatchFromMarc( $record, $biblionumber, $biblioitemnumber, '' ); }; > my $error_adding = $@; >+ > # Work on a clone so that if there are real errors, we can maybe > # fix them up later. >- my $clone_record = $record->clone(); >+ my $clone_record = $record->clone(); > C4::Biblio::_strip_item_fields($clone_record, ''); > # This sets the marc fields if there was an error, and also calls > # defer_marc_save. > ModBiblioMarc( $clone_record, $biblionumber, $framework ); > if ( $error_adding ) { > warn "ERROR: Adding items to bib $biblionumber failed: $error_adding"; >- printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile); >+ printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile); > # if we failed because of an exception, assume that > # the MARC columns in biblioitems were not set. > next RECORD; >- } >- else{ >- printlog({id=>$id||$originalid||$biblionumber, op=>"insert",status=>"ok"}) if ($logfile); >- } >+ } else { >+ printlog({id=>$id||$originalid||$biblionumber, op=>"insert",status=>"ok"}) if ($logfile); >+ } >+ > if ($dedup_barcode && grep { exists $_->{error_code} && $_->{error_code} eq 'duplicate_barcode' } @$errors_ref) { > # Find the record called 'barcode' > my ($tag, $sub) = C4::Biblio::GetMarcFromKohaField('items.barcode', $framework);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18389
:
61907
|
63353
|
63469
|
63851
|
66144
|
66379
|
66498
|
68587
|
68588
|
68589
|
68590
|
68591
|
68592