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 518-531
sub generate_deleted_marc_records {
Link Here
|
518 |
print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); |
518 |
print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type)); |
519 |
close $fh; |
519 |
close $fh; |
520 |
return $records_deleted; |
520 |
return $records_deleted; |
521 |
|
521 |
|
522 |
|
522 |
|
523 |
} |
523 |
} |
524 |
|
524 |
|
525 |
sub get_corrected_marc_record { |
525 |
sub get_corrected_marc_record { |
526 |
my ($record_type, $record_number, $noxml) = @_; |
526 |
my ($record_type, $record_number, $noxml) = @_; |
527 |
|
527 |
|
528 |
my $marc = get_raw_marc_record($record_type, $record_number, $noxml); |
528 |
my $marc = get_raw_marc_record($record_type, $record_number, $noxml); |
529 |
|
529 |
|
530 |
if (defined $marc) { |
530 |
if (defined $marc) { |
531 |
fix_leader($marc); |
531 |
fix_leader($marc); |
Lines 545-552
sub get_corrected_marc_record {
Link Here
|
545 |
|
545 |
|
546 |
sub get_raw_marc_record { |
546 |
sub get_raw_marc_record { |
547 |
my ($record_type, $record_number, $noxml) = @_; |
547 |
my ($record_type, $record_number, $noxml) = @_; |
548 |
|
548 |
|
549 |
my $marc; |
549 |
my $marc; |
550 |
if ($record_type eq 'biblio') { |
550 |
if ($record_type eq 'biblio') { |
551 |
if ($noxml) { |
551 |
if ($noxml) { |
552 |
my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?"); |
552 |
my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?"); |
Lines 589-595
sub fix_leader {
Link Here
|
589 |
# force them to be recalculated correct when |
589 |
# force them to be recalculated correct when |
590 |
# the $marc->as_usmarc() or $marc->as_xml() is called. |
590 |
# the $marc->as_usmarc() or $marc->as_xml() is called. |
591 |
# But why is this necessary? It would be a serious bug |
591 |
# But why is this necessary? It would be a serious bug |
592 |
# in MARC::Record (definitely) and MARC::File::XML (arguably) |
592 |
# in MARC::Record (definitely) and MARC::File::XML (arguably) |
593 |
# if they are emitting incorrect leader values. |
593 |
# if they are emitting incorrect leader values. |
594 |
my $marc = shift; |
594 |
my $marc = shift; |
595 |
|
595 |
|
Lines 608-614
sub fix_biblio_ids {
Link Here
|
608 |
my $biblioitemnumber; |
608 |
my $biblioitemnumber; |
609 |
if (@_) { |
609 |
if (@_) { |
610 |
$biblioitemnumber = shift; |
610 |
$biblioitemnumber = shift; |
611 |
} else { |
611 |
} else { |
612 |
my $sth = $dbh->prepare( |
612 |
my $sth = $dbh->prepare( |
613 |
"SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
613 |
"SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
614 |
$sth->execute($biblionumber); |
614 |
$sth->execute($biblionumber); |
Lines 626-632
sub fix_biblio_ids {
Link Here
|
626 |
# present in the MARC::Record object ought to be part of GetMarcBiblio. |
626 |
# present in the MARC::Record object ought to be part of GetMarcBiblio. |
627 |
# |
627 |
# |
628 |
# On the other hand, this better for now than what rebuild_zebra.pl used to |
628 |
# On the other hand, this better for now than what rebuild_zebra.pl used to |
629 |
# do, which was duplicate the code for inserting the biblionumber |
629 |
# do, which was duplicate the code for inserting the biblionumber |
630 |
# and biblioitemnumber |
630 |
# and biblioitemnumber |
631 |
C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber); |
631 |
C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber); |
632 |
|
632 |
|
Lines 710-716
Parameters:
Link Here
|
710 |
-k Do not delete export directory. |
710 |
-k Do not delete export directory. |
711 |
|
711 |
|
712 |
-s Skip export. Used if you have |
712 |
-s Skip export. Used if you have |
713 |
already exported the records |
713 |
already exported the records |
714 |
in a previous run. |
714 |
in a previous run. |
715 |
|
715 |
|
716 |
-noxml index from ISO MARC blob |
716 |
-noxml index from ISO MARC blob |
Lines 720-726
Parameters:
Link Here
|
720 |
|
720 |
|
721 |
-x export and index as xml instead of is02709 (biblios only). |
721 |
-x export and index as xml instead of is02709 (biblios only). |
722 |
use this if you might have records > 99,999 chars, |
722 |
use this if you might have records > 99,999 chars, |
723 |
|
723 |
|
724 |
-nosanitize export biblio/authority records directly from DB marcxml |
724 |
-nosanitize export biblio/authority records directly from DB marcxml |
725 |
field without sanitizing records. It speed up |
725 |
field without sanitizing records. It speed up |
726 |
dump process but could fail if DB contains badly |
726 |
dump process but could fail if DB contains badly |
Lines 732-741
Parameters:
Link Here
|
732 |
after doing batch indexing, zebraqueue should be |
732 |
after doing batch indexing, zebraqueue should be |
733 |
marked done for the affected record type(s) so that |
733 |
marked done for the affected record type(s) so that |
734 |
a running zebraqueue_daemon doesn't try to reindex |
734 |
a running zebraqueue_daemon doesn't try to reindex |
735 |
the same records - specify -y to override this. |
735 |
the same records - specify -y to override this. |
736 |
Cannot be used with -z. |
736 |
Cannot be used with -z. |
737 |
|
737 |
|
738 |
-v increase the amount of logging. Normally only |
738 |
-v increase the amount of logging. Normally only |
739 |
warnings and errors from the indexing are shown. |
739 |
warnings and errors from the indexing are shown. |
740 |
Use log level 2 (-v -v) to include all Zebra logs. |
740 |
Use log level 2 (-v -v) to include all Zebra logs. |
741 |
|
741 |
|
Lines 755-763
Parameters:
Link Here
|
755 |
_USAGE_ |
755 |
_USAGE_ |
756 |
} |
756 |
} |
757 |
|
757 |
|
758 |
# FIXME: the following routines are deprecated and |
758 |
# FIXME: the following routines are deprecated and |
759 |
# will be removed once it is determined whether |
759 |
# will be removed once it is determined whether |
760 |
# a script to fix Zebra configuration files is |
760 |
# a script to fix Zebra configuration files is |
761 |
# actually needed. |
761 |
# actually needed. |
762 |
sub munge_config { |
762 |
sub munge_config { |
763 |
# |
763 |
# |
Lines 875-887
if ($authorities) {
Link Here
|
875 |
print "Info: created $authorityserverdir/key\n"; |
875 |
print "Info: created $authorityserverdir/key\n"; |
876 |
$created_dir_or_file++; |
876 |
$created_dir_or_file++; |
877 |
} |
877 |
} |
878 |
|
878 |
|
879 |
unless (-d "$authorityserverdir/etc") { |
879 |
unless (-d "$authorityserverdir/etc") { |
880 |
mkdir "$authorityserverdir/etc"; |
880 |
mkdir "$authorityserverdir/etc"; |
881 |
print "Info: created $authorityserverdir/etc\n"; |
881 |
print "Info: created $authorityserverdir/etc\n"; |
882 |
$created_dir_or_file++; |
882 |
$created_dir_or_file++; |
883 |
} |
883 |
} |
884 |
|
884 |
|
885 |
# |
885 |
# |
886 |
# AUTHORITIES : copying mandatory files |
886 |
# AUTHORITIES : copying mandatory files |
887 |
# |
887 |
# |
Lines 916-922
if ($authorities) {
Link Here
|
916 |
print "Info: copied default.idx\n"; |
916 |
print "Info: copied default.idx\n"; |
917 |
$created_dir_or_file++; |
917 |
$created_dir_or_file++; |
918 |
} |
918 |
} |
919 |
|
919 |
|
920 |
unless (-f "$authorityserverdir/etc/ccl.properties") { |
920 |
unless (-f "$authorityserverdir/etc/ccl.properties") { |
921 |
# system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn}); |
921 |
# system("cp -f $kohadir/etc/zebradb/ccl.properties ".C4::Context->zebraconfig('authorityserver')->{ccl2rpn}); |
922 |
system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties"); |
922 |
system("cp -f $kohadir/etc/zebradb/ccl.properties $authorityserverdir/etc/ccl.properties"); |
Lines 929-942
if ($authorities) {
Link Here
|
929 |
print "Info: copied pqf.properties\n"; |
929 |
print "Info: copied pqf.properties\n"; |
930 |
$created_dir_or_file++; |
930 |
$created_dir_or_file++; |
931 |
} |
931 |
} |
932 |
|
932 |
|
933 |
# |
933 |
# |
934 |
# AUTHORITIES : copying mandatory files |
934 |
# AUTHORITIES : copying mandatory files |
935 |
# |
935 |
# |
936 |
unless (-f C4::Context->zebraconfig('authorityserver')->{config}) { |
936 |
unless (-f C4::Context->zebraconfig('authorityserver')->{config}) { |
937 |
open my $zd, '>:encoding(UTF-8)' ,C4::Context->zebraconfig('authorityserver')->{config}; |
937 |
open my $zd, '>:encoding(UTF-8)' ,C4::Context->zebraconfig('authorityserver')->{config}; |
938 |
print {$zd} " |
938 |
print {$zd} " |
939 |
# generated by KOHA/misc/migration_tools/rebuild_zebra.pl |
939 |
# generated by KOHA/misc/migration_tools/rebuild_zebra.pl |
940 |
profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
940 |
profilePath:\${srcdir:-.}:$authorityserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
941 |
|
941 |
|
942 |
encoding: UTF-8 |
942 |
encoding: UTF-8 |
Lines 974-986
rank:rank-1
Link Here
|
974 |
print "Info: creating zebra-authorities.cfg\n"; |
974 |
print "Info: creating zebra-authorities.cfg\n"; |
975 |
$created_dir_or_file++; |
975 |
$created_dir_or_file++; |
976 |
} |
976 |
} |
977 |
|
977 |
|
978 |
if ($created_dir_or_file) { |
978 |
if ($created_dir_or_file) { |
979 |
print "Info: created : $created_dir_or_file directories & files\n"; |
979 |
print "Info: created : $created_dir_or_file directories & files\n"; |
980 |
} else { |
980 |
} else { |
981 |
print "Info: file & directories OK\n"; |
981 |
print "Info: file & directories OK\n"; |
982 |
} |
982 |
} |
983 |
|
983 |
|
984 |
} |
984 |
} |
985 |
if ($biblios) { |
985 |
if ($biblios) { |
986 |
if ( $verbose_logging ) { |
986 |
if ( $verbose_logging ) { |
Lines 1027-1033
if ($biblios) {
Link Here
|
1027 |
print "Info: created $biblioserverdir/etc\n"; |
1027 |
print "Info: created $biblioserverdir/etc\n"; |
1028 |
$created_dir_or_file++; |
1028 |
$created_dir_or_file++; |
1029 |
} |
1029 |
} |
1030 |
|
1030 |
|
1031 |
# |
1031 |
# |
1032 |
# BIBLIOS : copying mandatory files |
1032 |
# BIBLIOS : copying mandatory files |
1033 |
# |
1033 |
# |
Lines 1074-1087
if ($biblios) {
Link Here
|
1074 |
print "Info: copied pqf.properties\n"; |
1074 |
print "Info: copied pqf.properties\n"; |
1075 |
$created_dir_or_file++; |
1075 |
$created_dir_or_file++; |
1076 |
} |
1076 |
} |
1077 |
|
1077 |
|
1078 |
# |
1078 |
# |
1079 |
# BIBLIOS : copying mandatory files |
1079 |
# BIBLIOS : copying mandatory files |
1080 |
# |
1080 |
# |
1081 |
unless (-f C4::Context->zebraconfig('biblioserver')->{config}) { |
1081 |
unless (-f C4::Context->zebraconfig('biblioserver')->{config}) { |
1082 |
open my $zd, '>:encoding(UTF-8)', C4::Context->zebraconfig('biblioserver')->{config}; |
1082 |
open my $zd, '>:encoding(UTF-8)', C4::Context->zebraconfig('biblioserver')->{config}; |
1083 |
print {$zd} " |
1083 |
print {$zd} " |
1084 |
# generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl |
1084 |
# generated by KOHA/misc/migrtion_tools/rebuild_zebra.pl |
1085 |
profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
1085 |
profilePath:\${srcdir:-.}:$biblioserverdir/tab/:$tabdir/tab/:\${srcdir:-.}/tab/ |
1086 |
|
1086 |
|
1087 |
encoding: UTF-8 |
1087 |
encoding: UTF-8 |
Lines 1119-1130
rank:rank-1
Link Here
|
1119 |
print "Info: creating zebra-biblios.cfg\n"; |
1119 |
print "Info: creating zebra-biblios.cfg\n"; |
1120 |
$created_dir_or_file++; |
1120 |
$created_dir_or_file++; |
1121 |
} |
1121 |
} |
1122 |
|
1122 |
|
1123 |
if ($created_dir_or_file) { |
1123 |
if ($created_dir_or_file) { |
1124 |
print "Info: created : $created_dir_or_file directories & files\n"; |
1124 |
print "Info: created : $created_dir_or_file directories & files\n"; |
1125 |
} else { |
1125 |
} else { |
1126 |
print "Info: file & directories OK\n"; |
1126 |
print "Info: file & directories OK\n"; |
1127 |
} |
1127 |
} |
1128 |
|
1128 |
|
1129 |
} |
1129 |
} |
1130 |
} |
1130 |
} |
1131 |
- |
|
|