From d71e6ab8c7ec1fb9bd1201046fd0aacafeae5daa 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 --- 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 f4127c2098..1be4e71861 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4958,6 +4958,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 a6edeb935b..b67218695d 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -648,4 +648,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