[Dive4elements-commits] [PATCH] Commit changes described in r6110

Wald Commits scm-commit at wald.intevation.org
Mon May 27 15:40:46 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1369662042 -7200
# Node ID 6815714c1f97ee080db0081458cb82cf9099cd3a
# Parent  5ba28b5636144a49e12dea4a531100e8aa8aac02
Commit changes described in r6110

diff -r 5ba28b563614 -r 6815714c1f97 artifacts/doc/conf/meta-data.xml
--- a/artifacts/doc/conf/meta-data.xml	Mon May 27 15:36:56 2013 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Mon May 27 15:40:42 2013 +0200
@@ -408,81 +408,77 @@
     </dc:macro>
 
     <dc:macro name="reference-curves">
-      <dc:variable name="facet_type" value="reference_curve"/>
-      <dc:call-macro name="select-facets">
-        <reference_curves>
-          <dc:for-each>
-            <dc:element name="${facet_name}">
-              <dc:attribute name="description" value="${facet_description}"/>
-              <dc:attribute name="factory" value="winfo"/>
-              <dc:attribute name="artifact-id" value="${aid}"/>
-              <dc:attribute name="ids" value="${aid}"/>
-              <dc:attribute name="out" value="reference_curve"/>
-            </dc:element>
-          </dc:for-each>
-        </reference_curves>
-      </dc:call-macro>
+      <dc:filter expr="$facet_name = 'reference_curve'">
+        <dc:if test="dc:has-result()">
+          <reference_curves>
+            <dc:for-each>
+              <dc:element name="${facet_name}">
+                <dc:attribute name="description" value="${facet_description}"/>
+                <dc:attribute name="factory" value="winfo"/>
+                <dc:attribute name="artifact-id" value="${a_id}"/>
+                <dc:attribute name="ids" value="${a_id}"/>
+                <dc:attribute name="out" value="reference_curve"/>
+              </dc:element>
+            </dc:for-each>
+          </reference_curves>
+        </dc:if>
+      </dc:filter>
     </dc:macro>
 
     <dc:macro name="computed-discharge-curve">
-      <dc:variable name="facet_type" value="computed_discharge_curve.q"/>
-      <dc:call-macro name="select-facets">
-        <computed_discharge_curves>
-          <dc:for-each>
-            <dc:element name="${facet_name}">
-              <dc:attribute name="description" value="${facet_description}"/>
-              <dc:attribute name="factory" value="winfo"/>
-              <dc:attribute name="artifact-id" value="${aid}"/>
-              <dc:attribute name="ids" value="${aid}"/>
-              <dc:attribute name="out" value="computed_discharge_curve"/>
-            </dc:element>
-          </dc:for-each>
-        </computed_discharge_curves>
-      </dc:call-macro>
+      <dc:filter expr="$facet_name = 'computed_discharge_curve.q'">
+        <dc:if test="dc:has-result()">
+          <computed_discharge_curves>
+            <dc:for-each>
+              <dc:element name="${facet_name}">
+                <dc:attribute name="description" value="${facet_description}"/>
+                <dc:attribute name="factory" value="winfo"/>
+                <dc:attribute name="artifact-id" value="${a_id}"/>
+                <dc:attribute name="ids" value="${a_id}"/>
+                <dc:attribute name="out" value="computed_discharge_curve"/>
+              </dc:element>
+            </dc:for-each>
+          </computed_discharge_curves>
+        </dc:if>
+      </dc:filter>
     </dc:macro>
 
     <dc:macro name="flood-map">
-      <dc:variable name="facet_type" value="floodmap.wsplgen"/>
-      <dc:call-macro name="select-facets">
-        <floodmap>
-          <dc:for-each>
-            <dc:element name="${facet_name}">
-              <dc:attribute name="description" value="${facet_description}"/>
-              <dc:attribute name="factory" value="winfo"/>
-              <dc:attribute name="artifact-id" value="${aid}"/>
-              <dc:attribute name="ids" value="${aid}"/>
-              <dc:attribute name="out" value="floodmap"/>
-            </dc:element>
-          </dc:for-each>
-        </floodmap>
-      </dc:call-macro>
+      <dc:filter expr="$facet_name = 'floodmap.wsplgen'">
+        <dc:if test="dc:has-result()">
+          <floodmap>
+            <dc:for-each>
+              <dc:element name="${facet_name}">
+                <dc:attribute name="description" value="${facet_description}"/>
+                <dc:attribute name="factory" value="winfo"/>
+                <dc:attribute name="artifact-id" value="${a_id}"/>
+                <dc:attribute name="ids" value="${a_id}"/>
+                <dc:attribute name="out" value="floodmap"/>
+              </dc:element>
+            </dc:for-each>
+          </floodmap>
+        </dc:if>
+      </dc:filter>
     </dc:macro>
 
     <dc:macro name="waterlevels">
       <dc:filter expr="$out_name = 'cross_section'">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name AS facet_name, num AS facet_num, description AS facet_description
