LP#1251394 un-squash repeated fields; some minor schema re-alignment
authorMike Rylander <mrylander@gmail.com>
Thu, 14 Nov 2013 21:43:31 +0000 (16:43 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 1 Sep 2017 21:17:47 +0000 (17:17 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/030.schema.metabib.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.metabib-display-field.sql

index 0a0ba47..a1ab64f 100644 (file)
@@ -2837,6 +2837,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Search Field" name="search_field" reporter:datatype="bool" />
                        <field reporter:label="Facet Field" name="facet_field" reporter:datatype="bool" />
                        <field reporter:label="Facet XPath" name="facet_xpath" reporter:datatype="text" />
+                       <field reporter:label="Display XPath" name="display_xpath" reporter:datatype="text" />
                        <field reporter:label="Browse Field" name="browse_field" reporter:datatype="bool" />
                        <field reporter:label="Browse XPath" name="browse_xpath" reporter:datatype="text" />
                        <field reporter:label="Restrict?" name="restrict" reporter:datatype="bool" />
@@ -3719,7 +3720,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
        <class id="mde" controller="open-ils.cstore open-ils.pcrud" 
                        oils_obj:fieldmapper="metabib::display_entry" 
                        oils_persist:tablename="metabib.display_entry" 
-                       reporter:label="Combined display Entry" oils_persist:readonly="true">
+                       reporter:label="Display Field Entry" oils_persist:readonly="true">
                <fields oils_persist:primary="id" oils_persist:sequence="metabib.display_entry_id_seq">
                        <field name="id" reporter:datatype="id" />
                        <field name="field" reporter:datatype="link"/>
@@ -3738,7 +3739,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
        </class>
        <class id="mfde" controller="open-ils.cstore open-ils.pcrud" 
                oils_obj:fieldmapper="metabib::flat_display_entry" 
-               reporter:label="Flat Display Entry View" oils_persist:readonly="true">
+               reporter:label="Flat Display Field Entry View" oils_persist:readonly="true">
                <oils_persist:source_definition>
                        SELECT 
                                mde.source, 
index ba48feb..e8f3f24 100644 (file)
@@ -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,
index 535945a..c9935ba 100644 (file)
@@ -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;
index be67728..9d20e59 100644 (file)
@@ -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;