[open-ils-commits] [GIT] Evergreen ILS branch master updated. 12159383d46bf76db3e710a689ad8b5140436007

Evergreen Git git at git.evergreen-ils.org
Wed Aug 24 12:58:07 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  12159383d46bf76db3e710a689ad8b5140436007 (commit)
       via  84bed711249098679ae25f83eeb588871022ed19 (commit)
       via  d61a652d97339961fd4a65bf27c77f4bc1314ffb (commit)
       via  8e959742b7751403e942694d1123a3f38cbbb239 (commit)
       via  7605ed8a65a2151e42a3e8c20cd8640f81fab962 (commit)
       via  28d9ccf8df4cd3e9989d91e3053c26aca6a48e76 (commit)
      from  92deb9cd8aa31f49ab406f776d7a9fcc318d58a1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 12159383d46bf76db3e710a689ad8b5140436007
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Aug 24 12:56:28 2016 -0400

    Stamping upgrade script for authority edit changes and propagation improvement
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index d7438fb..1e1dac8 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0993', :eg_version); -- berick/miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0994', :eg_version); -- berick/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql b/Open-ILS/src/sql/Pg/upgrade/0994.schema.authority-propage-edit-date.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
rename to Open-ILS/src/sql/Pg/upgrade/0994.schema.authority-propage-edit-date.sql
index 3d53c03..5d00342 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0994.schema.authority-propage-edit-date.sql
@@ -1,6 +1,8 @@
 
 BEGIN;
 
