Lines 191-197
sub index_records {
Link Here
|
191 |
my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_; |
191 |
my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_; |
192 |
|
192 |
|
193 |
my $num_records_exported = 0; |
193 |
my $num_records_exported = 0; |
194 |
my $num_records_deleted = 0; |
194 |
my $records_deleted; |
195 |
my $need_reset = check_zebra_dirs($server_dir); |
195 |
my $need_reset = check_zebra_dirs($server_dir); |
196 |
if ($need_reset) { |
196 |
if ($need_reset) { |
197 |
print "$0: found broken zebra server directories: forcing a rebuild\n"; |
197 |
print "$0: found broken zebra server directories: forcing a rebuild\n"; |
Lines 212-223
sub index_records {
Link Here
|
212 |
if ($process_zebraqueue) { |
212 |
if ($process_zebraqueue) { |
213 |
my $entries = select_zebraqueue_records($record_type, 'deleted'); |
213 |
my $entries = select_zebraqueue_records($record_type, 'deleted'); |
214 |
mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type"); |
214 |
mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type"); |
215 |
$num_records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml); |
215 |
$records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml); |
216 |
mark_zebraqueue_batch_done($entries); |
216 |
mark_zebraqueue_batch_done($entries); |
217 |
$entries = select_zebraqueue_records($record_type, 'updated'); |
217 |
$entries = select_zebraqueue_records($record_type, 'updated'); |
218 |
mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type"); |
218 |
mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type"); |
219 |
$num_records_exported = export_marc_records_from_list($record_type, |
219 |
$num_records_exported = export_marc_records_from_list($record_type, |
220 |
$entries, "$directory/upd_$record_type", $as_xml, $noxml); |
220 |
$entries, "$directory/upd_$record_type", $as_xml, $noxml, $records_deleted); |
221 |
mark_zebraqueue_batch_done($entries); |
221 |
mark_zebraqueue_batch_done($entries); |
222 |
} else { |
222 |
} else { |
223 |
my $sth = select_all_records($record_type); |
223 |
my $sth = select_all_records($record_type); |
Lines 239-245
sub index_records {
Link Here
|
239 |
my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ; |
239 |
my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ; |
240 |
if ($process_zebraqueue) { |
240 |
if ($process_zebraqueue) { |
241 |
do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
241 |
do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
242 |
if $num_records_deleted; |
242 |
if %$records_deleted; |
243 |
do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
243 |
do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
244 |
if $num_records_exported; |
244 |
if $num_records_exported; |
245 |
} else { |
245 |
} else { |
Lines 361-372
sub export_marc_records_from_sth {
Link Here
|
361 |
} |
361 |
} |
362 |
|
362 |
|
363 |
sub export_marc_records_from_list { |
363 |
sub export_marc_records_from_list { |
364 |
my ($record_type, $entries, $directory, $as_xml, $noxml) = @_; |
364 |
my ($record_type, $entries, $directory, $as_xml, $noxml, $records_deleted) = @_; |
365 |
|
365 |
|
366 |
my $num_exported = 0; |
366 |
my $num_exported = 0; |
367 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
367 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
368 |
my $i = 0; |
368 |
my $i = 0; |
369 |
my %found = (); |
369 |
|
|
|
370 |
# Skip any deleted records. We check for this anyway, but this reduces error spam |
371 |
my %found = %$records_deleted; |
370 |
foreach my $record_number ( map { $_->{biblio_auth_number} } |
372 |
foreach my $record_number ( map { $_->{biblio_auth_number} } |
371 |
grep { !$found{ $_->{biblio_auth_number} }++ } |
373 |
grep { !$found{ $_->{biblio_auth_number} }++ } |
372 |
@$entries ) { |
374 |
@$entries ) { |
Lines 391-397
sub export_marc_records_from_list {
Link Here
|
391 |
sub generate_deleted_marc_records { |
393 |
sub generate_deleted_marc_records { |
392 |
my ($record_type, $entries, $directory, $as_xml) = @_; |
394 |
my ($record_type, $entries, $directory, $as_xml) = @_; |
393 |
|
395 |
|
394 |
my $num_exported = 0; |
396 |
my $records_deleted = {}; |
395 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
397 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
396 |
my $i = 0; |
398 |
my $i = 0; |
397 |
foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) { |
399 |
foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) { |
Lines 409-419
sub generate_deleted_marc_records {
Link Here
|
409 |
} |
411 |
} |
410 |
|
412 |
|
411 |
print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc(); |
413 |
print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc(); |
412 |
$num_exported++; |
414 |
|
|
|
415 |
$records_deleted->{$record_number} = 1; |
413 |
} |
416 |
} |
414 |
print "\nRecords exported: $num_exported\n" if ( $verbose_logging ); |
417 |
print "\nRecords exported: $i\n" if ( $verbose_logging ); |
415 |
close OUT; |
418 |
close OUT; |
416 |
return $num_exported; |
419 |
return $records_deleted; |
417 |
|
420 |
|
418 |
|
421 |
|
419 |
} |
422 |
} |
Lines 457-463
sub get_raw_marc_record {
Link Here
|
457 |
} |
460 |
} |
458 |
} else { |
461 |
} else { |
459 |
eval { $marc = GetMarcBiblio($record_number); }; |
462 |
eval { $marc = GetMarcBiblio($record_number); }; |
460 |
if ($@) { |
463 |
if ($@ || !defined($marc)) { |
461 |
# here we do warn since catching an exception |
464 |
# here we do warn since catching an exception |
462 |
# means that the bib was found but failed |
465 |
# means that the bib was found but failed |
463 |
# to be parsed |
466 |
# to be parsed |
464 |
- |
|
|