]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/1118.data.bre_format_title_fix.sql
LP2061136 - Stamping 1405 DB upgrade script
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1118.data.bre_format_title_fix.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1118', :eg_version);
4
5 UPDATE action_trigger.event_definition
6 SET template =
7 $$
8 [%- USE date -%]
9 [%- SET user = target.0.owner -%]
10 To: [%- params.recipient_email || user.email %]
11 From: [%- params.sender_email || default_sender %]
12 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
13 Subject: Bibliographic Records
14 Auto-Submitted: auto-generated
15
16 [% FOR cbreb IN target %]
17 [% FOR item IN cbreb.items;
18     bre_id = item.target_biblio_record_entry;
19
20     bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
21     title = '';
22     FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
23         title = title _ part.textContent;
24     END;
25
26     author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
27     item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
28     publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
29     pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
30     isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
31     issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
32     upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
33 %]
34
35 [% loop.count %]/[% loop.size %].  Bib ID# [% bre_id %] 
36 [% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%]
37 [% IF issn %]ISSN: [% issn _ "\n" %][% END -%]
38 [% IF upc  %]UPC:  [% upc _ "\n" %] [% END -%]
39 Title: [% title %]
40 Author: [% author %]
41 Publication Info: [% publisher %] [% pubdate %]
42 Item Type: [% item_type %]
43
44 [% END %]
45 [% END %]
46 $$
47 WHERE hook = 'biblio.format.record_entry.email'
48 -- from previous stock definition
49 AND MD5(template) = 'ee4e6c1b3049086c570c7a77413d46c1';
50
51 UPDATE action_trigger.event_definition
52 SET template =
53 $$
54 <div>
55     <style> li { padding: 8px; margin 5px; }</style>
56     <ol>
57     [% FOR cbreb IN target %]
58     [% FOR item IN cbreb.items;
59         bre_id = item.target_biblio_record_entry;
60
61         bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
62         title = '';
63         FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
64             title = title _ part.textContent;
65         END;
66
67         author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
68         item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
69         publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
70         pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
71         isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
72         %]
73
74         <li>
75             Bib ID# [% bre_id %] ISBN: [% isbn %]<br />
76             Title: [% title %]<br />
77             Author: [% author %]<br />
78             Publication Info: [% publisher %] [% pubdate %]<br/>
79             Item Type: [% item_type %]
80         </li>
81     [% END %]
82     [% END %]
83     </ol>
84 </div>
85 $$
86 WHERE hook = 'biblio.format.record_entry.print'
87 -- from previous stock definition
88 AND MD5(template) = '9ada7ea8417cb23f89d0dc8f15ec68d0';
89
90 COMMIT;