-                    FROM facets
-                  WHERE out_id = ${out_id}
-                    ORDER BY num ASC, name DESC
-                </dc:statement>
-                <longitudinal_section_columns description="{$river} {$a_creation}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="winfo"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="cross_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </longitudinal_section_columns>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="concat($river, ' ', $a_creation)">
+              <dc:comment>Aheinecke: Why is this grouping different from the rest?</dc:comment>
+              <longitudinal_section_columns description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="winfo"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="cross_section"/>
+                  </dc:element>
+                </dc:for-each>
+              </longitudinal_section_columns>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
@@ -492,247 +488,175 @@
       <dc:filter expr="$out_name = 'longitudinal_section'">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name        AS facet_name,
-                         num         AS facet_num,
-                         description AS facet_description
-                  FROM facets
-                  WHERE out_id = ${out_id}
-                    ORDER BY num ASC, name DESC
-                </dc:statement>
-                <longitudinal_section_columns description="{$river} {$a_creation}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="winfo"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </longitudinal_section_columns>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="$river $a_creation">
+              <dc:comment>Aheinecke: Why is this grouping different from the rest?</dc:comment>
+              <longitudinal_section_columns description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="winfo"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
+              </longitudinal_section_columns>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="longitudinal-section">
-      <dc:filter expr="$out_name = 'fix_longitudinal_section_curve'">
+      <dc:filter expr="$out_name = 'fix_longitudinal_section_curve' and
+        (starts-with($facet_name, 'fix_deviation_ls') or
+        starts-with($facet_name, 'fix_sector_average_ls') or
+        starts-with($facet_name, 'fix_analysis_events_ls') or
+        starts-with($facet_name, 'fix_reference_events_ls'))">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name        AS facet_name,
-                         num         AS facet_num,
-                         description AS facet_description
-                  FROM facets
-                  WHERE out_id = ${out_id} AND (
-                      name LIKE 'fix_deviation_ls%'       OR
-                      name LIKE 'fix_sector_average_ls%'  OR
-                      name LIKE 'fix_analysis_events_ls%' OR
-                      name LIKE 'fix_reference_events_ls%')
-                  ORDER BY num ASC, name DESC
-                </dc:statement>
-                <waterlevels description="{$river} {$a_creation} {$collection_name}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="fixanalysis"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="fix_longitudinal_section_curve"/>
-                    </dc:element>
-                  </dc:for-each>
-                </waterlevels>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="fixanalysis"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="fix_longitudinal_section_curve"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="delta-wt">
-      <dc:filter expr="$out_name = 'fix_deltawt_curve'">
+      <dc:filter expr="$out_name = 'fix_deltawt_curve' and
+        ($facet_name = 'fix_analysis_events_dwt' or
+        $facet_name = 'fix_analysis_periods_dwt' or
+        $facet_name = 'fix_reference_events_dwt' or
+        starts-with($facet_name, 'fix_deviation_dwt') or
+        starts-with($facet_name, 'fix_sector_average_dwt'))">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name        AS facet_name,
-                         num         AS facet_num,
-                         description AS facet_description
-                  FROM facets
-                  WHERE out_id = ${out_id} and (
-                    name LIKE 'fix_sector_average_dwt%' OR
-                    name LIKE 'fix_deviation_dwt%'      OR
-                    name = 'fix_analysis_events_dwt'    OR
-                    name = 'fix_reference_events_dwt'   OR
-                    name = 'fix_analysis_periods_dwt')
-                  ORDER BY num ASC, name DESC
-                </dc:statement>
-                <waterlevels description="{$river} {$a_creation} {$collection_name}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="fixanalysis"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="fix_deltawt_curve"/>
-                    </dc:element>
-                  </dc:for-each>
-                </waterlevels>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="fixanalysis"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="fix_deltawt_curve"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="delta-wt-ls">
-      <dc:filter expr="$out_name = 'fix_deltawt_curve'">
+      <dc:filter expr="$out_name = 'fix_deltawt_curve' and
+        (starts-with($facet_name, 'fix_sector_average_dwt') or
+        starts-with($facet_name, 'fix_deviation_dwt'))">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name AS facet_name, num AS facet_num, description AS facet_description
-                  FROM facets
-                  WHERE out_id = ${out_id} and (
-                    name LIKE 'fix_sector_average_dwt%' OR
-                    name LIKE 'fix_deviation_dwt%')
-                  ORDER BY num ASC, name DESC
-                </dc:statement>
-                <waterlevels description="{$river} {$a_creation} {$collection_name}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="fixanalysis"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="fix_deltawt_curve"/>
-                    </dc:element>
-                  </dc:for-each>
-                </waterlevels>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="fixanalysis"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="fix_deltawt_curve"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="fix-derivate-curve">
-      <dc:filter expr="$out_name = 'fix_derivate_curve'">
+      <dc:filter expr="$out_name = 'fix_derivate_curve' and $facet_name = 'fix_derivate_curve'">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name AS facet_name, num AS facet_num, description AS facet_description
-                  FROM facets
-                  WHERE out_id = ${out_id} and name = 'fix_derivate_curve'
-                  ORDER BY num ASC, name DESC
-                </dc:statement>
-                <waterlevels description="{$river} {$a_creation} {$collection_name}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="fixanalysis"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="fix_derivate_curve"/>
-                    </dc:element>
-                  </dc:for-each>
-                </waterlevels>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="fixanalysis"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="fix_derivate_curve"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="fix-wq-curve">
-      <dc:filter expr="$out_name = 'fix_wq_curve'">
+      <dc:filter expr="$out_name = 'fix_wq_curve' and
+        (starts-with($facet_name, 'fix_analysis_events_wq') or
+        starts-with($facet_name, 'fix_reference_events_wq') or
+        starts-with($facet_name, 'fix_sector_average_wq') or
+        $facet_name = 'fix_wq_curve')">
         <dc:if test="dc:has-result()">
           <waterlevels>
