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