From: Ben Shum Date: Wed, 2 May 2018 05:45:14 +0000 (-0500) Subject: Revert "LP#1387722: Update MARC leader when deleting a record" X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d8e092ac014beee99ca75224a7524d3c0f41690b;p=evergreen%2Fpines.git Revert "LP#1387722: Update MARC leader when deleting a record" This reverts commit 7dfcdd814f60a20c1b8b4522e69c0a27c23123b5. --- diff --git a/Open-ILS/src/sql/Pg/010.schema.biblio.sql b/Open-ILS/src/sql/Pg/010.schema.biblio.sql index 7ce4490e98..857307e499 100644 --- a/Open-ILS/src/sql/Pg/010.schema.biblio.sql +++ b/Open-ILS/src/sql/Pg/010.schema.biblio.sql @@ -123,36 +123,4 @@ $$ LANGUAGE PLPGSQL; CREATE TRIGGER norm_sort_label BEFORE INSERT OR UPDATE ON biblio.monograph_part FOR EACH ROW EXECUTE PROCEDURE biblio.normalize_biblio_monograph_part_sortkey(); -CREATE OR REPLACE FUNCTION biblio.set_record_status_in_leader() RETURNS TRIGGER AS $func$ -use strict; -use MARC::Record; -use MARC::Field; -use MARC::File::XML (BinaryEncoding => 'utf8'); -use Unicode::Normalize; - -my $old_marc = MARC::Record->new_from_xml($_TD->{new}{marc}); -my $old_leader = $old_marc->leader(); -my $old_status = substr($old_leader,5,1); - -my $status; -if ($_TD->{event} eq 'INSERT') {$status = 'n';} -elsif ($_TD->{event} eq 'UPDATE' && $_TD->{new}{deleted} eq 't') {$status = 'd';} -elsif ($_TD->{event} eq 'UPDATE' && $_TD->{new}{deleted} eq 'f') {$status = 'c';} - -if ($old_status ne $status) { - my $marc = MARC::Record->new_from_xml($_TD->{new}{marc}); - my $leader = $marc->leader(); - substr($leader,5,1) = $status; - $marc->leader($leader); - my $marc_xml = $marc->as_xml_record(); - $marc_xml = NFC($marc_xml); - $_TD->{new}{marc} = $marc_xml; -} - -return "MODIFY"; - -$func$ LANGUAGE PLPERLU; - -CREATE TRIGGER set_record_status_in_leader BEFORE INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.set_record_status_in_leader(); - COMMIT; diff --git a/Open-ILS/src/sql/Pg/t/lp1387722_record_leader_updates.pg b/Open-ILS/src/sql/Pg/t/lp1387722_record_leader_updates.pg deleted file mode 100644 index ff845ce50a..0000000000 --- a/Open-ILS/src/sql/Pg/t/lp1387722_record_leader_updates.pg +++ /dev/null @@ -1,39 +0,0 @@ -BEGIN; - -SELECT plan(4); - ----------------------------------- --- Setup Test environment and data ----------------------------------- - --- create bib 70,000 -INSERT into biblio.record_entry (id, marc, last_xact_id) - VALUES (70000, - $$ - 00934|jm a2200241 a 450003-000374519991118131708.0971016n nyuuuu eng 4539Bartók, Béla,1881-1945.Concertos,piano,no. 1,Sz. 83(1926) Concertos,piano,no. 1,Sz. 83,(1926)Piano concerto no. 1 (1926) ; Rhapsody, op. 1 (1904)New York, NY :Vox - $$, - 'PGTAP' - ); - ------------------------------------ --- Test biblio.set_record_status_in_leader() ------------------------------------ - --- initially the status is undefined so now it should be 'n' -SELECT is((SELECT SUBSTR(ARRAY_TO_STRING(oils_xpath('//*[local-name()="leader"]/text()',marc),''),6,1) FROM biblio.record_entry WHERE id = 70000), 'n', 'Record is marked new.'); - --- check to see if it sets to 'c' correctly upon editing -UPDATE biblio.record_entry SET marc = REPLACE(marc,'piano','dydraulophone') WHERE id = 70000; -SELECT is((SELECT SUBSTR(ARRAY_TO_STRING(oils_xpath('//*[local-name()="leader"]/text()',marc),''),6,1) FROM biblio.record_entry WHERE id = 70000), 'c', 'Record is marked updated.'); - --- see if the record correctly marks as deleted 'd' -UPDATE biblio.record_entry SET deleted = TRUE WHERE id = 70000; -SELECT is((SELECT SUBSTR(ARRAY_TO_STRING(oils_xpath('//*[local-name()="leader"]/text()',marc),''),6,1) FROM biblio.record_entry WHERE id = 70000), 'd', 'Record is marked deleted.'); - --- see if the record is correctly set to 'c' when undeleted -UPDATE biblio.record_entry SET deleted = FALSE WHERE id = 70000; -SELECT is((SELECT SUBSTR(ARRAY_TO_STRING(oils_xpath('//*[local-name()="leader"]/text()',marc),''),6,1) FROM biblio.record_entry WHERE id = 70000), 'c', 'Record is marked updated.'); - -SELECT * FROM finish(); - -ROLLBACK; diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.set_record_status_in_leader_trigger.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.set_record_status_in_leader_trigger.sql deleted file mode 100644 index d7f72066ef..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.set_record_status_in_leader_trigger.sql +++ /dev/null @@ -1,37 +0,0 @@ -BEGIN; - -SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); - -CREATE OR REPLACE FUNCTION biblio.set_record_status_in_leader() RETURNS TRIGGER AS $func$ -use strict; -use MARC::Record; -use MARC::Field; -use MARC::File::XML (BinaryEncoding => 'utf8'); -use Unicode::Normalize; - -my $old_marc = MARC::Record->new_from_xml($_TD->{new}{marc}); -my $old_leader = $old_marc->leader(); -my $old_status = substr($old_leader,5,1); - -my $status; -if ($_TD->{event} eq 'INSERT') {$status = 'n';} -elsif ($_TD->{event} eq 'UPDATE' && $_TD->{new}{deleted} eq 't') {$status = 'd';} -elsif ($_TD->{event} eq 'UPDATE' && $_TD->{new}{deleted} eq 'f') {$status = 'c';} - -if ($old_status ne $status) { - my $marc = MARC::Record->new_from_xml($_TD->{new}{marc}); - my $leader = $marc->leader(); - substr($leader,5,1) = $status; - $marc->leader($leader); - my $marc_xml = $marc->as_xml_record(); - $marc_xml = NFC($marc_xml); - $_TD->{new}{marc} = $marc_xml; -} - -return "MODIFY"; - -$func$ LANGUAGE PLPERLU; - -CREATE TRIGGER set_record_status_in_leader BEFORE INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.set_record_status_in_leader(); - -COMMIT; diff --git a/docs/RELEASE_NOTES_NEXT/Cataloging/leader_updated_on_delete_creation_update.adoc b/docs/RELEASE_NOTES_NEXT/Cataloging/leader_updated_on_delete_creation_update.adoc deleted file mode 100644 index 527ef7c093..0000000000 --- a/docs/RELEASE_NOTES_NEXT/Cataloging/leader_updated_on_delete_creation_update.adoc +++ /dev/null @@ -1,7 +0,0 @@ -MARC Leader Updated on Bib Deletion, Creation and Update -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -There is now a trigger in place on the bibliographic record table that -will update the Leader/05 when a new record is inserted, when a record -is updated or deleted. On insert (created new or imported) it will be -marked as 'n' for new, on update (including undeletion) it will be -marked 'c' for modified and on deletion will be marked 'd' for deleted.