-            <dc:for-each>
-              <dc:context>
-                <dc:statement>
-                  SELECT name AS facet_name, num AS facet_num, description AS facet_description
-                  FROM facets
-                  WHERE out_id = ${out_id} and (
-                    name LIKE 'fix_sector_average_wq%'  OR
-                    name = 'fix_wq_curve'               OR
-                    name LIKE 'fix_analysis_events_wq%' OR
-                    name LIKE 'fix_reference_events_wq%' )
-                  ORDER BY num ASC, name DESC
-                </dc:statement>
-                <waterlevels description="{$river} {$a_creation} {$collection_name}">
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}"/>
-                      <dc:attribute name="factory" value="fixanalysis"/>
-                      <dc:attribute name="artifact-id" value="${a_gid}"/>
-                      <dc:attribute name="out" value="fix_wq_curve"/>
-                    </dc:element>
-                  </dc:for-each>
-                </waterlevels>
-              </dc:context>
-            </dc:for-each>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}"/>
+                    <dc:attribute name="factory" value="fixanalysis"/>
+                    <dc:attribute name="artifact-id" value="${a_gid}"/>
+                    <dc:attribute name="out" value="fix_wq_curve"/>
+                  </dc:element>
+                </dc:for-each>
+              </waterlevels>
+            </dc:group>
           </waterlevels>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="duration-curve">
-      <dc:context>
-        <dc:statement>
-          SELECT a.gid         AS aid,
-                 f.id          AS fid,
-                 f.name        AS facet_name,
-                 f.num         AS facet_num,
-                 f.description AS facet_description
-          FROM outs AS o, facets AS f, artifacts AS a
-          WHERE
-              (f.name = 'duration_curve.q' OR f.name = 'duration_curve.w') AND
-              f.out_id = o.id         AND
-              o.artifact_id = ${a_id} AND
-              a.id = ${a_id}
-        </dc:statement>
+      <dc:filter expr="$facet_name = 'duration_curve.q' or $facet_name = 'duration_curve.w'">
         <dc:if test="dc:has-result()">
           <computed_discharge_curves>
             <dc:for-each>
               <dc:element name="${facet_name}">
                 <dc:attribute name="description" value="${facet_description}"/>
                 <dc:attribute name="factory" value="winfo"/>
-                <dc:attribute name="artifact-id" value="${aid}"/>
-                <dc:attribute name="ids" value="${aid}"/>
+                <dc:attribute name="artifact-id" value="${a_id}"/>
+                <dc:attribute name="ids" value="${a_id}"/>
                 <dc:attribute name="out" value="duration_curve"/>
               </dc:element>
             </dc:for-each>
           </computed_discharge_curves>
         </dc:if>
