[open-ils-commits] r15778 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Mar 10 14:41:54 EST 2010


Author: scottmk
Date: 2010-03-10 14:41:50 -0500 (Wed, 10 Mar 2010)
New Revision: 15778

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql
Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
   trunk/Open-ILS/src/sql/Pg/build-db.sh
Log:
1. Eliminate somed source_definitions from the IDL where there is already
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


Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2010-03-10 19:22:00 UTC (rev 15777)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2010-03-10 19:41:50 UTC (rev 15778)
@@ -4394,7 +4394,7 @@
 			<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 @@
 			<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 @@
     </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 @@
     </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 @@
     </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 @@
     </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 @@
 		</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 @@
 			<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 @@
 			<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 @@
 		</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">

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-03-10 19:22:00 UTC (rev 15777)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-03-10 19:41:50 UTC (rev 15778)
@@ -51,7 +51,7 @@
     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,

Modified: trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/090.schema.action.sql	2010-03-10 19:22:00 UTC (rev 15777)
+++ trunk/Open-ILS/src/sql/Pg/090.schema.action.sql	2010-03-10 19:41:50 UTC (rev 15778)
@@ -473,7 +473,13 @@
             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 (
     num_circs INTEGER,

Modified: trunk/Open-ILS/src/sql/Pg/build-db.sh
===================================================================
--- trunk/Open-ILS/src/sql/Pg/build-db.sh	2010-03-10 19:22:00 UTC (rev 15777)
+++ trunk/Open-ILS/src/sql/Pg/build-db.sh	2010-03-10 19:41:50 UTC (rev 15778)
@@ -106,6 +106,7 @@
   110.hold_matrix.sql
 
   200.schema.acq.sql
+  201.acq.audit-functions.sql
   210.schema.serials.sql
 
   300.schema.staged_search.sql

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0185.schema.acq.aufhmxl-view.sql	2010-03-10 19:41:50 UTC (rev 15778)
@@ -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;



More information about the open-ils-commits mailing list