Z39.50 Batch Search/Overlay : SQL / IDL
authorBill Erickson <berick@esilibrary.com>
Wed, 30 Jan 2013 20:08:47 +0000 (15:08 -0500)
committerDan Wells <dbw2@calvin.edu>
Fri, 7 Jun 2013 18:52:25 +0000 (14:52 -0400)
 * DB table for Z39.50 index field maps, which link Z39 search fields to
   indexed bib data via metabib fields and record attributes (svf)

 * Seed data for Z39.50 batch search org unit settings
  ** cat.z3950.batch.max_parallel
  ** cat.z3950.batch.max_results

 * Stock seed data for config.z3950_index_field_map entries

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.z39-batch-fetch-overlay.sql [new file with mode: 0644]

index 122e044..8e69bbd 100644 (file)
@@ -966,6 +966,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
         </permacrud>
     </class>
 
         </permacrud>
     </class>
 
+    <class id="czifm" controller="open-ils.cstore open-ils.pcrud" 
+                       oils_obj:fieldmapper="config::z3950_index_field_map" 
+                       oils_persist:tablename="config.z3950_index_field_map" 
+                       reporter:label="Z39.50 Index Field Map">
+        <fields oils_persist:primary="id" oils_persist:sequence="config.z3950_index_field_map_id_seq">
+            <field reporter:label="Map ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="Label" name="label" reporter:datatype="text" oils_persist:i18n="true"/>
+            <field reporter:label="Metabib Field" name="metabib_field" reporter:datatype="link"/>
+            <field reporter:label="Record Attribute" name="record_attr" reporter:datatype="link"/>
+            <field reporter:label="Z39.50 Attribute" name="z3950_attr"  reporter:datatype="link"/>
+            <field reporter:label="Z39.50 Attribute Type" name="z3950_attr_type" reporter:datatype="text"/>
+        </fields>
+        <links>
+            <link field="metabib_field" reltype="has_a" key="id" map="" class="cmf"/>
+            <link field="record_attr" reltype="has_a" key="id" map="" class="crad"/>
+            <link field="z3950_attr" reltype="has_a" key="id" map="" class="cza"/>
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="ADMIN_Z3950_SOURCE" global_required="true"/>
+                <retrieve/>
+                <update permission="ADMIN_Z3950_SOURCE" global_required="true"/>
+                <delete permission="ADMIN_Z3950_SOURCE" global_required="true"/>
+            </actions>
+        </permacrud>
+    </class>
+
+
        <class id="ateo" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action_trigger::event_output" oils_persist:tablename="action_trigger.event_output" reporter:label="Event Output">
                <fields oils_persist:primary="id" oils_persist:sequence="action_trigger.event_output_id_seq">
                        <field reporter:label="Output ID" name="id" reporter:datatype="id"/>
        <class id="ateo" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action_trigger::event_output" oils_persist:tablename="action_trigger.event_output" reporter:label="Event Output">
                <fields oils_persist:primary="id" oils_persist:sequence="action_trigger.event_output_id_seq">
                        <field reporter:label="Output ID" name="id" reporter:datatype="id"/>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.z39-batch-fetch-overlay.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.z39-batch-fetch-overlay.sql
new file mode 100644 (file)
index 0000000..5e65faf
--- /dev/null
@@ -0,0 +1,53 @@
+BEGIN;
+
+-- TODO version check
+
+CREATE OR REPLACE FUNCTION 
+    evergreen.z3950_name_is_valid(TEXT) RETURNS BOOLEAN AS $func$
+    SELECT EXISTS (SELECT 1 FROM config.z3950_attr WHERE name = $1);
+$func$ LANGUAGE SQL STRICT IMMUTABLE;
+
+
+CREATE TABLE config.z3950_index_field_map (
+    id              SERIAL  PRIMARY KEY,
+    label           TEXT    NOT NULL, -- i18n
+    metabib_field   INTEGER REFERENCES config.metabib_field(id),
+    record_attr     TEXT    REFERENCES config.record_attr_definition(name),
+    z3950_attr      INTEGER REFERENCES config.z3950_attr(id),
+    z3950_attr_type TEXT,-- REFERENCES config.z3950_attr(name)
+    CONSTRAINT metabib_field_or_record_attr CHECK (
+        metabib_field IS NOT NULL OR 
+        record_attr IS NOT NULL
+    ),
+    CONSTRAINT attr_or_attr_type CHECK (
+        z3950_attr IS NOT NULL OR 
+        z3950_attr_type IS NOT NULL
+    ),
+    -- ensure the selected z3950_attr_type refers to a valid attr name
+    CONSTRAINT valid_z3950_attr_type CHECK (
+        z3950_attr_type IS NULL OR 
+            evergreen.z3950_name_is_valid(z3950_attr_type)
+    )
+);
+
+
+-- seed data
+
+INSERT INTO config.z3950_index_field_map 
+    (id, label, metabib_field, z3950_attr_type) VALUES 
+(1, oils_i18n_gettext(1, 'Title',   'czifm', 'label'), 5,  'title'),
+(2, oils_i18n_gettext(2, 'Author',  'czifm', 'label'), 8,  'author'),
+(3, oils_i18n_gettext(3, 'ISBN',    'czifm', 'label'), 18, 'isbn'),
+(4, oils_i18n_gettext(4, 'ISSN',    'czifm', 'label'), 19, 'issn'),
+(5, oils_i18n_gettext(5, 'LCCN',    'czifm', 'label'), 30, 'lccn');
+
+INSERT INTO config.z3950_index_field_map 
+    (id, label, record_attr, z3950_attr_type) VALUES 
+(6, oils_i18n_gettext(6, 'Pubdate',  'czifm', 'label'),'pubdate', 'pubdate'),
+(7, oils_i18n_gettext(7, 'Item Type', 'czifm', 'label'),'item_type', 'item_type');
+
+
+-- let's leave room for more stock mappings
+SELECT SETVAL('config.z3950_index_field_map_id_seq'::TEXT, 1000);
+
+COMMIT;