[open-ils-commits] r14583 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Oct 23 14:44:01 EDT 2009


Author: erickson
Date: 2009-10-23 14:43:57 -0400 (Fri, 23 Oct 2009)
New Revision: 14583

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
added support for passing in key/val pairs for hold update, instead of the entire hold object.  added open-ils.circ.hold.update.batch which expects either an array of holds as second param, or list of key/value hashes as 3rd param

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2009-10-23 17:33:25 UTC (rev 14582)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2009-10-23 18:43:57 UTC (rev 14583)
@@ -604,12 +604,51 @@
 	on the hold, the requestor must have UPDATE_HOLDS permissions.
 	NOTE
 
+__PACKAGE__->register_method(
+	method	=> "batch_update_hold",
+	api_name	=> "open-ils.circ.hold.update.batch",
+	notes		=> <<"	NOTE");
+	Updates the specified hold.  The login session
+	is the requestor and if the requestor is different from the usr field
+	on the hold, the requestor must have UPDATE_HOLDS permissions.
+	NOTE
+
 sub update_hold {
-	my($self, $client, $auth, $hold) = @_;
-
+	my($self, $client, $auth, $hold, $values) = @_;
     my $e = new_editor(authtoken=>$auth, xact=>1);
     return $e->die_event unless $e->checkauth;
+    my $resp = update_hold_impl($self, $e, $hold, $values);
+    return $resp if $U->event_code($resp);
+    $e->commit;
+    return $resp;
+}
 
+sub batch_update_hold {
+	my($self, $client, $auth, $hold_list, $values_list) = @_;
+    my $e = new_editor(authtoken=>$auth, xact => 1);
+    return $e->die_event unless $e->checkauth;
+
+    my $count = ($hold_list) ? scalar(@$hold_list) : scalar(@$values_list);
+    $hold_list ||= [];
+    $values_list ||= [];
+    for my $idx (0..$count-1) {
+        my $resp = update_hold_impl($self, $e, $hold_list->[$idx], $values_list->[$idx]);
+        return $resp if $U->event_code($resp);
+    }
+
+    $e->commit;
+    return 1;
+}
+
+sub update_hold_impl {
+    my($self, $e, $hold, $values) = @_;
+
+    unless($hold) {
+        $hold = $e->retrieve_action_hold_request($values->{id})
+            or return $e->die_event;
+        $hold->$_($values->{$_}) for keys %$values;
+    }
+
     my $orig_hold = $e->retrieve_action_hold_request($hold->id)
         or return $e->die_event;
 



More information about the open-ils-commits mailing list