[open-ils-commits] r17611 - branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Sep 12 11:55:25 EDT 2010


Author: miker
Date: 2010-09-12 11:55:22 -0400 (Sun, 12 Sep 2010)
New Revision: 17611

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
Log:
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

Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm	2010-09-12 15:52:33 UTC (rev 17610)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm	2010-09-12 15:55:22 UTC (rev 17611)
@@ -350,7 +350,99 @@
     ]);
 }
 
+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
 #



More information about the open-ils-commits mailing list