webstaff: new table to store shared prediction pattern codes
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 9 May 2017 18:53:18 +0000 (14:53 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 9 May 2017 18:53:18 +0000 (14:53 -0400)
serial.pattern_template is a new table for establishing a
shared list of predication pattern codes. Pattern templates
have an OU owner and share depth; CUD has a new ADMIN_SERIAL_PATTERN_TEMPLATE
permission.

The share depth is meant to be advisory, so there's no pcrud
permission tied to retrieving serial.pattern_template rows.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serial_pattern_templates.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/YYYY.data.spt_perms.sql [new file with mode: 0644]

index 8f35858..27dbe1e 100644 (file)
@@ -5397,6 +5397,25 @@ SELECT  usr,
                </permacrud>
        </class>
 
+       <class id="spt" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="serial::pattern_template" oils_persist:tablename="serial.pattern_template" reporter:label="Prediction Pattern Template">
+               <fields oils_persist:primary="id" oils_persist:sequence="serial.pattern_template_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id" />
+                       <field reporter:label="Name" name="name" reporter:datatype="text"/>
+                       <field reporter:label="Pattern Code" name="pattern_code" reporter:datatype="text"/>
+                       <field reporter:label="Owning Library" name="owning_lib" reporter:datatype="org_unit"/>
+                       <field reporter:label="Share Depth" name="share_depth"  reporter:datatype="int"/>
+               </fields>
+               <links>
+                       <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <create permission="ADMIN_SERIAL_PATTERN_TEMPLATE" context_field="owning_lib"/>
+                       <retrieve/>
+                       <update permission="ADMIN_SERIAL_PATTERN_TEMPLATE" context_field="owning_lib"/>
+                       <delete permission="ADMIN_SERIAL_PATTERN_TEMPLATE" context_field="owning_lib"/>
+               </permacrud>
+       </class>
+
        <class id="ascecm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::stat_cat_entry_copy_map" oils_persist:tablename="asset.stat_cat_entry_copy_map" reporter:label="Statistical Category Entry Copy Map">
                <fields oils_persist:primary="id" oils_persist:sequence="asset.stat_cat_entry_copy_map_id_seq">
                        <field name="id" reporter:datatype="id" />
index 2aa29c3..96fe005 100644 (file)
@@ -1677,7 +1677,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
  ( 588, 'ITEM_NOT_HOLDABLE.override', oils_i18n_gettext( 588,
     'Override the ITEM_NOT_HOLDABLE event', 'ppl', 'description' )),
  ( 589, 'ITEM_RENTAL_FEE_REQUIRED.override', oils_i18n_gettext( 589,
-    'Override the ITEM_RENTAL_FEE_REQUIRED event', 'ppl', 'description' ))
+    'Override the ITEM_RENTAL_FEE_REQUIRED event', 'ppl', 'description' )),
+ ( 590, 'ADMIN_SERIAL_PATTERN_TEMPLATE', oils_i18n_gettext( 590,
+    'Administer serial prediction pattern templates', 'ppl', 'description' ))
 ;
 
 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
@@ -2487,6 +2489,7 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
                        'ADMIN_SERIAL_CAPTION_PATTERN',
                        'ADMIN_SERIAL_DISTRIBUTION',
                        'ADMIN_SERIAL_ITEM',
+                       'ADMIN_SERIAL_PATTERN_TEMPLATE',
                        'ADMIN_SERIAL_STREAM',
                        'ADMIN_SERIAL_SUBSCRIPTION',
                        'ISSUANCE_HOLDS',
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serial_pattern_templates.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.serial_pattern_templates.sql
new file mode 100644 (file)
index 0000000..3a8ed1a
--- /dev/null
@@ -0,0 +1,14 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE TABLE serial.pattern_template (
+    id            SERIAL PRIMARY KEY,
+    name          TEXT NOT NULL,
+    pattern_code  TEXT NOT NULL,
+    owning_lib    INTEGER REFERENCES actor.org_unit(id) DEFERRABLE INITIALLY DEFERRED,
+    share_depth   INTEGER NOT NULL DEFAULT 0
+);
+CREATE INDEX serial_pattern_template_name_idx ON serial.pattern_template (evergreen.lowercase(name));
+
+-- COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.spt_perms.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.spt_perms.sql
new file mode 100644 (file)
index 0000000..3ef75db
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+INSERT INTO permission.perm_list ( id, code, description ) VALUES
+ ( 590, 'ADMIN_SERIAL_PATTERN_TEMPLATE', oils_i18n_gettext( 590,
+    'Administer serial prediction pattern templates', 'ppl', 'description' ))
+;
+
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
+    SELECT
+        pgt.id, perm.id, aout.depth, FALSE
+    FROM
+        permission.grp_tree pgt,
+        permission.perm_list perm,
+        actor.org_unit_type aout
+    WHERE
+        pgt.name = 'Serials' AND
+        aout.name = 'System' AND
+        perm.code IN (
+            'ADMIN_SERIAL_PATTERN_TEMPLATE'
+        );
+
+-- COMMIT;