Lines 34-39
my $want_help;
Link Here
|
34 |
my $as_xml; |
34 |
my $as_xml; |
35 |
my $process_zebraqueue; |
35 |
my $process_zebraqueue; |
36 |
my $do_not_clear_zebraqueue; |
36 |
my $do_not_clear_zebraqueue; |
|
|
37 |
my $item_limit; |
38 |
my $min; |
39 |
my $where; |
40 |
my $ofset; |
37 |
my $verbose_logging; |
41 |
my $verbose_logging; |
38 |
my $zebraidx_log_opt = " -v none,fatal,warn "; |
42 |
my $zebraidx_log_opt = " -v none,fatal,warn "; |
39 |
my $result = GetOptions( |
43 |
my $result = GetOptions( |
Lines 51-56
my $result = GetOptions(
Link Here
|
51 |
'x' => \$as_xml, |
55 |
'x' => \$as_xml, |
52 |
'y' => \$do_not_clear_zebraqueue, |
56 |
'y' => \$do_not_clear_zebraqueue, |
53 |
'z' => \$process_zebraqueue, |
57 |
'z' => \$process_zebraqueue, |
|
|
58 |
'l:i' => \$item_limit, |
59 |
'where:s' => \$where, |
60 |
'min:i' => \$min, |
61 |
'ofset:i' => \$ofset, |
54 |
'v' => \$verbose_logging, |
62 |
'v' => \$verbose_logging, |
55 |
); |
63 |
); |
56 |
|
64 |
|
Lines 78-83
if ( !$as_xml and $nosanitize ) {
Link Here
|
78 |
die $msg; |
86 |
die $msg; |
79 |
} |
87 |
} |
80 |
|
88 |
|
|
|
89 |
if ( $nosanitize and $item_limit ) { |
90 |
my $msg = "Cannot specify both -item_limit and -nosanitize\n"; |
91 |
$msg .= "Please do '$0 --help' to see usage.\n"; |
92 |
die $msg; |
93 |
} |
94 |
|
81 |
if ($process_zebraqueue and ($skip_export or $reset)) { |
95 |
if ($process_zebraqueue and ($skip_export or $reset)) { |
82 |
my $msg = "Cannot specify -r or -s if -z is specified\n"; |
96 |
my $msg = "Cannot specify -r or -s if -z is specified\n"; |
83 |
$msg .= "Please do '$0 --help' to see usage.\n"; |
97 |
$msg .= "Please do '$0 --help' to see usage.\n"; |
Lines 294-306
sub select_all_records {
Link Here
|
294 |
} |
308 |
} |
295 |
|
309 |
|
296 |
sub select_all_authorities { |
310 |
sub select_all_authorities { |
297 |
my $sth = $dbh->prepare("SELECT authid FROM auth_header"); |
311 |
my $strsth=qq{SELECT authid from auth_header}; |
|
|
312 |
$strsth.=qq{ WHERE $where } if ($where); |
313 |
$strsth.=qq{ LIMIT $min } if ($min && !$ofset); |
314 |
$strsth.=qq{ LIMIT $min,$ofset } if ($min && $ofset); |
315 |
my $sth = $dbh->prepare($strsth); |
298 |
$sth->execute(); |
316 |
$sth->execute(); |
299 |
return $sth; |
317 |
return $sth; |
300 |
} |
318 |
} |
301 |
|
319 |
|
302 |
sub select_all_biblios { |
320 |
sub select_all_biblios { |
303 |
my $sth = $dbh->prepare("SELECT biblionumber FROM biblioitems ORDER BY biblionumber"); |
321 |
my $strsth = qq{ SELECT biblionumber FROM biblioitems }; |
|
|
322 |
$strsth.=qq{ WHERE $where } if ($where); |
323 |
$strsth.=qq{ LIMIT $min } if ($min && !$ofset); |
324 |
$strsth.=qq{ LIMIT $min,$ofset } if ($ofset); |
325 |
my $sth = $dbh->prepare($strsth); |
304 |
$sth->execute(); |
326 |
$sth->execute(); |
305 |
return $sth; |
327 |
return $sth; |
306 |
} |
328 |
} |
Lines 406-411
sub generate_deleted_marc_records {
Link Here
|
406 |
my $marc = MARC::Record->new(); |
428 |
my $marc = MARC::Record->new(); |
407 |
if ($record_type eq 'biblio') { |
429 |
if ($record_type eq 'biblio') { |
408 |
fix_biblio_ids($marc, $record_number, $record_number); |
430 |
fix_biblio_ids($marc, $record_number, $record_number); |
|
|
431 |
fix_biblio_items( $marc ) if $item_limit; |
409 |
} else { |
432 |
} else { |
410 |
fix_authority_id($marc, $record_number); |
433 |
fix_authority_id($marc, $record_number); |
411 |
} |
434 |
} |
Lines 431-440
sub get_corrected_marc_record {
Link Here
|
431 |
|
454 |
|
432 |
if (defined $marc) { |
455 |
if (defined $marc) { |
433 |
fix_leader($marc); |
456 |
fix_leader($marc); |
434 |
if ($record_type eq 'authority') { |
457 |
if ( $record_type eq 'biblio' ) { |
435 |
fix_authority_id($marc, $record_number); |
458 |
my $succeeded = fix_biblio_ids( $marc, $record_number ); |
|
|
459 |
fix_biblio_items( $marc ) if $item_limit; |
460 |
return unless $succeeded; |
461 |
} else { |
462 |
fix_authority_id( $marc, $record_number ); |
436 |
} |
463 |
} |
437 |
if (C4::Context->preference("marcflavour") eq "UNIMARC") { |
464 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
438 |
fix_unimarc_100($marc); |
465 |
fix_unimarc_100($marc); |
439 |
} |
466 |
} |
440 |
} |
467 |
} |
Lines 498-503
sub fix_leader {
Link Here
|
498 |
$marc->leader(substr($leader, 0, 24)); |
525 |
$marc->leader(substr($leader, 0, 24)); |
499 |
} |
526 |
} |
500 |
|
527 |
|
|
|
528 |
sub fix_biblio_items { |
529 |
my $marc = shift; |
530 |
|
531 |
my ($itemtagfield, $itemtagsubfield) = GetMarcFromKohaField('items.itemnumber',''); |
532 |
|
533 |
my $i = 0; |
534 |
for my $itemfield ( $marc->field($itemtagfield) ) { |
535 |
$marc->delete_field($itemfield) if $i >= $item_limit; |
536 |
$i++; |
537 |
} |
538 |
} |
539 |
|
501 |
sub fix_biblio_ids { |
540 |
sub fix_biblio_ids { |
502 |
# FIXME - it is essential to ensure that the biblionumber is present, |
541 |
# FIXME - it is essential to ensure that the biblionumber is present, |
503 |
# otherwise, Zebra will choke on the record. However, this |
542 |
# otherwise, Zebra will choke on the record. However, this |
Lines 635-643
Parameters:
Link Here
|
635 |
the same records - specify -y to override this. |
674 |
the same records - specify -y to override this. |
636 |
Cannot be used with -z. |
675 |
Cannot be used with -z. |
637 |
|
676 |
|
|
|
677 |
-l set a maximum number of exported items per biblio. |
678 |
Doesn't work with -nosanitize. |
679 |
|
638 |
-v increase the amount of logging. Normally only |
680 |
-v increase the amount of logging. Normally only |
639 |
warnings and errors from the indexing are shown. |
681 |
warnings and errors from the indexing are shown. |
640 |
|
682 |
|
|
|
683 |
-min 1234 minimum biblionumber |
684 |
-ofset 1243 count biblios to process |
641 |
-munge-config Deprecated option to try |
685 |
-munge-config Deprecated option to try |
642 |
to fix Zebra config files. |
686 |
to fix Zebra config files. |
643 |
--help or -h show this message. |
687 |
--help or -h show this message. |