]> git.evergreen-ils.org Git - Evergreen.git/commit
Generic mapping index normalizer
authorBill Erickson <berick@esilibrary.com>
Tue, 6 Sep 2011 15:54:47 +0000 (11:54 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 6 Sep 2011 20:25:11 +0000 (16:25 -0400)
commit7ce222513d4610c7c978d283933f5dfa6555f14b
tree0ba6df80ad0737033aac5dcdffd6c6f830e16f07
parenta3244fbba42815b8a0edd23c1d270ab1af2d791c
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@gmail.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/999.functions.global.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.generic-mapping-index-normalizer.sql [new file with mode: 0644]