From 997a502c2293ed466178e86f091d9b7d7ce9f6ff Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 30 Oct 2013 04:22:39 +0000 Subject: [PATCH] Bug 7131: (follow-up) update the command-line import tools misc/commit_file.pl now properly displays the number of replaced and ignored items. misc/stage_file.pl now has a new command-line switch --item-action: --item-action action to take if --add-items is specifed; choices are 'always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore', or 'replace' Signed-off-by: Galen Charlton --- misc/commit_file.pl | 3 ++- misc/stage_file.pl | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/misc/commit_file.pl b/misc/commit_file.pl index 9c1089ad2c..bd29df3b85 100755 --- a/misc/commit_file.pl +++ b/misc/commit_file.pl @@ -82,7 +82,7 @@ sub process_batch { my ($import_batch_id) = @_; print "... importing MARC records -- please wait\n"; - my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) = + my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = BatchCommitRecords($import_batch_id, '', 100, \&print_progress_and_commit); print "... finished importing MARC records\n"; @@ -95,6 +95,7 @@ Number of new records added: $num_added Number of records replaced: $num_updated Number of records ignored: $num_ignored Number of items added: $num_items_added +Number of items replaced: $num_items_replaced Number of items ignored: $num_items_errored Note: an item is ignored if its barcode is a diff --git a/misc/stage_file.pl b/misc/stage_file.pl index 4ce16b59e1..3a8615e9df 100755 --- a/misc/stage_file.pl +++ b/misc/stage_file.pl @@ -45,12 +45,14 @@ my $input_file = ""; my $batch_comment = ""; my $want_help = 0; my $no_replace ; +my $item_action = 'always_add'; my $result = GetOptions( 'encoding:s' => \$encoding, 'file:s' => \$input_file, 'match|match-bibs:s' => \$match, 'add-items' => \$add_items, + 'item-action:s' => \$item_action, 'no-replace' => \$no_replace, 'comment:s' => \$batch_comment, 'authorities' => \$authorities, @@ -117,7 +119,7 @@ sub process_batch { # set default record overlay behavior SetImportBatchOverlayAction($batch_id, ($no_replace) ? 'ignore' : 'replace'); SetImportBatchNoMatchAction($batch_id, 'create_new'); - SetImportBatchItemAction($batch_id, 'always_add'); + SetImportBatchItemAction($batch_id, $item_action); print "... looking for matches with records already in database\n"; $num_with_matches = BatchFindDuplicates($batch_id, $matcher, 10, 100, \&print_progress_and_commit); print "... finished looking for matches\n"; @@ -186,6 +188,10 @@ Parameters: --add-items use this option to specify that item data is embedded in the MARC bibs and should be parsed. + --item-action action to take if --add-items is specifed; + choices are 'always_add', + 'add_only_for_matches', 'add_only_for_new', + 'ignore', or 'replace' --no-replace overlay action for record: default is to replace extant with the imported record. --comment optional comment to describe -- 2.39.5