]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/edi_translator/test_edi_translator.pl
LP#1739286: Revert "lp1739286 default search box in Z39.50"
[working/Evergreen.git] / Open-ILS / src / edi_translator / test_edi_translator.pl
1 #!/usr/bin/perl
2
3 # This assumes you have the translator (edi_webrick) running.
4
5 use strict;
6 use warnings;
7
8 use Data::Dumper;
9 use vars qw/$debug/;
10
11 use OpenILS::Utils::Cronscript;
12 use OpenILS::Utils::Fieldmapper;
13 use OpenILS::Application::AppUtils;
14 use OpenILS::Application::Acq::EDI;
15 use OpenSRF::Utils::Logger q/$logger/;
16
17 INIT {
18     $debug = 1;
19 }
20
21 my %defaults = (
22     'quiet' => 0,
23     'test'  => 0,
24 );
25
26 print "loading OpenILS environment... " if $debug;
27
28 my $cs = OpenILS::Utils::Cronscript->new(\%defaults);
29
30 my $opts = $cs->MyGetOptions;
31 my $e    = $cs->editor or die "Failed to get new CStoreEditor";
32
33 print "creating acq.edi_message object from stdin\n" if $debug;
34 my $message = new Fieldmapper::acq::edi_message;
35 $message->message_type("ORDERS");
36
37 my $input_field = $ENV{INPUT_IS_EDI} ? 'edi' : 'jedi';
38 my $output_field = $ENV{INPUT_IS_EDI} ? 'jedi' : 'edi';
39 {
40     local $/;
41     undef $/;
42     $message->$input_field(<STDIN>);
43
44 }
45
46 print "calling out to edi translator... \n" if $debug;
47
48 my $r = attempt_translation OpenILS::Application::Acq::EDI($message, !$ENV{INPUT_IS_EDI});
49
50 if (!$r) {
51     print STDERR "attempt_translation failed; see opensrf ERR logs\n";
52 } else {
53     print $r->$output_field,"\n";
54 }
55
56 print "done.\n" if $debug;
57