]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0626.schema.bookbag-goodies.sql
LP#1643709: Stamping upgrade scripts
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0626.schema.bookbag-goodies.sql
1 -- Evergreen DB patch 0626.schema.bookbag-goodies.sql
2
3 BEGIN;
4
5 SELECT evergreen.upgrade_deps_block_check('0626', :eg_version);
6
7 ALTER TABLE container.biblio_record_entry_bucket
8     ADD COLUMN description TEXT;
9
10 ALTER TABLE container.call_number_bucket
11     ADD COLUMN description TEXT;
12
13 ALTER TABLE container.copy_bucket
14     ADD COLUMN description TEXT;
15
16 ALTER TABLE container.user_bucket
17     ADD COLUMN description TEXT;
18
19 INSERT INTO action_trigger.hook (key, core_type, description, passive)
20 VALUES (
21     'container.biblio_record_entry_bucket.csv',
22     'cbreb',
23     oils_i18n_gettext(
24         'container.biblio_record_entry_bucket.csv',
25         'Produce a CSV file representing a bookbag',
26         'ath',
27         'description'
28     ),
29     FALSE
30 );
31
32 INSERT INTO action_trigger.reactor (module, description)
33 VALUES (
34     'ContainerCSV',
35     oils_i18n_gettext(
36         'ContainerCSV',
37         'Facilitates produce a CSV file representing a bookbag by introducing an "items" variable into the TT environment, sorted as dictated according to user params',
38         'atr',
39         'description'
40     )
41 );
42
43 INSERT INTO action_trigger.event_definition (
44     id, active, owner,
45     name, hook, reactor,
46     validator, template
47 ) VALUES (
48     48, TRUE, 1,
49     'Bookbag CSV', 'container.biblio_record_entry_bucket.csv', 'ContainerCSV',
50     'NOOP_True',
51 $$
52 [%-
53 # target is the bookbag itself. The 'items' variable does not need to be in
54 # the environment because a special reactor will take care of filling it in.
55
56 FOR item IN items;
57     bibxml = helpers.xml_doc(item.target_biblio_record_entry.marc);
58     title = "";
59     FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
60         title = title _ part.textContent;
61     END;
62     author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
63
64     helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n";
65 END -%]
66 $$
67 );
68
69 COMMIT;