From 0aa27fa4664b9957512c0763907ade67876d4f64 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 17 Aug 2006 20:10:09 +0000 Subject: [PATCH] only grabbing locations and statuses for the given copy - fleshing at call time when available git-svn-id: svn://svn.open-ils.org/ILS/trunk@5571 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/ScriptBuilder.pm | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm index 8b58dffd0f..b2d57616b7 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm @@ -15,8 +15,6 @@ use Data::Dumper; my $holdcode = "OpenILS::Application::Circ::Holds"; my $evt = "environment"; -my @COPY_STATUSES; -my @COPY_LOCATIONS; my %GROUP_SET; my $GROUP_TREE; my $ORG_TREE; @@ -99,38 +97,27 @@ sub fetch_bib_data { if(!$ctx->{copy}) { + my $flesh = { flesh => 1, flesh_fields => { acp => [ 'location', 'status', 'circ_lib' ] } }; + if($ctx->{copy_id}) { - $ctx->{copy} = $e->retrieve_asset_copy($ctx->{copy_id}) - or return $e->event; + $ctx->{copy} = $e->retrieve_asset_copy( + [$ctx->{copy_id}, $flesh ]) or return $e->event; } elsif( $ctx->{copy_barcode} ) { - my $cps = $e->search_asset_copy({barcode => $ctx->{copy_barcode}}); - return $e->event unless @$cps; - $ctx->{copy} = $$cps[0]; + $ctx->{copy} = $e->search_asset_copy( + [{barcode => $ctx->{copy_barcode}}, $flesh ])->[0] + or return $e->event; } } return undef unless my $copy = $ctx->{copy}; - # -------------------------------------------------------------------- - # Fetch/Cache the copy status and location objects - # -------------------------------------------------------------------- - if(!@COPY_STATUSES) { - my $s = $e->retrieve_all_config_copy_status(); - @COPY_STATUSES = @$s; - $s = $e->retrieve_all_asset_copy_location(); - @COPY_LOCATIONS = @$s; - } - - # Flesh the status and location - $copy->status( - grep { $_->id == $copy->status } @COPY_STATUSES ) - unless ref $copy->status; + $copy->location($e->retrieve_asset_copy_location($copy->location)) + unless( ref $copy->location ); - $copy->location( - grep { $_->id == $copy->location } @COPY_LOCATIONS ) - unless ref $copy->location; + $copy->status($e->retrieve_config_copy_status($copy->status)) + unless( ref $copy->status ); $copy->circ_lib( $e->retrieve_actor_org_unit($copy->circ_lib)) -- 2.11.0