</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"/>
-- TODO version check
-CREATE TABLE config.z3950_metabib_field_map (
+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),
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_metabib_field_map
+INSERT INTO config.z3950_index_field_map
(id, label, metabib_field, z3950_attr_type) VALUES
-(1, oils_i18n_gettext(1, 'Title', 'czmfm', 'label'), 5, 'title'),
-(2, oils_i18n_gettext(2, 'Author', 'czmfm', 'label'), 8, 'author'),
-(3, oils_i18n_gettext(3, 'ISBN', 'czmfm', 'label'), 18, 'isbn'),
-(4, oils_i18n_gettext(4, 'ISSN', 'czmfm', 'label'), 19, 'issn'),
-(5, oils_i18n_gettext(5, 'LCCN', 'czmfm', 'label'), 30, 'lccn');
+(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_metabib_field_map
+INSERT INTO config.z3950_index_field_map
(id, label, record_attr, z3950_attr_type) VALUES
-(6, oils_i18n_gettext(6, 'Pubdate', 'czmfm', 'label'),'pubdate', 'pubdate'),
-(7, oils_i18n_gettext(7, 'Item Type', 'czmfm', 'label'),'item_type', 'item_type');
+(6, oils_i18n_gettext(6, 'Pubdate', 'czifm', 'label'),'pubdate', 'pubdate'),
+(7, oils_i18n_gettext(7, 'Item Type', 'czifm', 'label'),'item_type', 'item_type');
COMMIT;