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