From: erickson Date: Fri, 23 Oct 2009 18:43:57 +0000 (+0000) Subject: added support for passing in key/val pairs for hold update, instead of the entire... X-Git-Tag: kcls-grey-screen-prod1~3217 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=405772e38d7593f8441e5e40272457b3205d7fa4;p=evergreen%2Fequinox.git 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@14583 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 7a34a66204..b0cab5b998 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -604,11 +604,50 @@ __PACKAGE__->register_method( on the hold, the requestor must have UPDATE_HOLDS permissions. NOTE -sub update_hold { - my($self, $client, $auth, $hold) = @_; +__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, $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;