1. Eliminate somed source_definitions from the IDL where there is already
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Mar 2010 19:41:50 +0000 (19:41 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Mar 2010 19:41:50 +0000 (19:41 +0000)
an equivalent view.  In the presence of a tablename attribute, the
source_definitions were being ignored anyway.  This step applies to classes
aufhl, aufhml, and aufhil.

2. For class aufhmxl: the IDL had both a tablename and a source_definition,
but there was no table or view corresponding to the tablename.
I eliminated the source_definition and created the corresponding view
action.unfulfilled_hold_max_loop.

3. For class aufhol: the IDL had both a tablename and a source_definition,
but neither was valid.  The tablename didn't exist in the database, and the
source_definition referenced the action.unfulfilled_hold_max_loop view, which
didn't exist.  I removed the tablename attribute and left the source_definition
in place, which is now valid because in step 2 I created the missing view.

4. Unrelated: added 201.acq.audit-functions.sql to the list of installation
scripts to run in build-db.sh.

M    Open-ILS/src/sql/Pg/090.schema.action.sql
M    Open-ILS/src/sql/Pg/002.schema.config.sql
A    Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql
M    Open-ILS/src/sql/Pg/build-db.sh
M    Open-ILS/examples/fm_IDL.xml

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15778 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/build-db.sh
Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql [new file with mode: 0644]

index e0ad0d6..2acae77 100644 (file)
@@ -4394,7 +4394,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="lineitem" reltype="has_a" key="id" map="" class="jub"/>
                        <link field="eg_bib" reltype="has_a" key="id" map="" class="bre"/>
                        <link field="request_type" reltype="has_a" key="id" map="" class="aurt"/>
-                       <link field="cancel_reason" reltype="might_have" key="id" map="" class="acqcr"/>
+                       <link field="cancel_reason" reltype="has_a" key="id" map="" class="acqcr"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
@@ -5138,7 +5138,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="lineitems" reltype="has_many" key="purchase_order" map="" class="jub"/>
                        <link field="notes" reltype="has_many" key="purchase_order" map="" class="acqpon"/>
                        <link field="ordering_agency" reltype="has_a" key="id" map="" class="aou"/>
-                       <link field="cancel_reason" reltype="might_have" key="id" map="" class="acqcr"/>
+                       <link field="cancel_reason" reltype="has_a" key="id" map="" class="acqcr"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
@@ -6017,16 +6017,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
     </class>
 
     <class id="aufhl" controller="open-ils.cstore" oils_obj:fieldmapper="action::unfulfilled_hold_loops" oils_persist:tablename="action.unfulfilled_hold_loops" oils_persist:readonly="true">
-               <oils_persist:source_definition>
-
-           SELECT  u.hold,
-                   c.circ_lib,
-                   count(*)
-             FROM  action.unfulfilled_hold_list u
-                   JOIN asset.copy c ON (c.id = u.current_copy)
-             GROUP BY 1,2
-
-               </oils_persist:source_definition>
         <fields>
             <field reporter:label="Hold ID" name="hold" reporter:datatype="link"/>
             <field reporter:label="Circulating Library" name="circ_lib" reporter:datatype="link"/>
@@ -6039,14 +6029,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
     </class>
 
     <class id="aufhml" controller="open-ils.cstore" oils_obj:fieldmapper="action::unfulfilled_hold_min_loop" oils_persist:tablename="action.unfulfilled_hold_min_loop" oils_persist:readonly="true">
-               <oils_persist:source_definition>
-
-           SELECT  hold,
-                   min(count)
-             FROM  action.unfulfilled_hold_loops
-             GROUP BY 1
-
-               </oils_persist:source_definition>
         <fields>
             <field reporter:label="Hold ID" name="hold" reporter:datatype="link"/>
             <field reporter:label="Min Loop" name="min" reporter:datatype="int"/>
@@ -6057,14 +6039,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
     </class>
 
     <class id="aufhil" controller="open-ils.cstore" oils_obj:fieldmapper="action::unfulfilled_hold_innermost_loop" oils_persist:tablename="action.unfulfilled_hold_innermost_loop" oils_persist:readonly="true">
-               <oils_persist:source_definition>
-
-           SELECT  DISTINCT l.*
-             FROM  action.unfulfilled_hold_loops l
-                   JOIN action.unfulfilled_hold_min_loop m USING (hold)
-             WHERE l.count = m.min
-
-               </oils_persist:source_definition>
         <fields>
             <field reporter:label="Hold ID" name="hold" reporter:datatype="link"/>
             <field reporter:label="Circulating Library" name="circ_lib" reporter:datatype="link"/>
@@ -6077,14 +6051,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
     </class>
 
     <class id="aufhmxl" controller="open-ils.cstore" oils_obj:fieldmapper="action::unfulfilled_hold_max_loop" oils_persist:tablename="action.unfulfilled_hold_max_loop" oils_persist:readonly="true">
-               <oils_persist:source_definition>
-
-           SELECT  hold,
-                   max(count)
-             FROM  action.unfulfilled_hold_loops
-             GROUP BY 1
-
-               </oils_persist:source_definition>
         <fields>
             <field reporter:label="Hold ID" name="hold" reporter:datatype="link"/>
             <field reporter:label="Max Loop" name="max" reporter:datatype="int"/>
@@ -6094,7 +6060,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </links>
     </class>
 
-    <class id="aufhol" controller="open-ils.cstore" oils_obj:fieldmapper="action::unfulfilled_hold_outermost_loop" oils_persist:tablename="action.unfulfilled_hold_outermost_loop" oils_persist:readonly="true">
+    <class id="aufhol" controller="open-ils.cstore" oils_obj:fieldmapper="action::unfulfilled_hold_outermost_loop" oils_persist:readonly="true">
                <oils_persist:source_definition>
 
            SELECT  DISTINCT l.*
@@ -6181,7 +6147,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Is Aggregate" name="is_aggregate" reporter:datatype="bool"/>
                </fields>
                <links>
-                       <link field="return_type" reltype="might_have" key="id" map="" class="qdt"/>
+                       <link field="return_type" reltype="has_a" key="id" map="" class="qdt"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                </permacrud>
@@ -6220,12 +6186,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Cast Type" name="cast_type" reporter:datatype="link"/>
                </fields>
                <links>
-                       <link field="parent_expr" reltype="might_have" key="id" map="" class="qxp"/>
-                       <link field="left_operand" reltype="might_have" key="id" map="" class="qxp"/>
-                       <link field="right_operand" reltype="might_have" key="id" map="" class="qxp"/>
-                       <link field="function_id" reltype="might_have" key="id" map="" class="qfs"/>
-                       <link field="subquery" reltype="might_have" key="id" map="" class="qsq"/>
-                       <link field="cast_type" reltype="might_have" key="id" map="" class="qdt"/>
+                       <link field="parent_expr" reltype="has_a" key="id" map="" class="qxp"/>
+                       <link field="left_operand" reltype="has_a" key="id" map="" class="qxp"/>
+                       <link field="right_operand" reltype="has_a" key="id" map="" class="qxp"/>
+                       <link field="function_id" reltype="has_a" key="id" map="" class="qfs"/>
+                       <link field="subquery" reltype="has_a" key="id" map="" class="qsq"/>
+                       <link field="cast_type" reltype="has_a" key="id" map="" class="qdt"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                </permacrud>
@@ -6241,7 +6207,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </fields>
                <links>
                        <link field="parent_expr" reltype="has_a" key="id" map="" class="qxp"/>
-                       <link field="condition" reltype="might_have" key="id" map="" class="qxp"/>
+                       <link field="condition" reltype="has_a" key="id" map="" class="qxp"/>
                        <link field="result" reltype="has_a" key="id" map="" class="qxp"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
index 753124e..3c7b5a3 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0184'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0185'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 11e7600..f7951b3 100644 (file)
@@ -473,6 +473,12 @@ CREATE OR REPLACE VIEW action.unfulfilled_hold_innermost_loop AS
             JOIN action.unfulfilled_hold_min_loop m USING (hold)
       WHERE l.count = m.min;
 
+CREATE VIEW action.unfulfilled_hold_max_loop AS
+    SELECT  hold,
+            max(count) AS max
+      FROM  action.unfulfilled_hold_loops
+      GROUP BY 1;
+
 
 -- represents a circ chain summary
 CREATE TYPE action.circ_chain_summary AS (
index a6642a0..77f614e 100755 (executable)
@@ -106,6 +106,7 @@ ordered_file_list="
   110.hold_matrix.sql
 
   200.schema.acq.sql
+  201.acq.audit-functions.sql
   210.schema.serials.sql
 
   300.schema.staged_search.sql
diff --git a/Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql b/Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql
new file mode 100644 (file)
index 0000000..3fb91b8
--- /dev/null
@@ -0,0 +1,11 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0185'); -- Scott McKellar
+
+CREATE VIEW action.unfulfilled_hold_max_loop AS
+       SELECT  hold,
+               max(count) AS max
+       FROM    action.unfulfilled_hold_loops
+       GROUP BY 1;
+
+COMMIT;