[open-ils-commits] r18303 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Oct 12 22:34:02 EDT 2010
Author: miker
Date: 2010-10-12 22:33:59 -0400 (Tue, 12 Oct 2010)
New Revision: 18303
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0436.schema.multiple-rules.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Log:
thinko supporting multiple rules of the same type in in-line merge rulesets
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-10-13 02:27:28 UTC (rev 18302)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-10-13 02:33:59 UTC (rev 18303)
@@ -70,7 +70,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0435'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0436'); -- 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-10-13 02:27:28 UTC (rev 18302)
+++ trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql 2010-10-13 02:33:59 UTC (rev 18303)
@@ -475,10 +475,10 @@
END IF;
END IF;
- add_rule := add_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="a"]/text()',incoming_xml),''),'');
- strip_rule := strip_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="d"]/text()',incoming_xml),''),'');
- replace_rule := replace_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="r"]/text()',incoming_xml),''),'');
- preserve_rule := preserve_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="p"]/text()',incoming_xml),''),'');
+ add_rule := add_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="a"]/text()',incoming_xml),','),'');
+ strip_rule := strip_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="d"]/text()',incoming_xml),','),'');
+ replace_rule := replace_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="r"]/text()',incoming_xml),','),'');
+ preserve_rule := preserve_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="p"]/text()',incoming_xml),','),'');
output.add_rule := BTRIM(add_rule,',');
output.replace_rule := BTRIM(replace_rule,',');
Modified: trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2010-10-13 02:27:28 UTC (rev 18302)
+++ trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2010-10-13 02:33:59 UTC (rev 18303)
@@ -14146,10 +14146,10 @@
END IF;
END IF;
- add_rule := add_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="a"]/text()',incoming_xml),''),'');
- strip_rule := strip_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="d"]/text()',incoming_xml),''),'');
- replace_rule := replace_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="r"]/text()',incoming_xml),''),'');
- preserve_rule := preserve_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="p"]/text()',incoming_xml),''),'');
+ add_rule := add_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="a"]/text()',incoming_xml),','),'');
+ strip_rule := strip_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="d"]/text()',incoming_xml),','),'');
+ replace_rule := replace_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="r"]/text()',incoming_xml),','),'');
+ preserve_rule := preserve_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="p"]/text()',incoming_xml),','),'');
output.add_rule := BTRIM(add_rule,',');
output.replace_rule := BTRIM(replace_rule,',');
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0436.schema.multiple-rules.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0436.schema.multiple-rules.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0436.schema.multiple-rules.sql 2010-10-13 02:33:59 UTC (rev 18303)
@@ -0,0 +1,50 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0436'); -- miker
+
+CREATE OR REPLACE FUNCTION vandelay.compile_profile ( incoming_xml TEXT ) RETURNS vandelay.compile_profile AS $_$
+DECLARE
+ output vandelay.compile_profile%ROWTYPE;
+ profile vandelay.merge_profile%ROWTYPE;
+ profile_tmpl TEXT;
+ profile_tmpl_owner TEXT;
+ add_rule TEXT := '';
+ strip_rule TEXT := '';
+ replace_rule TEXT := '';
+ preserve_rule TEXT := '';
+
+BEGIN
+
+ profile_tmpl := (oils_xpath('//*[@tag="905"]/*[@code="t"]/text()',incoming_xml))[1];
+ profile_tmpl_owner := (oils_xpath('//*[@tag="905"]/*[@code="o"]/text()',incoming_xml))[1];
+
+ IF profile_tmpl IS NOT NULL AND profile_tmpl <> '' AND profile_tmpl_owner IS NOT NULL AND profile_tmpl_owner <> '' THEN
+ SELECT p.* INTO profile
+ FROM vandelay.merge_profile p
+ JOIN actor.org_unit u ON (u.id = p.owner)
+ WHERE p.name = profile_tmpl
+ AND u.shortname = profile_tmpl_owner;
+
+ IF profile.id IS NOT NULL THEN
+ add_rule := COALESCE(profile.add_spec,'');
+ strip_rule := COALESCE(profile.strip_spec,'');
+ replace_rule := COALESCE(profile.replace_spec,'');
+ preserve_rule := COALESCE(profile.preserve_spec,'');
+ END IF;
+ END IF;
+
+ add_rule := add_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="a"]/text()',incoming_xml),','),'');
+ strip_rule := strip_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="d"]/text()',incoming_xml),','),'');
+ replace_rule := replace_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="r"]/text()',incoming_xml),','),'');
+ preserve_rule := preserve_rule || ',' || COALESCE(ARRAY_TO_STRING(oils_xpath('//*[@tag="905"]/*[@code="p"]/text()',incoming_xml),','),'');
+
+ output.add_rule := BTRIM(add_rule,',');
+ output.replace_rule := BTRIM(replace_rule,',');
+ output.strip_rule := BTRIM(strip_rule,',');
+ output.preserve_rule := BTRIM(preserve_rule,',');
+
+ RETURN output;
+END;
+$_$ LANGUAGE PLPGSQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list