From 1b83bd7261a0fa44de2dab2ff2bccca863992503 Mon Sep 17 00:00:00 2001 From: Vitor Fernandes Date: Fri, 19 Jun 2015 11:40:41 +0100 Subject: [PATCH] Bug 14420 : bulkmarcimport.pl - Some problems http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14420 Created by: Vitor Fernandes Sponsored by: KEEP SOLUTIONS --- misc/migration_tools/bulkmarcimport.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 8d1f518..31ba504 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -35,7 +35,7 @@ use open qw( :std :encoding(UTF-8) ); binmode( STDOUT, ":encoding(UTF-8)" ); my ( $input_marc_file, $number, $offset) = ('',0,0); my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile); -my ( $insert, $filters, $update, $all, $yamlfile, $authtypes, $append ); +my ( $insert, $filters, $update, $updateadditems, $all, $yamlfile, $authtypes, $append ); my $cleanisbn = 1; my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode); my $framework = ''; @@ -65,6 +65,7 @@ GetOptions( 'filter=s@' => \$filters, 'insert' => \$insert, 'update' => \$update, + 'updateadditems' => \$updateadditems, 'all' => \$all, 'match=s@' => \$match, 'i|isbn' => \$isbn_check, @@ -207,7 +208,7 @@ else { } # the SQL query to search on isbn -my $sth_isbn = $dbh->prepare("SELECT biblionumber,biblioitemnumber FROM biblioitems WHERE isbn=?"); +my $sth_isbn = $dbh->prepare("SELECT biblionumber,biblioitemnumber FROM biblioitems WHERE isbn=? OR isbn like ? OR isbn like ? OR isbn like ?"); $dbh->{AutoCommit} = 0; my $loghandle; @@ -253,7 +254,7 @@ RECORD: while ( ) { if ($biblios && $cleanisbn) { my $tag = $marcFlavour eq 'UNIMARC' ? '010' : '020'; my $field = $record->field($tag); - my $isbn = $field && $field->subfield('a'); + $isbn = $field && $field->subfield('a'); if ( $isbn ) { $isbn =~ s/-//g; $field->update('a' => $isbn); @@ -385,7 +386,7 @@ RECORD: while ( ) { # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter if (!$biblionumber && $isbn_check && $isbn) { # warn "search ISBN : $isbn"; - $sth_isbn->execute($isbn); + $sth_isbn->execute($isbn, $isbn." | %", "% | ".$isbn, "% | ".$isbn." | %"); ($biblionumber,$biblioitemnumber) = $sth_isbn->fetchrow; } if (defined $idmapfl) { @@ -403,7 +404,8 @@ RECORD: while ( ) { if ($biblionumber) { eval{$biblioitemnumber=GetBiblioData($biblionumber)->{biblioitemnumber};}; if ($update) { - eval { ( $biblionumber, $biblioitemnumber ) = ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) }; + my $clone = $updateadditems ? $record->clone() : $record; + eval { ModBiblio( $clone, $biblionumber, GetFrameworkCode($biblionumber) ) }; if ($@) { warn "ERROR: Edit biblio $biblionumber failed: $@\n"; printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile); -- 1.9.1