|
Lines 45-54
my $input_file = "";
Link Here
|
| 45 |
my $batch_comment = ""; |
45 |
my $batch_comment = ""; |
| 46 |
my $want_help = 0; |
46 |
my $want_help = 0; |
| 47 |
my $no_replace ; |
47 |
my $no_replace ; |
|
|
48 |
my $format = 'ISO2709'; |
| 48 |
my $item_action = 'always_add'; |
49 |
my $item_action = 'always_add'; |
| 49 |
|
50 |
|
| 50 |
my $result = GetOptions( |
51 |
my $result = GetOptions( |
| 51 |
'encoding:s' => \$encoding, |
52 |
'encoding:s' => \$encoding, |
|
|
53 |
'format:s' => \$format, |
| 52 |
'file:s' => \$input_file, |
54 |
'file:s' => \$input_file, |
| 53 |
'match|match-bibs:s' => \$match, |
55 |
'match|match-bibs:s' => \$match, |
| 54 |
'add-items' => \$add_items, |
56 |
'add-items' => \$add_items, |
|
Lines 76-107
unless (-r $input_file) {
Link Here
|
| 76 |
|
78 |
|
| 77 |
my $dbh = C4::Context->dbh; |
79 |
my $dbh = C4::Context->dbh; |
| 78 |
$dbh->{AutoCommit} = 0; |
80 |
$dbh->{AutoCommit} = 0; |
| 79 |
process_batch($input_file, $record_type, $match, $add_items, $batch_comment); |
81 |
process_batch($format, $input_file, $record_type, $match, $add_items, $batch_comment); |
| 80 |
$dbh->commit(); |
82 |
$dbh->commit(); |
| 81 |
|
83 |
|
| 82 |
exit 0; |
84 |
exit 0; |
| 83 |
|
85 |
|
| 84 |
sub process_batch { |
86 |
sub process_batch { |
| 85 |
my ($input_file, $record_type, $match, $add_items, $batch_comment) = @_; |
87 |
my ($format, $input_file, $record_type, $match, $add_items, $batch_comment) = @_; |
| 86 |
|
88 |
|
| 87 |
open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n"; |
89 |
my $marc_records = C4::ImportBatch::RecordsFromISO2709File($input_file) if $format eq 'ISO2709'; |
| 88 |
my $marc_records = ""; |
90 |
$marc_records = C4::ImportBatch::RecordsFromMARCXMLFile($input_file, $encoding) if $format eq 'MARCXML'; |
| 89 |
$/ = "\035"; |
91 |
my $num_input_records = ($marc_records) ? scalar(@$marc_records) : 0; |
| 90 |
my $num_input_records = 0; |
|
|
| 91 |
while (<IN>) { |
| 92 |
s/^\s+//; |
| 93 |
s/\s+$//; |
| 94 |
next unless $_; # skip if record has only whitespace, as might occur |
| 95 |
# if file includes newlines between each MARC record |
| 96 |
$marc_records .= $_; # FIXME - this sort of string concatenation |
| 97 |
# is probably rather inefficient |
| 98 |
$num_input_records++; |
| 99 |
} |
| 100 |
close IN; |
| 101 |
|
92 |
|
| 102 |
print "... staging MARC records -- please wait\n"; |
93 |
print "... staging MARC records -- please wait\n"; |
| 103 |
my ($batch_id, $num_valid_records, $num_items, @import_errors) = |
94 |
my ($batch_id, $num_valid_records, $num_items, @import_errors) = |
| 104 |
BatchStageMarcRecords($record_type, $encoding, $marc_records, $input_file, undef, $batch_comment, '', $add_items, 0, |
95 |
BatchStageMarcRecords($format, $record_type, $encoding, $marc_records, $input_file, undef, $batch_comment, '', $add_items, 0, |
| 105 |
100, \&print_progress_and_commit); |
96 |
100, \&print_progress_and_commit); |
| 106 |
print "... finished staging MARC records\n"; |
97 |
print "... finished staging MARC records\n"; |
| 107 |
|
98 |
|
|
Lines 179-184
Parameters:
Link Here
|
| 179 |
--encoding <encoding> encoding of MARC records, default is utf8. |
170 |
--encoding <encoding> encoding of MARC records, default is utf8. |
| 180 |
Other possible options are: MARC-8, |
171 |
Other possible options are: MARC-8, |
| 181 |
ISO_5426, ISO_6937, ISO_8859-1, EUC-KR |
172 |
ISO_5426, ISO_6937, ISO_8859-1, EUC-KR |
|
|
173 |
--format The MARC transport format to use? |
| 174 |
Defaults to ISO2709. |
| 175 |
Available values, MARCXML, ISO2709. |
| 182 |
--match <match_id> use this option to match records |
176 |
--match <match_id> use this option to match records |
| 183 |
in the file with records already in |
177 |
in the file with records already in |
| 184 |
the database for future overlay. |
178 |
the database for future overlay. |