-      </dc:context>
+      </dc:filter>
     </dc:macro>
 
-    <dc:comment>TODO doesnt work nicely for fix/wq-diags.</dc:comment>
+    <dc:comment>TODO doesnt work nicely for fix/wq-diags. Aheinecke (27.5.2013): Why?</dc:comment>
     <dc:macro name="waterlevels-fix">
-      <dc:filter expr="$out_name = 'longitudinal_section'">
-        <waterlevels>
-          <dc:for-each>
-            <dc:context>
-              <dc:statement>
-                SELECT name AS facet_name, num AS facet_num, description AS facet_description
-                FROM facets
-                WHERE out_id = ${out_id} and name = 'longitudinal_section.w'
-                ORDER BY num ASC, name DESC
-              </dc:statement>
-              <waterlevels description="{$river} {$a_creation} {$collection_name}">
+      <dc:filter expr="$out_name = 'longitudinal_section' and $facet_name = 'longitudinal_section.w'">
+        <dc:if test="dc:has-result()">
+          <waterlevels>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <waterlevels description="{dc:group-key()}">
                 <dc:for-each>
                   <dc:element name="${facet_name}">
                     <dc:attribute name="description" value="${facet_description}"/>
@@ -743,342 +667,212 @@
                   </dc:element>
                 </dc:for-each>
               </waterlevels>
-            </dc:context>
-          </dc:for-each>
-        </waterlevels>
+            </dc:group>
+          </waterlevels>
+        </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="floodmap-hws-user">
-      <dc:filter expr="$out_name = 'floodmap'">
-        <dc:for-each>
-          <dc:context>
-            <dc:statement>
-              SELECT name        AS facet_name,
-              num         AS facet_num,
-              description AS facet_description
-              FROM facets
-              WHERE out_id = ${out_id} AND name = 'floodmap.usershape'
-              ORDER BY num ASC, name DESC
-            </dc:statement>
-            <own-hws>
-              <dc:for-each>
-                <dc:element name="${facet_name}">
-                  <dc:attribute name="description" value="${facet_description}"/>
-                  <dc:attribute name="ids" value="${facet_num}"/>
-                  <dc:attribute name="factory" value="winfo"/>
-                  <dc:attribute name="artifact-id" value="${a_gid}"/>
-                  <dc:attribute name="out" value="floodmap"/>
-                </dc:element>
-              </dc:for-each>
-            </own-hws>
-          </dc:context>
-        </dc:for-each>
+      <dc:comment>No grouping in this?</dc:comment>
+      <dc:filter expr="$out_name = 'floodmap' and $facet_name = 'floodmap.usershape'">
+        <own-hws>
+          <dc:for-each>
+            <dc:element name="${facet_name}">
+              <dc:attribute name="description" value="${facet_description}"/>
+              <dc:attribute name="ids" value="${facet_num}"/>
+              <dc:attribute name="factory" value="winfo"/>
+              <dc:attribute name="artifact-id" value="${a_gid}"/>
+              <dc:attribute name="out" value="floodmap"/>
+            </dc:element>
+          </dc:for-each>
+        </own-hws>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bedquality-bed">
-      <dc:filter expr="$out_name = 'bed_longitudinal_section'">
+      <dc:filter expr="$out_name = 'bed_longitudinal_section' and
+        ($facet_name = 'bed_longitudinal_section.bed_diameter_toplayer' or
+        $facet_name = 'bed_longitudinal_section.bed_diameter_sublayer')">
         <dc:if test="dc:has-result()">
           <bed_quality_bed>
-            <dc:for-each>
-              <quality-bed description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                    f.id          AS fid,
-                    f.name        AS facet_name,
-                    f.num         AS facet_num,
-                    f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE
-                    (f.name = 'bed_longitudinal_section.bed_diameter_toplayer'
-                    OR f.name = 'bed_longitudinal_section.bed_diameter_sublayer') AND
-                    f.out_id = o.id         AND
-                    o.artifact_id = ${a_id} AND
-                    a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="bed_longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <quality-bed description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="bed_longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
               </quality-bed>
-            </dc:for-each>
+            </dc:group>
           </bed_quality_bed>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bedquality-load">
-      <dc:filter expr="$out_name = 'bed_longitudinal_section'">
+      <dc:filter expr="$out_name = 'bed_longitudinal_section' and
+        $facet_name = 'bed_longitudinal_section.bedload_diameter'">
         <dc:if test="dc:has-result()">
           <bed_quality_load>
