From 2ce54127d256e0087abcf2be8a1e0258b22ffee8 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 18 Aug 2017 17:18:29 -0400 Subject: [PATCH] LP#1251394: Seed data changes Removing the topic_subject map, since it ends up with single terms rather than the more useful "--"-separated full subjects. Also added an "all creators" mapping so that if the default "author" is empty for a record, the display logic can do its best to find an appropriate value. Gone, again, is the representative_field structure from the baseline (and from my upgrade changes). Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/src/sql/Pg/002.schema.config.sql | 20 ------------- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 28 +++++++++++++------ .../XXXX.schema.metabib-display-field.sql | 20 ------------- .../YYYY.data.metabib-display-field.sql | 14 ++++++---- 4 files changed, 28 insertions(+), 54 deletions(-) diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 246894866c..e8f3f24673 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -224,26 +224,6 @@ a "class" of either title, subject, author, keyword, series or identifier. $$; -CREATE OR REPLACE FUNCTION - config.metabib_representative_field_is_valid(INTEGER, TEXT) RETURNS BOOLEAN AS $$ - SELECT EXISTS (SELECT 1 FROM config.metabib_field WHERE id = $1 AND field_class = $2); -$$ LANGUAGE SQL STRICT IMMUTABLE; - -COMMENT ON FUNCTION config.metabib_representative_field_is_valid(INTEGER, TEXT) IS $$ -Ensure the field_class value on the selected representative field matches -the class name. -$$; - -ALTER TABLE config.metabib_class - ADD COLUMN representative_field - INTEGER REFERENCES config.metabib_field(id), - ADD CONSTRAINT rep_field_unique UNIQUE(representative_field), - ADD CONSTRAINT rep_field_is_valid CHECK ( - representative_field IS NULL OR - config.metabib_representative_field_is_valid(representative_field, name) - ) -; - CREATE UNIQUE INDEX config_metabib_field_class_name_idx ON config.metabib_field (field_class, name); CREATE TABLE config.ts_config_list ( diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 99ea346ad5..1d2f9d1259 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -125,15 +125,13 @@ INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, (4, 'title', 'alternative', oils_i18n_gettext(4, 'Alternate Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and starts-with(@type,'alternative')]$$, '//@xlink:href', $$*[local-name() != "nonSort"]$$ ); INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_sort_xpath ) VALUES (5, 'title', 'uniform', oils_i18n_gettext(5, 'Uniform Title', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform-nfi')]$$, '//@xlink:href', $$*[local-name() != "nonSort"]$$ ); -INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_field ) VALUES - (6, 'title', 'proper', oils_i18n_gettext(6, 'Title Proper', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$, '//@xlink:href', FALSE ); -UPDATE config.metabib_class SET representative_field = 6 WHERE name = 'title'; +INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, authority_xpath, browse_field, display_field ) VALUES + (6, 'title', 'proper', oils_i18n_gettext(6, 'Title Proper', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:titleNonfiling[mods32:title and not (@type)]$$, '//@xlink:href', FALSE,TRUE ); INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_xpath, facet_field , authority_xpath, browse_xpath) VALUES (7, 'author', 'corporate', oils_i18n_gettext(7, 'Corporate Author', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:name[@type='corporate' and (mods32:role/mods32:roleTerm[text()='creator'] or mods32:role/mods32:roleTerm[text()='aut'] or mods32:role/mods32:roleTerm[text()='cre'])]$$, $$//*[local-name()='namePart']$$, TRUE, '//@xlink:href',$$//*[local-name()='namePart']$$ ); -- /* to fool vim */; -INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_xpath, facet_field, authority_xpath, browse_xpath ) VALUES - (8, 'author', 'personal', oils_i18n_gettext(8, 'Personal Author', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:name[@type='personal' and mods32:role/mods32:roleTerm[text()='creator']]$$, $$//*[local-name()='namePart']$$, TRUE, '//@xlink:href',$$//*[local-name()='namePart']$$ ); -- /* to fool vim */; -UPDATE config.metabib_class SET representative_field = 8 WHERE name = 'author'; +INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_xpath, facet_field, authority_xpath, browse_xpath, display_field, display_xpath ) VALUES + (8, 'author', 'personal', oils_i18n_gettext(8, 'Personal Author', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:name[@type='personal' and mods32:role/mods32:roleTerm[text()='creator']]$$, $$//*[local-name()='namePart']$$, TRUE, '//@xlink:href',$$//*[local-name()='namePart']$$,TRUE,$$//*[local-name()='namePart']$$ ); -- /* to fool vim */; INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_xpath, facet_field, authority_xpath, browse_xpath ) VALUES (9, 'author', 'conference', oils_i18n_gettext(9, 'Conference Author', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:name[@type='conference' and mods32:role/mods32:roleTerm[text()='creator']]$$, $$//*[local-name()='namePart']$$, TRUE, '//@xlink:href',$$//*[local-name()='namePart']$$ ); -- /* to fool vim */; INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, facet_xpath, facet_field, authority_xpath, browse_xpath ) VALUES @@ -152,7 +150,7 @@ INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, browse_field, display_field ) VALUES (15, 'keyword', 'keyword', oils_i18n_gettext(15, 'General Keywords', 'cmf', 'label'), 'mods32', $$//mods32:mods/*[not(local-name()='originInfo')]$$, FALSE, FALSE ); -- /* to fool vim */; INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, browse_field, display_field ) VALUES - (16, 'subject', 'complete', oils_i18n_gettext(16, 'All Subjects', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:subject$$, FALSE, FALSE ); + (16, 'subject', 'complete', oils_i18n_gettext(16, 'All Subjects', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:subject$$, FALSE, TRUE ); INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, browse_field ) VALUES (17, 'identifier', 'accession', oils_i18n_gettext(17, 'Accession Number', 'cmf', 'label'), 'marcxml', $$//marc:controlfield[@tag='001']$$, FALSE ); @@ -190,7 +188,7 @@ INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, browse_field, facet_field, facet_xpath, joiner ) VALUES (33, 'identifier', 'genre', oils_i18n_gettext(33, 'Genre', 'cmf', 'label'), 'marcxml', $$//marc:datafield[@tag='655']$$, FALSE, TRUE, $$//*[local-name()='subfield' and contains('abvxyz',@code)]$$, ' -- ' ); -- /* to fool vim */; -UPDATE config.metabib_field SET joiner = ' -- ' WHERE field_class = 'subject' AND name NOT IN ('name', 'complete'); +UPDATE config.metabib_field SET joiner = ' -- ' WHERE field_class = 'subject' AND name NOT IN ('name'); INSERT INTO config.metabib_field ( id, field_class, name, label, format, xpath, search_field, browse_field, authority_xpath, joiner ) VALUES @@ -207,6 +205,12 @@ INSERT INTO config.metabib_field ( id, field_class, name, label, (36, 'subject', 'temporal_browse', oils_i18n_gettext(36, 'Temporal Term Browse', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:subject[local-name(./*[1]) = "temporal"]$$, FALSE, TRUE, '//@xlink:href', ' -- ' ); -- /* to fool vim */; +INSERT INTO config.metabib_field ( id, field_class, name, label, + format, xpath, display_field, display_xpath ) VALUES + (37, 'author', 'creator', oils_i18n_gettext(8, 'All Creators', 'cmf', 'label'), + 'mods32', $$//mods32:mods/mods32:name[mods32:role/mods32:roleTerm[text()='creator']]$$, TRUE, $$//*[local-name()='namePart']$$ ); -- /* to fool vim */; + + INSERT INTO config.metabib_field_index_norm_map (field,norm) SELECT m.id, i.id @@ -217,6 +221,14 @@ INSERT INTO config.metabib_field_index_norm_map (field,norm) SELECT SETVAL('config.metabib_field_id_seq', GREATEST(1000, (SELECT MAX(id) FROM config.metabib_field))); +INSERT INTO config.display_field_map (name, field, multi) VALUES + ('title', 6, FALSE), + ('author', 8, FALSE), + ('creators', 37, TRUE), + ('subject', 16, TRUE), + ('isbn', 18, TRUE) +; + INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('kw','keyword'); INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.keyword','keyword'); INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.publisher','keyword'); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql index 1dd3753769..b679ff65aa 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql @@ -1,26 +1,6 @@ BEGIN; -CREATE OR REPLACE FUNCTION - config.metabib_representative_field_is_valid(INTEGER, TEXT) RETURNS BOOLEAN AS $$ - SELECT EXISTS (SELECT 1 FROM config.metabib_field WHERE id = $1 AND field_class = $2); -$$ LANGUAGE SQL STRICT IMMUTABLE; - -COMMENT ON FUNCTION config.metabib_representative_field_is_valid(INTEGER, TEXT) IS $$ -Ensure the field_class value on the selected representative field matches -the class name. -$$; - -ALTER TABLE config.metabib_class - ADD COLUMN representative_field - INTEGER REFERENCES config.metabib_field(id), - ADD CONSTRAINT rep_field_unique UNIQUE(representative_field), - ADD CONSTRAINT rep_field_is_valid CHECK ( - representative_field IS NULL OR - config.metabib_representative_field_is_valid(representative_field, name) - ) -; - ALTER TABLE config.metabib_field ADD COLUMN display_xpath TEXT, ADD COLUMN display_field BOOL NOT NULL DEFAULT FALSE; diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.metabib-display-field.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.metabib-display-field.sql index 08832be41e..c1258e7a5b 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.metabib-display-field.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.metabib-display-field.sql @@ -6,21 +6,23 @@ INSERT INTO config.internal_flag (name, enabled) -- Adds seed data to replace (for now) values from the 'mvr' class -UPDATE config.metabib_field SET display_field = TRUE WHERE id IN (6, 8, 14, 16, 18); +UPDATE config.metabib_field SET display_field = TRUE WHERE id IN (6, 8, 16, 18); + +INSERT INTO config.metabib_field ( id, field_class, name, label, + format, xpath, display_field, display_xpath ) VALUES + (37, 'author', 'creator', oils_i18n_gettext(8, 'All Creators', 'cmf', 'label'), + 'mods32', $$//mods32:mods/mods32:name[mods32:role/mods32:roleTerm[text()='creator']]$$, TRUE, $$//*[local-name()='namePart']$$ ); -- /* to fool vim */; INSERT INTO config.display_field_map (name, field, multi) VALUES ('title', 6, FALSE), ('author', 8, FALSE), + ('creators', 37, TRUE), ('subject', 16, TRUE), - ('topic_subject', 14, TRUE), ('isbn', 18, TRUE) ; -UPDATE config.metabib_class SET representative_field = 6 WHERE name = 'title'; -UPDATE config.metabib_class SET representative_field = 8 WHERE name = 'author'; - COMMIT; -- REINGEST DISPLAY ENTRIES -SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE, TRUE, '{6,8,14,16,18}'::INT[]) FROM biblio.record_entry WHERE NOT deleted AND id > 0; +SELECT metabib.reingest_metabib_field_entries(id, TRUE, FALSE, TRUE, TRUE, '{6,8,16,18,37}'::INT[]) FROM biblio.record_entry WHERE NOT deleted AND id > 0; -- 2.43.2