]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.schema.z39-batch-fetch-overlay.sql
Z39.50 Batch Search/Overlay Seed Data
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.schema.z39-batch-fetch-overlay.sql
1 BEGIN;
2
3 -- TODO version check
4
5 CREATE OR REPLACE FUNCTION 
6     evergreen.z3950_name_is_valid(TEXT) RETURNS BOOLEAN AS $func$
7     SELECT EXISTS (SELECT 1 FROM config.z3950_attr WHERE name = $1);
8 $func$ LANGUAGE SQL STRICT IMMUTABLE;
9
10
11 CREATE TABLE config.z3950_index_field_map (
12     id              SERIAL  PRIMARY KEY,
13     label           TEXT    NOT NULL, -- i18n
14     metabib_field   INTEGER REFERENCES config.metabib_field(id),
15     record_attr     TEXT    REFERENCES config.record_attr_definition(name),
16     z3950_attr      INTEGER REFERENCES config.z3950_attr(id),
17     z3950_attr_type TEXT,-- REFERENCES config.z3950_attr(name)
18     CONSTRAINT metabib_field_or_record_attr CHECK (
19         metabib_field IS NOT NULL OR 
20         record_attr IS NOT NULL
21     ),
22     CONSTRAINT attr_or_attr_type CHECK (
23         z3950_attr IS NOT NULL OR 
24         z3950_attr_type IS NOT NULL
25     ),
26     -- ensure the selected z3950_attr_type refers to a valid attr name
27     CONSTRAINT valid_z3950_attr_type CHECK (
28         z3950_attr_type IS NULL OR 
29             evergreen.z3950_name_is_valid(z3950_attr_type)
30     )
31 );
32
33 -- seed data
34
35 INSERT INTO config.z3950_index_field_map 
36     (id, label, metabib_field, z3950_attr_type) VALUES 
37 (1, oils_i18n_gettext(1, 'Title',   'czifm', 'label'), 5,  'title'),
38 (2, oils_i18n_gettext(2, 'Author',  'czifm', 'label'), 8,  'author'),
39 (3, oils_i18n_gettext(3, 'ISBN',    'czifm', 'label'), 18, 'isbn'),
40 (4, oils_i18n_gettext(4, 'ISSN',    'czifm', 'label'), 19, 'issn'),
41 (5, oils_i18n_gettext(5, 'LCCN',    'czifm', 'label'), 30, 'lccn');
42
43 INSERT INTO config.z3950_index_field_map 
44     (id, label, record_attr, z3950_attr_type) VALUES 
45 (6, oils_i18n_gettext(6, 'Pubdate',  'czifm', 'label'),'pubdate', 'pubdate'),
46 (7, oils_i18n_gettext(7, 'Item Type', 'czifm', 'label'),'item_type', 'item_type');
47
48
49 -- let's leave room for more stock mappings
50 SELECT SETVAL('config.z3950_index_field_map_id_seq'::TEXT, 1000);
51
52 INSERT INTO config.org_unit_setting_type
53     (name, grp, label, description, datatype)
54     VALUES (
55         'cat.z3950.batch.max_parallel',
56         'cat',
57         oils_i18n_gettext(
58             'cat.z3950.batch.max_parallel',
59             'Maximum Parallel Z39.50 Batch Searches',
60             'coust',
61             'label'
62         ),
63         oils_i18n_gettext(
64             'cat.z3950.batch.max_parallel',
65             'The maximum number of Z39.50 searches that can be in-flight at any given time when performing batch Z39.50 searches',
66             'coust',
67             'description'
68         ),
69         'integer'
70     );
71
72 INSERT INTO config.org_unit_setting_type
73     (name, grp, label, description, datatype)
74     VALUES (
75         'cat.z3950.batch.max_results',
76         'cat',
77         oils_i18n_gettext(
78             'cat.z3950.batch.max_results',
79             'Maximum Z39.50 Batch Search Results',
80             'coust',
81             'label'
82         ),
83         oils_i18n_gettext(
84             'cat.z3950.batch.max_results',
85             'The maximum number of search results to retrieve and queue for each record + Z39 source during batch Z39.50 searches',
86             'coust',
87             'description'
88         ),
89         'integer'
90     );
91
92 INSERT INTO vandelay.bib_attr_definition (id, code, description, xpath) 
93     VALUES (
94         16, 
95         'zsource',
96         oils_i18n_gettext(16, 'Z39.50 Source', 'vqbrad', 'description'),
97         '//*[@tag="901"]/*[@code="z"]'
98     );
99
100
101
102 COMMIT;