|
Lines 57-63
my $result = GetOptions(
Link Here
|
| 57 |
'munge-config' => \$do_munge, |
57 |
'munge-config' => \$do_munge, |
| 58 |
'a' => \$authorities, |
58 |
'a' => \$authorities, |
| 59 |
'h|help' => \$want_help, |
59 |
'h|help' => \$want_help, |
| 60 |
'x' => \$as_xml, |
60 |
'x' => \$as_xml, |
| 61 |
'y' => \$do_not_clear_zebraqueue, |
61 |
'y' => \$do_not_clear_zebraqueue, |
| 62 |
'z' => \$process_zebraqueue, |
62 |
'z' => \$process_zebraqueue, |
| 63 |
'where:s' => \$where, |
63 |
'where:s' => \$where, |
|
Lines 121-127
my $use_tempdir = 0;
Link Here
|
| 121 |
unless ($directory) { |
121 |
unless ($directory) { |
| 122 |
$use_tempdir = 1; |
122 |
$use_tempdir = 1; |
| 123 |
$directory = tempdir(CLEANUP => ($keep_export ? 0 : 1)); |
123 |
$directory = tempdir(CLEANUP => ($keep_export ? 0 : 1)); |
| 124 |
} |
124 |
} |
| 125 |
|
125 |
|
| 126 |
|
126 |
|
| 127 |
my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory}; |
127 |
my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory}; |
|
Lines 195-213
if ($keep_export) {
Link Here
|
| 195 |
# If they don't, then zebra is likely to spit the dummy. This returns true |
195 |
# If they don't, then zebra is likely to spit the dummy. This returns true |
| 196 |
# if the directories had to be created, false otherwise. |
196 |
# if the directories had to be created, false otherwise. |
| 197 |
sub check_zebra_dirs { |
197 |
sub check_zebra_dirs { |
| 198 |
my ($base) = shift() . '/'; |
198 |
my ($base) = shift() . '/'; |
| 199 |
my $needed_repairing = 0; |
199 |
my $needed_repairing = 0; |
| 200 |
my @dirs = ( '', 'key', 'register', 'shadow', 'tmp' ); |
200 |
my @dirs = ( '', 'key', 'register', 'shadow', 'tmp' ); |
| 201 |
foreach my $dir (@dirs) { |
201 |
foreach my $dir (@dirs) { |
| 202 |
my $bdir = $base . $dir; |
202 |
my $bdir = $base . $dir; |
| 203 |
if (! -d $bdir) { |
203 |
if (! -d $bdir) { |
| 204 |
$needed_repairing = 1; |
204 |
$needed_repairing = 1; |
| 205 |
mkdir $bdir || die "Unable to create '$bdir': $!\n"; |
205 |
mkdir $bdir || die "Unable to create '$bdir': $!\n"; |
| 206 |
print "$0: needed to create '$bdir'\n"; |
206 |
print "$0: needed to create '$bdir'\n"; |
| 207 |
} |
207 |
} |
| 208 |
} |
208 |
} |
| 209 |
return $needed_repairing; |
209 |
return $needed_repairing; |
| 210 |
} # ---------- end of subroutine check_zebra_dirs ---------- |
210 |
} # ---------- end of subroutine check_zebra_dirs ---------- |
| 211 |
|
211 |
|
| 212 |
sub index_records { |
212 |
sub index_records { |
| 213 |
my ($record_type, $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_; |
213 |
my ($record_type, $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_; |
|
Lines 216-223
sub index_records {
Link Here
|
| 216 |
my $records_deleted; |
216 |
my $records_deleted; |
| 217 |
my $need_reset = check_zebra_dirs($server_dir); |
217 |
my $need_reset = check_zebra_dirs($server_dir); |
| 218 |
if ($need_reset) { |
218 |
if ($need_reset) { |
| 219 |
print "$0: found broken zebra server directories: forcing a rebuild\n"; |
219 |
print "$0: found broken zebra server directories: forcing a rebuild\n"; |
| 220 |
$reset = 1; |
220 |
$reset = 1; |
| 221 |
} |
221 |
} |
| 222 |
if ($skip_export && $verbose_logging) { |
222 |
if ($skip_export && $verbose_logging) { |
| 223 |
print "====================\n"; |
223 |
print "====================\n"; |
|
Lines 238-244
sub index_records {
Link Here
|
| 238 |
mark_zebraqueue_batch_done($entries); |
238 |
mark_zebraqueue_batch_done($entries); |
| 239 |
$entries = select_zebraqueue_records($record_type, 'updated'); |
239 |
$entries = select_zebraqueue_records($record_type, 'updated'); |
| 240 |
mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type"); |
240 |
mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type"); |
| 241 |
$num_records_exported = export_marc_records_from_list($record_type, |
241 |
$num_records_exported = export_marc_records_from_list($record_type, |
| 242 |
$entries, "$directory/upd_$record_type", $as_xml, $noxml, $records_deleted); |
242 |
$entries, "$directory/upd_$record_type", $as_xml, $noxml, $records_deleted); |
| 243 |
mark_zebraqueue_batch_done($entries); |
243 |
mark_zebraqueue_batch_done($entries); |
| 244 |
} else { |
244 |
} else { |
|
Lines 285-291
sub select_zebraqueue_records {
Link Here
|
| 285 |
my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver'; |
285 |
my $server = ($record_type eq 'biblio') ? 'biblioserver' : 'authorityserver'; |
| 286 |
my $op = ($update_type eq 'deleted') ? 'recordDelete' : 'specialUpdate'; |
286 |
my $op = ($update_type eq 'deleted') ? 'recordDelete' : 'specialUpdate'; |
| 287 |
|
287 |
|
| 288 |
my $sth = $dbh->prepare("SELECT id, biblio_auth_number |
288 |
my $sth = $dbh->prepare("SELECT id, biblio_auth_number |
| 289 |
FROM zebraqueue |
289 |
FROM zebraqueue |
| 290 |
WHERE server = ? |
290 |
WHERE server = ? |
| 291 |
AND operation = ? |
291 |
AND operation = ? |
|
Lines 379-385
sub export_marc_records_from_sth {
Link Here
|
| 379 |
$record->encoding('UTF-8'); |
379 |
$record->encoding('UTF-8'); |
| 380 |
my @itemsrecord; |
380 |
my @itemsrecord; |
| 381 |
foreach my $item (@items){ |
381 |
foreach my $item (@items){ |
| 382 |
my $record = Item2Marc($item, $record_number); |
382 |
my $record = Item2Marc($item, $record_number); |
| 383 |
push @itemsrecord, $record->field($itemtag); |
383 |
push @itemsrecord, $record->field($itemtag); |
| 384 |
} |
384 |
} |
| 385 |
$record->insert_fields_ordered(@itemsrecord); |
385 |
$record->insert_fields_ordered(@itemsrecord); |
|
Lines 517-530
sub generate_deleted_marc_records {
Link Here
|
| 517 |
print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); |
517 |
print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); |
| 518 |
close $fh; |
518 |
close $fh; |
| 519 |
return $records_deleted; |
519 |
return $records_deleted; |
| 520 |
|
520 |
|
| 521 |
|
521 |
|
| 522 |
} |
522 |
} |
| 523 |
|
523 |
|
| 524 |
sub get_corrected_marc_record { |
524 |
sub get_corrected_marc_record { |
| 525 |
my ($record_type, $record_number, $noxml) = @_; |
525 |
my ($record_type, $record_number, $noxml) = @_; |
| 526 |
|
526 |
|
| 527 |
my $marc = get_raw_marc_record($record_type, $record_number, $noxml); |
527 |
my $marc = get_raw_marc_record($record_type, $record_number, $noxml); |
| 528 |
|
528 |
|
| 529 |
if (defined $marc) { |
529 |
if (defined $marc) { |
| 530 |
fix_leader($marc); |
530 |
fix_leader($marc); |
|
Lines 544-551
sub get_corrected_marc_record {
Link Here
|
| 544 |
|
544 |
|
| 545 |
sub get_raw_marc_record { |
545 |
sub get_raw_marc_record { |
| 546 |
my ($record_type, $record_number, $noxml) = @_; |
546 |
my ($record_type, $record_number, $noxml) = @_; |
| 547 |
|
547 |
|
| 548 |
my $marc; |
548 |
my $marc; |
| 549 |
if ($record_type eq 'biblio') { |
549 |
if ($record_type eq 'biblio') { |
| 550 |
if ($noxml) { |
550 |
if ($noxml) { |
| 551 |
my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?"); |
551 |
my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?"); |
|
Lines 588-594
sub fix_leader {
Link Here
|
| 588 |
# force them to be recalculated correct when |
588 |
# force them to be recalculated correct when |
| 589 |
# the $marc->as_usmarc() or $marc->as_xml() is called. |
589 |
# the $marc->as_usmarc() or $marc->as_xml() is called. |
| 590 |
# But why is this necessary? It would be a serious bug |
590 |
# But why is this necessary? It would be a serious bug |
| 591 |
# in MARC::Record (definitely) and MARC::File::XML (arguably) |
591 |
# in MARC::Record (definitely) and MARC::File::XML (arguably) |
| 592 |
# if they are emitting incorrect leader values. |
592 |
# if they are emitting incorrect leader values. |
| 593 |
my $marc = shift; |
593 |
my $marc = shift; |
| 594 |
|
594 |
|
|
Lines 607-613
sub fix_biblio_ids {
Link Here
|
| 607 |
my $biblioitemnumber; |
607 |
my $biblioitemnumber; |
| 608 |
if (@_) { |
608 |
if (@_) { |
| 609 |
$biblioitemnumber = shift; |
609 |
$biblioitemnumber = shift; |
| 610 |
} else { |
610 |
} else { |
| 611 |
my $sth = $dbh->prepare( |
611 |
my $sth = $dbh->prepare( |
| 612 |
"SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
612 |
"SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
| 613 |
$sth->execute($biblionumber); |
613 |
$sth->execute($biblionumber); |
|
Lines 625-631
sub fix_biblio_ids {
Link Here
|
| 625 |
# present in the MARC::Record object ought to be part of GetMarcBiblio. |
625 |
# present in the MARC::Record object ought to be part of GetMarcBiblio. |
| 626 |
# |
626 |
# |
| 627 |
# On the other hand, this better for now than what rebuild_zebra.pl used to |
627 |
# On the other hand, this better for now than what rebuild_zebra.pl used to |
| 628 |
# do, which was duplicate the code for inserting the biblionumber |
628 |
# do, which was duplicate the code for inserting the biblionumber |
| 629 |
# and biblioitemnumber |
629 |
# and biblioitemnumber |
| 630 |
C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber); |
630 |
C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber); |
| 631 |
|
631 |
|
|
Lines 709-715
Parameters:
Link Here
|
| 709 |
-k Do not delete export directory. |
709 |
-k Do not delete export directory. |
| 710 |
|
710 |
|
| 711 |
-s Skip export. Used if you have |
711 |
-s Skip export. Used if you have |
| 712 |
already exported the records |
712 |
already exported the records |
| 713 |
in a previous run. |
713 |
in a previous run. |
| 714 |
|
714 |
|
| 715 |
-noxml index from ISO MARC blob |
715 |
-noxml index from ISO MARC blob |
|
Lines 719-725
Parameters:
Link Here
|
| 719 |
|
719 |
|
| 720 |
-x export and index as xml instead of is02709 (biblios only). |
720 |
-x export and index as xml instead of is02709 (biblios only). |
| 721 |
use this if you might have records > 99,999 chars, |
721 |
use this if you might have records > 99,999 chars, |
| 722 |
|
722 |
|
| 723 |
-nosanitize export biblio/authority records directly from DB marcxml |
723 |
-nosanitize export biblio/authority records directly from DB marcxml |
| 724 |
field without sanitizing records. It speed up |
724 |
field without sanitizing records. It speed up |
| 725 |
dump process but could fail if DB contains badly |
725 |
dump process but could fail if DB contains badly |
|
Lines 731-740
Parameters:
Link Here
|
| 731 |
after doing batch indexing, zebraqueue should be |
731 |
after doing batch indexing, zebraqueue should be |
| 732 |
marked done for the affected record type(s) so that |
732 |
marked done for the affected record type(s) so that |
| 733 |
a running zebraqueue_daemon doesn't try to reindex |
733 |
a running zebraqueue_daemon doesn't try to reindex |
| 734 |
the same records - specify -y to override this. |
734 |
the same records - specify -y to override this. |
| 735 |
Cannot be used with -z. |
735 |
Cannot be used with -z. |
| 736 |
|
736 |
|
| 737 |
-v increase the amount of logging. Normally only |
737 |
-v increase the amount of logging. Normally only |
| 738 |
warnings and errors from the indexing are shown. |
738 |
warnings and errors from the indexing are shown. |
| 739 |
Use log level 2 (-v -v) to include all Zebra logs. |
739 |
Use log level 2 (-v -v) to include all Zebra logs. |
| 740 |
|
740 |
|
|
Lines 754-762
Parameters:
Link Here
|
| 754 |
_USAGE_ |
754 |
_USAGE_ |
| 755 |
} |
755 |
} |
| 756 |
|
756 |
|
| 757 |
# FIXME: the following routines are deprecated and |
757 |
# FIXME: the following routines are deprecated and |
| 758 |
# will be removed once it is determined whether |
758 |
# will be removed once it is determined whether |
| 759 |
# a script to fix Zebra configuration files is |
759 |
# a script to fix Zebra configuration files is |
| 760 |
# actually needed. |
760 |
# actually needed. |
| 761 |
sub munge_config { |
761 |
sub munge_config { |
| 762 |
# |
762 |
# |
|
Lines 874-886
if ($authorities) {
Link Here
|
| 874 |
print "Info: created $authorityserverdir/key\n"; |
874 |
print "Info: created $authorityserverdir/key\n"; |
| 875 |
$created_dir_or_file++; |
875 |
$created_dir_or_file++; |
| 876 |
} |
876 |
} |
| 877 |
|
877 |
|
| 878 |
unless (-d "$authorityserverdir/etc") { |
878 |
unless (-d "$authorityserverdir/etc") { |
| 879 |
mkdir "$authorityserverdir/etc"; |
879 |
mkdir "$authorityserverdir/etc"; |
| 880 |
print "Info: created $authorityserverdir/etc\n"; |
880 |
print "Info: created $authorityserverdir/etc\n"; |
| 881 |
$created_dir_or_file++; |
881 |
$created_dir_or_file++; |
| 882 |
} |
882 |
} |
| 883 |
|
883 |
|
| 884 |
# |
884 |
# |
| 885 |
# AUTHORITIES : copying mandatory files |
885 |
# AUTHORITIES : copying mandatory files |
| 886 |
# |
886 |
# |
|
Lines 915-921
if ($authorities) {
Link Here
|
| 915 |
print "Info: copied default.idx\n"; |
915 |
print "Info: copied default.idx\n"; |
| 916 |
$created_dir_or_file++; |
916 |
$created_dir_or_file++; |
| 917 |
} |
917 |
} |
| 918 |
|
918 |
|
| 919 |
unless (-f "$authorityserverdir/etc/ccl.properties") { |
919 |
unless (-f "$authorityserverdir/etc/ccl.properties") { |
| 920 |
# system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn}); |
920 |
# system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn}); |
| 921 |
system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties"); |
921 |
system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties"); |
|
Lines 928-941
if ($authorities) {
Link Here
|
| 928 |
print "Info: copied pqf.properties\n"; |
928 |
print "Info: copied pqf.properties\n"; |
| 929 |
$created_dir_or_file++; |
929 |
$created_dir_or_file++; |
| 930 |
} |
930 |
} |
| 931 |
|
931 |
|
| 932 |
# |
932 |
# |
| 933 |
# AUTHORITIES : copying mandatory files |
933 |
# AUTHORITIES : copying mandatory files |
| 934 |
# |
934 |
# |
| 935 |
unless (-f C4::Context->zebraconfig('authorityserver')->{config}) { |
935 |
unless (-f C4::Context->zebraconfig('authorityserver')->{config}) { |
| 936 |
open my $zd, '>:encoding(UTF-8)' ,C4::Context->zebraconfig('authorityserver')->{config}; |
936 |
open my $zd, '>:encoding(UTF-8)' ,C4::Context->zebraconfig('authorityserver')->{config}; |
| 937 |
print {$zd} " |
937 |
print {$zd} " |
| 938 |
# generated by KOHA/misc/migration_tools/rebuild_zebra.pl |
938 |
# generated by KOHA/misc/migration_tools/rebuild_zebra.pl |
| 939 |
profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
939 |
profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
| 940 |
|
940 |
|
| 941 |
encoding: UTF-8 |
941 |
encoding: UTF-8 |
|
Lines 973-985
rank:rank-1
Link Here
|
| 973 |
print "Info: creating zebra-authorities.cfg\n"; |
973 |
print "Info: creating zebra-authorities.cfg\n"; |
| 974 |
$created_dir_or_file++; |
974 |
$created_dir_or_file++; |
| 975 |
} |
975 |
} |
| 976 |
|
976 |
|
| 977 |
if ($created_dir_or_file) { |
977 |
if ($created_dir_or_file) { |
| 978 |
print "Info: created : $created_dir_or_file directories & files\n"; |
978 |
print "Info: created : $created_dir_or_file directories & files\n"; |
| 979 |
} else { |
979 |
} else { |
| 980 |
print "Info: file & directories OK\n"; |
980 |
print "Info: file & directories OK\n"; |
| 981 |
} |
981 |
} |
| 982 |
|
982 |
|
| 983 |
} |
983 |
} |
| 984 |
if ($biblios) { |
984 |
if ($biblios) { |
| 985 |
if ( $verbose_logging ) { |
985 |
if ( $verbose_logging ) { |
|
Lines 1026-1032
if ($biblios) {
Link Here
|
| 1026 |
print "Info: created $biblioserverdir/etc\n"; |
1026 |
print "Info: created $biblioserverdir/etc\n"; |
| 1027 |
$created_dir_or_file++; |
1027 |
$created_dir_or_file++; |
| 1028 |
} |
1028 |
} |
| 1029 |
|
1029 |
|
| 1030 |
# |
1030 |
# |
| 1031 |
# BIBLIOS : copying mandatory files |
1031 |
# BIBLIOS : copying mandatory files |
| 1032 |
# |
1032 |
# |
|
Lines 1073-1086
if ($biblios) {
Link Here
|
| 1073 |
print "Info: copied pqf.properties\n"; |
1073 |
print "Info: copied pqf.properties\n"; |
| 1074 |
$created_dir_or_file++; |
1074 |
$created_dir_or_file++; |
| 1075 |
} |
1075 |
} |
| 1076 |
|
1076 |
|
| 1077 |
# |
1077 |
# |
| 1078 |
# BIBLIOS : copying mandatory files |
1078 |
# BIBLIOS : copying mandatory files |
| 1079 |
# |
1079 |
# |
| 1080 |
unless (-f C4::Context->zebraconfig('biblioserver')->{config}) { |
1080 |
unless (-f C4::Context->zebraconfig('biblioserver')->{config}) { |
| 1081 |
open my $zd, '>:encoding(UTF-8)', C4::Context->zebraconfig('biblioserver')->{config}; |
1081 |
open my $zd, '>:encoding(UTF-8)', C4::Context->zebraconfig('biblioserver')->{config}; |
| 1082 |
print {$zd} " |
1082 |
print {$zd} " |
| 1083 |
# generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl |
1083 |
# generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl |
| 1084 |
profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
1084 |
profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
| 1085 |
|
1085 |
|
| 1086 |
encoding: UTF-8 |
1086 |
encoding: UTF-8 |
|
Lines 1118-1129
rank:rank-1
Link Here
|
| 1118 |
print "Info: creating zebra-biblios.cfg\n"; |
1118 |
print "Info: creating zebra-biblios.cfg\n"; |
| 1119 |
$created_dir_or_file++; |
1119 |
$created_dir_or_file++; |
| 1120 |
} |
1120 |
} |
| 1121 |
|
1121 |
|
| 1122 |
if ($created_dir_or_file) { |
1122 |
if ($created_dir_or_file) { |
| 1123 |
print "Info: created : $created_dir_or_file directories & files\n"; |
1123 |
print "Info: created : $created_dir_or_file directories & files\n"; |
| 1124 |
} else { |
1124 |
} else { |
| 1125 |
print "Info: file & directories OK\n"; |
1125 |
print "Info: file & directories OK\n"; |
| 1126 |
} |
1126 |
} |
| 1127 |
|
1127 |
|
| 1128 |
} |
1128 |
} |
| 1129 |
} |
1129 |
} |
| 1130 |
- |
|
|