From 1655e87e968e08dea8e52c6bd888f73668deff2a Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 12 Sep 2010 15:55:22 +0000 Subject: [PATCH] Backporting r17605 and r17606 from trunk: Method for retrieving received issuances attached to a bib, optionally scoped by location, holding type or item status, with paging and ordering support git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_0@17611 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Serial.pm | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm b/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm index d4bd00aade..574f256da2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm @@ -350,6 +350,98 @@ sub pub_fleshed_serial_issuance_retrieve_batch { ]); } +sub received_siss_by_bib { + my $self = shift; + my $client = shift; + my $bib = shift; + + my $args = shift || {}; + $$args{order} ||= 'asc'; + + my $e = new_editor(); + my $issuances = $e->json_query({ + select => { 'siss' => [ 'id' ] }, + from => { + siss => { + ssub => { + field => 'id', + fkey => 'subscription' + }, + sitem => { + field => 'issuance', + fkey => 'id', + $$args{ou} ? ( join => { + sstr => { + field => 'id', + fkey => 'stream', + join => { + sdist => { + field => 'id', + fkey => 'distribution' + } + } + } + }) : () + } + } + }, + where => { + $$args{type} ? ( 'holding_type' => $$args{type} ) : (), + '+ssub' => { record_entry => $bib }, + '+sitem' => { + # XXX should we also take specific item statuses into account? + date_received => { '!=' => undef }, + $$args{status} ? ( 'status' => $$args{status} ) : () + }, + $$args{ou} ? ( '+sdist' => { + holding_lib => { + 'in' => { + from => [ + 'actor.org_unit_descendants', + defined($$args{depth}) ? ( $$args{ou}, $$args{depth} ) : ( $$args{ou} ) + ] + } + } + }) : () + }, + $$args{limit} ? ( limit => $$args{limit} ) : (), + $$args{offset} ? ( offset => $$args{offset} ) : (), + order_by => [{ class => 'siss', field => 'date_published', direction => $$args{order} }], + distinct => 1 + }); + + $client->respond($e->retrieve_serial_issuance($_->{id})) for @$issuances; + return undef; +} +__PACKAGE__->register_method( + method => 'received_siss_by_bib', + api_name => 'open-ils.serial.received_siss.retrieve.by_bib', + api_level => 1, + argc => 1, + stream => 1, + signature => { + desc => 'Receives a Bib ID and other optional params and returns "siss" (issuance) objects', + params => [ + { name => 'bibid', + desc => 'id of the bre to which the issuances belong', + type => 'number' + }, + { name => 'args', + desc => +q/A hash of optional arguments. Valid keys and their meanings: + order := date_published sort direction, either "asc" (chronological, default) or "desc" (reverse chronological) + limit := Number of issuances to return. Useful for paging results, or finding the oldest or newest + offest := Number of issuance to skip before returning results. Useful for paging. + orgid := OU id used to scope retrieval, based on distribution.holding_lib + depth := OU depth used to range the scope of orgid + type := Holding type filter. Valid values are "basic", "supplement" and "index". Can be a scalar (one) or arrayref (one or more). + status := Item status filter. Valid values are "Bindery", "Bound", "Claimed", "Discarded", "Expected", "Not Held", "Not Published" and "Received". Can be a scalar (one) or arrayref (one or more). +/ + } + ] + } +); + ########################################################################## # unit methods -- 2.11.0