[open-ils-commits] r16759 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Trigger sql/Pg sql/Pg/upgrade (atz)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jun 18 11:57:00 EDT 2010
Author: atz
Date: 2010-06-18 11:56:57 -0400 (Fri, 18 Jun 2010)
New Revision: 16759
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0312.data.acq.jedi_template.sql
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
0312 - JEDI template support for multiple ISBNs
of same or different types. The first ISBN-13 is treated as
primary, if there is one. Otherwise the first ISBN-10 is used.
Signed-off-by: Joe Atzberger <atz at esilibrary.com>
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2010-06-18 15:56:56 UTC (rev 16758)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2010-06-18 15:56:57 UTC (rev 16759)
@@ -93,6 +93,26 @@
return $U->ou_ancestor_setting_value($org_id, $setting);
},
+ # This basically greps/maps out ths isbn string values, but also promotes the first isbn-13 to the
+ # front of the line (so that the EDI translator takes it as primary) if there is one.
+ get_li_isbns => sub {
+ my $attrs = shift;
+ my @isbns;
+ my $primary;
+ foreach (@$attrs) {
+ $_->attr_name eq 'isbn' or next;
+ my $val = $_->attr_value;
+ if (! $primary and length($val) == 13) {
+ $primary = $val;
+ } else {
+ push @isbns, $val;
+ }
+ }
+ $primary and unshift @isbns, $primary;
+ $logger->error("get_li_isbns returning isbns: " . join(', ', @isbns));
+ return @isbns;
+ },
+
# helpers.get_li_attr('isbn_13', li.attributes)
# returns matching line item attribute, or undef
get_li_attr => sub {
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-06-18 15:56:56 UTC (rev 16758)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-06-18 15:56:57 UTC (rev 16759)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0311'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0312'); -- atz
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-06-18 15:56:56 UTC (rev 16758)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-06-18 15:56:57 UTC (rev 16759)
@@ -4864,9 +4864,15 @@
"items":[
[% FOR li IN target.lineitems %]
{
- "identifiers":[
- {"id-qualifier":"SA","id":"[% li.id %]"},
- {"id-qualifier":"IB","id":"[% helpers.get_li_attr('isbn_13', li.attributes) || helpers.get_li_attr('isbn_10', li.attributes) %]"}
+ "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":"SA","id":"[% li.id %]"}
],
"price":[% li.estimated_unit_price || '0.00' %],
"desc":[
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0312.data.acq.jedi_template.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0312.data.acq.jedi_template.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0312.data.acq.jedi_template.sql 2010-06-18 15:56:57 UTC (rev 16759)
@@ -0,0 +1,64 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0312'); --atz
+
+UPDATE action_trigger.event_definition SET template =
+$$[%- USE date -%]
+[%# start JEDI document -%]
+[%- 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 -%]
+ "id":"[% target.ordering_agency.mailing_address.san _ ' ' _ target.provider.edi_default.vendcode %]",
+ "id-qualifier": 91
+ [%- 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 %]
+ {
+ "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":"SA","id":"[% li.id %]"}
+ ],
+ "price":[% li.estimated_unit_price || '0.00' %],
+ "desc":[
+ {"BTI":"[% helpers.get_li_attr('title', '', li.attributes) %]"},
+ {"BPU":"[% helpers.get_li_attr('publisher', '', li.attributes) %]"},
+ {"BPD":"[% helpers.get_li_attr('pubdate', '', li.attributes) %]"},
+ {"BPH":"[% helpers.get_li_attr('pagination','', li.attributes) %]"}
+ ],
+ "quantity":[% li.lineitem_details.size %]
+ }[% 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;
+
+COMMIT;
More information about the open-ils-commits
mailing list