'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
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};
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) {
}
$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) {