changeset 7970:d66ea32d98bc

Updated macros and db statement for minfo bedheight differences.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 26 Jun 2014 14:54:04 +0200
parents 09c9920e6f24
children 93da474506e7
files artifacts/doc/conf/meta-data.xml
diffstat 1 files changed, 42 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Thu Jun 26 12:54:31 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Thu Jun 26 14:54:04 2014 +0200
@@ -1734,23 +1734,22 @@
                      FROM   bed_height_single bhs
                             JOIN bed_height_single_values bhsv
                               ON bhsv.bed_height_single_id = bhs.id
-                     WHERE  bhs.river_id = ${river_id}
-                            AND bhs.year BETWEEN ${year_from} AND ${year_to}),
+                     WHERE  bhs.river_id = ${river_id}),
                  csta
-                 AS (SELECT b1.id          AS id1,
+                 AS (SELECT b1.id          AS b1id,
                             b1.description AS b1desc,
                             b1.year        AS b1year,
-                            b2.id          AS id2,
-                            b2.description AS b2desv,
+                            b2.id          AS b2id,
+                            b2.description AS b2desc,
                             b2.year        AS b2year
                      FROM   sta b1
                             JOIN sta b2
                               ON b1.station = b2.station
                                  AND b1.id &lt; b2.id)
-            SELECT id1, b1desc, b1year,
-                   id2, b2desc, b2year
+            SELECT DISTINCT b1id, b1desc, b1year,
+                   b2id, b2desc, b2year
             FROM   csta
-            ORDER BY b1year, b2year
+            ORDER BY b1desc, b2desc
           </dc:statement>
           <dc:if test="dc:has-result()">
             <bedheights>
@@ -1763,38 +1762,55 @@
     </dc:macro>
 
     <dc:macro name="bed-heights-single-diff">
-      <dc:filter expr="not(contains(lower-case($b1desc), 'epoche') or contains(lower-case($b2desc), 'epoche'))">
+      <dc:filter expr="not(contains(dc:lowercase($b1desc), 'epoche') or contains(dc:lowercase($b2desc), 'epoche'))">
         <years>
-          <dc:call-macro name="bed-heights-diff-tree"/>
+          <dc:call-macro name="minfo-heights-diff-tree"/>
         </years>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bed-heights-epoch-diff">
-      <dc:filter expr="contains(lower-case($b1desc), 'epoche') and contains(lower-case($b2desc), 'epoche')">
+      <dc:filter expr="contains(dc:lowercase($b1desc), 'epoche') and contains(dc:lowercase($b2desc), 'epoche')">
         <epochs>
-          <dc:call-macro name="bed-heights-diff-tree"/>
+          <dc:call-macro name="minfo-heights-diff-tree"/>
         </epochs>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="minfo-heights-diff-tree">
-      <dc:group expr="$b1year #!# $b2year">
-        <dc:element name="${dc:group-key()}">
-          <dc:comment>TODO: Better structure</dc:comment>
+      <dc:group expr="dc:coalesce($b1year, 'sonstige') #!# dc:coalesce($b2year, 'sonstige')">
+        <minfo-diff name="{dc:group-key()}">
           <dc:for-each>
-            <dc:comment>A - B</dc:comment>
-            <height factory="bedheight"
-                    target_out="{$out}"
-                    ids="bedheight-single-{$b1id}-{$b2id}"
-                    description="{$b1desc} - {$b2desc}"/>
-            <dc:comment>B - A</dc:comment>
-            <height factory="bedheight"
-                    target_out="{$out}"
-                    ids="bedheight-single-{$b2id}-{$b1id}"
-                    description="{$b2desc} - {$b1desc}"/>
+            <dc:choose>
+              <dc:when test="dc:group-key() = $b1year">
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b1id}-{$b1year}#bedheight-single-{$b2id}-{$b2year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b1desc} - {$b2desc}"/>
+              </dc:when>
+              <dc:when test="dc:group-key() = 'sonstige'">
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b1id}-{$b1year}#bedheight-single-{$b2id}-{$b2year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b1desc} - {$b2desc}"/>
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b2id}-{$b2year}#bedheight-single-{$b1id}-{$b1year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b2desc} - {$b1desc}"/>
+              </dc:when>
+              <dc:otherwise>
+                <height factory="bedheight"
+                        target_out="{$out}"
+                        ids="bedheight-single-{$b2id}-{$b2year}#bedheight-single-{$b1id}-{$b1year}"
+                        info="{$b1desc}#{$b2desc}"
+                        description="{$b2desc} - {$b1desc}"/>
+              </dc:otherwise>
+            </dc:choose>
           </dc:for-each>
-        </dc:element>
+        </minfo-diff>
       </dc:group>
     </dc:macro>
 

http://dive4elements.wald.intevation.org