From: Bill Erickson Date: Mon, 11 Feb 2013 19:39:42 +0000 (-0500) Subject: Z39 Batch ML : queueing results X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9c47d3cd6ecf036c1f6134a980dbdcf706a1b17d;p=evergreen%2Fequinox.git Z39 Batch ML : queueing results Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm index c508fd5a84..191e6cea1f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm @@ -18,6 +18,7 @@ use OpenSRF::Utils::JSON; use OpenILS::Application::AppUtils; use OpenSRF::Utils::Logger qw/$logger/; use OpenILS::Utils::CStoreEditor q/:funcs/; +use OpenILS::Utils::Normalize qw/clean_marc/; MARC::Charset->assume_unicode(1); MARC::Charset->ignore_errors(1); @@ -605,6 +606,37 @@ sub create_z39_bucket_queue { return $queue; } +# sets the 901c value to the Z39 service and +# adds the record to the growing vandelay queue +sub stamp_and_queue_results { + my ($e, $queue, $service, $bre_id, $result) = @_; + $logger->info("z3950 got bucket response for $bre_id"); + + for my $rec (@{$result->{records}}) { + $logger->info("z39: got result for $bre_id : $rec"); + + # insert z39 service as the 901z + my $marc = MARC::Record->new_from_xml( + $rec->{marcxml}, 'UTF-8', 'USMARC'); + + $marc->insert_fields_ordered( + MARC::Field->new('901', '', '', z => $service)); + + # put the record into the queue + my $qrec = Fieldmapper::vandelay::queued_bib_record->new; + $qrec->marc(clean_marc($marc)); + $qrec->queue($queue->id); + + $e->xact_begin; + if ($e->create_vandelay_queued_bib_record($qrec)) { + $e->commit; + } else { + my $evt = $e->die_event; + $logger->error("z39: unable to queue record: $evt"); + } + } +} + sub send_and_queue_bucket_searches { my ($conn, $e, $queue, $z_searches) = @_; @@ -628,17 +660,9 @@ sub send_and_queue_bucket_searches { # there will be one response per z-source for my $resp (@{$req->{response}}) { $response->{search_complete}++; - - $logger->info("z3950 got bucket response for $bre_id"); - my $result = $resp->content or next; my $service = $result->{service}; - - for my $rec (@{$result->{records}}) { - # TODO stamp zsource 901z; add to queue - $response->{queue_count}++; - $logger->info("z39: got result for $bre_id : $rec"); - } + stamp_and_queue_results($e, $queue, $service, $bre_id, $result); } $conn->respond($response);