-            <dc:for-each>
-              <quality-load description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE
-                       f.name = 'bed_longitudinal_section.bedload_diameter' AND
-                       f.out_id = o.id         AND
-                       o.artifact_id = ${a_id} AND
-                       a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="bed_longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <quality-load description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="bed_longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
               </quality-load>
-            </dc:for-each>
+            </dc:group>
           </bed_quality_load>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bedquality-density">
-      <dc:filter expr="$out_name = 'bed_longitudinal_section'">
+      <dc:filter expr="$out_name = 'bed_longitudinal_section' and
+        ($facet_name = 'bed_longitudinal_section.sediment_density_toplayer' or
+         $facet_name = 'bed_longitudinal_section.sediment_density_sublayer')">
         <dc:if test="dc:has-result()">
           <bed_quality_density>
-            <dc:for-each>
-              <density description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE
-                       (f.name = 'bed_longitudinal_section.sediment_density_toplayer' OR
-                        f.name = 'bed_longitudinal_section.sediment_density_sublayer') AND
-                       f.out_id = o.id         AND
-                       o.artifact_id = ${a_id} AND
-                       a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="bed_longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <density description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="bed_longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
               </density>
-            </dc:for-each>
+            </dc:group>
           </bed_quality_density>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bedquality-porosity">
-      <dc:filter expr="$out_name = 'bed_longitudinal_section'">
+      <dc:filter expr="$out_name = 'bed_longitudinal_section' and
+        ($facet_name = 'bed_longitudinal_section.porosity_toplayer' or
+        $facet_name = 'bed_longitudinal_section.porosity_sublayer')">
         <dc:if test="dc:has-result()">
           <bed_quality_porosity>
-            <dc:for-each>
-              <porosity description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE
-                       (f.name = 'bed_longitudinal_section.porosity_toplayer' OR
-                        f.name = 'bed_longitudinal_section.porosity_sublayer') AND
-                       f.out_id = o.id         AND
-                       o.artifact_id = ${a_id} AND
-                       a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="bed_longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <porosity description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="bed_longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
               </porosity>
-            </dc:for-each>
+            </dc:group>
           </bed_quality_porosity>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="flow-velocity">
-      <dc:filter expr="$out_name = 'flow_velocity'">
+      <dc:filter expr="$out_name = 'flow_velocity' and
+        ($facet_name = 'flow_velocity.totalchannel' or
+         $facet_name = 'flow_velocity.mainchannel' or
+         $facet_name = 'flow_velocity.totalchannel.filtered' or
+         $facet_name = 'flow_velocity.mainchannel.filtered')">
         <dc:if test="dc:has-result()">
           <flow-velocity>
-            <dc:for-each>
-              <flow description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE
-                      (f.name = 'flow_velocity.totalchannel' OR
-                       f.name = 'flow_velocity.mainchannel' OR
-                       f.name = 'flow_velocity.totalchannel.filtered' OR
-                       f.name = 'flow_velocity.mainchannel.filtered') AND
-                       f.out_id = o.id         AND
-                       o.artifact_id = ${a_id} AND
-                       a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="flow_velocity"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <flow description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="flow_velocity"/>
+                  </dc:element>
+                </dc:for-each>
               </flow>
-            </dc:for-each>
+            </dc:group>
           </flow-velocity>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="sediment-load">
-      <dc:filter expr="$out_name = 'sedimentload_ls'">
+      <dc:filter expr="$out_name = 'sedimentload_ls' and starts-with($facet_name, 'sedimentload')">
         <dc:if test="dc:has-result()">
           <sediment-load>
-            <dc:for-each>
-              <load description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE f.name LIKE 'sedimentload%' AND
-                          f.out_id = o.id         AND
-                          o.artifact_id = ${a_id} AND
-                          a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="sedimentload_ls"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <load description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="sedimentload_ls"/>
+                  </dc:element>
+                </dc:for-each>
               </load>
-            </dc:for-each>
+            </dc:group>
           </sediment-load>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="bedheight-differences">
-      <dc:filter expr="$out_name = 'bed_difference_year' or $out_name = 'bed_difference_epoch'">
+      <dc:filter expr="($out_name = 'bed_difference_year' or $out_name = 'bed_difference_epoch') and
+        (starts-with($facet_name, 'bedheight_difference.year') or starts-with($facet_name, 'bedheight_difference.epoch'))">
         <dc:if test="dc:has-result()">
           <bedheight-differences>
