From 5d0bdbce59052abbab348d87ef2975f7b0222478 Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Tue, 6 Nov 2012 17:48:23 +1300 Subject: [PATCH] Bug 9012 - --framework option for bulkmarcimport This allows the --framework option to be specified when running bulkmarkimport. This option allows a framework code to be specified for the records being imported. Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer All tests pass, perlcritic fails before and after. Tested - imported records with -framework FA, FA framework is used - imported records without -framework, default framework is used Signed-off-by: Jared Camins-Esakov --- misc/migration_tools/bulkmarcimport.pl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index a9fee95d14..894138d0f9 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -35,6 +35,7 @@ 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 $cleanisbn = 1; my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode); +my $framework = ''; $|=1; @@ -62,6 +63,7 @@ GetOptions( 'idmap:s' => \$idmapfl, 'cleanisbn!' => \$cleanisbn, 'dedupbarcode' => \$dedup_barcode, + 'framework=s' => \$framework, ); $biblios=!$authorities||$biblios; @@ -154,7 +156,7 @@ if ($authorities){ } else { ( $tagid, $subfieldid ) = - GetMarcFromKohaField( "biblio.biblionumber", '' ); + GetMarcFromKohaField( "biblio.biblionumber", $framework ); $tagid||="001"; } @@ -308,7 +310,7 @@ RECORD: while ( ) { } else { - eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio($record, '', { defer_marc_save => 1 }) }; + eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio($record, $framework, { defer_marc_save => 1 }) }; } if ( $@ ) { warn "ERROR: Adding biblio $biblionumber failed: $@\n"; @@ -326,7 +328,7 @@ RECORD: while ( ) { 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, '' ); + 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); @@ -339,7 +341,7 @@ RECORD: while ( ) { } 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', ''); + my ($tag, $sub) = C4::Biblio::GetMarcFromKohaField('items.barcode', $framework); # Now remove any items that didn't have a duplicate_barcode error, # erase the barcodes on items that did, and re-add those items. my %dupes; @@ -372,7 +374,7 @@ RECORD: while ( ) { 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. - ModBiblioMarc( $record, $biblionumber, '' ); + ModBiblioMarc( $record, $biblionumber, $framework ); next RECORD; } else { printlog({id=>$id||$originalid||$biblionumber, op=>"insert",status=>"ok"}) if ($logfile); @@ -594,6 +596,12 @@ to add the record is retried, thereby giving the record a blank barcode. This is useful when something has set barcodes to be a biblio ID, or similar (usually other software.) +=item B<-framework> + +This is the code for the framework that the requested records will have attached +to them when they are created. If not specified, then the default framework +will be used. + =back =cut -- 2.39.5