1 -- Evergreen DB patch 0689.data.record_print_format_update.sql
3 -- Updates print and email templates for bib record actions
8 -- check whether patch can be applied
9 SELECT evergreen.upgrade_deps_block_check('0689', :eg_version);
11 UPDATE action_trigger.event_definition SET template = $$
13 <style> li { padding: 8px; margin 5px; }</style>
15 [% FOR cbreb IN target %]
16 [% FOR item IN cbreb.items;
17 bre_id = item.target_biblio_record_entry;
19 bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
20 FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
21 title = title _ part.textContent;
24 author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
25 item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
26 publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
27 pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
28 isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
29 issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
30 upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
34 Bib ID# [% bre_id %]<br/>
35 [% IF isbn %]ISBN: [% isbn %]<br/>[% END %]
36 [% IF issn %]ISSN: [% issn %]<br/>[% END %]
37 [% IF upc %]UPC: [% upc %]<br/>[% END %]
38 Title: [% title %]<br />
39 Author: [% author %]<br />
40 Publication Info: [% publisher %] [% pubdate %]<br/>
41 Item Type: [% item_type %]
48 WHERE hook = 'biblio.format.record_entry.print' AND id < 100; -- sample data
51 UPDATE action_trigger.event_definition SET delay = '00:00:00', template = $$
52 [%- SET user = target.0.owner -%]
53 To: [%- params.recipient_email || user.email %]
54 From: [%- params.sender_email || default_sender %]
55 Subject: Bibliographic Records
57 [% FOR cbreb IN target %]
58 [% FOR item IN cbreb.items;
59 bre_id = item.target_biblio_record_entry;
61 bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
62 FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
63 title = title _ part.textContent;
66 author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
67 item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
68 publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
69 pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
70 isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
71 issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
72 upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
75 [% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %]
76 [% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%]
77 [% IF issn %]ISSN: [% issn _ "\n" %][% END -%]
78 [% IF upc %]UPC: [% upc _ "\n" %] [% END -%]
81 Publication Info: [% publisher %] [% pubdate %]
82 Item Type: [% item_type %]
87 WHERE hook = 'biblio.format.record_entry.email' AND id < 100; -- sample data
89 -- remove a swath of unused environment entries
91 DELETE FROM action_trigger.environment env
92 USING action_trigger.event_definition def
93 WHERE env.event_def = def.id AND
94 env.path != 'items' AND
95 def.hook = 'biblio.format.record_entry.print' AND
96 def.id < 100; -- sample data
98 DELETE FROM action_trigger.environment env
99 USING action_trigger.event_definition def
100 WHERE env.event_def = def.id AND
101 env.path != 'items' AND
102 env.path != 'owner' AND
103 def.hook = 'biblio.format.record_entry.email' AND
104 def.id < 100; -- sample data