# returns the number of successfully queued records
sub stamp_and_queue_results {
my ($e, $queue, $service, $bre_id, $result) = @_;
- $logger->info("z3950 got bucket response for $bre_id");
my $qcount = 0;
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');
};
# searches are about to be in flight
+ # let the caller know we're still alive
$conn->respond($response);
my $handle_search_result = sub {
my ($self, $req) = @_;
my $bre_id = $req->{req}->{_bre_id};
- # there will be one response per z-source
+ my @p = $req->{req}->payload->params;
+ $logger->debug("z39: multi-search response for request [$bre_id]".
+ OpenSRF::Utils::JSON->perl2JSON(\@p));
+
for my $resp (@{$req->{response}}) {
$response->{search_complete}++;
my $result = $resp->content or next;
}
}
- # To avoid searching on clumped ISBN values and/or ISBNs with extra
- # junk [e.g. 9781405144094 (hardcover : alk. paper)], send ISBN values
- # through a normalizer which returns a clean list of values. For each
- # extracted ISBN, clone the search so that every ISBN is covered.
- # TODO: is this overkill?
+ # To avoid searching on clumped ISBN values, split the values
+ # and create new searches to accommodate all of them.
# TODO: do we need similar treatment for other ident fields?
+ # NOTE: isbn are sent through the translate_isbn1013 normalize
+ # before entring metabib.identifier_field_entry. As such, there
+ # will always be at minimum 2 ISBNs per record w/ ISBN and the
+ # data will be pre-sanitized.
+ # TODO: do we make ISBN (etc?) splitting configurable? Having it
+ # always on means each record will likely have 2 matches for every
+ # base ISBn value, which may be overkill
for my $bre_id (keys %z_searches) {
for my $src (keys %{$z_searches{$bre_id}}) {
my $blob = $z_searches{$bre_id}{$src};
if (my $isbn = $blob->{search}{isbn}) {
- next if $isbn =~ /^[A-Za-z0-9]+$/; # clean and single
-
- my $clean_str = $e->json_query({
- from => ['translate_isbn1013', $isbn]})->[0];
- next unless ref $clean_str and
- $clean_str = $clean_str->{translate_isbn1013};
+ my @isbn_list = split(/\s/, $isbn);
- my @isbn_list = split(/\s/, $clean_str);
+ # TODO: in testing, this construct just results in
+ # duplicate search results and seems to provide
+ # no value. for now let's use the first iSBN
+ @isbn_list = ($isbn_list[0]);
if (@isbn_list == 1) {
$blob->{search}{isbn} = $isbn_list[0];
next;
}
- # create a new container for the set of searches
+ # create a new container for the searches
$z_searches{$bre_id}{$src} = [];
my $cur_blob;
$cur_blob = $blob;
} else {
# clone
- $logger->info("z30 cloning search for clean ISBN $clean_isbn");
$cur_blob = OpenSRF::Utils::JSON->JSON2perl(
OpenSRF::Utils::JSON->perl2JSON($blob));
}
$cur_blob->{search}{isbn} = $clean_isbn;
push(@{$z_searches{$bre_id}{$src}}, $cur_blob);
- $logger->info("z30 clean ISBN $clean_isbn");
}
}
}