]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0660.data.bib-container-csv-unapi-template.sql
Stamping upgrade for truncate-to-max-fine
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0660.data.bib-container-csv-unapi-template.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0660', :eg_version);
4
5 UPDATE action_trigger.event_definition SET template = $$
6 [%-
7 # target is the bookbag itself. The 'items' variable does not need to be in
8 # the environment because a special reactor will take care of filling it in.
9
10 FOR item IN items;
11     bibxml = helpers.unapi_bre(item.target_biblio_record_entry, {flesh => '{mra}'});
12     title = "";
13     FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
14         title = title _ part.textContent;
15     END;
16     author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
17     item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
18
19     helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n";
20 END -%]
21 $$
22 WHERE reactor = 'ContainerCSV';
23
24 COMMIT;