[PATCH 1 of 3] Updated macros and db statement for minfo bedheight differences

Wald Commits scm-commit at wald.intevation.org
Thu Jun 26 15:00:32 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1403787244 -7200
# Node ID d66ea32d98bc9e0c103d436d068d1324aae51d91
# Parent  09c9920e6f24d49b1cf3d94d12aec920934beb97
Updated macros and db statement for minfo bedheight differences.

diff -r 09c9920e6f24 -r d66ea32d98bc artifacts/doc/conf/meta-data.xml
--- 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 < 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>
 


More information about the Dive4Elements-commits mailing list