[open-ils-commits] r17605 - trunk/Open-ILS/src/perlmods/OpenILS/Application (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Sep 11 14:35:50 EDT 2010
Author: miker
Date: 2010-09-11 14:35:46 -0400 (Sat, 11 Sep 2010)
New Revision: 17605
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
Log:
Method for retrieving received issuances attached to a bib, optionally scoped by location, with paging and ordering support
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm 2010-09-11 14:51:18 UTC (rev 17604)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm 2010-09-11 18:35:46 UTC (rev 17605)
@@ -349,7 +349,95 @@
]);
}
+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 => {
+ '+ssub' => { record_entry => $bib },
+ '+sitem' => {
+ # XXX should we also take specific item statuses into account?
+ date_received => { '!=' => undef }
+ },
+ $$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.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
+/
+ }
+ ]
+ }
+);
+
+
##########################################################################
# unit methods
#
More information about the open-ils-commits
mailing list