From: Mike Rylander Date: Thu, 14 Nov 2013 21:43:31 +0000 (-0500) Subject: LP#1251394 un-squash repeated fields; some minor schema re-alignment X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9d57def5f515dc7aa9ef11a02f016e6fe8a33b17;p=Evergreen.git LP#1251394 un-squash repeated fields; some minor schema re-alignment Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 0a0ba47300..a1ab64f722 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2837,6 +2837,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -3719,7 +3720,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + reporter:label="Display Field Entry" oils_persist:readonly="true"> @@ -3738,7 +3739,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + reporter:label="Flat Display Field Entry View" oils_persist:readonly="true"> SELECT mde.source, diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index ba48febe0b..e8f3f24673 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -209,6 +209,7 @@ CREATE TABLE config.metabib_field ( browse_xpath TEXT, browse_sort_xpath TEXT, facet_xpath TEXT, + display_xpath TEXT, authority_xpath TEXT, joiner TEXT, restrict BOOL DEFAULT FALSE NOT NULL, diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index 535945a431..c9935bae2d 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -192,8 +192,6 @@ CREATE TABLE metabib.display_entry ( CREATE INDEX metabib_display_entry_field_idx ON metabib.display_entry (field); -CREATE INDEX metabib_display_entry_value_idx - ON metabib.display_entry (SUBSTRING(value,1,1024)); CREATE INDEX metabib_display_entry_source_idx ON metabib.display_entry (source); @@ -778,6 +776,25 @@ BEGIN output_row.facet_field = FALSE; END IF; + -- insert raw node text for display + IF idx.display_field THEN + + IF idx.display_xpath IS NOT NULL AND idx.display_xpath <> '' THEN + display_text := oils_xpath_string( idx.display_xpath, xml_node, joiner, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] ); + ELSE + display_text := curr_text; + END IF; + + output_row.field_class = idx.field_class; + output_row.field = -1 * idx.id; + output_row.source = rid; + output_row.value = BTRIM(REGEXP_REPLACE(display_text, E'\\s+', ' ', 'g')); + + output_row.display_field = TRUE; + RETURN NEXT output_row; + output_row.display_field = FALSE; + END IF; + END LOOP; CONTINUE WHEN raw_text IS NULL OR raw_text = ''; @@ -794,17 +811,6 @@ BEGIN output_row.search_field = FALSE; END IF; - IF idx.display_field THEN - output_row.field_class = idx.field_class; - output_row.field = idx.id; - output_row.source = rid; - output_row.value = BTRIM(REGEXP_REPLACE(raw_text, E'\\s+', ' ', 'g')); - - output_row.display_field = TRUE; - RETURN NEXT output_row; - output_row.display_field = FALSE; - END IF; - END LOOP; END; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql index be67728298..9d20e593c9 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql @@ -1,6 +1,9 @@ BEGIN; +ALTER TABLE config.metabib_field ADD COLUMN display_xpath TEXT, display_field BOOL NOT NULL DEFAULT TRUE; +UPDATE config.metabib_field SET display_field = FALSE WHERE field_class = 'keyword' OR name = 'complete'; + CREATE TABLE metabib.display_entry ( id BIGSERIAL PRIMARY KEY, source BIGINT NOT NULL, @@ -10,8 +13,6 @@ CREATE TABLE metabib.display_entry ( CREATE INDEX metabib_display_entry_field_idx ON metabib.display_entry (field); -CREATE INDEX metabib_display_entry_value_idx - ON metabib.display_entry (SUBSTRING(value,1,1024)); CREATE INDEX metabib_display_entry_source_idx ON metabib.display_entry (source); @@ -238,6 +239,25 @@ BEGIN output_row.facet_field = FALSE; END IF; + -- insert raw node text for display + IF idx.display_field THEN + + IF idx.display_xpath IS NOT NULL AND idx.display_xpath <> '' THEN + display_text := oils_xpath_string( idx.display_xpath, xml_node, joiner, ARRAY[ARRAY[xfrm.prefix, xfrm.namespace_uri]] ); + ELSE + display_text := curr_text; + END IF; + + output_row.field_class = idx.field_class; + output_row.field = -1 * idx.id; + output_row.source = rid; + output_row.value = BTRIM(REGEXP_REPLACE(display_text, E'\\s+', ' ', 'g')); + + output_row.display_field = TRUE; + RETURN NEXT output_row; + output_row.display_field = FALSE; + END IF; + END LOOP; CONTINUE WHEN raw_text IS NULL OR raw_text = ''; @@ -254,17 +274,6 @@ BEGIN output_row.search_field = FALSE; END IF; - IF idx.display_field THEN - output_row.field_class = idx.field_class; - output_row.field = idx.id; - output_row.source = rid; - output_row.value = BTRIM(REGEXP_REPLACE(raw_text, E'\\s+', ' ', 'g')); - - output_row.display_field = TRUE; - RETURN NEXT output_row; - output_row.display_field = FALSE; - END IF; - END LOOP; END;