3 INSERT INTO config.upgrade_log (version) VALUES ('0319'); --miker
5 -- Making this a global_flag (UI accessible) instead of an internal_flag
6 INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
8 'ingest.disable_authority_linking',
10 'ingest.disable_authority_linking',
11 'Authority Automation: Disable bib-authority link tracking',
16 UPDATE config.global_flag SET enabled = (SELECT enabled FROM ONLY config.internal_flag WHERE name = 'ingest.disable_authority_linking');
17 DELETE FROM config.internal_flag WHERE name = 'ingest.disable_authority_linking';
19 INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
21 'ingest.disable_authority_auto_update',
23 'ingest.disable_authority_auto_update',
24 'Authority Automation: Disable automatic authority updating (requires link tracking)',
31 CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
32 UPDATE biblio.record_entry
33 SET marc = vandelay.merge_record_xml( marc, authority.generate_overlay_template( $1 ) )
38 CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT) RETURNS SETOF BIGINT AS $func$
39 SELECT authority.propagate_changes( authority, bib ) FROM authority.bib_linking WHERE authority = $1;
42 CREATE OR REPLACE FUNCTION authority.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$
45 IF NEW.deleted IS TRUE THEN -- If this authority is deleted
46 RETURN NEW; -- and ... we're done
49 IF TG_OP = 'UPDATE' THEN -- re-ingest?
50 PERFORM * FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc' AND enabled;
52 IF NOT FOUND AND OLD.marc = NEW.marc THEN -- don't do anything if the MARC didn't change
58 -- authority change propogation
59 PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_auto_update' AND enabled;
61 PERFORM authority.propagate_changes( NEW.id );
66 $func$ LANGUAGE PLPGSQL;
68 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 ();