<field reporter:label="B Weight" name="b_weight" reporter:datatype="float" />
<field reporter:label="C Weight" name="c_weight" reporter:datatype="float" />
<field reporter:label="D Weight" name="d_weight" reporter:datatype="float" />
+ <field reporter:label="Representative Field" name="representative_field" reporter:datatype="link" />
<field reporter:label="Fields" name="fields" reporter:datatype="link" oils_persist:virtual="true"/>
</fields>
<links>
<link field="fields" reltype="has_many" key="name" map="" class="cmf"/>
+ <link field="representative_field" reltype="has_a" key="id" map="" class="cmf"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
<class id="mde" controller="open-ils.cstore open-ils.pcrud"
oils_obj:fieldmapper="metabib::display_entry"
oils_persist:tablename="metabib.display_entry"
+ oils_persist:field_safe="true"
reporter:label="Display Field Entry" oils_persist:readonly="true">
<fields oils_persist:primary="id" oils_persist:sequence="metabib.display_entry_id_seq">
<field name="id" reporter:datatype="id" />
</class>
<class id="mfde" controller="open-ils.cstore open-ils.pcrud"
oils_obj:fieldmapper="metabib::flat_display_entry"
+ oils_persist:field_safe="true"
reporter:label="Flat Display Field Entry View" oils_persist:readonly="true">
<oils_persist:source_definition>
- 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)
</oils_persist:source_definition>
<fields>
<field name="source" reporter:datatype="id" />
<field name="field_class" reporter:datatype="text"/>
<field name="name" reporter:datatype="text"/>
<field name="label" reporter:datatype="text"/>
+ <field name="representative" reporter:datatype="text"/>
</fields>
<links>
<link field="source" reltype="has_a" key="id" map="" class="bre"/>
'mods32'
);
+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,
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 (
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') );
BEGIN;
-ALTER TABLE config.metabib_field ADD COLUMN display_xpath TEXT, display_field BOOL NOT NULL DEFAULT TRUE;
-UPDATE config.metabib_field SET display_field = FALSE WHERE field_class = 'keyword' OR name = 'complete';
+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,
BEFORE UPDATE OR INSERT ON metabib.display_entry
FOR EACH ROW EXECUTE PROCEDURE evergreen.display_field_force_nfc();
-ALTER TABLE config.metabib_field
- ADD COLUMN display_field BOOL NOT NULL DEFAULT TRUE;
-
ALTER TYPE metabib.field_entry_template ADD ATTRIBUTE display_field BOOL;
CREATE OR REPLACE FUNCTION biblio.extract_metabib_field_entry ( rid BIGINT, default_joiner TEXT ) RETURNS SETOF metabib.field_entry_template AS $func$
$func$ LANGUAGE PLPGSQL;
--- DATA -------------------
+-- DATA --------------------------------------
--- "General Keywords" and "All Subjects"
--- more?
-UPDATE config.metabib_field SET display_field = FALSE WHERE id IN (15, 16);
+UPDATE config.metabib_field SET display_field = FALSE
+ WHERE field_class = 'keyword' OR name = 'complete';
INSERT INTO config.internal_flag (name, enabled)
VALUES ('ingest.skip_display_indexing', FALSE);
--- TODO: targeted ingest?
-
--- Dumb Reingest ---
---UPDATE config.internal_flag SET enabled = TRUE
--- WHERE name = 'ingest.reingest.force_on_same_marc';
---UPDATE biblio.record_entry SET marc = marc;
---UPDATE config.internal_flag SET enabled = FALSE
--- WHERE name = 'ingest.reingest.force_on_same_marc';
+-- 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;
---ROLLBACK;
+
+
+/*
+-- Ham-fisted reingest for Testing ---------------------
+
+-- disable everything we can for reindexing
+UPDATE config.internal_flag SET enabled = TRUE WHERE name IN (
+ 'ingest.assume_inserts_only',
+ 'ingest.disable_authority_auto_update',
+ 'ingest.disable_authority_linking',
+ 'ingest.disable_located_uri',
+ 'ingest.disable_metabib_field_entry',
+ 'ingest.disable_metabib_full_rec',
+ 'ingest.disable_metabib_rec_descriptor',
+ 'ingest.metarecord_mapping.preserve_on_delete',
+ 'ingest.metarecord_mapping.skip_on_insert',
+ 'ingest.metarecord_mapping.skip_on_update',
+ 'ingest.reingest.force_on_same_marc',
+ 'ingest.skip_browse_indexing',
+ 'ingest.skip_facet_indexing',
+ 'ingest.skip_search_indexing'
+);
+
+UPDATE config.internal_flag SET enabled = TRUE
+ WHERE name = 'ingest.reingest.force_on_same_marc';
+
+UPDATE biblio.record_entry SET marc = marc;
+
+UPDATE config.internal_flag SET enabled = FALSE
+ WHERE name = 'ingest.reingest.force_on_same_marc';
+
+-- re-enable the default ingest flags
+UPDATE config.internal_flag SET enabled = FALSE WHERE name IN (
+ 'ingest.assume_inserts_only',
+ 'ingest.disable_authority_auto_update',
+ 'ingest.disable_authority_linking',
+ 'ingest.disable_located_uri',
+ 'ingest.disable_metabib_field_entry',
+ 'ingest.disable_metabib_full_rec',
+ 'ingest.disable_metabib_rec_descriptor',
+ 'ingest.metarecord_mapping.preserve_on_delete',
+ 'ingest.metarecord_mapping.skip_on_insert',
+ 'ingest.metarecord_mapping.skip_on_update',
+ 'ingest.reingest.force_on_same_marc',
+ 'ingest.skip_browse_indexing',
+ 'ingest.skip_facet_indexing',
+ 'ingest.skip_search_indexing'
+);
+
+*/
+