From 1741ce377f536f47bc1380d6144b2d88eced387c Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Thu, 26 Jul 2012 10:17:06 -0400 Subject: [PATCH] Feed JEDI to the EDI translator to get EDI, and vice versa. Run this script as the opensrf user. INPUT_IS_EDI=1 perl test_edi_translator.pl < blob.edi -or- perl test_edi_translator.pl < blob.jedi Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/src/edi_translator/test_edi_translator.pl | 57 ++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) create mode 100644 Open-ILS/src/edi_translator/test_edi_translator.pl diff --git a/Open-ILS/src/edi_translator/test_edi_translator.pl b/Open-ILS/src/edi_translator/test_edi_translator.pl new file mode 100644 index 0000000..a7149ad --- /dev/null +++ b/Open-ILS/src/edi_translator/test_edi_translator.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +# This assumes you have the translator (edi_webrick) running. + +use strict; +use warnings; + +use Data::Dumper; +use vars qw/$debug/; + +use OpenILS::Utils::Cronscript; +use OpenILS::Utils::Fieldmapper; +use OpenILS::Application::AppUtils; +use OpenILS::Application::Acq::EDI; +use OpenSRF::Utils::Logger q/$logger/; + +INIT { + $debug = 1; +} + +my %defaults = ( + 'quiet' => 0, + 'test' => 0, +); + +print "loading OpenILS environment... " if $debug; + +my $cs = OpenILS::Utils::Cronscript->new(\%defaults); + +my $opts = $cs->MyGetOptions; +my $e = $cs->editor or die "Failed to get new CStoreEditor"; + +print "creating acq.edi_message object from stdin\n" if $debug; +my $message = new Fieldmapper::acq::edi_message; +$message->message_type("ORDERS"); + +my $input_field = $ENV{INPUT_IS_EDI} ? 'edi' : 'jedi'; +my $output_field = $ENV{INPUT_IS_EDI} ? 'jedi' : 'edi'; +{ + local $/; + undef $/; + $message->$input_field(); + +} + +print "calling out to edi translator... \n" if $debug; + +my $r = attempt_translation OpenILS::Application::Acq::EDI($message, !$ENV{INPUT_IS_EDI}); + +if (!$r) { + print STDERR "attempt_translation failed; see opensrf ERR logs\n"; +} else { + print $r->$output_field,"\n"; +} + +print "done.\n" if $debug; + -- 1.7.2.5