]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0867.data.mmr-holds-formats.sql
LP#1661688: Add a link and other tweaks to alternate hold pickup feature
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0867.data.mmr-holds-formats.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0867', :eg_version);
4
5 INSERT INTO config.global_flag (name, label, value, enabled) VALUES (
6     'opac.metarecord.holds.format_attr', 
7     oils_i18n_gettext(
8         'opac.metarecord.holds.format_attr',
9         'OPAC Metarecord Hold Formats Attribute', 
10         'cgf',
11         'label'
12     ),
13     'mr_hold_format', 
14     TRUE
15 );
16
17 -- until we have a custom attribute for the selector, 
18 -- default to the icon_format attribute
19 INSERT INTO config.global_flag (name, label, value, enabled) VALUES (
20     'opac.format_selector.attr', 
21     oils_i18n_gettext(
22         'opac.format_selector.attr', 
23         'OPAC Format Selector Attribute', 
24         'cgf',
25         'label'
26     ),
27     'icon_format', 
28     TRUE
29 );
30
31
32 INSERT INTO config.record_attr_definition 
33     (name, label, multi, filter, composite) 
34 VALUES (
35     'mr_hold_format', 
36     oils_i18n_gettext(
37         'mr_hold_format',
38         'Metarecord Hold Formats', 
39         'crad',
40         'label'
41     ),
42     TRUE, TRUE, TRUE
43 );
44
45 -- these formats are a subset of the "icon_format" attribute,
46 -- modified to exclude electronic resources, which are not holdable
47
48 -- for i18n purposes, these have to be listed individually
49 INSERT INTO config.coded_value_map
50     (id, ctype, code, value, search_label) VALUES 
51 (588, 'mr_hold_format', 'book', 
52     oils_i18n_gettext(588, 'Book', 'ccvm', 'value'),
53     oils_i18n_gettext(588, 'Book', 'ccvm', 'search_label')),
54 (589, 'mr_hold_format', 'braille', 
55     oils_i18n_gettext(589, 'Braille', 'ccvm', 'value'),
56     oils_i18n_gettext(589, 'Braille', 'ccvm', 'search_label')),
57 (590, 'mr_hold_format', 'software', 
58     oils_i18n_gettext(590, 'Software and video games', 'ccvm', 'value'),
59     oils_i18n_gettext(590, 'Software and video games', 'ccvm', 'search_label')),
60 (591, 'mr_hold_format', 'dvd', 
61     oils_i18n_gettext(591, 'DVD', 'ccvm', 'value'),
62     oils_i18n_gettext(591, 'DVD', 'ccvm', 'search_label')),
63 (592, 'mr_hold_format', 'kit', 
64     oils_i18n_gettext(592, 'Kit', 'ccvm', 'value'),
65     oils_i18n_gettext(592, 'Kit', 'ccvm', 'search_label')),
66 (593, 'mr_hold_format', 'map', 
67     oils_i18n_gettext(593, 'Map', 'ccvm', 'value'),
68     oils_i18n_gettext(593, 'Map', 'ccvm', 'search_label')),
69 (594, 'mr_hold_format', 'microform', 
70     oils_i18n_gettext(594, 'Microform', 'ccvm', 'value'),
71     oils_i18n_gettext(594, 'Microform', 'ccvm', 'search_label')),
72 (595, 'mr_hold_format', 'score', 
73     oils_i18n_gettext(595, 'Music Score', 'ccvm', 'value'),
74     oils_i18n_gettext(595, 'Music Score', 'ccvm', 'search_label')),
75 (596, 'mr_hold_format', 'picture', 
76     oils_i18n_gettext(596, 'Picture', 'ccvm', 'value'),
77     oils_i18n_gettext(596, 'Picture', 'ccvm', 'search_label')),
78 (597, 'mr_hold_format', 'equip', 
79     oils_i18n_gettext(597, 'Equipment, games, toys', 'ccvm', 'value'),
80     oils_i18n_gettext(597, 'Equipment, games, toys', 'ccvm', 'search_label')),
81 (598, 'mr_hold_format', 'serial', 
82     oils_i18n_gettext(598, 'Serials and magazines', 'ccvm', 'value'),
83     oils_i18n_gettext(598, 'Serials and magazines', 'ccvm', 'search_label')),
84 (599, 'mr_hold_format', 'vhs', 
85     oils_i18n_gettext(599, 'VHS', 'ccvm', 'value'),
86     oils_i18n_gettext(599, 'VHS', 'ccvm', 'search_label')),
87 (600, 'mr_hold_format', 'cdaudiobook', 
88     oils_i18n_gettext(600, 'CD Audiobook', 'ccvm', 'value'),
89     oils_i18n_gettext(600, 'CD Audiobook', 'ccvm', 'search_label')),
90 (601, 'mr_hold_format', 'cdmusic', 
91     oils_i18n_gettext(601, 'CD Music recording', 'ccvm', 'value'),
92     oils_i18n_gettext(601, 'CD Music recording', 'ccvm', 'search_label')),
93 (602, 'mr_hold_format', 'casaudiobook', 
94     oils_i18n_gettext(602, 'Cassette audiobook', 'ccvm', 'value'),
95     oils_i18n_gettext(602, 'Cassette audiobook', 'ccvm', 'search_label')),
96 (603, 'mr_hold_format', 'casmusic',
97     oils_i18n_gettext(603, 'Audiocassette music recording', 'ccvm', 'value'),
98     oils_i18n_gettext(603, 'Audiocassette music recording', 'ccvm', 'search_label')),
99 (604, 'mr_hold_format', 'phonospoken', 
100     oils_i18n_gettext(604, 'Phonograph spoken recording', 'ccvm', 'value'),
101     oils_i18n_gettext(604, 'Phonograph spoken recording', 'ccvm', 'search_label')),
102 (605, 'mr_hold_format', 'phonomusic', 
103     oils_i18n_gettext(605, 'Phonograph music recording', 'ccvm', 'value'),
104     oils_i18n_gettext(605, 'Phonograph music recording', 'ccvm', 'search_label')),
105 (606, 'mr_hold_format', 'lpbook', 
106     oils_i18n_gettext(606, 'Large Print Book', 'ccvm', 'value'),
107     oils_i18n_gettext(606, 'Large Print Book', 'ccvm', 'search_label'))
108 ;
109
110 -- but we can auto-generate the composite definitions
111
112 DO $$
113     DECLARE format TEXT;
114 BEGIN
115     FOR format IN SELECT UNNEST(
116         '{book,braille,software,dvd,kit,map,microform,score,picture,equip,serial,vhs,cdaudiobook,cdmusic,casaudiobook,casmusic,phonospoken,phonomusic,lpbook}'::text[]) LOOP
117
118         INSERT INTO config.composite_attr_entry_definition 
119             (coded_value, definition) VALUES
120             (
121                 -- get the ID from the new ccvm above
122                 (SELECT id FROM config.coded_value_map 
123                     WHERE code = format AND ctype = 'mr_hold_format'),
124                 -- get the def of the matching ccvm attached to the icon_format attr
125                 (SELECT definition FROM config.composite_attr_entry_definition ccaed
126                     JOIN config.coded_value_map ccvm ON (ccaed.coded_value = ccvm.id)
127                     WHERE ccvm.ctype = 'icon_format' AND ccvm.code = format)
128             );
129     END LOOP; 
130 END $$;
131
132 INSERT INTO config.coded_value_map
133     (id, ctype, code, value, search_label) VALUES 
134 (607, 'icon_format', 'music', 
135     oils_i18n_gettext(607, 'Musical Sound Recording (Unknown Format)', 'ccvm', 'value'),
136     oils_i18n_gettext(607, 'Musical Sound Recording (Unknown Format)', 'ccvm', 'search_label'));
137
138 INSERT INTO config.composite_attr_entry_definition 
139     (coded_value, definition) VALUES
140 (607, '{"0":{"_attr":"item_type","_val":"j"},"1":{"_not":[{"_attr":"sr_format","_val":"a"},{"_attr":"sr_format","_val":"b"},{"_attr":"sr_format","_val":"c"},{"_attr":"sr_format","_val":"d"},{"_attr":"sr_format","_val":"f"},{"_attr":"sr_format","_val":"e"},{"_attr":"sr_format","_val":"l"}]}}');
141
142 -- icon for blu-ray
143 INSERT INTO config.coded_value_map
144     (id, ctype, code, value, search_label) VALUES 
145 (608, 'icon_format', 'blu-ray', 
146     oils_i18n_gettext(608, 'Blu-ray', 'ccvm', 'value'),
147     oils_i18n_gettext(608, 'Blu-ray', 'ccvm', 'search_label'));
148 INSERT INTO config.composite_attr_entry_definition 
149     (coded_value, definition) VALUES (608, '{"_attr":"vr_format","_val":"s"}');
150
151 -- metarecord hold format for blu-ray
152 INSERT INTO config.coded_value_map
153     (id, ctype, code, value, search_label) VALUES 
154 (609, 'mr_hold_format', 'blu-ray', 
155     oils_i18n_gettext(609, 'Blu-ray', 'ccvm', 'value'),
156     oils_i18n_gettext(609, 'Blu-ray', 'ccvm', 'search_label'));
157 INSERT INTO config.composite_attr_entry_definition 
158     (coded_value, definition) VALUES (609, '{"_attr":"vr_format","_val":"s"}');
159
160 COMMIT;
161