From: Bill Erickson Date: Thu, 25 Sep 2014 21:50:56 +0000 (-0400) Subject: LP#1373690 edi_pusher get --from-edi and --defs options for skipping translation... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a609676961369381665c7c35e5a88ef82167f0d4;p=working%2FEvergreen.git LP#1373690 edi_pusher get --from-edi and --defs options for skipping translation stage Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/support-scripts/edi_pusher.pl b/Open-ILS/src/support-scripts/edi_pusher.pl index e94abb85a1..99cc469bbc 100755 --- a/Open-ILS/src/support-scripts/edi_pusher.pl +++ b/Open-ILS/src/support-scripts/edi_pusher.pl @@ -34,6 +34,8 @@ my %defaults = ( 'quiet' => 0, 'test' => 0, # TODO 'max-batch-size=i' => -1, + 'from-edi' => 0, + 'def=s' => 0, # if true, print final EDI to STDOUT, send nothign to the vendor, write nothing to the DB 'debug-only' => 0 @@ -44,11 +46,16 @@ my $cs = OpenILS::Utils::Cronscript->new(\%defaults); my $opts = $cs->MyGetOptions(); my $e = $cs->editor() or die "Failed to get new CStoreEditor"; my $hook = 'acqpo.activated'; -my $defs = $e->search_action_trigger_event_definition({ - hook => $hook, - reactor => 'GeneratePurchaseOrderJEDI', - active => 't' -}); +my $defs; +if ($opts->{def}) { + $defs = [$e->retrieve_action_trigger_event_definition($opts->{def})]; +} else { + $defs = $e->search_action_trigger_event_definition({ + hook => $hook, + reactor => 'GeneratePurchaseOrderJEDI', + active => 't' + }); +} $opts->{verbose} = 0 if $opts->{quiet}; @@ -167,22 +174,30 @@ foreach my $def (@$defs) { next; } - printf "\nNow calling attempt_translation for $logstr2\n\n"; + if ($opts->{'from-edi'}) { - unless (OpenILS::Application::Acq::EDI->attempt_translation($message, 1)) { - print STDERR "ERROR: attempt_translation failed for $logstr2\n"; - next; - # The premise here is that if the translator failed, it is better to try again later from a "fresh" fetched file - # than to add a cascade of failing inscrutable copies of the same message(s) to our DB. - } + print "Skipping JEDI translation on raw EDI definition\n"; + $message->edi($message->jedi); - if ($opts->{'debug-only'}) { - print OpenILS::Application::Acq::EDI->attempt_translation($message, 1)->edi . "\n"; - print "\ndebug-only => skipping FTP\n"; - next; + } else { + printf "\nNow calling attempt_translation for $logstr2\n\n"; + + unless (OpenILS::Application::Acq::EDI->attempt_translation($message, 1)) { + print STDERR "ERROR: attempt_translation failed for $logstr2\n"; + next; + # The premise here is that if the translator failed, it is better to try again later from a "fresh" fetched file + # than to add a cascade of failing inscrutable copies of the same message(s) to our DB. + } + + if ($opts->{'debug-only'}) { + print OpenILS::Application::Acq::EDI->attempt_translation($message, 1)->edi . "\n"; + print "\ndebug-only => skipping FTP\n"; + next; + } + + print "Writing new message + translation to DB for $logstr2\n"; } - print "Writing new message + translation to DB for $logstr2\n"; $e->xact_begin; if($message->isnew) { @@ -198,6 +213,9 @@ foreach my $def (@$defs) { } $e->xact_commit; + # XXX TESTING + exit; + print "Calling send_core(...) for message (", $message->id, ")\n"; my $res = OpenILS::Application::Acq::EDI->send_core($target->provider->edi_default, [$message->id]); if (@$res) {