From f372ad57932c7f1e0d2d0a8920d7e9b50df84b75 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 28 Mar 2014 13:04:34 -0400 Subject: [PATCH] Make circ rule owing org units array-able Signed-off-by: Mike Rylander --- Open-ILS/examples/fm_IDL.xml | 2 +- Open-ILS/src/sql/Pg/100.circ_matrix.sql | 39 ++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index adfcd2eb15..a485933fbd 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1719,7 +1719,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/src/sql/Pg/100.circ_matrix.sql b/Open-ILS/src/sql/Pg/100.circ_matrix.sql index 837c34e534..4a235b2f16 100644 --- a/Open-ILS/src/sql/Pg/100.circ_matrix.sql +++ b/Open-ILS/src/sql/Pg/100.circ_matrix.sql @@ -50,11 +50,11 @@ ALTER TABLE asset.copy ADD CONSTRAINT circ_mod_fkey FOREIGN KEY (circ_modifier) ** developers focus on specific parts of the matrix. **/ -CREATE TABLE config.circ_matrix_matchpoint ( +CREATE TABLE config.circ_matrix_matchpoint_base ( id SERIAL PRIMARY KEY, active BOOL NOT NULL DEFAULT TRUE, -- Match Fields - org_unit INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best" + org_unit INT[] NOT NULL, -- Set to an array of the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best" grp INT NOT NULL REFERENCES permission.grp_tree (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top applicable group from the group tree; will need descendents and prox functions for filtering circ_modifier TEXT REFERENCES config.circ_modifier (code) DEFERRABLE INITIALLY DEFERRED, copy_location INT REFERENCES asset.copy_location (id) DEFERRABLE INITIALLY DEFERRED, @@ -85,7 +85,40 @@ CREATE TABLE config.circ_matrix_matchpoint ( ); -- Nulls don't count for a constraint match, so we have to coalesce them into something that does. -CREATE UNIQUE INDEX ccmm_once_per_paramset ON config.circ_matrix_matchpoint (org_unit, grp, COALESCE(circ_modifier, ''), COALESCE(copy_location::TEXT, ''), COALESCE(marc_type, ''), COALESCE(marc_form, ''), COALESCE(marc_bib_level,''), COALESCE(marc_vr_format, ''), COALESCE(copy_circ_lib::TEXT, ''), COALESCE(copy_owning_lib::TEXT, ''), COALESCE(user_home_ou::TEXT, ''), COALESCE(ref_flag::TEXT, ''), COALESCE(juvenile_flag::TEXT, ''), COALESCE(is_renewal::TEXT, ''), COALESCE(usr_age_lower_bound::TEXT, ''), COALESCE(usr_age_upper_bound::TEXT, ''), COALESCE(item_age::TEXT, '')) WHERE active; +CREATE UNIQUE INDEX ccmm_once_per_paramset ON config.circ_matrix_matchpoint_base (org_unit, grp, COALESCE(circ_modifier, ''), COALESCE(copy_location::TEXT, ''), COALESCE(marc_type, ''), COALESCE(marc_form, ''), COALESCE(marc_bib_level,''), COALESCE(marc_vr_format, ''), COALESCE(copy_circ_lib::TEXT, ''), COALESCE(copy_owning_lib::TEXT, ''), COALESCE(user_home_ou::TEXT, ''), COALESCE(ref_flag::TEXT, ''), COALESCE(juvenile_flag::TEXT, ''), COALESCE(is_renewal::TEXT, ''), COALESCE(usr_age_lower_bound::TEXT, ''), COALESCE(usr_age_upper_bound::TEXT, ''), COALESCE(item_age::TEXT, '')) WHERE active; + +-- Backword compat view +CREATE VIEW config.circ_matrix_matchpoint AS + SELECT id, + active, + UNNEST(org_unit) AS org_unit, + grp, + circ_modifier, + copy_location, + marc_type, + marc_form, + marc_bib_level, + marc_vr_format, + copy_circ_lib, + copy_owning_lib, + user_home_ou, + ref_flag, + juvenile_flag, + is_renewal, + usr_age_lower_bound, + usr_age_upper_bound, + item_age, + circulate, + duration_rule, + recurring_fine_rule, + max_fine_rule, + hard_due_date, + renewals, + grace_period, + script_test, + total_copy_hold_ratio, + available_copy_hold_ratio + FROM config.circ_matrix_matchpoint_base; -- Limit groups for circ counting CREATE TABLE config.circ_limit_group ( -- 2.11.0