From: Mike Rylander Date: Tue, 6 Sep 2011 20:28:55 +0000 (-0400) Subject: Stamp upgrade for generic mapping index normalizer X-Git-Tag: sprint4-merge-nov22~5167 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a09ba5cdfeba633714e6c79e1c6d8e1c992c0e7d;p=working%2FEvergreen.git Stamp upgrade for generic mapping index normalizer Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 1e5427f5f9..5c4cd1e4d1 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -86,7 +86,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 ('0614', :eg_version); -- miker/phasefx +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0615', :eg_version); -- miker/berick CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql b/Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql new file mode 100644 index 0000000000..3c63dcfb91 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql @@ -0,0 +1,43 @@ +-- Evergreen DB patch XXXX.schema.generic-mapping-index-normalizer.sql +-- +BEGIN; + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('0615', :eg_version); + +-- evergreen.generic_map_normalizer + +CREATE OR REPLACE FUNCTION evergreen.generic_map_normalizer ( TEXT, TEXT ) RETURNS TEXT AS $f$ +my $string = shift; +my %map; + +my $default = $string; + +$_ = shift; +while (/^\s*?(.*?)\s*?=>\s*?(\S+)\s*/) { + if ($1 eq '') { + $default = $2; + } else { + $map{$2} = [split(/\s*,\s*/, $1)]; + } + $_ = $'; +} + +for my $key ( keys %map ) { + return $key if (grep { $_ eq $string } @{ $map{$key} }); +} + +return $default; + +$f$ LANGUAGE PLPERLU; + +-- evergreen.generic_map_normalizer + +INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES ( + 'Generic Mapping Normalizer', + 'Map values or sets of values to new values', + 'generic_map_normalizer', + 1 +); + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.generic-mapping-index-normalizer.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.generic-mapping-index-normalizer.sql deleted file mode 100644 index d7239fd6c5..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.generic-mapping-index-normalizer.sql +++ /dev/null @@ -1,43 +0,0 @@ --- Evergreen DB patch XXXX.schema.generic-mapping-index-normalizer.sql --- -BEGIN; - --- check whether patch can be applied -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - --- evergreen.generic_map_normalizer - -CREATE OR REPLACE FUNCTION evergreen.generic_map_normalizer ( TEXT, TEXT ) RETURNS TEXT AS $f$ -my $string = shift; -my %map; - -my $default = $string; - -$_ = shift; -while (/^\s*?(.*?)\s*?=>\s*?(\S+)\s*/) { - if ($1 eq '') { - $default = $2; - } else { - $map{$2} = [split(/\s*,\s*/, $1)]; - } - $_ = $'; -} - -for my $key ( keys %map ) { - return $key if (grep { $_ eq $string } @{ $map{$key} }); -} - -return $default; - -$f$ LANGUAGE PLPERLU; - --- evergreen.generic_map_normalizer - -INSERT INTO config.index_normalizer (name, description, func, param_count) VALUES ( - 'Generic Mapping Normalizer', - 'Map values or sets of values to new values', - 'generic_map_normalizer', - 1 -); - -COMMIT;