From: Bill Erickson Date: Fri, 1 Aug 2014 21:23:31 +0000 (-0400) Subject: LP#1347774 open-ils.search unapi API X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=746b2f4bc1154619d4d834996f90fa698faef477;p=working%2FEvergreen.git LP#1347774 open-ils.search unapi API Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 15685b0af1..9c878b0bb2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2791,6 +2791,60 @@ sub copies_by_cn_label { return [ map { ($U->is_true($_->location->opac_visible) && $U->is_true($_->status->opac_visible)) ? ($_->id) : () } @$copies ]; } +__PACKAGE__->register_method( + method => "unapi_records", + api_name => "open-ils.search.unapi.bre", + stream => 1, + # TODO +); + +__PACKAGE__->register_method( + method => "unapi_records", + api_name => "open-ils.search.unapi.mmr", + stream => 1, + # TODO +); + +sub unapi_records { + my ($self, $client, $rec_id, $unapi_args) = @_; + + my $rec_ids = ref $rec_id eq 'ARRAY' ? $rec_id : [$rec_id]; + + $unapi_args ||= {}; + $unapi_args->{site} ||= $U->get_org_tree->shortname; + $unapi_args->{flesh} ||= '{bre}'; # default to just the record + $unapi_args->{flesh_depth} ||= 5; + $unapi_args->{flesh_limit} ||= ''; + $unapi_args->{format} ||= 'marcxml'; + $unapi_args->{ename} ||= 'record'; + + my $unapi_type = + ($self->api_name =~ /bre/) ? 'unapi.bre' : 'unapi.mmr'; + + my $e = new_editor; + for my $id (@$rec_ids) { + $client->respond( + $e->json_query({ + from => [ + $unapi_type, + $id, + $unapi_args->{format}, + $unapi_args->{ename}, + $unapi_args->{flesh}, + $unapi_args->{site}, + $unapi_args->{depth}, + $unapi_args->{flesh_limit}, + $unapi_args->{flesh_offset}, + $unapi_args->{inc_xmlns}, + $unapi_args->{pref_lib} + ] + })->[0] + ); + } + + return undef; +} + 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 18489c2ae8..56ac994c51 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -295,7 +295,7 @@ sub get_records_and_facets { my $outer_self = $self; $self->timelog("get_records_and_facets(): about to call multisession"); my $ses = OpenSRF::MultiSession->new( - app => 'open-ils.cstore', + app => 'open-ils.search', cap => 10, # XXX config success_handler => sub { my($self, $req) = @_; @@ -396,15 +396,18 @@ sub get_records_and_facets { # tag the record with the MR id $flesh =~ s/}$/,mmr.unapi}/g if $is_meta; + my $method = $is_meta ? + 'open-ils.search.unapi.mmr' : + 'open-ils.search.unapi.bre'; + $ses->request( - 'open-ils.cstore.json_query', - {from => [ - $unapi_type, $bid, 'marcxml','record', $flesh, - $unapi_args->{site}, - $unapi_args->{depth}, - $slimit, - undef, undef, $unapi_args->{pref_lib} - ]} + $method, $bid, { + flesh => $flesh, + site => $unapi_args->{site}, + depth => $unapi_args->{depth}, + flesh_limit => $slimit, + pref_lib => $unapi_args->{pref_lib} + } ); } }