[open-ils-commits] r15835 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Mar 12 15:12:57 EST 2010
Author: miker
Date: 2010-03-12 15:12:52 -0500 (Fri, 12 Mar 2010)
New Revision: 15835
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0194.schema.vandelay.internal-id-crosscheck.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Log:
adding 901c cross-check to auto-overlay logic to prevent isbn, etc auto-overlay
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-12 19:14:34 UTC (rev 15834)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-12 20:12:52 UTC (rev 15835)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0193'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0194'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql 2010-03-12 19:14:34 UTC (rev 15834)
+++ trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql 2010-03-12 20:12:52 UTC (rev 15835)
@@ -358,6 +358,7 @@
DECLARE
eg_id BIGINT;
match_count INT;
+ match_attr vandelay.bib_attr_definition%ROWTYPE;
BEGIN
SELECT COUNT(*) INTO match_count FROM vandelay.bib_match WHERE queued_record = import_id;
@@ -366,6 +367,17 @@
RETURN FALSE;
END IF;
+ SELECT d.* INTO match_attr
+ FROM vandelay.bib_attr_definition d
+ JOIN vandelay.queued_bib_record_attr a ON (a.field = d.id)
+ JOIN vandelay.bib_match m ON (m.matched_attr = a.id)
+ WHERE m.queued_record = import_id;
+
+ IF NOT (match_attr.xpath ~ '@tag="901"' AND match_attr.xpath ~ '@code="c"') THEN
+ -- RAISE NOTICE 'not a 901c match';
+ RETURN FALSE;
+ END IF;
+
SELECT m.eg_record INTO eg_id
FROM vandelay.bib_match m
WHERE m.queued_record = import_id
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0194.schema.vandelay.internal-id-crosscheck.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0194.schema.vandelay.internal-id-crosscheck.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0194.schema.vandelay.internal-id-crosscheck.sql 2010-03-12 20:12:52 UTC (rev 15835)
@@ -0,0 +1,42 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0194'); -- miker
+
+CREATE OR REPLACE FUNCTION vandelay.auto_overlay_bib_record ( import_id BIGINT, merge_profile_id INT ) RETURNS BOOL AS $$
+DECLARE
+ eg_id BIGINT;
+ match_count INT;
+ match_attr vandelay.bib_attr_definition%ROWTYPE;
+BEGIN
+ SELECT COUNT(*) INTO match_count FROM vandelay.bib_match WHERE queued_record = import_id;
+
+ IF match_count <> 1 THEN
+ -- RAISE NOTICE 'not an exact match';
+ RETURN FALSE;
+ END IF;
+
+ SELECT d.* INTO match_attr
+ FROM vandelay.bib_attr_definition d
+ JOIN vandelay.queued_bib_record_attr a ON (a.field = d.id)
+ JOIN vandelay.bib_match m ON (m.matched_attr = a.id)
+ WHERE m.queued_record = import_id;
+
+ IF NOT (match_attr.xpath ~ '@tag="901"' AND match_attr.xpath ~ '@code="c"') THEN
+ -- RAISE NOTICE 'not a 901c match';
+ RETURN FALSE;
+ END IF;
+
+ SELECT m.eg_record INTO eg_id
+ FROM vandelay.bib_match m
+ WHERE m.queued_record = import_id
+ LIMIT 1;
+
+ IF eg_id IS NULL THEN
+ RETURN FALSE;
+ END IF;
+
+ RETURN vandelay.overlay_bib_record( import_id, eg_id, merge_profile_id );
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list