From: Dan Scott Date: Thu, 22 Mar 2012 21:07:10 +0000 (-0400) Subject: Wrap upgrade script for bib record email / print actions X-Git-Tag: sprint4-merge-nov22~4436 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=94656bc7edb68ee2f3d1d4eecb128a2837f55d33;p=working%2FEvergreen.git Wrap upgrade script for bib record email / print actions Thanks again to Bill Erickson for another nice piece o' functionality. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/upgrade/0689.data.record_print_format_update.sql b/Open-ILS/src/sql/Pg/upgrade/0689.data.record_print_format_update.sql new file mode 100644 index 0000000000..c8c43a9543 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0689.data.record_print_format_update.sql @@ -0,0 +1,106 @@ +-- Evergreen DB patch 0689.data.record_print_format_update.sql +-- +-- Updates print and email templates for bib record actions +-- +BEGIN; + + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('0689', :eg_version); + +UPDATE action_trigger.event_definition SET template = $$ +
+ +
    + [% FOR cbreb IN target %] + [% FOR item IN cbreb.items; + bre_id = item.target_biblio_record_entry; + + bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; + pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; + isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; + upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; + %] + +
  1. + Bib ID# [% bre_id %]
    + [% IF isbn %]ISBN: [% isbn %]
    [% END %] + [% IF issn %]ISSN: [% issn %]
    [% END %] + [% IF upc %]UPC: [% upc %]
    [% END %] + Title: [% title %]
    + Author: [% author %]
    + Publication Info: [% publisher %] [% pubdate %]
    + Item Type: [% item_type %] +
  2. + [% END %] + [% END %] +
+
+$$ +WHERE hook = 'biblio.format.record_entry.print' AND id < 100; -- sample data + + +UPDATE action_trigger.event_definition SET delay = '00:00:00', template = $$ +[%- SET user = target.0.owner -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Bibliographic Records + +[% FOR cbreb IN target %] +[% FOR item IN cbreb.items; + bre_id = item.target_biblio_record_entry; + + bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; + pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; + isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; + upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; +%] + +[% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %] +[% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%] +[% IF issn %]ISSN: [% issn _ "\n" %][% END -%] +[% IF upc %]UPC: [% upc _ "\n" %] [% END -%] +Title: [% title %] +Author: [% author %] +Publication Info: [% publisher %] [% pubdate %] +Item Type: [% item_type %] + +[% END %] +[% END %] +$$ +WHERE hook = 'biblio.format.record_entry.email' AND id < 100; -- sample data + +-- remove a swath of unused environment entries + +DELETE FROM action_trigger.environment env + USING action_trigger.event_definition def + WHERE env.event_def = def.id AND + env.path != 'items' AND + def.hook = 'biblio.format.record_entry.print' AND + def.id < 100; -- sample data + +DELETE FROM action_trigger.environment env + USING action_trigger.event_definition def + WHERE env.event_def = def.id AND + env.path != 'items' AND + env.path != 'owner' AND + def.hook = 'biblio.format.record_entry.email' AND + def.id < 100; -- sample data + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql deleted file mode 100644 index fa31353719..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql +++ /dev/null @@ -1,98 +0,0 @@ - - -UPDATE action_trigger.event_definition SET template = $$ -
- -
    - [% FOR cbreb IN target %] - [% FOR item IN cbreb.items; - bre_id = item.target_biblio_record_entry; - - bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); - FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); - title = title _ part.textContent; - END; - - author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; - item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); - publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; - pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; - isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; - issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; - upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; - %] - -
  1. - Bib ID# [% bre_id %]
    - [% IF isbn %]ISBN: [% isbn %]
    [% END %] - [% IF issn %]ISSN: [% issn %]
    [% END %] - [% IF upc %]UPC: [% upc %]
    [% END %] - Title: [% title %]
    - Author: [% author %]
    - Publication Info: [% publisher %] [% pubdate %]
    - Item Type: [% item_type %] -
  2. - [% END %] - [% END %] -
-
-$$ -WHERE hook = 'biblio.format.record_entry.print' AND id < 100; -- sample data - - -UPDATE action_trigger.event_definition SET delay = '00:00:00', template = $$ -[%- SET user = target.0.owner -%] -To: [%- params.recipient_email || user.email %] -From: [%- params.sender_email || default_sender %] -Subject: Bibliographic Records - -[% FOR cbreb IN target %] -[% FOR item IN cbreb.items; - bre_id = item.target_biblio_record_entry; - - bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); - FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); - title = title _ part.textContent; - END; - - author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; - item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); - publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; - pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; - isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; - issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; - upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; -%] - -[% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %] -[% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%] -[% IF issn %]ISSN: [% issn _ "\n" %][% END -%] -[% IF upc %]UPC: [% upc _ "\n" %] [% END -%] -Title: [% title %] -Author: [% author %] -Publication Info: [% publisher %] [% pubdate %] -Item Type: [% item_type %] - -[% END %] -[% END %] -$$ -WHERE hook = 'biblio.format.record_entry.email' AND id < 100; -- sample data - --- remove a swath of unused environment entries - -DELETE FROM action_trigger.environment env - USING action_trigger.event_definition def - WHERE env.event_def = def.id AND - env.path != 'items' AND - def.hook = 'biblio.format.record_entry.print' AND - def.id < 100; -- sample data - -DELETE FROM action_trigger.environment env - USING action_trigger.event_definition def - WHERE env.event_def = def.id AND - env.path != 'items' AND - env.path != 'owner' AND - def.hook = 'biblio.format.record_entry.email' AND - def.id < 100; -- sample data - -