custom org tree : db / idl (todo: update schema)
authorBill Erickson <berick@esilibrary.com>
Mon, 19 Mar 2012 20:30:52 +0000 (16:30 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 21 Mar 2012 18:19:36 +0000 (14:19 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql

index 1c92c2e..b707d64 100644 (file)
@@ -4921,6 +4921,45 @@ SELECT  usr,
             </actions>
         </permacrud>
        </class>
+       <class id="aouct" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="actor::org_unit_custom_tree" oils_persist:tablename="actor.org_unit_custom_tree" reporter:label="Org Unit Custom Tree">
+               <fields oils_persist:primary="id" oils_persist:sequence="action.org_unit_custom_tree_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Active" name="active" reporter:datatype="bool"/>
+                       <field reporter:label="Purpose" name="purpose" reporter:datatype="text"/>
+               </fields>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <create permission="ADMIN_ORG_UNIT_CUSTOM_TREE" global_required="true" />
+                               <retrieve/>
+                               <update permission="ADMIN_ORG_UNIT_CUSTOM_TREE" global_required="true" />
+                               <delete permission="ADMIN_ORG_UNIT_CUSTOM_TREE" global_required="true" />
+                       </actions>
+               </permacrud>
+       </class>
+       <class id="aouct" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="actor::org_unit_custom_tree_node" oils_persist:tablename="actor.org_unit_custom_tree_node" reporter:label="Org Unit Custom Tree Node">
+               <fields oils_persist:primary="id" oils_persist:sequence="action.org_unit_custom_tree_node_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Tree" name="tree" reporter:datatype="link"/>
+                       <field reporter:label="Org Unit" name="org_unit" reporter:datatype="link"/>
+                       <field reporter:label="Parent" name="parent_node" reporter:datatype="link"/>
+                       <field reporter:label="Sibling Sort Order" name="sibling_order" reporter:datatype="int"/>
+                       <field reporter:label="Children" name="children" reporter:datatype="link" oils_persist:virtual="true" />
+               </fields>
+               <links>
+                       <link field="tree" reltype="has_a" key="id" map="" class="aouct"/>
+                       <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="parent_node" reltype="has_a" key="id" map="" class="aouctn"/>
+                       <link field="children" reltype="has_many" key="parent_node" map="" class="aouctn"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <create permission="ADMIN_ORG_UNIT_CUSTOM_TREE" global_required="true" />
+                               <retrieve/>
+                               <update permission="ADMIN_ORG_UNIT_CUSTOM_TREE" global_required="true" />
+                               <delete permission="ADMIN_ORG_UNIT_CUSTOM_TREE" global_required="true" />
+                       </actions>
+               </permacrud>
+       </class>
        <class id="ccnb" controller="open-ils.cstore" oils_obj:fieldmapper="container::call_number_bucket" oils_persist:tablename="container.call_number_bucket" reporter:label="Call Number Bucket">
                <fields oils_persist:primary="id" oils_persist:sequence="container.call_number_bucket_id_seq">
                        <field name="items" oils_persist:virtual="true" reporter:datatype="link"/>
index 115613a..fd1c002 100644 (file)
@@ -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;
 */