Bug 12289: (follow-up) fix the compilation error
[srvgit] / misc / stage_file.pl
index 4ce16b5..5fc70b7 100755 (executable)
@@ -45,13 +45,17 @@ my $input_file = "";
 my $batch_comment = "";
 my $want_help = 0;
 my $no_replace ;
+my $no_create;
+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,
+    'no-create'     => \$no_create,
     'comment:s'     => \$batch_comment,
     'authorities'   => \$authorities,
     'h|help'        => \$want_help
@@ -98,8 +102,9 @@ sub process_batch {
     close IN;
 
     print "... staging MARC records -- please wait\n";
+    #FIXME: We should really allow the use of marc modification frameworks and to_marc plugins here if possible
     my ($batch_id, $num_valid_records, $num_items, @import_errors) =
-        BatchStageMarcRecords($record_type, $encoding, $marc_records, $input_file, $batch_comment, '', $add_items, 0,
+        BatchStageMarcRecords($record_type, $encoding, $marc_records, $input_file, undef, undef, $batch_comment, '', $add_items, 0,
                               100, \&print_progress_and_commit);
     print "... finished staging MARC records\n";
 
@@ -116,8 +121,8 @@ 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');
+        SetImportBatchNoMatchAction($batch_id, ($no_create) ? 'ignore' : 'create_new');
+        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,8 +191,14 @@ 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.
+    --no-create             nomatch action for record: default is to
+                            create new record with imported record.
     --comment <comment>     optional comment to describe
                             the record batch; if the comment
                             has spaces in it, surround the