From 43999e0c9c6c6334e6c5e7b70a9c4c43327a5844 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 19 Mar 2012 16:30:52 -0400 Subject: [PATCH] Custom Org Tree : DB and IDL Support for building custom org unit hierarchies for display purposes. Initially, this is meant to support custom OPAC trees, but the design leaves from for other types of trees. The only restrictions to custom org trees is that no org unit appear more once and that they in fact be tree-shaped. Otherwise, any node can be the parent/child of any other node, regardless of ou_type, etc. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/examples/fm_IDL.xml | 39 ++++++++++++++++++++++ Open-ILS/src/sql/Pg/005.schema.actors.sql | 16 +++++++++ .../XXXX.schema.org_unit_opac_vis_and_sorting.sql | 21 ++++++++++++ 3 files changed, 76 insertions(+) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index c9357baab5..10b58372de 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4984,6 +4984,45 @@ SELECT usr, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index 4f9f39b49e..21363b966b 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -665,4 +665,20 @@ CREATE UNIQUE INDEX label_once_per_ws ON actor.toolbar (ws, label) WHERE ws IS N CREATE UNIQUE INDEX label_once_per_org ON actor.toolbar (org, label) WHERE org IS NOT NULL; CREATE UNIQUE INDEX label_once_per_usr ON actor.toolbar (usr, label) WHERE usr IS NOT NULL; +CREATE TYPE actor.org_unit_custom_tree_purpose AS ENUM ('opac'); +CREATE TABLE actor.org_unit_custom_tree ( + id SERIAL PRIMARY KEY, + active BOOLEAN DEFAULT FALSE, + purpose actor.org_unit_custom_tree_purpose NOT NULL DEFAULT 'opac' UNIQUE +); + +CREATE TABLE actor.org_unit_custom_tree_node ( + id SERIAL PRIMARY KEY, + tree INTEGER REFERENCES actor.org_unit_custom_tree (id) DEFERRABLE INITIALLY DEFERRED, + org_unit INTEGER NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, + parent_node INTEGER REFERENCES actor.org_unit_custom_tree_node (id) DEFERRABLE INITIALLY DEFERRED, + sibling_order INTEGER NOT NULL DEFAULT 0, + CONSTRAINT aouctn_once_per_org UNIQUE (tree, org_unit) +); + COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql index 115613ab6f..fd1c0023b8 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql @@ -14,11 +14,32 @@ INSERT INTO config.global_flag (name, enabled, label) ) ); +CREATE TYPE actor.org_unit_custom_tree_purpose AS ENUM ('opac'); + +CREATE TABLE actor.org_unit_custom_tree ( + id SERIAL PRIMARY KEY, + active BOOLEAN DEFAULT FALSE, + purpose actor.org_unit_custom_tree_purpose NOT NULL DEFAULT 'opac' UNIQUE +); + +CREATE TABLE actor.org_unit_custom_tree_node ( + id SERIAL PRIMARY KEY, + tree INTEGER REFERENCES actor.org_unit_custom_tree (id) DEFERRABLE INITIALLY DEFERRED, + org_unit INTEGER NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, + parent_node INTEGER REFERENCES actor.org_unit_custom_tree_node (id) DEFERRABLE INITIALLY DEFERRED, + sibling_order INTEGER NOT NULL DEFAULT 0, + CONSTRAINT aouctn_once_per_org UNIQUE (tree, org_unit) +); + + COMMIT; /* UNDO BEGIN; DELETE FROM config.global_flag WHERE name = 'opac.org_unit.non_inheritied_visibility'; +DROP TABLE actor.org_unit_custom_tree_node; +DROP TABLE actor.org_unit_custom_tree; +DROP TYPE actor.org_unit_custom_tree_purpose; COMMIT; */ -- 2.11.0