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);
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) = @_;
# 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);