]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/WWWW.data.display-field-seed-data.sql
LP#1744385: Various improvements based on testing
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / WWWW.data.display-field-seed-data.sql
1 BEGIN;
2
3 -- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
4
5 -- NEW config.metabib_field entries
6
7 UPDATE config.metabib_field SET display_xpath = facet_xpath, display_field = TRUE WHERE id = 33;
8
9 INSERT INTO config.metabib_field (id, field_class, name, 
10     label, xpath, display_field, search_field, browse_field)
11 VALUES (
12     38, 'keyword', 'edition', 
13     oils_i18n_gettext(38, 'Edition', 'cmf', 'label'),
14     $$//mods33:mods/mods33:originInfo//mods33:edition[1]$$,
15     TRUE, TRUE, FALSE
16 );
17
18 INSERT INTO config.metabib_field (id, field_class, name, 
19     label, xpath, display_field, search_field, browse_field)
20 VALUES (
21     39, 'keyword', 'physical_description', 
22     oils_i18n_gettext(39, 'Physical Descrption', 'cmf', 'label'),
23     $$(//mods33:mods/mods33:physicalDescription/mods33:form|//mods33:mods/mods33:physicalDescription/mods33:extent|//mods33:mods/mods33:physicalDescription/mods33:reformattingQuality|//mods33:mods/mods33:physicalDescription/mods33:internetMediaType|//mods33:mods/mods33:physicalDescription/mods33:digitalOrigin)$$,
24     TRUE, TRUE, FALSE
25 );
26
27 INSERT INTO config.metabib_field (id, field_class, name, 
28     label, xpath, display_field, search_field, browse_field)
29 VALUES (
30     40, 'keyword', 'publisher', 
31     oils_i18n_gettext(40, 'Publisher', 'cmf', 'label'),
32     $$//mods33:mods/mods33:originInfo//mods33:publisher[1]$$,
33     TRUE, TRUE, FALSE
34 );
35
36 INSERT INTO config.metabib_field (id, field_class, name, 
37     label, xpath, display_field, search_field, browse_field)
38 VALUES (
39     41, 'keyword', 'abstract', 
40     oils_i18n_gettext(41, 'Abstract', 'cmf', 'label'),
41     $$//mods33:mods/mods33:abstract$$,
42     TRUE, TRUE, FALSE
43 );
44
45 INSERT INTO config.metabib_field (id, field_class, name, 
46     label, xpath, display_field, search_field, browse_field)
47 VALUES (
48     42, 'keyword', 'toc', 
49     oils_i18n_gettext(42, 'Table of Contents', 'cmf', 'label'),
50     $$//mods33:tableOfContents$$,
51     TRUE, TRUE, FALSE
52 );
53
54 INSERT INTO config.metabib_field (id, field_class, name, 
55     label, xpath, display_field, search_field, browse_field)
56 VALUES (
57     43, 'identifier', 'type_of_resource', 
58     oils_i18n_gettext(43, 'Type of Resource', 'cmf', 'label'),
59     $$//mods33:mods/mods33:typeOfResource$$,
60     TRUE, FALSE, FALSE
61 );
62
63 INSERT INTO config.metabib_field (id, field_class, name, 
64     label, xpath, display_field, search_field, browse_field)
65 VALUES (
66     44, 'identifier', 'pubdate', 
67     oils_i18n_gettext(44, 'Publication Date', 'cmf', 'label'),
68     $$//mods33:mods/mods33:originInfo//mods33:dateIssued[@encoding="marc"]|//mods33:mods/mods33:originInfo//mods33:dateIssued[1]$$,
69     TRUE, FALSE, FALSE
70 );
71
72 INSERT INTO config.metabib_field (id, field_class, name, 
73     label, xpath, display_field, search_field, browse_field)
74 VALUES (
75     46, 'keyword', 'bibliography', 
76     oils_i18n_gettext(46, 'Bibliography', 'cmf', 'label'),
77     $$//mods33:note[@type='bibliography']$$,
78     TRUE, TRUE, FALSE
79 ),(
80     47, 'keyword', 'thesis', 
81     oils_i18n_gettext(47, 'Thesis', 'cmf', 'label'),
82     $$//mods33:note[@type='thesis']$$,
83     TRUE, TRUE, FALSE
84 ),(
85     48, 'keyword', 'production_credits', 
86     oils_i18n_gettext(48, 'Creation/Production Credits', 'cmf', 'label'),
87     $$//mods33:note[@type='creation/production credits']$$,
88     TRUE, TRUE, FALSE
89 ),(
90     49, 'keyword', 'performers', 
91     oils_i18n_gettext(49, 'Performers', 'cmf', 'label'),
92     $$//mods33:note[@type='performers']$$,
93     TRUE, TRUE, FALSE
94 ),(
95     50, 'keyword', 'general_note', 
96     oils_i18n_gettext(50, 'General Note', 'cmf', 'label'),
97     $$//mods33:note[not(@type)]$$,
98     TRUE, TRUE, FALSE
99 )
100 ;
101
102 INSERT INTO config.metabib_field (id, field_class, name, format,
103     label, xpath, display_xpath, display_field, search_field, browse_field)
104 VALUES (
105     51, 'author', 'first_author', 'mods32',
106     oils_i18n_gettext(51, 'Author', 'cmf', 'label'),
107     $$//mods32:mods/mods32:name[mods32:role/mods32:roleTerm[text()='creator']][1]$$,
108     $$//*[local-name()='namePart']$$,
109     TRUE, TRUE, FALSE
110 );
111
112 INSERT INTO config.metabib_field (id, field_class, name, format,
113     label, xpath, display_xpath, display_field, search_field, browse_field)
114 VALUES (
115     52, 'keyword', 'origin_info', 'marcxml',
116     oils_i18n_gettext(52, 'Origin Info', 'cmf', 'label'),
117     $$//*[@tag='260']$$,
118     $$//*[local-name()='subfield' and contains('abc',@code)]$$,
119     TRUE, TRUE, FALSE
120 );
121
122
123 -- Modify existing config.metabib_field entries
124
125 UPDATE config.metabib_field SET display_field = TRUE WHERE id IN (
126     1,  -- seriestitle
127     11, -- subject_geographic 
128     12, -- subject_name
129     13, -- subject_temporal
130     14, -- subject_topic
131     19, -- ISSN
132     20, -- UPC
133     26  -- TCN
134 );
135
136 -- Map display field names to config.metabib_field entries
137
138 INSERT INTO config.display_field_map (name, field, multi) VALUES 
139     ('series_title',         1, FALSE),
140     ('subject_geographic',  11, TRUE),
141     ('subject_name',        12, TRUE),
142     ('subject_temporal',    13, TRUE),
143     ('subject_topic',       14, TRUE),
144     ('issn',                19, TRUE),
145     ('upc',                 20, TRUE),
146     ('tcn',                 26, FALSE),
147     ('edition',             38, FALSE),
148     ('physical_description',39, TRUE),
149     ('publisher',           52, FALSE),
150     ('abstract',            41, FALSE),
151     ('toc',                 42, FALSE),
152     ('type_of_resource',    43, FALSE),
153     ('pubdate',             44, FALSE)
154 ;
155
156 UPDATE config.display_field_map SET field = 51 WHERE name = 'author';
157
158 -- Add a column to wide-display-entry per well-known field
159
160 DROP VIEW IF EXISTS metabib.wide_display_entry;
161 CREATE VIEW metabib.wide_display_entry AS
162     SELECT 
163         bre.id AS source,
164         COALESCE(mcde_title.value, 'null')::TEXT AS title,
165         COALESCE(mcde_author.value, 'null')::TEXT AS author,
166         COALESCE(mcde_subject_geographic.value, 'null')::TEXT AS subject_geographic,
167         COALESCE(mcde_subject_name.value, 'null')::TEXT AS subject_name,
168         COALESCE(mcde_subject_temporal.value, 'null')::TEXT AS subject_temporal,
169         COALESCE(mcde_subject_topic.value, 'null')::TEXT AS subject_topic,
170         COALESCE(mcde_creators.value, 'null')::TEXT AS creators,
171         COALESCE(mcde_isbn.value, 'null')::TEXT AS isbn,
172         COALESCE(mcde_issn.value, 'null')::TEXT AS issn,
173         COALESCE(mcde_upc.value, 'null')::TEXT AS upc,
174         COALESCE(mcde_tcn.value, 'null')::TEXT AS tcn,
175         COALESCE(mcde_edition.value, 'null')::TEXT AS edition,
176         COALESCE(mcde_physical_description.value, 'null')::TEXT AS physical_description,
177         COALESCE(mcde_publisher.value, 'null')::TEXT AS publisher,
178         COALESCE(mcde_series_title.value, 'null')::TEXT AS series_title,
179         COALESCE(mcde_abstract.value, 'null')::TEXT AS abstract,
180         COALESCE(mcde_toc.value, 'null')::TEXT AS toc,
181         COALESCE(mcde_pubdate.value, 'null')::TEXT AS pubdate,
182         COALESCE(mcde_type_of_resource.value, 'null')::TEXT AS type_of_resource
183     FROM biblio.record_entry bre 
184     LEFT JOIN metabib.compressed_display_entry mcde_title 
185         ON (bre.id = mcde_title.source AND mcde_title.name = 'title')
186     LEFT JOIN metabib.compressed_display_entry mcde_author 
187         ON (bre.id = mcde_author.source AND mcde_author.name = 'author')
188     LEFT JOIN metabib.compressed_display_entry mcde_subject 
189         ON (bre.id = mcde_subject.source AND mcde_subject.name = 'subject')
190     LEFT JOIN metabib.compressed_display_entry mcde_subject_geographic 
191         ON (bre.id = mcde_subject_geographic.source 
192             AND mcde_subject_geographic.name = 'subject_geographic')
193     LEFT JOIN metabib.compressed_display_entry mcde_subject_name 
194         ON (bre.id = mcde_subject_name.source 
195             AND mcde_subject_name.name = 'subject_name')
196     LEFT JOIN metabib.compressed_display_entry mcde_subject_temporal 
197         ON (bre.id = mcde_subject_temporal.source 
198             AND mcde_subject_temporal.name = 'subject_temporal')
199     LEFT JOIN metabib.compressed_display_entry mcde_subject_topic 
200         ON (bre.id = mcde_subject_topic.source 
201             AND mcde_subject_topic.name = 'subject_topic')
202     LEFT JOIN metabib.compressed_display_entry mcde_creators 
203         ON (bre.id = mcde_creators.source AND mcde_creators.name = 'creators')
204     LEFT JOIN metabib.compressed_display_entry mcde_isbn 
205         ON (bre.id = mcde_isbn.source AND mcde_isbn.name = 'isbn')
206     LEFT JOIN metabib.compressed_display_entry mcde_issn 
207         ON (bre.id = mcde_issn.source AND mcde_issn.name = 'issn')
208     LEFT JOIN metabib.compressed_display_entry mcde_upc 
209         ON (bre.id = mcde_upc.source AND mcde_upc.name = 'upc')
210     LEFT JOIN metabib.compressed_display_entry mcde_tcn 
211         ON (bre.id = mcde_tcn.source AND mcde_tcn.name = 'tcn')
212     LEFT JOIN metabib.compressed_display_entry mcde_edition 
213         ON (bre.id = mcde_edition.source AND mcde_edition.name = 'edition')
214     LEFT JOIN metabib.compressed_display_entry mcde_physical_description 
215         ON (bre.id = mcde_physical_description.source 
216             AND mcde_physical_description.name = 'physical_description')
217     LEFT JOIN metabib.compressed_display_entry mcde_publisher 
218         ON (bre.id = mcde_publisher.source AND mcde_publisher.name = 'publisher')
219     LEFT JOIN metabib.compressed_display_entry mcde_series_title 
220         ON (bre.id = mcde_series_title.source AND mcde_series_title.name = 'series_title')
221     LEFT JOIN metabib.compressed_display_entry mcde_abstract 
222         ON (bre.id = mcde_abstract.source AND mcde_abstract.name = 'abstract')
223     LEFT JOIN metabib.compressed_display_entry mcde_toc 
224         ON (bre.id = mcde_toc.source AND mcde_toc.name = 'toc')
225     LEFT JOIN metabib.compressed_display_entry mcde_pubdate 
226         ON (bre.id = mcde_pubdate.source AND mcde_pubdate.name = 'pubdate')
227     LEFT JOIN metabib.compressed_display_entry mcde_type_of_resource 
228         ON (bre.id = mcde_type_of_resource.source 
229             AND mcde_type_of_resource.name = 'type_of_resource')
230 ;
231
232 CREATE OR REPLACE VIEW reporter.old_super_simple_record AS
233 SELECT  r.id,
234     r.fingerprint,
235     r.quality,
236     r.tcn_source,
237     r.tcn_value,
238     evergreen.oils_json_to_text(d.title) AS title,
239     evergreen.oils_json_to_text(d.author) AS author,
240     evergreen.oils_json_to_text(d.publisher) AS publisher,
241     evergreen.oils_json_to_text(d.pubdate) AS pubdate,
242     CASE WHEN d.isbn = 'null'
243         THEN NULL
244         ELSE (SELECT ARRAY(SELECT json_array_elements_text(d.isbn::JSON)))
245     END AS isbn,
246     CASE WHEN d.issn = 'null'
247         THEN NULL
248         ELSE (SELECT ARRAY(SELECT json_array_elements_text(d.issn::JSON)))
249     END AS issn
250   FROM  biblio.record_entry r
251         JOIN metabib.wide_display_entry d ON (r.id = d.source);
252
253 COMMIT;
254