[open-ils-commits] [GIT] Evergreen ILS branch master updated. 8227dd59af80c12740ad51ea076d7e5806b8ff62

Evergreen Git git at git.evergreen-ils.org
Wed Aug 1 15:18:13 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  8227dd59af80c12740ad51ea076d7e5806b8ff62 (commit)
       via  ab47e65292278af4213df9dc7a6afa020bc208e4 (commit)
       via  d6bab7ae43feb872af795022106f6848f41f09ad (commit)
       via  1741ce377f536f47bc1380d6144b2d88eced387c (commit)
      from  cff5fb73738b1ef632c9de88a4156f5b291c4d71 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8227dd59af80c12740ad51ea076d7e5806b8ff62
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Aug 1 15:17:59 2012 -0400

    Stamping upgrade script for JEDI with Copies
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 2188d80..7b86406 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0732', :eg_version); -- berick/senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0733', :eg_version); -- berick/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.jedi_with_copies.sql b/Open-ILS/src/sql/Pg/upgrade/0733.data.jedi_with_copies.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.jedi_with_copies.sql
rename to Open-ILS/src/sql/Pg/upgrade/0733.data.jedi_with_copies.sql
index 21552a2..99ec8bc 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.jedi_with_copies.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0733.data.jedi_with_copies.sql
@@ -7,6 +7,10 @@
 -- updating.  No env fields are removed (that aren't otherwise replaced).
 --
 
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0732', :eg_version);
+
 UPDATE action_trigger.event_definition SET template =
 $$[%- USE date -%]
 [%# start JEDI document 
@@ -179,5 +183,5 @@ BEGIN
 
 END $$;
 
-
+COMMIT;
 

commit ab47e65292278af4213df9dc7a6afa020bc208e4
Author: Bill Erickson <berick at esilibrary.com>
Date:   Fri Jul 27 12:11:23 2012 -0400

    EDI ORDER template, now with copies
    
    Adds a new "copies" structure to the stock JEDI ORDER template.  Copies
    are ultimately mapped into one or more GIR segments in the outbound EDI.
    This commit only adds the change to the stock template (seed data).  It
    also adds entries to the environment for the stock template and existing
    template 23 via upgrade script (to expedite local template editing).
    
    With the current template, GIR segments look like so:
    
    GIR+001+8:LCO+TESTFUND2:LFN+SYS1-BR1:LLO+FIC ROW 456:LSM+Stacks:LSQ'
    GIR+002+9:LCO+TESTFUND2:LFN+SYS1-BR1:LLO+FIC ROW 456:LSM+Stacks:LSQ'
    GIR+003+10:LCO+TESTFUND2:LFN+SYS1-BR1:LLO+FIC ROW 456:LSM+Stacks:LSQ'
    GIR+004+11:LCO+TESTFUND2:LFN+SYS1-BR1:LLO+FIC ROW 456:LSM+Stacks:LSQ'
    GIR+005+12:LCO+TESTFUND2:LFN+SYS1-BR1:LLO+FIC ROW 456:LSM+Stacks:LSQ'
    GIR+006+13:LCO+TESTFUND2:LFN+SYS1-BR2:LLO+FIC ROW 456:LSM+Young Adult:LSQ'
    GIR+007+14:LCO+TESTFUND2:LFN+SYS1-BR2:LLO+FIC ROW 456:LSM+Young Adult:LSQ'
    GIR+008+15:LCO+TESTFUND2:LFN+SYS1-BR2:LLO+FIC ROW 456:LSM+Young Adult:LSQ'
    
    LQT / quantity is also supported.
    
    The current implementation is meant to cover all possible fields so that
    users can remove/alter items on a vendor by vendor basis as needed.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 841d95c..94ca8f2 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -8058,7 +8058,32 @@ END;
             "free-text":[ 
                 [% FOR note IN ftx_vals -%] "[% note %]"[% UNLESS loop.last %], [% END %][% END %] 
             ],            
-            "quantity":[% li.lineitem_details.size %]
+            "quantity":[% li.lineitem_details.size %],
+            "copies" : [
+                [%- IF 1 -%]
+                [%- FOR lid IN li.lineitem_details;
+                        fund = lid.fund.code;
+                        item_type = lid.circ_modifier;
+                        callnumber = lid.cn_label;
+                        owning_lib = lid.owning_lib.shortname;
+                        location = lid.location;
+    
+                        # when we have real copy data, treat it as authoritative for some fields
+                        acp = lid.eg_copy_id;
+                        IF acp;
+                            item_type = acp.circ_modifier;
+                            callnumber = acp.call_number.label;
+                            location = acp.location.name;
+                        END -%]
+                {   [%- IF fund %] "fund" : "[% fund %]",[% END -%]
+                    [%- IF callnumber %] "call_number" : "[% callnumber %]", [% END -%]
+                    [%- IF item_type %] "item_type" : "[% item_type %]", [% END -%]
+                    [%- IF location %] "copy_location" : "[% location %]", [% END -%]
+                    [%- IF owning_lib %] "owning_lib" : "[% owning_lib %]", [% END -%]
+                    [%- #chomp %]"copy_id" : "[% lid.id %]" }[% ',' UNLESS loop.last %]
+                [% END -%]
+                [%- END -%]
+             ]
         }[% UNLESS loop.last %],[% END %]
         [%-# TODO: lineitem details (later) -%]
         [% END %]
@@ -8074,7 +8099,11 @@ $$
 
 INSERT INTO action_trigger.environment (event_def, path) VALUES 
   (23, 'lineitems.attributes'), 
-  (23, 'lineitems.lineitem_details'), 
+  (23, 'lineitems.lineitem_details.owning_lib'),
+  (23, 'lineitems.lineitem_details.location'),
+  (23, 'lineitems.lineitem_details.fund'),
+  (23, 'lineitems.lineitem_details.eg_copy_id.location'),
+  (23, 'lineitems.lineitem_details.eg_copy_id.call_number'),
   (23, 'lineitems.lineitem_notes'), 
   (23, 'ordering_agency.mailing_address'), 
   (23, 'provider'),
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.jedi_with_copies.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.jedi_with_copies.sql
new file mode 100644
index 0000000..21552a2
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.jedi_with_copies.sql
@@ -0,0 +1,183 @@
+
+
+-- XXX
+-- Template update included here for reference only.
+-- The stock JEDI template is not updated here (see WHERE clause)
+-- We do update the environment, though, for easier local template 
+-- updating.  No env fields are removed (that aren't otherwise replaced).
+--
+
+UPDATE action_trigger.event_definition SET template =
+$$[%- USE date -%]
+[%# start JEDI document 
+  # Vendor specific kludges:
+  # BT      - vendcode goes to NAD/BY *suffix*  w/ 91 qualifier
+  # INGRAM  - vendcode goes to NAD/BY *segment* w/ 91 qualifier (separately)
+  # BRODART - vendcode goes to FTX segment (lineitem level)
+-%]
+[%- 
+IF target.provider.edi_default.vendcode && target.provider.code == 'BRODART';
+    xtra_ftx = target.provider.edi_default.vendcode;
+END;
+-%]
+[%- BLOCK big_block -%]
+{
+   "recipient":"[% target.provider.san %]",
+   "sender":"[% target.ordering_agency.mailing_address.san %]",
+   "body": [{
+     "ORDERS":[ "order", {
+        "po_number":[% target.id %],
+        "date":"[% date.format(date.now, '%Y%m%d') %]",
+        "buyer":[
+            [%   IF   target.provider.edi_default.vendcode && (target.provider.code == 'BT' || target.provider.name.match('(?i)^BAKER & TAYLOR'))  -%]
+                {"id-qualifier": 91, "id":"[% target.ordering_agency.mailing_address.san _ ' ' _ target.provider.edi_default.vendcode %]"}
+            [%- ELSIF target.provider.edi_default.vendcode && target.provider.code == 'INGRAM' -%]
+                {"id":"[% target.ordering_agency.mailing_address.san %]"},
+                {"id-qualifier": 91, "id":"[% target.provider.edi_default.vendcode %]"}
+            [%- ELSE -%]
+                {"id":"[% target.ordering_agency.mailing_address.san %]"}
+            [%- END -%]
+        ],
+        "vendor":[
+            [%- # target.provider.name (target.provider.id) -%]
+            "[% target.provider.san %]",
+            {"id-qualifier": 92, "id":"[% target.provider.id %]"}
+        ],
+        "currency":"[% target.provider.currency_type %]",
+                
+        "items":[
+        [%- FOR li IN target.lineitems %]
+        {
+            "line_index":"[% li.id %]",
+            "identifiers":[   [%-# li.isbns = helpers.get_li_isbns(li.attributes) %]
+            [% FOR isbn IN helpers.get_li_isbns(li.attributes) -%]
+                [% IF isbn.length == 13 -%]
+                {"id-qualifier":"EN","id":"[% isbn %]"},
+                [% ELSE -%]
+                {"id-qualifier":"IB","id":"[% isbn %]"},
+                [%- END %]
+            [% END %]
+                {"id-qualifier":"IN","id":"[% li.id %]"}
+            ],
+            "price":[% li.estimated_unit_price || '0.00' %],
+            "desc":[
+                {"BTI":"[% helpers.get_li_attr_jedi('title',     '', li.attributes) %]"},
+                {"BPU":"[% helpers.get_li_attr_jedi('publisher', '', li.attributes) %]"},
+                {"BPD":"[% helpers.get_li_attr_jedi('pubdate',   '', li.attributes) %]"},
+                {"BPH":"[% helpers.get_li_attr_jedi('pagination','', li.attributes) %]"}
+            ],
+            [%- ftx_vals = []; 
+                FOR note IN li.lineitem_notes; 
+                    NEXT UNLESS note.vendor_public == 't'; 
+                    ftx_vals.push(note.value); 
+                END; 
+                IF xtra_ftx;           ftx_vals.unshift(xtra_ftx); END; 
+                IF ftx_vals.size == 0; ftx_vals.unshift('');       END;  # BT needs FTX+LIN for every LI, even if it is an empty one
+            -%]
+
+            "free-text":[ 
+                [% FOR note IN ftx_vals -%] "[% note %]"[% UNLESS loop.last %], [% END %][% END %] 
+            ],            
+            "quantity":[% li.lineitem_details.size %],
+            "copies" : [
+                [%- IF 1 -%]
+                [%- FOR lid IN li.lineitem_details;
+                        fund = lid.fund.code;
+                        item_type = lid.circ_modifier;
+                        callnumber = lid.cn_label;
+                        owning_lib = lid.owning_lib.shortname;
+                        location = lid.location;
+    
+                        # when we have real copy data, treat it as authoritative
+                        acp = lid.eg_copy_id;
+                        IF acp;
+                            item_type = acp.circ_modifier;
+                            callnumber = acp.call_number.label;
+                            location = acp.location.name;
+                        END -%]
+                {   [%- IF fund %] "fund" : "[% fund %]",[% END -%]
+                    [%- IF callnumber %] "call_number" : "[% callnumber %]", [% END -%]
+                    [%- IF item_type %] "item_type" : "[% item_type %]", [% END -%]
+                    [%- IF location %] "copy_location" : "[% location %]", [% END -%]
+                    [%- IF owning_lib %] "owning_lib" : "[% owning_lib %]", [% END -%]
+                    [%- #chomp %]"copy_id" : "[% lid.id %]" }[% ',' UNLESS loop.last %]
+                [% END -%]
+                [%- END -%]
+             ]
+        }[% UNLESS loop.last %],[% END %]
+        [%-# TODO: lineitem details (later) -%]
+        [% END %]
+        ],
+        "line_items":[% target.lineitems.size %]
+     }]  [%# close ORDERS array %]
+   }]    [%# close  body  array %]
+}
+[% END %]
+[% tempo = PROCESS big_block; helpers.escape_json(tempo) %]
+$$
+WHERE id = 23 AND FALSE; -- DON'T PERFORM THE UPDATE
+
+
+-- add copy-related fields to the environment if they're not already there.
+DO $$
+BEGIN
+    PERFORM 1 
+        FROM action_trigger.environment 
+        WHERE 
+            event_def = 23 AND 
+            path = 'lineitems.lineitem_details.owning_lib';
+    IF NOT FOUND THEN
+        INSERT INTO action_trigger.environment (event_def, path) 
+            VALUES (23, 'lineitems.lineitem_details.owning_lib'); 
+    END IF;
+
+    PERFORM 1 
+        FROM action_trigger.environment 
+        WHERE 
+            event_def = 23 AND 
+            path = 'lineitems.lineitem_details.fund';
+    IF NOT FOUND THEN
+        INSERT INTO action_trigger.environment (event_def, path) 
+            VALUES (23, 'lineitems.lineitem_details.fund'); 
+    END IF;
+
+    PERFORM 1 
+        FROM action_trigger.environment 
+        WHERE 
+            event_def = 23 AND 
+            path = 'lineitems.lineitem_details.location';
+    IF NOT FOUND THEN
+        INSERT INTO action_trigger.environment (event_def, path) 
+            VALUES (23, 'lineitems.lineitem_details.location'); 
+    END IF;
+
+    PERFORM 1 
+        FROM action_trigger.environment 
+        WHERE 
+            event_def = 23 AND 
+            path = 'lineitems.lineitem_details.eg_copy_id.location';
+    IF NOT FOUND THEN
+        INSERT INTO action_trigger.environment (event_def, path) 
+            VALUES (23, 'lineitems.lineitem_details.eg_copy_id.location'); 
+    END IF;
+
+    PERFORM 1 
+        FROM action_trigger.environment 
+        WHERE 
+            event_def = 23 AND 
+            path = 'lineitems.lineitem_details.eg_copy_id.call_number';
+    IF NOT FOUND THEN
+        INSERT INTO action_trigger.environment (event_def, path) 
+            VALUES (23, 'lineitems.lineitem_details.eg_copy_id.call_number'); 
+    END IF;
+
+
+
+    -- remove redundant entry
+    DELETE FROM action_trigger.environment 
+        WHERE event_def = 23 AND path = 'lineitems.lineitem_details'; 
+
+END $$;
+
+
+

commit d6bab7ae43feb872af795022106f6848f41f09ad
Author: Bill Erickson <berick at esilibrary.com>
Date:   Fri Jul 27 11:11:25 2012 -0400

    Added debug-only option to edi_pusher.pl
    
    Option causes the final EDI to be printed to STDOUT, but does not
    populate any data in the DB nor does it FTP the file to the vendor.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/support-scripts/edi_pusher.pl b/Open-ILS/src/support-scripts/edi_pusher.pl
index 80e4e19..e94abb8 100755
--- a/Open-ILS/src/support-scripts/edi_pusher.pl
+++ b/Open-ILS/src/support-scripts/edi_pusher.pl
@@ -33,7 +33,10 @@ INIT {
 my %defaults = (
     'quiet' => 0,
     'test'  => 0,   # TODO
-    'max-batch-size=i' => -1
+    'max-batch-size=i' => -1,
+
+    # if true, print final EDI to STDOUT, send nothign to the vendor, write nothing to the DB
+    'debug-only' => 0
 );
 
 my $cs = OpenILS::Utils::Cronscript->new(\%defaults);
@@ -173,6 +176,12 @@ foreach my $def (@$defs) {
             # 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";
 
         $e->xact_begin;

commit 1741ce377f536f47bc1380d6144b2d88eced387c
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Thu Jul 26 10:17:06 2012 -0400

    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 <lebbeous at esilibrary.com>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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(<STDIN>);
+
+}
+
+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;
+

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/edi_translator/test_edi_translator.pl |   57 ++++++
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   33 ++++-
 .../sql/Pg/upgrade/0733.data.jedi_with_copies.sql  |  187 ++++++++++++++++++++
 Open-ILS/src/support-scripts/edi_pusher.pl         |   11 +-
 5 files changed, 286 insertions(+), 4 deletions(-)
 create mode 100644 Open-ILS/src/edi_translator/test_edi_translator.pl
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0733.data.jedi_with_copies.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list