[open-ils-commits] r17058 - in trunk/Open-ILS/src/sql/Pg: . upgrade (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 29 19:12:35 EDT 2010
Author: erickson
Date: 2010-07-29 19:12:34 -0400 (Thu, 29 Jul 2010)
New Revision: 17058
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0354.schema.vandelay_template_overlay_fix.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Log:
repaired copy/paste thinko in the vandelay auto-overlay-with-merge-profile logic
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-07-29 21:08:36 UTC (rev 17057)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-07-29 23:12:34 UTC (rev 17058)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0353'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0354'); -- berick
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-07-29 21:08:36 UTC (rev 17057)
+++ trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql 2010-07-29 23:12:34 UTC (rev 17058)
@@ -496,7 +496,7 @@
SELECT b.marc INTO eg_marc
FROM biblio.record_entry b
- JOIN vandelay.bib_match m ON (m.eg_record = b.id AND m.queued_record = import_id)
+ WHERE b.id = eg_id
LIMIT 1;
IF eg_marc IS NULL OR v_marc IS NULL THEN
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0354.schema.vandelay_template_overlay_fix.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0354.schema.vandelay_template_overlay_fix.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0354.schema.vandelay_template_overlay_fix.sql 2010-07-29 23:12:34 UTC (rev 17058)
@@ -0,0 +1,69 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0354'); -- berick
+
+CREATE OR REPLACE FUNCTION vandelay.template_overlay_bib_record ( v_marc TEXT, eg_id BIGINT, merge_profile_id INT ) RETURNS BOOL AS $$
+DECLARE
+ merge_profile vandelay.merge_profile%ROWTYPE;
+ dyn_profile vandelay.compile_profile%ROWTYPE;
+ editor_string TEXT;
+ editor_id INT;
+ source_marc TEXT;
+ target_marc TEXT;
+ eg_marc TEXT;
+ replace_rule TEXT;
+ match_count INT;
+BEGIN
+
+ SELECT b.marc INTO eg_marc
+ FROM biblio.record_entry b
+ WHERE b.id = eg_id
+ LIMIT 1;
+
+ IF eg_marc IS NULL OR v_marc IS NULL THEN
+ -- RAISE NOTICE 'no marc for template or bib record';
+ RETURN FALSE;
+ END IF;
+
+ dyn_profile := vandelay.compile_profile( v_marc );
+
+ IF merge_profile_id IS NOT NULL THEN
+ SELECT * INTO merge_profile FROM vandelay.merge_profile WHERE id = merge_profile_id;
+ IF FOUND THEN
+ dyn_profile.add_rule := BTRIM( dyn_profile.add_rule || ',' || COALESCE(merge_profile.add_spec,''), ',');
+ dyn_profile.strip_rule := BTRIM( dyn_profile.strip_rule || ',' || COALESCE(merge_profile.strip_spec,''), ',');
+ dyn_profile.replace_rule := BTRIM( dyn_profile.replace_rule || ',' || COALESCE(merge_profile.replace_spec,''), ',');
+ dyn_profile.preserve_rule := BTRIM( dyn_profile.preserve_rule || ',' || COALESCE(merge_profile.preserve_spec,''), ',');
+ END IF;
+ END IF;
+
+ IF dyn_profile.replace_rule <> '' AND dyn_profile.preserve_rule <> '' THEN
+ -- RAISE NOTICE 'both replace [%] and preserve [%] specified', dyn_profile.replace_rule, dyn_profile.preserve_rule;
+ RETURN FALSE;
+ END IF;
+
+ IF dyn_profile.replace_rule <> '' THEN
+ source_marc = v_marc;
+ target_marc = eg_marc;
+ replace_rule = dyn_profile.replace_rule;
+ ELSE
+ source_marc = eg_marc;
+ target_marc = v_marc;
+ replace_rule = dyn_profile.preserve_rule;
+ END IF;
+
+ UPDATE biblio.record_entry
+ SET marc = vandelay.merge_record_xml( target_marc, source_marc, dyn_profile.add_rule, replace_rule, dyn_profile.strip_rule )
+ WHERE id = eg_id;
+
+ IF NOT FOUND THEN
+ -- RAISE NOTICE 'update of biblio.record_entry failed';
+ RETURN FALSE;
+ END IF;
+
+ RETURN TRUE;
+
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list