only grabbing locations and statuses for the given copy - fleshing at call time when...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Aug 2006 20:10:09 +0000 (20:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Aug 2006 20:10:09 +0000 (20:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5571 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm

index 8b58dff..b2d5761 100644 (file)
@@ -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))