From c1c972de6360babba55762ad2f4748de0df39ec0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 5 Dec 2011 16:11:12 -0500 Subject: [PATCH] acq vandelay : acq ML bits Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Acq/Order.pm | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 62e0d7929b..fb315873fa 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -19,6 +19,7 @@ sub new { picklist => undef, complete => 0, indexed => 0, + queue => undef, total => 0 }; $self->{cache} = {}; @@ -319,13 +320,13 @@ sub import_li_bibs_via_vandelay { my $e = $mgr->editor; $e->xact_begin; - my $queue_id = $vandelay->{existing_queue}; + my $queue; if (my $name = $vandelay->{queue_name}) { # first, see if a queue w/ this name already exists # for this user. If so, use that instead. - my $queue = $e->search_vandelay_bib_queue( + $queue = $e->search_vandelay_bib_queue( {name => $name, owner => $e->requestor->id})->[0]; if ($queue) { @@ -343,10 +344,14 @@ sub import_li_bibs_via_vandelay { $queue = $e->create_vandelay_bib_queue($queue) or return $res; } - $queue_id = $queue->id; - } + } else { + $queue = $e->retrieve_vandelay_queue($vandelay->{existing_queue}) + or return undef; + } + - return $res unless $queue_id; + return $res unless $queue; + $mgr->{args}->{queue} = $queue; # load the lineitems into the queue for merge processing my @vqbr_ids; @@ -357,8 +362,8 @@ sub import_li_bibs_via_vandelay { my $vqbr = Fieldmapper::vandelay::queued_bib_record->new; $vqbr->marc($li->marc); - $vqbr->queue($queue_id); - $vqbr->bib_source($vandelay->{bib_source}); + $vqbr->queue($queue->id); + $vqbr->bib_source($vandelay->{bib_source} || undef); $vqbr = $e->create_vandelay_queued_bib_record($vqbr) or return $res; push(@vqbr_ids, $vqbr->id); $mgr->add_vqbr; @@ -417,7 +422,7 @@ sub import_li_bibs_via_vandelay { $ses->kill_me; $logger->info("acq-vl: successfully imported lineitems [@success_lis]"); - return {queue => $queue_id, li_ids => \@success_lis}; + return {queue => $queue, li_ids => \@success_lis}; } # returns event on error, undef on success @@ -2285,9 +2290,8 @@ sub activate_purchase_order_impl { if (!$li->eg_bib_id and !$dry_run) { # we encountered a lineitem that was not successfully imported. # we cannot continue. rollback and report. - my $queue = $e->retrieve_vandelay_queue($vl_resp->{queue}); $e->rollback; - return OpenILS::Event->new('ACQ_LI_IMPORT_FAILED', {queue => $queue}); + return OpenILS::Event->new('ACQ_LI_IMPORT_FAILED', {queue => $vl_resp->{queue}}); } $li->state('on-order'); -- 2.11.0