[open-ils-commits] [GIT] Evergreen ILS branch master updated. a09ba5cdfeba633714e6c79e1c6d8e1c992c0e7d
Evergreen Git
git at git.evergreen-ils.org
Tue Sep 6 16:34:48 EDT 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via a09ba5cdfeba633714e6c79e1c6d8e1c992c0e7d (commit)
via 7ce222513d4610c7c978d283933f5dfa6555f14b (commit)
from a3244fbba42815b8a0edd23c1d270ab1af2d791c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a09ba5cdfeba633714e6c79e1c6d8e1c992c0e7d
Author: Mike Rylander <mrylander at gmail.com>
Date: Tue Sep 6 16:28:55 2011 -0400
Stamp upgrade for generic mapping index normalizer
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 1e5427f..5c4cd1e 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/XXXX.schema.generic-mapping-index-normalizer.sql b/Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql
similarity index 93%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.generic-mapping-index-normalizer.sql
rename to Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql
index d7239fd..3c63dcf 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.generic-mapping-index-normalizer.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql
@@ -3,7 +3,7 @@
BEGIN;
-- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0615', :eg_version);
-- evergreen.generic_map_normalizer
commit 7ce222513d4610c7c978d283933f5dfa6555f14b
Author: Bill Erickson <berick at esilibrary.com>
Date: Tue Sep 6 11:54:47 2011 -0400
Generic mapping index normalizer
Useful for mapping values extracted for SVF (metabib.record_attr.attrs)
attributes to alternate values. For example, you can map collections of
MARC Audience codes into groups of codes for to create audience groups.
This normalizer takes a text parameter (in addition to the extracted value)
that defines a simple mapping between input and output. Each mapping
consists of one or more comma separated strings on the left of a separator
(called the source group), a separator, and a alphanumeric string to the
right of the separator (called the mapping target). The format of a mapping
is:
{string}[,{string}][..]=>{non-whitespace-string}
For example:
a,b,c=>X
Multiple mappings can be supplied, separated by whitespace. Each mapping
itself is not sensitive to most whitespace. For instance, the following
are all equivalent:
a,b,c=>X
a, b, c => X
a , b , c => X
In each, "a", "b" and "c" are mapped to "X", and anything else is returned
without mapping.
Additionionally, whitespace within a string in the source group is tolerated.
Given a mapping of:
a e i o u, y, w => V
The string "a e i o u", "y" or "w" will return "V".
In addition to explicit mapping, an empty source group will produce a default
mapping, where anything not matching another mapping will return the mapping
target. For instance, given the following:
=>X a,b,c=>Y
An input of "b" will return "Y" and an input of "k" will return "X". The
Default mapping target may be the same as the mapping target with an explicit
source group. For instance, the following can be interperated as "map a, b
and c to X, map 1, 2, 3 and anything we don't know about to Y":
a,b,c=>X 1,2,3=>Y =>Y
As a practical example, simplifying the audience values in MARC fixed fields
to three groups and using those values in a new coded value map would allow
one to create a dynamically populated search interface that uses more patron-
friendly terms. For instance:
a,b,j=>K c,d=>T a=>A =>A g=>E
The above makes the assumption that Unknown, Specialized and Not Coded should
be lumped in with Audult, just to be safe, and General is for (E)veryone.
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Bill Erickson <berick at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 8d224e8..d16f77f 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -6045,6 +6045,13 @@ INSERT INTO config.index_normalizer (name, description, func, param_count) VALUE
0
);
+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
+);
+
-- make use of the index normalizers
INSERT INTO config.metabib_field_index_norm_map (field,norm)
diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index 034b9e9..25dfb6a 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1897,3 +1897,29 @@ CREATE TRIGGER ingest_item_trigger
AFTER INSERT OR UPDATE ON vandelay.queued_bib_record
FOR EACH ROW EXECUTE PROCEDURE vandelay.ingest_bib_items();
+
+-- 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;
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
new file mode 100644
index 0000000..d7239fd
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.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('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;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/950.data.seed-values.sql | 7 +++
Open-ILS/src/sql/Pg/999.functions.global.sql | 26 ++++++++++++
...615.schema.generic-mapping-index-normalizer.sql | 43 ++++++++++++++++++++
4 files changed, 77 insertions(+), 1 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0615.schema.generic-mapping-index-normalizer.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list