|
Lines 18-29
$| = 1;
Link Here
|
| 18 |
# command-line parameters |
18 |
# command-line parameters |
| 19 |
my $batch_number = ""; |
19 |
my $batch_number = ""; |
| 20 |
my $list_batches = 0; |
20 |
my $list_batches = 0; |
|
|
21 |
my $progress_interval = 100; |
| 21 |
my $want_help = 0; |
22 |
my $want_help = 0; |
|
|
23 |
my $revert = 0; |
| 22 |
|
24 |
|
| 23 |
my $result = GetOptions( |
25 |
my $result = GetOptions( |
| 24 |
'batch-number:s' => \$batch_number, |
26 |
'batch-number:s' => \$batch_number, |
| 25 |
'list-batches' => \$list_batches, |
27 |
'list-batches' => \$list_batches, |
| 26 |
'h|help' => \$want_help |
28 |
'progress-interval' => \$progress_interval, |
|
|
29 |
'revert' => \$revert, |
| 30 |
'h|help' => \$want_help |
| 27 |
); |
31 |
); |
| 28 |
|
32 |
|
| 29 |
if ($want_help or (not $batch_number and not $list_batches)) { |
33 |
if ($want_help or (not $batch_number and not $list_batches)) { |
|
Lines 47-53
if ($batch_number =~ /^\d+$/ and $batch_number > 0) {
Link Here
|
| 47 |
die "$0: import batch $batch_number does not exist in database\n" unless defined $batch; |
51 |
die "$0: import batch $batch_number does not exist in database\n" unless defined $batch; |
| 48 |
die "$0: import batch $batch_number status is '" . $batch->{'import_status'} . "', and therefore cannot be imported\n" |
52 |
die "$0: import batch $batch_number status is '" . $batch->{'import_status'} . "', and therefore cannot be imported\n" |
| 49 |
unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted"; |
53 |
unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted"; |
| 50 |
process_batch($batch_number); |
54 |
if ($revert) { |
|
|
55 |
revert_batch($batch_number); |
| 56 |
} else { |
| 57 |
process_batch($batch_number); |
| 58 |
} |
| 51 |
$dbh->commit(); |
59 |
$dbh->commit(); |
| 52 |
} else { |
60 |
} else { |
| 53 |
die "$0: please specify a numeric batch ID\n"; |
61 |
die "$0: please specify a numeric batch ID\n"; |
|
Lines 75-81
sub process_batch {
Link Here
|
| 75 |
|
83 |
|
| 76 |
print "... importing MARC records -- please wait\n"; |
84 |
print "... importing MARC records -- please wait\n"; |
| 77 |
my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) = |
85 |
my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) = |
| 78 |
BatchCommitBibRecords($import_batch_id, '', 100, \&print_progress_and_commit); |
86 |
BatchCommitBibRecords($import_batch_id, $progress_interval, \&print_progress_and_commit); |
| 79 |
print "... finished importing MARC records\n"; |
87 |
print "... finished importing MARC records\n"; |
| 80 |
|
88 |
|
| 81 |
print <<_SUMMARY_; |
89 |
print <<_SUMMARY_; |
|
Lines 94-99
duplicate of one already in the database.
Link Here
|
| 94 |
_SUMMARY_ |
102 |
_SUMMARY_ |
| 95 |
} |
103 |
} |
| 96 |
|
104 |
|
|
|
105 |
sub revert_batch { |
| 106 |
my ($import_batch_id) = @_; |
| 107 |
|
| 108 |
print "... reverting MARC records -- please wait\n"; |
| 109 |
my ($num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored) = |
| 110 |
BatchRevertBibRecords($import_batch_id); |
| 111 |
print "... finished revrting MARC records\n"; |
| 112 |
|
| 113 |
print <<_SUMMARY_; |
| 114 |
|
| 115 |
MARC record reversion report |
| 116 |
---------------------------------------- |
| 117 |
Batch number: $import_batch_id |
| 118 |
Number of bibs deleted: $num_deleted |
| 119 |
Number of errors: $num_errors |
| 120 |
Number of bibs reverted: $num_reverted |
| 121 |
Number of items deleted: $num_items_deleted |
| 122 |
Number of ignored: $num_ignored |
| 123 |
|
| 124 |
Note: an item is ignored if its in batch but not actually commited. |
| 125 |
_SUMMARY_ |
| 126 |
} |
| 127 |
|
| 97 |
sub print_progress_and_commit { |
128 |
sub print_progress_and_commit { |
| 98 |
my $recs = shift; |
129 |
my $recs = shift; |
| 99 |
print "... processed $recs records\n"; |
130 |
print "... processed $recs records\n"; |
|
Lines 112-117
stage_biblios_file.pl or by the Koha Tools option
Link Here
|
| 112 |
Parameters: |
143 |
Parameters: |
| 113 |
--batch-number <#> number of the record batch |
144 |
--batch-number <#> number of the record batch |
| 114 |
to import |
145 |
to import |
|
|
146 |
--progress-interval <#> update import progress every <#> records |
| 147 |
(default 100) |
| 148 |
--revert revert the batch rather than commiting it |
| 115 |
--list-batches print a list of record batches |
149 |
--list-batches print a list of record batches |
| 116 |
available to commit |
150 |
available to commit |
| 117 |
--help or -h show this message. |
151 |
--help or -h show this message. |
| 118 |
- |
|
|