'circ.patron_search.diacritic_insensitive',
'true'
);
+
+INSERT INTO config.global_flag (name, enabled, label) VALUES (
+ 'ingest.disable_authority_auto_update_bib_meta', FALSE,
+ oils_i18n_gettext(
+ 'ingest.disable_authority_auto_update_bib_meta',
+ 'Authority Automation: Disable automatic authority updates ' ||
+ 'from modifying bib record editor and edit_date',
+ 'cgf',
+ 'label'
+ )
+);
+
CREATE TRIGGER a_opac_vis_mat_view_tgr AFTER INSERT OR UPDATE ON actor.org_unit FOR EACH ROW EXECUTE PROCEDURE asset.cache_copy_visibility();
-- Authority ingest routines
-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, bid BIGINT) RETURNS BIGINT AS $func$
+DECLARE
+ bib_rec biblio.record_entry%ROWTYPE;
+BEGIN
+
+ SELECT INTO bib_rec * FROM biblio.record_entry WHERE id = bid;
+
+ bib_rec.marc := vandelay.merge_record_xml(
+ bib_rec.marc, authority.generate_overlay_template(aid));
+
+ PERFORM 1 FROM config.global_flag
+ WHERE name = 'ingest.disable_authority_auto_update_bib_meta'
+ AND enabled;
+
+ IF NOT FOUND THEN
+ -- update the bib record editor and edit_date
+ bib_rec.editor := (
+ SELECT editor FROM authority.record_entry WHERE id = aid);
+ bib_rec.edit_date = NOW();
+ END IF;
+
+ UPDATE biblio.record_entry SET
+ marc = bib_rec.marc,
+ editor = bib_rec.editor,
+ edit_date = bib_rec.edit_date
+ WHERE id = bid;
+
+ RETURN aid;
+
+END;
+$func$ LANGUAGE PLPGSQL;
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;
--- /dev/null
+
+BEGIN;
+
+DROP FUNCTION authority.propagate_changes (BIGINT, BIGINT);
+
+CREATE OR REPLACE FUNCTION authority.propagate_changes
+ (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
+DECLARE
+ bib_rec biblio.record_entry%ROWTYPE;
+BEGIN
+
+ SELECT INTO bib_rec * FROM biblio.record_entry WHERE id = bid;
+
+ bib_rec.marc := vandelay.merge_record_xml(
+ bib_rec.marc, authority.generate_overlay_template(aid));
+
+ PERFORM 1 FROM config.global_flag
+ WHERE name = 'ingest.disable_authority_auto_update_bib_meta'
+ AND enabled;
+
+ IF NOT FOUND THEN
+ -- update the bib record editor and edit_date
+ bib_rec.editor := (
+ SELECT editor FROM authority.record_entry WHERE id = aid);
+ bib_rec.edit_date = NOW();
+ END IF;
+
+ UPDATE biblio.record_entry SET
+ marc = bib_rec.marc,
+ editor = bib_rec.editor,
+ edit_date = bib_rec.edit_date
+ WHERE id = bid;
+
+ RETURN aid;
+
+END;
+$func$ LANGUAGE PLPGSQL;
+
+
+-- DATA
+-- Disabled by default
+INSERT INTO config.global_flag (name, enabled, label) VALUES (
+ 'ingest.disable_authority_auto_update_bib_meta', FALSE,
+ oils_i18n_gettext(
+ 'ingest.disable_authority_auto_update_bib_meta',
+ 'Authority Automation: Disable automatic authority updates ' ||
+ 'from modifying bib record editor and edit_date',
+ 'cgf',
+ 'label'
+ )
+);
+
+
+COMMIT;
+