From 8d0fd597d19b742685cc905f47c7c947641b8a8f Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 30 Apr 2010 16:34:33 +0000 Subject: [PATCH] Give event definition a proper id (23) Signed-off-by: Joe Atzberger git-svn-id: svn://svn.open-ils.org/ILS/trunk@16362 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 49 ++++++++++++++++++++++ .../upgrade/0167.data.event_definition_po_jedi.sql | 12 +++--- .../upgrade/0246.data.event_definition_po_jedi.sql | 8 ++-- 3 files changed, 59 insertions(+), 10 deletions(-) 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 0fd9936d6..6bbf9e190 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -4659,6 +4659,55 @@ INSERT INTO action_trigger.environment (event_def, path) VALUES INSERT INTO action_trigger.environment ( event_def, path) VALUES ( 13, 'open_billable_transactions_summary.circulation' ); +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, cleanup_success, cleanup_failure, delay, delay_field, group_field, template) VALUES (23, true, 1, 'PO JEDI', 'format.po.jedi', 'NOOP_True', 'ProcessTemplate', NULL, NULL, '00:05:00', NULL, NULL, +$$[%- USE date -%] +[%# start JEDI document -%] +[%- BLOCK big_block -%] +["order", { + "po_number":[% target.id %], + "date":"[% date.format(date.now, '%Y%m%d') %]", + "buyer":[ + {"id":"[% target.ordering_agency.mailing_address.san %]", + "reference":{"API":"[% target.ordering_agency.mailing_address.san %]"}} + ], + "vendor":[ + "[% target.provider.san %]", // [% target.provider.name %] ([% target.provider.id %]) + {"id-qualifier":"91", "reference":{"IA":"[% target.provider.id %]"}, "id":"[% target.provider.san %]"} + ], + "currency":"[% target.provider.currency_type %]", + "items":[ + [% FOR li IN target.lineitems %] + { + "identifiers":[ + {"id-qualifier":"SA","id":"[% li.id %]"}, + {"id-qualifier":"IB","id":"[% helpers.get_li_attr('isbn', li.attributes) %]"} + ], + "price":[% helpers.get_li_attr('estimated_price', '', li.attributes) %], + "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 %] + [%-# TODO: lineitem details (later) -%] + }[% UNLESS loop.last %],[% END -%] + [%- END %] + ], + "line_items":[% target.lineitems.size %] +}] +[% END %] +[% tempo = PROCESS big_block; helpers.escape_json(tempo) %] +$$ +); + +INSERT INTO action_trigger.environment (event_def, path) VALUES + (23, 'lineitems.attributes'), + (23, 'lineitems.lineitem_details'), + (23, 'lineitems.lineitem_notes'), + (23, 'ordering_agency.mailing_address'), + (23, 'provider'), + (23, 'provider.edi_default'); INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES ( diff --git a/Open-ILS/src/sql/Pg/upgrade/0167.data.event_definition_po_jedi.sql b/Open-ILS/src/sql/Pg/upgrade/0167.data.event_definition_po_jedi.sql index 2bd8d4459..46ff16507 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0167.data.event_definition_po_jedi.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0167.data.event_definition_po_jedi.sql @@ -2,7 +2,7 @@ BEGIN; INSERT INTO config.upgrade_log (version) VALUES ('0167'); -INSERT INTO action_trigger.event_definition (active, owner, name, hook, validator, reactor, cleanup_success, cleanup_failure, delay, delay_field, group_field, template) VALUES (true, 1, 'PO JEDI', 'format.po.jedi', 'NOOP_True', 'ProcessTemplate', NULL, NULL, '00:05:00', NULL, NULL, +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, cleanup_success, cleanup_failure, delay, delay_field, group_field, template) VALUES (23, true, 1, 'PO JEDI', 'format.po.jedi', 'NOOP_True', 'ProcessTemplate', NULL, NULL, '00:05:00', NULL, NULL, $$[%- USE date -%] [%# start JEDI document -%] [%- BLOCK big_block -%] @@ -66,11 +66,11 @@ SA = supplier’s article number INSERT INTO action_trigger.environment (event_def, path) VALUES - ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.attributes'), - ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.lineitem_details'), - ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'lineitems.lineitem_notes'), - ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'ordering_agency.mailing_address'), - ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'provider'); + (23, 'lineitems.attributes'), + (23, 'lineitems.lineitem_details'), + (23, 'lineitems.lineitem_notes'), + (23, 'ordering_agency.mailing_address'), + (23, 'provider'); -- The environment insert has to happen here because it relies on subquerying the user-editable field "name" to -- provide the FK. Outside of this transaction, we cannot be sure the user hasn't changed the name to something else. diff --git a/Open-ILS/src/sql/Pg/upgrade/0246.data.event_definition_po_jedi.sql b/Open-ILS/src/sql/Pg/upgrade/0246.data.event_definition_po_jedi.sql index 1595f673e..12165353a 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0246.data.event_definition_po_jedi.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0246.data.event_definition_po_jedi.sql @@ -2,7 +2,7 @@ BEGIN; INSERT INTO config.upgrade_log (version) VALUES ('0246'); -UPDATE action_trigger.event_definition SET template = +UPDATE action_trigger.event_definition SET id=23, template = $$[%- USE date -%] [%# start JEDI document -%] [%- BLOCK big_block -%] @@ -53,10 +53,10 @@ $$[%- USE date -%] [% END %] [% tempo = PROCESS big_block; helpers.escape_json(tempo) %] $$ -WHERE name='PO JEDI'; - +WHERE name='PO JEDI' or id=23; -- bring updated DB in line w/ baseline DB + -- nobody but devs will have the old 100+ id, and only atz put it in use INSERT INTO action_trigger.environment (event_def, path) VALUES - ((SELECT id FROM action_trigger.event_definition WHERE name='PO JEDI'), 'provider.edi_default'); + (23, 'provider.edi_default'); -- Hope they haven't changed the name... -- 2.11.0