Make circ rule owing org units array-able
authorMike Rylander <mrylander@gmail.com>
Fri, 28 Mar 2014 17:04:34 +0000 (13:04 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 28 Mar 2014 17:05:55 +0000 (13:05 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/100.circ_matrix.sql

index adfcd2e..a485933 100644 (file)
@@ -1719,7 +1719,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Matchpoint ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="Renewal?" name="is_renewal" reporter:datatype="bool"/>
                        <field reporter:label="Active?" name="active" reporter:datatype="bool"/>
-                       <field reporter:label="Org Unit" name="org_unit" reporter:datatype="org_unit" oils_obj:required="true"/>
+                       <field reporter:label="Org Unit" name="org_unit" reporter:datatype="org_unit" oils_persist:primitive="array" oils_obj:required="true"/>
                        <field reporter:label="Copy Circ Lib" name="copy_circ_lib" reporter:datatype="org_unit"/>
                        <field reporter:label="Copy Owning Lib" name="copy_owning_lib" reporter:datatype="org_unit"/>
                        <field reporter:label="User Home Lib" name="user_home_ou" reporter:datatype="org_unit"/>
index 837c34e..4a235b2 100644 (file)
@@ -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 (