-            <dc:for-each>
-              <difference description="{$river} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE (f.name LIKE 'bedheight_difference.year%' OR
-                           f.name LIKE 'bedheight_difference.epoch%') AND
-                          f.out_id = o.id         AND
-                          o.artifact_id = ${a_id} AND
-                          a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="minfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:choose>
-                        <dc:when test="dc:contains($o_name, 'bed_difference_year')">
-                          <dc:attribute name="out" value="bed_difference_year"/>
-                        </dc:when>
-                        <dc:otherwise>
-                          <dc:attribute name="out" value="bed_difference_epoch"/>
-                        </dc:otherwise>
-                      </dc:choose>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($river, ' ', $a_creation, ' ', $collection_name)">
+              <difference description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="minfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="${out}"/>
+                  </dc:element>
+                </dc:for-each>
               </difference>
-            </dc:for-each>
+            </dc:group>
           </bedheight-differences>
         </dc:if>
       </dc:filter>
     </dc:macro>
 
     <dc:macro name="waterlevels-discharge">
-      <dc:filter expr="$out_name = 'discharge_longitudinal_section'">
+      <dc:filter expr="$out_name = 'discharge_longitudinal_section' and $facet_name = 'discharge_longitudinal_section.w">
         <dc:if test="dc:has-result()">
           <waterlevels-discharge>
-            <dc:for-each>
-              <discharge description="{$oid} {$river} {$a_id} {$a_creation} {$collection_name}">
-                <dc:context>
-                  <dc:statement>
-                    SELECT a.gid         AS aid,
-                           f.id          AS fid,
-                           f.name        AS facet_name,
-                           f.num         AS facet_num,
-                           f.description AS facet_description
-                    FROM outs AS o, facets AS f, artifacts AS a
-                    WHERE f.name = 'discharge_longitudinal_section.w' AND
-                          f.out_id = o.id         AND
-                          o.artifact_id = ${a_id} AND
-                          a.id = ${a_id}
-                  </dc:statement>
-                  <dc:for-each>
-                    <dc:element name="${facet_name}">
-                      <dc:attribute name="factory" value="winfo"/>
-                      <dc:attribute name="description" value="${facet_description}"/>
-                      <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
-                      <dc:attribute name="artifact-id" value="${aid}"/>
-                      <dc:attribute name="out" value="longitudinal_section"/>
-                    </dc:element>
-                  </dc:for-each>
-                </dc:context>
+            <dc:group expr="concat($oid, ' ', $river, ' ', $a_id, ' ', $a_creation, ' ', $collection_name)">
+              <discharge description="{dc:group-key()}">
+                <dc:for-each>
+                  <dc:element name="${facet_name}">
+                    <dc:attribute name="factory" value="winfo"/>
+                    <dc:attribute name="description" value="${facet_description}"/>
+                    <dc:attribute name="ids" value="${facet_num}-${facet_name}"/>
+                    <dc:attribute name="artifact-id" value="${a_id}"/>
+                    <dc:attribute name="out" value="longitudinal_section"/>
+                  </dc:element>
+                </dc:for-each>
               </discharge>
-            </dc:for-each>
+            </dc:group>
           </waterlevels-discharge>
         </dc:if>
       </dc:filter>
@@ -2521,7 +2315,7 @@
                  wc.position    AS wst_column_position,
                  wc.description AS info,
                  w.description  AS wst_description,
-                 wc.name        AS wst_column_name,
+                 COALESCE(wc.name, '')        AS wst_column_name,
                  wr.a           AS deffrom,
                  wr.b           AS defto
           FROM wst_columns wc
@@ -2548,11 +2342,16 @@
                  COALESCE(ma.ld_from, '')      AS ld_f,
                  COALESCE(ma.ld_to, '')        AS ld_t,
                  o.name                        AS out_name,
-                 o.id                          AS out_id
+                 o.id                          AS out_id,
+                 f.name                        AS facet_name,
+                 f.num                         AS facet_num,
+                 f.description                 AS facet_description,
+                 f.id                          AS fid
           FROM users u
             JOIN collections c             ON c.user_id = u.id
             JOIN master_artifacts_range ma ON ma.collection_id = c.id
             JOIN outs o                    ON o.artifact_id = ma.id
+            JOIN facets f                  ON f.out_id = o.id
           WHERE  u.gid = CAST(${user-id} AS UUID)
             AND ma.gid <> CAST(${artifact-id} AS uuid)
             AND EXISTS (


More information about the Dive4elements-commits mailing list