]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0737.data.update_ContainerCSV_template.sql
LP#1917826: tweaks to data update
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0737.data.update_ContainerCSV_template.sql
1 BEGIN;
2 -- check whether patch can be applied
3 SELECT evergreen.upgrade_deps_block_check('0737', :eg_version);
4
5 UPDATE action_trigger.event_definition
6 SET template =
7 $$
8 [%-
9 # target is the bookbag itself. The 'items' variable does not need to be in
10 # the environment because a special reactor will take care of filling it in.
11
12 FOR item IN items;
13     bibxml = helpers.unapi_bre(item.target_biblio_record_entry, {flesh => '{mra}'});
14     title = "";
15     FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
16         title = title _ part.textContent;
17     END;
18     author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
19     item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
20     pub_date = "";
21     FOR pdatum IN bibxml.findnodes('//*[@tag="260"]/*[@code="c"]');
22         IF pub_date ;
23             pub_date = pub_date _ ", " _ pdatum.textContent;
24         ELSE ;
25             pub_date = pdatum.textContent;
26         END;
27     END;
28     helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(pub_date) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n";
29 END -%]
30 $$
31 WHERE name = 'Bookbag CSV';
32
33 COMMIT;