+SELECT evergreen.upgrade_deps_block_check('0994', :eg_version);
+
 CREATE OR REPLACE FUNCTION authority.propagate_changes 
     (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
 DECLARE

commit 84bed711249098679ae25f83eeb588871022ed19
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Aug 24 11:38:49 2016 -0400

    LP#1588948: Only attempt a bib update if the heading changes
    
    This should significantly reduce the churn on bibs and the time to save
    an authority where the heading that would propagate to bibs has not changed.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index 04b0b29..612a4ba 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1658,10 +1658,10 @@ BEGIN
             RETURN NEW;
         END IF;
 
-        -- Unless there's a setting stopping us, propagate these updates to any linked bib records
+        -- Unless there's a setting stopping us, propagate these updates to any linked bib records when the heading changes
         PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_auto_update' AND enabled;
 
-        IF NOT FOUND THEN
+        IF NOT FOUND AND NEW.heading <> OLD.heading THEN
             PERFORM authority.propagate_changes(NEW.id);
         END IF;
 	
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
index b5bd375..3d53c03 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
@@ -1,8 +1,6 @@
 
 BEGIN;
 
-DROP FUNCTION authority.propagate_changes (BIGINT, BIGINT);
-
 CREATE OR REPLACE FUNCTION authority.propagate_changes 
     (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
 DECLARE
@@ -58,5 +56,87 @@ INSERT INTO config.global_flag (name, enabled, label) VALUES (
 );
 
 
+CREATE OR REPLACE FUNCTION authority.indexing_ingest_or_delete () RETURNS TRIGGER AS $func$
+DECLARE
+    ashs    authority.simple_heading%ROWTYPE;
+    mbe_row metabib.browse_entry%ROWTYPE;
+    mbe_id  BIGINT;
+    ash_id  BIGINT;
+BEGIN
+
+    IF NEW.deleted IS TRUE THEN -- If this authority is deleted
+        DELETE FROM authority.bib_linking WHERE authority = NEW.id; -- Avoid updating fields in bibs that are no longer visible
+        DELETE FROM authority.full_rec WHERE record = NEW.id; -- Avoid validating fields against deleted authority records
+        DELETE FROM authority.simple_heading WHERE record = NEW.id;
+          -- Should remove matching $0 from controlled fields at the same time?
+
+        -- XXX What do we about the actual linking subfields present in
+        -- authority records that target this one when this happens?
+        DELETE FROM authority.authority_linking
+            WHERE source = NEW.id OR target = NEW.id;
+
+        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;
+
+        -- Unless there's a setting stopping us, propagate these updates to any linked bib records when the heading changes
+        PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_auto_update' AND enabled;
+
+        IF NOT FOUND AND NEW.heading <> OLD.heading THEN
+            PERFORM authority.propagate_changes(NEW.id);
+        END IF;
+	
+        DELETE FROM authority.simple_heading WHERE record = NEW.id;
+        DELETE FROM authority.authority_linking WHERE source = NEW.id;
+    END IF;
+
+    INSERT INTO authority.authority_linking (source, target, field)
+        SELECT source, target, field FROM authority.calculate_authority_linking(
+            NEW.id, NEW.control_set, NEW.marc::XML
+        );
+
+    FOR ashs IN SELECT * FROM authority.simple_heading_set(NEW.marc) LOOP
+
+        INSERT INTO authority.simple_heading (record,atag,value,sort_value,thesaurus)
+            VALUES (ashs.record, ashs.atag, ashs.value, ashs.sort_value, ashs.thesaurus);
+            ash_id := CURRVAL('authority.simple_heading_id_seq'::REGCLASS);
+
+        SELECT INTO mbe_row * FROM metabib.browse_entry
+            WHERE value = ashs.value AND sort_value = ashs.sort_value;
+
+        IF FOUND THEN
+            mbe_id := mbe_row.id;
+        ELSE
+            INSERT INTO metabib.browse_entry
+                ( value, sort_value ) VALUES
+                ( ashs.value, ashs.sort_value );
+
+            mbe_id := CURRVAL('metabib.browse_entry_id_seq'::REGCLASS);
+        END IF;
+
+        INSERT INTO metabib.browse_entry_simple_heading_map (entry,simple_heading) VALUES (mbe_id,ash_id);
+
+    END LOOP;
+
+    -- Flatten and insert the afr data
+    PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_full_rec' AND enabled;
+    IF NOT FOUND THEN
+        PERFORM authority.reingest_authority_full_rec(NEW.id);
+        PERFORM * FROM config.internal_flag WHERE name = 'ingest.disable_authority_rec_descriptor' AND enabled;
+        IF NOT FOUND THEN
+            PERFORM authority.reingest_authority_rec_descriptor(NEW.id);
+        END IF;
+    END IF;
+
+    RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
 COMMIT;
 

commit d61a652d97339961fd4a65bf27c77f4bc1314ffb
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jun 13 13:57:30 2016 -0400

    LP#1588948 Auth propagate bib meta on change only
    
    Only update bib record editor and edit_date if an authority record
    change propagation resulted in a modified bib record.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index bbd76f8..04b0b29 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1487,13 +1487,20 @@ CREATE OR REPLACE FUNCTION authority.propagate_changes
     (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
 DECLARE
     bib_rec biblio.record_entry%ROWTYPE;
+    new_marc TEXT;
 BEGIN
 
     SELECT INTO bib_rec * FROM biblio.record_entry WHERE id = bid;
 
-    bib_rec.marc := vandelay.merge_record_xml(
+    new_marc := vandelay.merge_record_xml(
         bib_rec.marc, authority.generate_overlay_template(aid));
 
+    IF new_marc = bib_rec.marc THEN
+        -- Authority record change had no impact on this bib record.
+        -- Nothing left to do.
+        RETURN aid;
+    END IF;
+
     PERFORM 1 FROM config.global_flag 
         WHERE name = 'ingest.disable_authority_auto_update_bib_meta' 
             AND enabled;
@@ -1506,7 +1513,7 @@ BEGIN
     END IF;
 
     UPDATE biblio.record_entry SET
-        marc = bib_rec.marc,
+        marc = new_marc,
         editor = bib_rec.editor,
         edit_date = bib_rec.edit_date
     WHERE id = bid;
diff --git a/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
index 4dd5e15..201fffc 100644
--- a/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
+++ b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
@@ -6,7 +6,7 @@ editor and edit_date), but includes general tests for confirming authority
 update propagation to bib records.
 */
 
-SELECT plan(8);
+SELECT plan(9);
 
 INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name,
             passwd, first_given_name, expire_date, dob, suffix)
@@ -52,6 +52,25 @@ SELECT is(
     'Bib edit_date is updated'
 );
 
+-- Apply a change to the authority record that has no effect on the bib.
+
+UPDATE biblio.record_entry 
+    SET editor = 1, edit_date = NOW() - '1 week'::INTERVAL
+    WHERE id = 1234512345;
+
+UPDATE authority.record_entry SET 
+    editor = CURRVAL('actor.usr_id_seq'), -- test user created above
+    marc = $$
+<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane Smith</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield><subfield code="x">test</subfield></datafield></record>
+$$
+WHERE id = 999999100;
+
+SELECT isnt(
+    (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
+    CURRENT_DATE,
+    'Authority change with no effect does not update bib record'
+);
+
 -- Reset the bib data for easier testing
 
 UPDATE biblio.record_entry 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
index c22b73d..b5bd375 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
@@ -7,13 +7,20 @@ CREATE OR REPLACE FUNCTION authority.propagate_changes
     (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$
 DECLARE
     bib_rec biblio.record_entry%ROWTYPE;
+    new_marc TEXT;
 BEGIN
 
     SELECT INTO bib_rec * FROM biblio.record_entry WHERE id = bid;
 
-    bib_rec.marc := vandelay.merge_record_xml(
+    new_marc := vandelay.merge_record_xml(
         bib_rec.marc, authority.generate_overlay_template(aid));
 
+    IF new_marc = bib_rec.marc THEN
+        -- Authority record change had no impact on this bib record.
+        -- Nothing left to do.
+        RETURN aid;
+    END IF;
+
     PERFORM 1 FROM config.global_flag 
         WHERE name = 'ingest.disable_authority_auto_update_bib_meta' 
             AND enabled;
@@ -26,7 +33,7 @@ BEGIN
     END IF;
 
     UPDATE biblio.record_entry SET
-        marc = bib_rec.marc,
+        marc = new_marc,
         editor = bib_rec.editor,
         edit_date = bib_rec.edit_date
     WHERE id = bid;

commit 8e959742b7751403e942694d1123a3f38cbbb239
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jun 6 10:19:30 2016 -0400

    LP#1588948 Release notes (auth prop. bib edit[or|_date])
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/docs/RELEASE_NOTES_NEXT/Cataloging/auth_prop_bib_update.adoc b/docs/RELEASE_NOTES_NEXT/Cataloging/auth_prop_bib_update.adoc
new file mode 100644
index 0000000..6116040
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/Cataloging/auth_prop_bib_update.adoc
@@ -0,0 +1,16 @@
+Authority Propagation Updates Bib Editor / Edit Date
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+When a bib record is automatically updated as a result of the
+modification of a linked authority record, the bib record's "Last Edit
+Data/Time" and "Last Editing User" fields will be updated to match the
+time of the update and the editor of the modified authority record.
+
+A new global flag is available to control this behavior called
+'ingest.disable_authority_auto_update_bib_meta' ("Authority Automation:
+Disable automatic authority updates from modifying bib record editor
+and edit_date").  When enabled, theses fields will not be updated.  By
+default, this setting is disabled.
+
+An additional speed improvement is included in this feature.  No attempt
+will be made to update linked bib records when the normalized heading of
+the modified authority record is unchanged by the authority record update.

commit 7605ed8a65a2151e42a3e8c20cd8640f81fab962
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jun 6 11:14:47 2016 -0400

    LP#1588948 Authority propagation PGTAP test
    
    Adds a new general purpose authority->bib propagation pgtap test,
    covering basic propagation and editor / edit_date propagation.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
new file mode 100644
index 0000000..4dd5e15
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
@@ -0,0 +1,105 @@
+BEGIN;
+
+/* 
+Started as a test plan for LP#1588948 (authority edits modify bib record
+editor and edit_date), but includes general tests for confirming authority
+update propagation to bib records.
+*/
+
+SELECT plan(8);
+
+INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name,
+            passwd, first_given_name, expire_date, dob, suffix)
+    VALUES (13, 1, 'TEST_USER', 1, 'TESTER', 'TEST1234', 'TEST',
+            NOW() + '3 years'::INTERVAL, NULL, NULL);
+
+INSERT INTO authority.record_entry (id, marc, last_xact_id)
+VALUES (999999100, $$
+<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield></datafield></record>
+$$, 'test'
+);
+
+INSERT INTO biblio.record_entry (id, editor, edit_date, last_xact_id, marc)
+    VALUES (1234512345, 1, now() - '15 days'::INTERVAL, 'test', $$
+<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>00620cam a2200205Ka 4500</leader><controlfield tag="001">1234512345</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606145837.0</controlfield><controlfield tag="008">070101s                            eng d</controlfield><datafield tag="100" ind1=" " ind2=" "><subfield code="0">(LOCAL)999999100</subfield><subfield code="a">Doe, Jane</subfield></datafield><datafield tag="245" ind1=" " ind2=" "><subfield code="a">Test Record</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="a">1234512345</subfield><subfield code="b"></subfield><subfield code="c">1234512345</subfield><subfield code="t">biblio</subfield></datafield></record>
+$$);
+
+
+-- modify the authority record to propagate changes
+UPDATE authority.record_entry SET 
+    editor = CURRVAL('actor.usr_id_seq'), -- test user created above
+    marc = $$
+<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane Smith</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield></datafield></record>
+$$
+WHERE id = 999999100;
+
+SELECT is(
+    (SELECT value FROM metabib.full_rec 
+        WHERE record = 1234512345 AND tag = '100' and subfield = 'a'),
+    'doe, jane smith',
+    'Authority field change propagated to bib record'
+);
+
+SELECT is(
+    (SELECT editor FROM biblio.record_entry WHERE id = 1234512345),
+    CURRVAL('actor.usr_id_seq')::INTEGER,
+    'Bib editor matches authority editor'
+);
+
+SELECT is(
+    (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
+    CURRENT_DATE,
+    'Bib edit_date is updated'
+);
+
+-- Reset the bib data for easier testing
+
+UPDATE biblio.record_entry 
+    SET editor = 1, edit_date = NOW() - '1 week'::INTERVAL 
+    WHERE id = 1234512345;
+
+SELECT is(
+    (SELECT editor FROM biblio.record_entry WHERE id = 1234512345),
+    1,
+    'Bib editor is reset'
+);
+
+SELECT is(
+    (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
+    DATE(NOW() - '1 week'::INTERVAL),
+    'Bib edit_date is reset'
+);
+
+-- Disable bib edit data propagation by enabled the disable flag
+UPDATE config.global_flag SET enabled = TRUE
+    WHERE name = 'ingest.disable_authority_auto_update_bib_meta';
+
+-- modify the authority record to propagate changes
+UPDATE authority.record_entry SET 
+    editor = CURRVAL('actor.usr_id_seq'), -- test user created above
+    marc = $$
+<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane Double-Smith</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield></datafield></record>
+$$
+WHERE id = 999999100;
+
+SELECT is(
+    (SELECT value FROM metabib.full_rec 
+        WHERE record = 1234512345 AND tag = '100' and subfield = 'a'),
+    'doe, jane double smith',
+    'Authority field change propagated to bib record'
+);
+
+SELECT isnt(
+    (SELECT editor FROM biblio.record_entry WHERE id = 1234512345),
+    CURRVAL('actor.usr_id_seq')::INTEGER,
+    'Bib editor does not match authority editor'
+);
+
+SELECT isnt(
+    (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
+    CURRENT_DATE,
+    'Bib edit_date is not updated'
+);
+
+ROLLBACK;
+

commit 28d9ccf8df4cd3e9989d91e3053c26aca6a48e76
Author: Bill Erickson <berickxx at gmail.com>
Date:   Fri Jun 3 15:16:58 2016 -0400

    LP#1588948 Propagate authority->bib edit[or|_date]
    
    Adds a new global flag 'ingest.disable_authority_auto_update_bib_meta',
    which is disabled by default.
    
    When disabled, the 'editor' and 'edit_date' columns on bib records
    updated via authority field propagation are updated to the value of the
    editor on the authority record and NOW(), respectively.
    
    When enabled, editor and edit_date are not modified.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 e8228c8..b21fe2a 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -16344,3 +16344,15 @@ INSERT INTO actor.org_unit_setting (
     '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'
+    )
+);
+
diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index 97ce100..bbd76f8 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1483,12 +1483,38 @@ CREATE TRIGGER a_opac_vis_mat_view_tgr AFTER INSERT OR UPDATE ON config.copy_sta
 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;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
new file mode 100644
index 0000000..c22b73d
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql
@@ -0,0 +1,55 @@
+
+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;
+

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   12 ++
 Open-ILS/src/sql/Pg/999.functions.global.sql       |   49 +++++++--
 .../sql/Pg/t/authority-update-bib-propagation.pg   |  124 ++++++++++++++++++++
 ...=> 0994.schema.authority-propage-edit-date.sql} |   74 ++++++++++--
 .../Cataloging/auth_prop_bib_update.adoc           |   16 +++
 6 files changed, 259 insertions(+), 18 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
 copy Open-ILS/src/sql/Pg/upgrade/{0897.schema.authority_disable_auto_update.sql => 0994.schema.authority-propage-edit-date.sql} (61%)
 create mode 100644 docs/RELEASE_NOTES_NEXT/Cataloging/auth_prop_bib_update.adoc


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list