View | Details | Raw Unified | Return to bug 14420
Collapse All | Expand All

(-)a/misc/migration_tools/bulkmarcimport.pl (-6 / +7 lines)
Lines 35-41 use open qw( :std :encoding(UTF-8) ); Link Here
35
binmode( STDOUT, ":encoding(UTF-8)" );
35
binmode( STDOUT, ":encoding(UTF-8)" );
36
my ( $input_marc_file, $number, $offset) = ('',0,0);
36
my ( $input_marc_file, $number, $offset) = ('',0,0);
37
my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile);
37
my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile);
38
my ( $insert, $filters, $update, $all, $yamlfile, $authtypes, $append );
38
my ( $insert, $filters, $update, $updateadditems, $all, $yamlfile, $authtypes, $append );
39
my $cleanisbn = 1;
39
my $cleanisbn = 1;
40
my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode);
40
my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode);
41
my $framework = '';
41
my $framework = '';
Lines 65-70 GetOptions( Link Here
65
    'filter=s@'     => \$filters,
65
    'filter=s@'     => \$filters,
66
    'insert'        => \$insert,
66
    'insert'        => \$insert,
67
    'update'        => \$update,
67
    'update'        => \$update,
68
    'updateadditems' => \$updateadditems,
68
    'all'           => \$all,
69
    'all'           => \$all,
69
    'match=s@'    => \$match,
70
    'match=s@'    => \$match,
70
    'i|isbn' => \$isbn_check,
71
    'i|isbn' => \$isbn_check,
Lines 207-213 else { Link Here
207
}
208
}
208
209
209
# the SQL query to search on isbn
210
# the SQL query to search on isbn
210
my $sth_isbn = $dbh->prepare("SELECT biblionumber,biblioitemnumber FROM biblioitems WHERE isbn=?");
211
my $sth_isbn = $dbh->prepare("SELECT biblionumber,biblioitemnumber FROM biblioitems WHERE isbn=? OR isbn like ? OR isbn like ? OR isbn like ?");
211
212
212
$dbh->{AutoCommit} = 0;
213
$dbh->{AutoCommit} = 0;
213
my $loghandle;
214
my $loghandle;
Lines 253-259 RECORD: while ( ) { Link Here
253
    if ($biblios && $cleanisbn) {
254
    if ($biblios && $cleanisbn) {
254
        my $tag = $marcFlavour eq 'UNIMARC' ? '010' : '020';
255
        my $tag = $marcFlavour eq 'UNIMARC' ? '010' : '020';
255
        my $field = $record->field($tag);
256
        my $field = $record->field($tag);
256
        my $isbn = $field && $field->subfield('a');
257
        $isbn = $field && $field->subfield('a');
257
        if ( $isbn ) {
258
        if ( $isbn ) {
258
            $isbn =~ s/-//g;
259
            $isbn =~ s/-//g;
259
            $field->update('a' => $isbn);
260
            $field->update('a' => $isbn);
Lines 385-391 RECORD: while ( ) { Link Here
385
            # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter
386
            # check for duplicate, based on ISBN (skip it if we already have found a duplicate with match parameter
386
            if (!$biblionumber && $isbn_check && $isbn) {
387
            if (!$biblionumber && $isbn_check && $isbn) {
387
    #         warn "search ISBN : $isbn";
388
    #         warn "search ISBN : $isbn";
388
                $sth_isbn->execute($isbn);
389
                $sth_isbn->execute($isbn, $isbn." | %", "% | ".$isbn, "% | ".$isbn." | %");
389
                ($biblionumber,$biblioitemnumber) = $sth_isbn->fetchrow;
390
                ($biblionumber,$biblioitemnumber) = $sth_isbn->fetchrow;
390
            }
391
            }
391
        	if (defined $idmapfl) {
392
        	if (defined $idmapfl) {
Lines 403-409 RECORD: while ( ) { Link Here
403
            if ($biblionumber) {
404
            if ($biblionumber) {
404
                eval{$biblioitemnumber=GetBiblioData($biblionumber)->{biblioitemnumber};};
405
                eval{$biblioitemnumber=GetBiblioData($biblionumber)->{biblioitemnumber};};
405
                if ($update) {
406
                if ($update) {
406
                    eval { ( $biblionumber, $biblioitemnumber ) = ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) };
407
                    my $clone = $updateadditems ? $record->clone() : $record;
408
                    eval { ModBiblio( $clone, $biblionumber, GetFrameworkCode($biblionumber) ) };
407
                    if ($@) {
409
                    if ($@) {
408
                        warn "ERROR: Edit biblio $biblionumber failed: $@\n";
410
                        warn "ERROR: Edit biblio $biblionumber failed: $@\n";
409
                        printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile);
411
                        printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile);
410
- 

Return to bug 14420