[open-ils-commits] r16817 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jun 25 16:33:04 EDT 2010
Author: miker
Date: 2010-06-25 16:32:58 -0400 (Fri, 25 Jun 2010)
New Revision: 16817
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0319.schema.authority-update-propogation.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
Log:
add stored procs to implement authority propagation if links exist; add trigger to optionally fire this propagation (default ON)
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-06-25 17:31:21 UTC (rev 16816)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-06-25 20:32:58 UTC (rev 16817)
@@ -57,7 +57,6 @@
INSERT INTO config.internal_flag (name) VALUES ('ingest.disable_metabib_full_rec');
INSERT INTO config.internal_flag (name) VALUES ('ingest.disable_metabib_rec_descriptor');
INSERT INTO config.internal_flag (name) VALUES ('ingest.disable_metabib_field_entry');
-INSERT INTO config.internal_flag (name) VALUES ('ingest.disable_authority_linking');
CREATE TABLE config.global_flag (
label TEXT NOT NULL
@@ -69,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0318'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0319'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql 2010-06-25 17:31:21 UTC (rev 16816)
+++ trunk/Open-ILS/src/sql/Pg/030.schema.metabib.sql 2010-06-25 20:32:58 UTC (rev 16817)
@@ -883,6 +883,44 @@
END;
$func$ LANGUAGE PLPGSQL;
+CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
+ UPDATE biblio.record_entry
+ SET marc = vandelay.merge_record_xml( marc, authority.generate_overlay_template( $1 ) )
+ WHERE id = $2;
+ SELECT $1;
+$func$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT) RETURNS SETOF BIGINT AS $func$
+ SELECT authority.propagate_changes( authority, bib ) FROM authority.bib_linking WHERE authority = $1;
+$func$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION authority.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$
+BEGIN
+
+ IF NEW.deleted IS TRUE THEN -- If this authority is deleted
+ RETURN NEW; -- and ... we're done
+ END IF;
+
+ IF TG_OP = 'UPDATE' THEN -- re-ingest?
+ PERFORM * FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc' AND enabled;
+
+ IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change
+ RETURN NEW;
+ END IF;
+ END IF;
+
+
+ -- authority change propogation
+ PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_auto_update' AND enabled;
+ IF NOT FOUND THEN
+ PERFORM authority.propagate_changes( NEW.id );
+ END IF;
+
+ RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+
CREATE OR REPLACE FUNCTION biblio.map_authority_linking (bibid BIGINT, marc TEXT) RETURNS BIGINT AS $func$
DELETE FROM authority.bib_linking WHERE bib = $1;
INSERT INTO authority.bib_linking (bib, authority)
@@ -910,8 +948,6 @@
IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change
RETURN NEW;
END IF;
-
-
END IF;
-- Record authority linking
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-06-25 17:31:21 UTC (rev 16816)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-06-25 20:32:58 UTC (rev 16817)
@@ -5613,6 +5613,28 @@
INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
VALUES (
+ 'ingest.disable_authority_linking',
+ oils_i18n_gettext(
+ 'ingest.disable_authority_linking',
+ 'Authority Automation: Disable bib-authority link tracking',
+ 'cgf',
+ 'label'
+ )
+ );
+
+INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
+ VALUES (
+ 'ingest.disable_authority_auto_update',
+ oils_i18n_gettext(
+ 'ingest.disable_authority_auto_update',
+ 'Authority Automation: Disable automatic authority updating (requires link tracking)',
+ 'cgf',
+ 'label'
+ )
+ );
+
+INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
+ VALUES (
'cat.bib.use_id_for_tcn',
oils_i18n_gettext(
'cat.bib.use_id_for_tcn',
Modified: trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2010-06-25 17:31:21 UTC (rev 16816)
+++ trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2010-06-25 20:32:58 UTC (rev 16817)
@@ -1116,6 +1116,8 @@
CREATE TRIGGER aaa_indexing_ingest_or_delete AFTER INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.indexing_ingest_or_delete ();
CREATE TRIGGER bbb_simple_rec_trigger AFTER INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_trigger ();
+CREATE TRIGGER aaa_auth_ingest_or_delete AFTER INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE authority.indexing_ingest_or_delete ();
+
-- Utility routines, callable via cstore
CREATE OR REPLACE FUNCTION config.interval_to_seconds( interval_val INTERVAL )
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0319.schema.authority-update-propogation.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0319.schema.authority-update-propogation.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0319.schema.authority-update-propogation.sql 2010-06-25 20:32:58 UTC (rev 16817)
@@ -0,0 +1,72 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0319'); --miker
+
+-- Making this a global_flag (UI accessible) instead of an internal_flag
+INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
+ VALUES (
+ 'ingest.disable_authority_linking',
+ oils_i18n_gettext(
+ 'ingest.disable_authority_linking',
+ 'Authority Automation: Disable bib-authority link tracking',
+ 'cgf',
+ 'label'
+ )
+ );
+UPDATE config.global_flag SET enabled = (SELECT enabled FROM config.internal_flag WHERE name = 'ingest.disable_authority_linking');
+DELETE FROM config.internal_flag WHERE name = 'ingest.disable_authority_linking';
+
+INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
+ VALUES (
+ 'ingest.disable_authority_auto_update',
+ oils_i18n_gettext(
+ 'ingest.disable_authority_auto_update',
+ 'Authority Automation: Disable automatic authority updating (requires link tracking)',
+ 'cgf',
+ 'label'
+ )
+ );
+
+
+CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
+ UPDATE biblio.record_entry
+ SET marc = vandelay.merge_record_xml( marc, authority.generate_overlay_template( $1 ) )
+ WHERE id = $2;
+ SELECT $2;
+$func$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT) RETURNS SETOF BIGINT AS $func$
+ SELECT authority.propagate_changes( authority, bib ) FROM authority.bib_linking WHERE authority = $1;
+$func$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION authority.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$
+BEGIN
+
+ IF NEW.deleted IS TRUE THEN -- If this authority is deleted
+ RETURN NEW; -- and ... we're done
+ END IF;
+
+ IF TG_OP = 'UPDATE' THEN -- re-ingest?
+ PERFORM * FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc' AND enabled;
+
+ IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change
+ RETURN NEW;
+ END IF;
+ END IF;
+
+
+ -- authority change propogation
+ PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_auto_update' AND enabled;
+ IF NOT FOUND THEN
+ PERFORM authority.propagate_changes( NEW.id );
+ END IF;
+
+ RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER aaa_auth_ingest_or_delete AFTER INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE authority.indexing_ingest_or_delete ();
+
+
+COMMIT;
+
More information about the open-ils-commits
mailing list