adding backend support for system-supplied "search groups" -- user search groups...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Apr 2008 02:11:04 +0000 (02:11 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Apr 2008 02:11:04 +0000 (02:11 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9213 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/300.schema.staged_search.sql

index 196371f..fc571fe 100644 (file)
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
                 <create permission="CREATE_RELEVANCE_ADJUSTMENT" global_required="true"/>
-                <retrieve/>
+                <retrieve permission="CREATE_RELEVANCE_ADJUSTMENT|UPDATE_RELEVANCE_ADJUSTMENT|DELETE_RELEVANCE_ADJUSTMENT" global_required="true"/>
                 <update permission="UPDATE_RELEVANCE_ADJUSTMENT" global_required="true"/>
                 <delete permission="DELETE_RELEVANCE_ADJUSTMENT" global_required="true"/>
             </actions>
         </permacrud>
        </class>
+       <class id="lasso" controller="open-ils.cstore" oils_obj:fieldmapper="actor::org_lasso" oils_persist:tablename="actor.org_lasso">
+               <fields oils_persist:primary="id" oils_persist:sequence="actor.org_lasso_id_seq">
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+                       <field name="name" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="text"/>
+               </fields>
+               <links/>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="CREATE_LASSO" global_required="true"/>
+                <retrieve permission="CREATE_LASSO|UPDATE_LASSO|DELETE_LASSO" global_required="true"/>
+                <update permission="UPDATE_LASSO" global_required="true"/>
+                <delete permission="DELETE_LASSO" global_required="true"/>
+            </actions>
+        </permacrud>
+       </class>
+       <class id="lmap" controller="open-ils.cstore" oils_obj:fieldmapper="actor::org_lasso_map" oils_persist:tablename="actor.org_lasso_map">
+               <fields oils_persist:primary="id" oils_persist:sequence="actor.org_lasso_map_id_seq">
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+                       <field name="lasso" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field name="org_unit" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="org_unit"/>
+               </fields>
+               <links>
+                       <link field="lasso" reltype="has_a" key="id" map="" class="lasso"/>
+                       <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
+               </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="CREATE_LASSO_MAP" global_required="true"/>
+                <retrieve permission="CREATE_LASSO_MAP|UPDATE_LASSO_MAP|DELETE_LASSO_MAP" global_required="true"/>
+                <update permission="UPDATE_LASSO_MAP" global_required="true"/>
+                <delete permission="DELETE_LASSO_MAP" global_required="true"/>
+            </actions>
+        </permacrud>
+       </class>
        <class id="aoup" controller="open-ils.cstore" oils_obj:fieldmapper="actor::org_unit_proximity" oils_persist:tablename="actor.org_unit_proximity">
                <fields oils_persist:primary="id" oils_persist:sequence="actor.org_unit_proximity_id_seq">
                        <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
index 745435c..8670de1 100644 (file)
@@ -4,7 +4,7 @@ BEGIN;
 CREATE SCHEMA actor;
 COMMENT ON SCHEMA actor IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * Schema: actor
@@ -66,7 +66,7 @@ CREATE TABLE actor.usr (
 );
 COMMENT ON TABLE actor.usr IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * User objects
@@ -150,7 +150,7 @@ CREATE TABLE actor.usr_standing_penalty (
 );
 COMMENT ON TABLE actor.usr_standing_penalty IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * User standing penalties
@@ -180,7 +180,7 @@ CREATE TABLE actor.usr_setting (
 );
 COMMENT ON TABLE actor.usr_setting IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * User settings
@@ -214,7 +214,7 @@ CREATE TABLE actor.stat_cat (
 );
 COMMENT ON TABLE actor.stat_cat IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * User Statistical Catagories
@@ -246,7 +246,7 @@ CREATE TABLE actor.stat_cat_entry (
 );
 COMMENT ON TABLE actor.stat_cat_entry IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * User Statistical Catagory Entries
@@ -280,7 +280,7 @@ CREATE TABLE actor.stat_cat_entry_usr_map (
 );
 COMMENT ON TABLE actor.stat_cat_entry_usr_map IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * Statistical Catagory Entry to User map
@@ -312,7 +312,7 @@ CREATE TABLE actor.card (
 );
 COMMENT ON TABLE actor.card IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * Library Cards
@@ -371,6 +371,19 @@ CREATE INDEX actor_org_unit_billing_address_idx ON actor.org_unit (billing_addre
 CREATE INDEX actor_org_unit_mailing_address_idx ON actor.org_unit (mailing_address);
 CREATE INDEX actor_org_unit_holds_address_idx ON actor.org_unit (holds_address);
 
+CREATE TABLE actor.org_lasso (
+    id      SERIAL  PRIMARY KEY,
+    name       TEXT    UNIQUE
+);
+
+CREATE TABLE actor.org_lasso_map (
+    id          SERIAL  PRIMARY KEY,
+    lasso       INT     NOT NULL REFERENCES actor.org_lasso (id) ON DELETE CASCADE,
+    org_unit    INT     NOT NULL REFERENCES actor.org_unit (id) ON DELETE CASCADE
+);
+CREATE INDEX ou_lasso_lasso_idx ON actor.org_lasso_map (lasso);
+CREATE INDEX ou_lasso_org_unit_idx ON actor.org_lasso_map (org_unit);
+
 CREATE TABLE actor.org_unit_proximity (
        id              BIGSERIAL       PRIMARY KEY,
        from_org        INT,
@@ -431,7 +444,7 @@ CREATE TABLE actor.org_unit_setting (
 );
 COMMENT ON TABLE actor.org_unit_setting IS $$
 /*
- * Copyright (C) 2005  Georgia Public Library Service 
+ * Copyright (C) 2005-2008  Equinox Software, Inc. / Georgia Public Library Service 
  * Mike Rylander <mrylander@gmail.com>
  *
  * Org Unit settings
index 69d1e75..049a8dc 100644 (file)
@@ -337,10 +337,16 @@ BEGIN
                         ' GROUP BY 1 ORDER BY 4' || CASE WHEN sort_desc THEN ' DESC' ELSE ' ASC' END || ';';
     --RAISE NOTICE 'Base Query:  %', core_rel_query;
 
-    IF param_depth IS NOT NULL THEN
-        SELECT array_accum(distinct id) INTO search_org_list FROM actor.org_unit_descendants( param_search_ou, param_depth );
-    ELSE
-        SELECT array_accum(distinct id) INTO search_org_list FROM actor.org_unit_descendants( param_search_ou );
+    IF param_search_ou > 0 THEN
+        IF param_depth IS NOT NULL THEN
+            SELECT array_accum(distinct id) INTO search_org_list FROM actor.org_unit_descendants( param_search_ou, param_depth );
+        ELSE
+            SELECT array_accum(distinct id) INTO search_org_list FROM actor.org_unit_descendants( param_search_ou );
+        END IF;
+    ELSIF param_search_ou < 0 THEN
+        SELECT array_accum(distinct org_unit) INTO search_org_list FROM actor.org_lasso_map WHERE lasso = -param_search_ou;
+    ELSIF param_search_ou = 0 THEN
+        -- reserved for user lassos (ou_buckets/type='lasso') with ID passed in depth ... hack? sure.
     END IF;
 
     OPEN core_cursor FOR EXECUTE core_rel_query;