changeset 7278:03fa985dd044

issue1345: Minor refactoring, made structure for epoch loads equal year loads.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 10 Oct 2013 11:19:30 +0200
parents 0ba4c4fbd410
children 237d5305b1a9
files artifacts/doc/conf/meta-data.xml
diffstat 1 files changed, 55 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Thu Oct 10 11:10:50 2013 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Thu Oct 10 11:19:30 2013 +0200
@@ -1305,6 +1305,53 @@
                 ids="{$syid}" />
       </dc:for-each>
     </dc:macro>
+
+    <dc:macro name="loads">
+     <dc:if test="dc:has-result()">
+       <dc:filter expr="$fraction='sand'">
+         <dc:if test="dc:has-result()">
+           <sand>
+             <dc:call-macro name="one-load"/>
+           </sand>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='fine_middle'">
+         <dc:if test="dc:has-result()">
+           <fine_middle>
+             <dc:call-macro name="one-load"/>
+           </fine_middle>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='coarse'">
+         <dc:if test="dc:has-result()">
+           <coarse>
+             <dc:call-macro name="one-load"/>
+           </coarse>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='suspended_sediment'">
+         <dc:if test="dc:has-result()">
+           <susp_sediment>
+             <dc:call-macro name="one-load"/>
+           </susp_sediment>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='susp_sand'">
+         <dc:if test="dc:has-result()">
+           <susp_sand>
+            <dc:call-macro name="one-load"/>
+           </susp_sand>
+         </dc:if>
+       </dc:filter>
+       <dc:filter expr="$fraction='susp_sand_bed'">
+         <dc:if test="dc:has-result()">
+           <susp_sand_bed>
+             <dc:call-macro name="one-load"/>
+           </susp_sand_bed>
+         </dc:if>
+       </dc:filter>
+     </dc:if>
+    </dc:macro>
       
     <dc:macro name="yields">
       <yields>
@@ -1312,7 +1359,7 @@
       <dc:context>
         <dc:statement>
             SELECT DISTINCT
-                sy.id AS syid,
+                sy.id          AS syid,
                 sy.description AS description,
                 ti.start_time  AS year,
                 gf.name        AS fraction
@@ -1326,76 +1373,28 @@
                 AND syv.station BETWEEN ${fromkm} AND ${tokm}
             ORDER BY fraction
         </dc:statement>
-        <dc:if test="dc:has-result()">
-          <dc:filter expr="$fraction='sand'">
-            <dc:if test="dc:has-result()">
-              <sand>
-                <dc:call-macro name="one-load"/>
-              </sand>
-            </dc:if>
-          </dc:filter>
-          <dc:filter expr="$fraction='fine_middle'">
-            <dc:if test="dc:has-result()">
-              <fine_middle>
-                <dc:call-macro name="one-load"/>
-              </fine_middle>
-            </dc:if>
-          </dc:filter>
-          <dc:filter expr="$fraction='coarse'">
-            <dc:if test="dc:has-result()">
-              <coarse>
-                <dc:call-macro name="one-load"/>
-              </coarse>
-            </dc:if>
-          </dc:filter>
-          <dc:filter expr="$fraction='suspended_sediment'">
-            <dc:if test="dc:has-result()">
-              <susp_sediment>
-                <dc:call-macro name="one-load"/>
-              </susp_sediment>
-            </dc:if>
-          </dc:filter>
-          <dc:filter expr="$fraction='susp_sand'">
-            <dc:if test="dc:has-result()">
-              <susp_sand>
-               <dc:call-macro name="one-load"/>
-              </susp_sand>
-            </dc:if>
-          </dc:filter>
-          <dc:filter expr="$fraction='susp_sand_bed'">
-            <dc:if test="dc:has-result()">
-              <susp_sand_bed>
-                <dc:call-macro name="one-load"/>
-              </susp_sand_bed>
-            </dc:if>
-          </dc:filter>
-        </dc:if>
+        <dc:call-macro name="loads"/>
       </dc:context>
       </years>
       <epochs>
       <dc:context>
         <dc:statement>
             SELECT DISTINCT
-                sy.id AS syid,
+                sy.id          AS syid,
                 sy.description AS description,
-                ti.start_time AS year
+                ti.start_time  AS year,
+                gf.name        AS fraction
             FROM     sediment_yield sy
                 JOIN rivers r ON sy.river_id = r.id
                 JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id
                 JOIN time_intervals ti ON sy.time_interval_id = ti.id
+                JOIN grain_fraction gf ON gf.id = sy.grain_fraction_id
             WHERE   r.id = ${river_id}
                 AND ti.stop_time IS NOT NULL
                 AND syv.station BETWEEN ${fromkm} AND ${tokm}
+            ORDER BY fraction
         </dc:statement>
-        <dc:if test="dc:has-result()">
-          <dc:for-each>
-            <epoch description="{$description}"
-                   factory="sedimentyield"
-                   target_out="{$out}"
-                   info=""
-                   ids="{$syid}" />
-          </dc:for-each>
-        </dc:if>
+        <dc:call-macro name="loads"/>
       </dc:context>
       </epochs>
 

http://dive4elements.wald.intevation.org