From: Bill Erickson Date: Mon, 18 Nov 2013 16:48:49 +0000 (-0500) Subject: display field / cmc.representative_field X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=da46fd7c2bacfea083efdfcf626894857066a869;p=working%2FEvergreen.git display field / cmc.representative_field Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 7babc13e08..d153495697 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2414,10 +2414,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -3331,15 +3333,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA oils_persist:field_safe="true" reporter:label="Flat Display Field Entry View" oils_persist:readonly="true"> - SELECT - mde.source, - mde.value, + SELECT + mde.source, + mde.value, cmf.id AS field, - cmf.field_class, - cmf.name, - cmf.label - FROM metabib.display_entry mde - JOIN config.metabib_field cmf ON (cmf.id = mde.field) + cmf.field_class, + cmf.name, + cmf.label, + cmc.name AS representative + FROM metabib.display_entry mde + JOIN config.metabib_field cmf ON (cmf.id = mde.field) LEFT JOIN config.metabib_class cmc ON + (cmc.name = cmf.field_class AND cmc.representative_field = cmf.id) @@ -3348,6 +3352,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index ac9fea8cac..462cab7830 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -169,6 +169,16 @@ INSERT INTO config.biblio_fingerprint (name, xpath, format, first_word) TRUE ); +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. +$$; + CREATE TABLE config.metabib_class ( name TEXT PRIMARY KEY, label TEXT NOT NULL UNIQUE, @@ -179,6 +189,12 @@ CREATE TABLE config.metabib_class ( b_weight NUMERIC DEFAULT 0.4 NOT NULL, c_weight NUMERIC DEFAULT 0.2 NOT NULL, d_weight NUMERIC DEFAULT 0.1 NOT NULL + representative_field INTEGER REFERENCES config.metabib_field(id), + CONSTRAINT rep_field_unique UNIQUE(representative_field), + CONSTRAINT rep_field_is_valid CHECK ( + representative_field IS NULL OR + config.metabib_representative_field_is_valid(representative_field, name) + ) ); CREATE TABLE config.metabib_field ( 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 7fc30a0373..22c8715c68 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -96,8 +96,8 @@ SELECT SETVAL('config.standing_penalty_id_seq', 100); INSERT INTO config.metabib_class ( name, label ) VALUES ( 'identifier', oils_i18n_gettext('identifier', 'Identifier', 'cmc', 'label') ); INSERT INTO config.metabib_class ( name, label ) VALUES ( 'keyword', oils_i18n_gettext('keyword', 'Keyword', 'cmc', 'label') ); -INSERT INTO config.metabib_class ( name, label ) VALUES ( 'title', oils_i18n_gettext('title', 'Title', 'cmc', 'label') ); -INSERT INTO config.metabib_class ( name, label ) VALUES ( 'author', oils_i18n_gettext('author', 'Author', 'cmc', 'label') ); +INSERT INTO config.metabib_class ( name, label, representative_field ) VALUES ( 'title', oils_i18n_gettext('title', 'Title', 'cmc', 'label'), 6 ); +INSERT INTO config.metabib_class ( name, label, representative_field ) VALUES ( 'author', oils_i18n_gettext('author', 'Author', 'cmc', 'label'), 8 ); INSERT INTO config.metabib_class ( name, label ) VALUES ( 'subject', oils_i18n_gettext('subject', 'Subject', 'cmc', 'label') ); INSERT INTO config.metabib_class ( name, label ) VALUES ( 'series', oils_i18n_gettext('series', 'Series', 'cmc', 'label') ); 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 b2ccd5df2a..775b5ebf59 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 @@ -5,6 +5,25 @@ ALTER TABLE config.metabib_field ADD COLUMN display_xpath TEXT, ADD COLUMN display_field BOOL NOT NULL DEFAULT TRUE; +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 TABLE metabib.display_entry ( id BIGSERIAL PRIMARY KEY, source BIGINT NOT NULL, @@ -398,6 +417,10 @@ UPDATE config.metabib_field SET display_field = FALSE INSERT INTO config.internal_flag (name, enabled) VALUES ('ingest.skip_display_indexing', FALSE); +-- personal author +UPDATE config.metabib_class SET representative_field = 8 WHERE name = 'author'; +-- title proper +UPDATE config.metabib_class SET representative_field = 6 WHERE name = 'title'; COMMIT;