From: Bill Erickson Date: Mon, 30 Jul 2012 01:11:55 +0000 (-0400) Subject: vandelay copy overlay; perl cleanup X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=485955bdbee38ece27aebb9a8ac4652d2ea4c819;p=evergreen%2Fequinox.git vandelay copy overlay; perl cleanup Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm index 3f75236c83..b5a6b28932 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm @@ -1584,6 +1584,8 @@ sub import_record_asset_list_impl { if (my $copy_id = $item->internal_id) { # assignment # copy matches an existing copy. Overlay instead of create. + $logger->info("vl: performing copy overlay for internal_id=$copy_id"); + my $qt = $e->json_query({ select => {vbq => ['queue_type']}, from => {vqbr => 'vbq'}, @@ -1601,6 +1603,7 @@ sub import_record_asset_list_impl { next; } $copy_id = $lid->eg_copy_id; + $logger->info("vl: performing ACQ copy overlay for copy $copy_id"); } $copy = $e->search_asset_copy([ @@ -1615,7 +1618,9 @@ sub import_record_asset_list_impl { } # prevent update of unrelated copies - if ($copy->call_number->record != $rec->imported_as) { + if ($copy->call_number->record != $rec_id) { + $logger->info("vl: attempt to overlay unrelated copy=$copy_id; rec=$rec_id"); + $evt = OpenILS::Event->new('INVALID_IMPORT_COPY_ID', note => 'Cannot overlay copies for unlinked bib', bre => $rec->imported_as, @@ -1651,10 +1656,11 @@ sub import_record_asset_list_impl { })->[0]->{count}; if ($count == 1) { - # if this is the only copy attached to this # callnumber, just update the callnumber + $logger->info("vl: updating callnumber label in copy overlay"); + $copy->call_number->label($item->call_number); if (!$e->udpate_asset_call_number($copy->call_number)) { $$report_args{evt} = $e->die_event; @@ -1669,6 +1675,8 @@ sub import_record_asset_list_impl { # note that overlay does not allow the owning_lib # to be changed. Should it? + $logger->info("vl: moving copy to new callnumber in copy overlay"); + ($vol, $evt) = OpenILS::Application::Cat::AssetCommon->find_or_create_volume( $e, $item->call_number, @@ -1686,21 +1694,14 @@ sub import_record_asset_list_impl { } } # cn-update - # for any field that has a defined value, replace the value on the copy - $copy->barcode($item->barcode) if defined $item->barcode; - $copy->location($item->location) if defined $item->location; - $copy->circ_lib($item->circ_lib) if defined $item->circ_lib; - $copy->status($item->status) if defined $item->status; - $copy->circulate($item->circulate) if defined $item->circulate; - $copy->deposit($item->deposit) if $item->deposit; - $copy->deposit_amount($item->deposit_amount) if defined $item->deposit_amount; - $copy->ref($item->ref) if defined $item->ref; - $copy->holdable($item->holdable) if defined $item->holdable; - $copy->price($item->price) if defined $item->price; - $copy->circ_as_type($item->circ_as_type) if defined $item->circ_as_type; - $copy->alert_message($item->alert_message) if defined $item->alert_message; - $copy->opac_visible($item->opac_visible) if defined $item->opac_visible; - $copy->circ_modifier($item->circ_modifier) if defined $item->circ_modifier; + # for every field that has a non-'' value, overlay the copy value + foreach (qw/ barcode location circ_lib status + circulate deposit deposit_amount ref holdable + price circ_as_type alert_message opac_visible circ_modifier/) { + + my $val = $item->$_(); + $copy->$_($val) if $val and $val ne ''; + } # de-flesh for update $copy->call_number($copy->call_number->id); @@ -1717,6 +1718,7 @@ sub import_record_asset_list_impl { } else { # Creating a new copy + $logger->info("vl: creating new copy in import"); # -------------------------------------------------------------------------------- # Find or create the volume