3 INSERT INTO config.upgrade_log (version) VALUES ('0504'); -- miker
5 CREATE TABLE biblio.monograph_part (
7 record BIGINT NOT NULL REFERENCES biblio.record_entry (id),
9 label_sortkey TEXT NOT NULL,
10 CONSTRAINT record_label_unique UNIQUE (record,label)
13 CREATE OR REPLACE FUNCTION biblio.normalize_biblio_monograph_part_sortkey () RETURNS TRIGGER AS $$
15 NEW.label_sortkey := REGEXP_REPLACE(
16 lpad_number_substrings(
17 naco_normalize(NEW.label),
29 CREATE TRIGGER norm_sort_label BEFORE INSERT OR UPDATE ON biblio.monograph_part FOR EACH ROW EXECUTE PROCEDURE biblio.normalize_biblio_monograph_part_sortkey();
31 CREATE TABLE asset.copy_part_map (
32 id SERIAL PRIMARY KEY,
33 target_copy BIGINT NOT NULL, -- points o asset.copy
34 part INT NOT NULL REFERENCES biblio.monograph_part (id) ON DELETE CASCADE
36 CREATE UNIQUE INDEX copy_part_map_cp_part_idx ON asset.copy_part_map (target_copy, part);
38 CREATE OR REPLACE FUNCTION asset.normalize_affix_sortkey () RETURNS TRIGGER AS $$
40 NEW.label_sortkey := REGEXP_REPLACE(
41 lpad_number_substrings(
42 naco_normalize(NEW.label),
54 CREATE TABLE asset.call_number_prefix (
55 id SERIAL PRIMARY KEY,
56 owning_lib INT NOT NULL REFERENCES actor.org_unit (id),
57 label TEXT NOT NULL, -- i18n
60 CREATE TRIGGER prefix_normalize_tgr BEFORE INSERT OR UPDATE ON asset.call_number_prefix FOR EACH ROW EXECUTE PROCEDURE asset.normalize_affix_sortkey();
61 CREATE UNIQUE INDEX asset_call_number_prefix_once_per_lib ON asset.call_number_prefix (label, owning_lib);
62 CREATE INDEX asset_call_number_prefix_sortkey_idx ON asset.call_number_prefix (label_sortkey);
64 CREATE TABLE asset.call_number_suffix (
65 id SERIAL PRIMARY KEY,
66 owning_lib INT NOT NULL REFERENCES actor.org_unit (id),
67 label TEXT NOT NULL, -- i18n
70 CREATE TRIGGER suffix_normalize_tgr BEFORE INSERT OR UPDATE ON asset.call_number_suffix FOR EACH ROW EXECUTE PROCEDURE asset.normalize_affix_sortkey();
71 CREATE UNIQUE INDEX asset_call_number_suffix_once_per_lib ON asset.call_number_suffix (label, owning_lib);
72 CREATE INDEX asset_call_number_suffix_sortkey_idx ON asset.call_number_suffix (label_sortkey);
74 INSERT INTO asset.call_number_suffix (id, owning_lib, label) VALUES (-1, 1, '');
75 INSERT INTO asset.call_number_prefix (id, owning_lib, label) VALUES (-1, 1, '');
77 DROP INDEX IF EXISTS asset.asset_call_number_label_once_per_lib;
79 ALTER TABLE asset.call_number
80 ADD COLUMN prefix INT NOT NULL DEFAULT -1 REFERENCES asset.call_number_prefix(id) DEFERRABLE INITIALLY DEFERRED,
81 ADD COLUMN suffix INT NOT NULL DEFAULT -1 REFERENCES asset.call_number_suffix(id) DEFERRABLE INITIALLY DEFERRED;
83 CREATE UNIQUE INDEX asset_call_number_label_once_per_lib ON asset.call_number (record, owning_lib, label, prefix, suffix) WHERE deleted = FALSE OR deleted IS FALSE;
85 INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
86 'ui.cat.volume_copy_editor.horizontal',
88 'ui.cat.volume_copy_editor.horizontal',
89 'GUI: Horizontal layout for Volume/Copy Creator/Editor.',
92 'ui.cat.volume_copy_editor.horizontal',
93 'The main entry point for this interface is in Holdings Maintenance, Actions for Selected Rows, Edit Item Attributes / Call Numbers / Replace Barcodes. This setting changes the top and bottom panes for that interface into left and right panes.',
94 'coust', 'description'),
99 CREATE OR REPLACE FUNCTION unapi.bmp ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit INT DEFAULT NULL, soffset INT DEFAULT NULL ) RETURNS XML AS $F$
103 'http://open-ils.org/spec/holdings/v1' AS xmlns,
104 'tag:open-ils.org:U2@bmp/' || id AS id,
108 'tag:open-ils.org:U2@bre/' || record AS record
111 WHEN ('acp' = ANY ($4)) THEN
112 XMLELEMENT( name copies,
113 (SELECT XMLAGG(acp) FROM (
114 SELECT unapi.acp( cp.id, 'xml', 'copy', array_remove_item_by_value($4,'bmp'), $5, $6, $7, $8)
116 JOIN asset.copy_part_map cpm ON (cpm.target_copy = cp.id)
118 ORDER BY COALESCE(cp.copy_number,0), cp.barcode
125 CASE WHEN ('bre' = ANY ($4)) THEN unapi.bre( record, 'marcxml', 'record', array_remove_item_by_value($4,'bmp'), $5, $6, $7, $8) ELSE NULL END
127 FROM biblio.monograph_part
129 GROUP BY id, label, label_sortkey, record;
132 CREATE OR REPLACE FUNCTION unapi.acnp ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit INT DEFAULT NULL, soffset INT DEFAULT NULL ) RETURNS XML AS $F$
134 name call_number_prefix,
136 'http://open-ils.org/spec/holdings/v1' AS xmlns,
141 unapi.aou( owning_lib, $2, 'owning_lib', array_remove_item_by_value($4,'acnp'), $5, $6, $7, $8)
143 FROM asset.call_number_prefix
147 CREATE OR REPLACE FUNCTION unapi.acns ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit INT DEFAULT NULL, soffset INT DEFAULT NULL ) RETURNS XML AS $F$
149 name call_number_suffix,
151 'http://open-ils.org/spec/holdings/v1' AS xmlns,
156 unapi.aou( owning_lib, $2, 'owning_lib', array_remove_item_by_value($4,'acns'), $5, $6, $7, $8)
158 FROM asset.call_number_suffix
162 CREATE OR REPLACE FUNCTION unapi.holdings_xml (bid BIGINT, ouid INT, org TEXT, depth INT DEFAULT NULL, includes TEXT[] DEFAULT NULL::TEXT[], slimit INT DEFAULT NULL, soffset INT DEFAULT NULL) RETURNS XML AS $F$
166 'http://open-ils.org/spec/holdings/v1' AS xmlns,
167 CASE WHEN ('bre' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN 'tag:open-ils.org:U2@bre/' || $1 || '/' || $3 ELSE NULL END AS id
171 (SELECT XMLAGG(XMLELEMENT::XML) FROM (
174 XMLATTRIBUTES('public' as type, depth, org_unit, coalesce(transcendant,0) as transcendant, available, visible as count, unshadow)
176 FROM asset.opac_ou_record_copy_count($2, $1)
180 XMLATTRIBUTES('staff' as type, depth, org_unit, coalesce(transcendant,0) as transcendant, available, visible as count, unshadow)
182 FROM asset.staff_ou_record_copy_count($2, $1)
187 WHEN ('bmp' = ANY ($5)) THEN
188 XMLELEMENT( name monograph_parts,
189 XMLAGG((SELECT unapi.bmp( id, 'xml', 'monograph_part', array_remove_item_by_value( array_remove_item_by_value($5,'bre'), 'holdings_xml'), $3, $4, $6, $7) FROM biblio.monograph_part WHERE record = $1))
193 CASE WHEN ('acn' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN
196 (SELECT XMLAGG(acn) FROM (
197 SELECT unapi.acn(acn.id,'xml','volume',array_remove_item_by_value(array_remove_item_by_value('{acn,auri}'::TEXT[] || $5,'holdings_xml'),'bre'), $3, $4, $6, $7)
198 FROM asset.call_number acn
199 WHERE acn.record = $1
203 JOIN actor.org_unit_descendants(
208 FROM actor.org_unit_type aout
209 JOIN actor.org_unit aou ON (aou.ou_type = aout.id AND aou.id = $2)
212 ) aoud ON (acp.circ_lib = aoud.id)
215 ORDER BY label_sortkey
221 CASE WHEN ('ssub' = ANY ('{acn,auri}'::TEXT[] || $5)) THEN
224 (SELECT XMLAGG(ssub) FROM (
225 SELECT unapi.ssub(id,'xml','subscription','{}'::TEXT[], $3, $4, $6, $7)
226 FROM serial.subscription
227 WHERE record_entry = $1
234 CREATE OR REPLACE FUNCTION unapi.acp ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit INT DEFAULT NULL, soffset INT DEFAULT NULL ) RETURNS XML AS $F$
238 'http://open-ils.org/spec/holdings/v1' AS xmlns,
239 'tag:open-ils.org:U2@acp/' || id AS id,
240 create_date, edit_date, copy_number, circulate, deposit,
241 ref, holdable, deleted, deposit_amount, price, barcode,
242 circ_modifier, circ_as_type, opac_visible
244 unapi.ccs( status, $2, 'status', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8),
245 unapi.acl( location, $2, 'location', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8),
246 unapi.aou( circ_lib, $2, 'circ_lib', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8),
247 unapi.aou( circ_lib, $2, 'circlib', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8),
248 CASE WHEN ('acn' = ANY ($4)) THEN unapi.acn( call_number, $2, 'call_number', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8) ELSE NULL END,
249 XMLELEMENT( name copy_notes,
251 WHEN ('acpn' = ANY ($4)) THEN
252 XMLAGG((SELECT unapi.acpn( id, 'xml', 'copy_note', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8) FROM asset.copy_note WHERE owning_copy = cp.id AND pub))
256 XMLELEMENT( name statcats,
258 WHEN ('ascecm' = ANY ($4)) THEN
259 XMLAGG((SELECT unapi.ascecm( stat_cat_entry, 'xml', 'statcat', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8) FROM asset.stat_cat_entry_copy_map WHERE owning_copy = cp.id))
264 WHEN ('bmp' = ANY ($4)) THEN
265 XMLELEMENT( name monograph_parts,
266 XMLAGG((SELECT unapi.bmp( part, 'xml', 'monograph_part', array_remove_item_by_value($4,'acp'), $5, $6, $7, $8) FROM asset.copy_part_map WHERE target_copy = cp.id))
273 GROUP BY id, status, location, circ_lib, call_number, create_date, edit_date, copy_number, circulate, deposit, ref, holdable, deleted, deposit_amount, price, barcode, circ_modifier, circ_as_type, opac_visible;
276 CREATE OR REPLACE FUNCTION unapi.acn ( obj_id BIGINT, format TEXT, ename TEXT, includes TEXT[], org TEXT, depth INT DEFAULT NULL, slimit INT DEFAULT NULL, soffset INT DEFAULT NULL ) RETURNS XML AS $F$
280 'http://open-ils.org/spec/holdings/v1' AS xmlns,
281 'tag:open-ils.org:U2@acn/' || acn.id AS id,
283 o.opac_visible AS opac_visible,
284 deleted, label, label_sortkey, label_class, record
286 unapi.aou( owning_lib, $2, 'owning_lib', array_remove_item_by_value($4,'acn'), $5, $6, $7, $8),
287 XMLELEMENT( name copies,
289 WHEN ('acp' = ANY ($4)) THEN
290 (SELECT XMLAGG(acp) FROM (
291 SELECT unapi.acp( cp.id, 'xml', 'copy', array_remove_item_by_value($4,'acn'), $5, $6, $7, $8)
293 JOIN actor.org_unit_descendants(
294 (SELECT id FROM actor.org_unit WHERE shortname = $5),
295 (COALESCE($6,(SELECT aout.depth FROM actor.org_unit_type aout JOIN actor.org_unit aou ON (aou.ou_type = aout.id AND aou.shortname = $5))))
296 ) aoud ON (cp.circ_lib = aoud.id)
297 WHERE cp.call_number = acn.id
298 ORDER BY COALESCE(cp.copy_number,0), cp.barcode
307 (SELECT XMLAGG(auri) FROM (SELECT unapi.auri(uri,'xml','uri', array_remove_item_by_value($4,'acn'), $5, $6, $7, $8) FROM asset.uri_call_number_map WHERE call_number = acn.id)x)
309 CASE WHEN ('acnp' = ANY ($4)) THEN unapi.acnp( acn.prefix, 'marcxml', 'prefix', array_remove_item_by_value($4,'acn'), $5, $6, $7, $8) ELSE NULL END,
310 CASE WHEN ('acns' = ANY ($4)) THEN unapi.acns( acn.suffix, 'marcxml', 'suffix', array_remove_item_by_value($4,'acn'), $5, $6, $7, $8) ELSE NULL END,
311 CASE WHEN ('bre' = ANY ($4)) THEN unapi.bre( acn.record, 'marcxml', 'record', array_remove_item_by_value($4,'acn'), $5, $6, $7, $8) ELSE NULL END
313 FROM asset.call_number acn
314 JOIN actor.org_unit o ON (o.id = acn.owning_lib)
316 GROUP BY acn.id, o.shortname, o.opac_visible, deleted, label, label_sortkey, label_class, owning_lib, record, acn.prefix, acn.suffix;