12 # command-line parameters
16 my $batch_comment = "";
19 my $result = GetOptions(
20 'file:s' => \$input_file,
21 'match-bibs' => \$match_bibs,
22 'add-items' => \$add_items,
23 'comment:s' => \$batch_comment,
24 'h|help' => \$want_help
27 if (not $result or $input_file eq "" or $want_help) {
32 unless (-r $input_file) {
33 die "$0: cannot open input file $input_file: $!\n";
36 process_batch($input_file, $match_bibs, $add_items, $batch_comment);
41 my ($input_file, $match_bibs, $add_items, $batch_comment) = @_;
43 open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
44 my $marc_records = "";
46 my $num_input_records = 0;
48 $marc_records .= $_; # FIXME - this sort of string concatenation
49 # is probably rather inefficient
54 my $marc_flavor = C4::Context->preference('marcflavour');
56 print "... staging MARC records -- please wait\n";
57 my ($batch_id, $num_valid, $num_items, @import_errors) =
58 BatchStageMarcRecords($marc_flavor, $marc_records, $input_file, $batch_comment, '', $add_items, 0,
59 100, \&print_progress);
60 print "... finished staging MARC records\n";
62 my $num_with_matches = 0;
64 my $matcher = C4::Matcher->new('biblio');
65 $matcher->add_simple_matchpoint('isbn', 1000, '020', 'a', -1, 0, '');
66 $matcher->add_simple_required_check('245', 'a', -1, 0, '',
67 '245', 'a', -1, 0, '');
68 print "... looking for matches with records already in database\n";
69 $num_with_matches = BatchFindBibDuplicates($batch_id, $matcher, 10, 100, \&print_progress);
70 print "... finished looking for matches\n";
73 my $num_invalid_bibs = scalar(@import_errors);
76 MARC record staging report
77 ------------------------------------
78 Input file: $input_file
79 Number of input bibs: $num_input_records
80 Number of valid bibs: $num_valid
81 Number of invalid bibs: $num_invalid_bibs
84 print "Number of bibs matched: $num_with_matches\n";
86 print "Incoming bibs not matched against existing bibs (--match-bibs option not supplied)\n";
89 print "Number of items parsed: $num_items\n";
91 print "No items parsed (--add-items option not supplied)\n";
95 print "Batch number assigned: $batch_id\n";
101 print "... processed $recs records\n";
106 $0: stage MARC bib file into reservoir.
108 Use this batch job to load a file of MARC bibliographic records
109 (with optional item information) into the Koha reservoir.
111 After running this program to stage your file, you can use
112 either the batch job commit_biblios_file.pl or the Koha
113 Tools option "Manage Staged MARC Records" to load the
114 records into the main Koha database.
117 --file <file_name> name of input MARC bib file
118 --match-bibs use this option to match bibs
119 in the file with bibs already in
120 the database for future overlay.
121 --add-items use this option to specify that
122 item data is embedded in the MARC
123 bibs and should be parsed.
124 --comment <comment> optional comment to describe
125 the record batch; if the comment
126 has spaces in it, surround the
127 comment with quotation marks.
128 --help or -h show this message.