This patch makes two adjustments:
[1] For the verbose option, verbose level 2 now means print the
formatted version of each record.
[2] If a module LocalChanges.pm is found in misc/migration_tools, the
routine "customize" in this module is called for each marc record.
This allows you to make local changes to these marc records before
importing them.
Test plan:
[1] Test the verbose option: a single -v for medium verbosity and two
-v to dump a human-readable version of the record to standard output.
(Do not yet copy LocalChanges.pm in the folder.)
You may used the attached example file on Bugzilla:
perl misc/migration_tools/bulkmarcimport.pl -file zztest01.xml -v -v -b -m XML -t | more
Note the option t for test; no records will be imported.
[2] Copy LocalChanges.pm in the migration_tools folder. You may use the
example provided on Bugzilla (in a patch). If you use the example module,
check the contents of 001, 005 and 590 fields. (The -v -v option allows
you to easily check that.)
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
use IO::File;
use Pod::Usage;
use IO::File;
use Pod::Usage;
+my $localcust= $FindBin::Bin.'/LocalChanges.pm';
+$localcust= -e $localcust? $localcust: undef;
+require $localcust if $localcust;
+$localcust=\&customize if $localcust;
+
use open qw( :std :encoding(UTF-8) );
binmode( STDOUT, ":encoding(UTF-8)" );
my ( $input_marc_file, $number, $offset) = ('',0,0);
use open qw( :std :encoding(UTF-8) );
binmode( STDOUT, ":encoding(UTF-8)" );
my ( $input_marc_file, $number, $offset) = ('',0,0);
't|test' => \$test_parameter,
's' => \$skip_marc8_conversion,
'c:s' => \$char_encoding,
't|test' => \$test_parameter,
's' => \$skip_marc8_conversion,
'c:s' => \$char_encoding,
'fk' => \$fk_off,
'm:s' => \$format,
'l:s' => \$logfile,
'fk' => \$fk_off,
'm:s' => \$format,
'l:s' => \$logfile,
# skip if we get an empty record (that is MARC valid, but will result in AddBiblio failure
last unless ( $record );
$i++;
# skip if we get an empty record (that is MARC valid, but will result in AddBiblio failure
last unless ( $record );
$i++;
- print ".";
- print "\n$i" unless $i % 100;
-
+ if( ($verbose//1)==1 ) { #no dot for verbose==2
+ print "." . ( $i % 100==0 ? "\n$i" : '' );
+ }
+
# transcode the record to UTF8 if needed & applicable.
if ($record->encoding() eq 'MARC-8' and not $skip_marc8_conversion) {
# FIXME update condition
# transcode the record to UTF8 if needed & applicable.
if ($record->encoding() eq 'MARC-8' and not $skip_marc8_conversion) {
# FIXME update condition
}
}
SetUTF8Flag($record);
}
}
SetUTF8Flag($record);
+ &$localcust($record) if $localcust;
my $isbn;
# remove trailing - in isbn (only for biblios, of course)
if ($biblios && $cleanisbn) {
my $isbn;
# remove trailing - in isbn (only for biblios, of course)
if ($biblios && $cleanisbn) {
}
$dbh->commit() if (0 == $i % $commitnum);
}
}
$dbh->commit() if (0 == $i % $commitnum);
}
+ print $record->as_formatted()."\n" if ($verbose//0)==2;
last if $i == $number;
}
$dbh->commit();
last if $i == $number;
}
$dbh->commit();