From c00b00e2ff0ad5b32147b3e091bf9c263613188f Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 9 Feb 2006 23:32:54 +0000 Subject: [PATCH] tweaks git-svn-id: svn://svn.open-ils.org/ILS/trunk@3023 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/AppUtils.pm | 3 +++ .../OpenILS/Application/Circ/Circulate.pm | 19 ++++++++----- .../OpenILS/Application/Circ/Holds.pm | 27 +++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm index 203ede7a84..38338b79f9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm @@ -147,9 +147,12 @@ sub simplereq { } sub get_storage_session { + if( $storage_session and $storage_session->connected and + $storage_session->transport_connected and $storage_session->app eq 'open-ils.storage' ) { + $logger->debug("get_storage_session(): returning existing session"); return $storage_session; } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 66e79228c4..044674d454 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -529,7 +529,8 @@ sub checkout { $evt = _update_checkout_copy($ctx); return $evt if $evt; - $evt = _handle_related_holds($ctx); + my $holds; + ($holds, $evt) = _handle_related_holds($ctx); return $evt if $evt; @@ -538,10 +539,11 @@ sub checkout { my $record = $U->record_to_mvr($ctx->{title}) unless $ctx->{precat}; return OpenILS::Event->new('SUCCESS', - payload => { - copy => $U->unflesh_copy($ctx->{copy}), - circ => $ctx->{circ}, - record => $record, + payload => { + copy => $U->unflesh_copy($ctx->{copy}), + circ => $ctx->{circ}, + record => $record, + holds_fulfilled => $holds, } ); } @@ -744,7 +746,9 @@ sub _handle_related_holds { my $patron = $ctx->{patron}; my $holds = $holdcode->fetch_related_holds($copy->id); $U->logmark; + my @fulfilled; + # XXX should we fulfill all the holds or just the first if(ref($holds) && @$holds) { # for now, just sort by id to get what should be the oldest hold @@ -759,11 +763,12 @@ sub _handle_related_holds { $hold->fulfillment_time('now'); my $r = $ctx->{session}->request( "open-ils.storage.direct.action.hold_request.update", $hold )->gather(1); - return $U->DB_UPDATE_FAILED( $hold ) unless $r; + return (undef,$U->DB_UPDATE_FAILED( $hold )) unless $r; + push( @fulfilled, $hold->id ); } } - return undef; + return (\@fulfilled, undef); } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 846f4e0dcb..3f7f736c67 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -309,7 +309,10 @@ __PACKAGE__->register_method( NOTE sub capture_copy { - my( $self, $client, $login_session, $barcode, $flesh ) = @_; + my( $self, $client, $login_session, $params ) = @_; + my %params = %$params; + my $barcode = $params{barcode}; + my( $user, $target, $copy, $hold, $evt ); @@ -320,7 +323,7 @@ sub capture_copy { $evt = $apputils->check_perms($user->id, $user->home_ou, "COPY_CHECKIN"); return $evt if $evt; - $logger->info("Capturing copy with barcode $barcode, flesh=$flesh"); + $logger->info("Capturing copy with barcode $barcode"); my $session = $apputils->start_db_session(); @@ -357,19 +360,21 @@ sub capture_copy { "open-ils.storage.direct.asset.copy.update", $copy )->gather(1); if(!$stat) { throw OpenSRF::EX ("Error updating copy " . $copy->id); } - - my $title = undef; - if($flesh) { - ($title, $evt) = $apputils->fetch_record_by_copy( $copy->id ); + my $payload = { hold => $hold }; + $payload->{copy} = $copy if $params{flesh_copy}; + + if($params{flesh_record}) { + my $record; + ($record, $evt) = $apputils->fetch_record_by_copy( $copy->id ); return $evt if $evt; - $title = $apputils->record_to_mvr($title); - } + $record = $apputils->record_to_mvr($record); + $payload->{record} = $record; + } $apputils->commit_db_session($session); - my $payload = { copy => $copy, record => $title, hold => $hold, }; - - return OpenILS::Event->new('ROUTE_ITEM', route_to => $hold->pickup_lib, payload => $payload ); + return OpenILS::Event->new('ROUTE_ITEM', + route_to => $hold->pickup_lib, payload => $payload ); } sub _build_hold_transit { -- 2.43.2