changeset 6183:3f8f212253a0

Simplify and fix range filtering for server data. We did not use the user id in the user range and the ld_* values are provided as parameters for the datacage no need of that artifact database access. This also fixes Location awareness for DGMs
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 04 Jun 2013 16:04:08 +0200
parents 95257f28bb3f
children 58e78e6662fa
files artifacts/doc/conf/meta-data.xml
diffstat 1 files changed, 19 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Tue Jun 04 16:02:17 2013 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Tue Jun 04 16:04:08 2013 +0200
@@ -5,8 +5,12 @@
     <dc:comment>
       User specific part
       ------------------
+      This is a hack because we currently have no way to supress empty
+      folders (either in the client or in the datacage).
     </dc:comment>
-    <dc:if test="dc:contains($parameters, 'user-id') and not(dc:contains($artifact-outs, 'floodmap-hws'))">
+    <dc:if test="dc:contains($parameters, 'user-id') and
+      not(dc:contains($artifact-outs, 'floodmap-hws')) and
+      not($current-state-id = 'state.winfo.uesk.dgm')">
       <dc:call-macro name="load-user"/>
     </dc:if>
 
@@ -32,7 +36,7 @@
     </dc:macro>
 
     <dc:macro name="generate-system-content">
-      <dc:call-macro name="user-range">
+      <dc:call-macro name="artifact-range">
         <dc:call-macro name="km-filtered-wsts">
           <dc:choose>
             <dc:when test="dc:contains($parameters, 'recommended')">
@@ -272,7 +276,7 @@
     </dc:macro>
 
     <dc:macro name="generate-user-content">
-      <dc:call-macro name="user-range">
+      <dc:call-macro name="artifact-range">
         <dc:call-macro name="all-user-artifacts">
           <dc:call-macro name="km-filtered-user-artifacts">
             <dc:choose>
@@ -1442,21 +1446,22 @@
                    d.name  AS name,
                    t.start_time AS start_time,
                    t.stop_time AS stop_time,
-                   'Projektion: ' || d.projection || '$' ||
-                   'Rasterweite: '   || d.resolution || 'm$' ||
-                   'Format: '  || d.format || '$' ||
+                   'Projektion: ' || d.projection || '&lt;BR&gt;' ||
+                   'Rasterweite: '   || d.resolution || 'm&lt;BR&gt;' ||
+                   'Format: '  || d.format || '&lt;BR&gt;' ||
                    'Zeitraum: '
                    AS info
             FROM dem d
               JOIN ranges r ON d.range_id = r.id
               LEFT JOIN time_intervals t ON d.time_interval_id = t.id
-            WHERE d.river_id = ${river_id}
-          </dc:statement>
-          <dc:for-each>
+              WHERE d.river_id = ${river_id}
+              AND NOT((${tokm} &lt; r.a) or (${fromkm} &gt; r.b))
+            </dc:statement>
+            <dc:for-each>
             <dem factory="demfactory" target_out="{$out}"
               ids="{$dem_id}"
               name="{$name}"
-              info="{dc:replace($info, '$', '&lt;BR&gt;')}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}"/>
+              info="{$info}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}"/>
           </dc:for-each>
         </dc:context>
       </dems>
@@ -2397,31 +2402,10 @@
       </dc:filter>
     </dc:macro>
 
-    <dc:macro name="user-range">
-      <dc:choose>
-        <dc:when test="dc:contains($parameters, 'user-id')">
-          <dc:context connection="user">
-            <dc:statement>
-              SELECT COALESCE(ld_mode, '')      AS ldm,
-                     COALESCE(ld_locations, '') AS ldl,
-                     COALESCE(ld_from, '')      AS ldf,
-                     COALESCE(ld_to, '')        AS ldt
-              FROM master_artifacts_range
-              WHERE gid = CAST(${artifact-id} AS uuid)
-            </dc:statement>
-            <dc:for-each>
-              <dc:variable name="fromkm" type="number" expr="dc:fromValue($ldm, $ldl, $ldf)"/>
-              <dc:variable name="tokm" type="number" expr="dc:toValue($ldm, $ldl, $ldt)"/>
-              <dc:macro-body/>
-            </dc:for-each>
-          </dc:context>
-        </dc:when>
-        <dc:otherwise>
-          <dc:variable name="fromkm" type="number" expr="dc:fromValue('', '', '')"/>
-          <dc:variable name="tokm" type="number" expr="dc:toValue('', '', '')"/>
-          <dc:macro-body/>
-        </dc:otherwise>
-      </dc:choose>
+    <dc:macro name="artifact-range">
+      <dc:variable name="fromkm" type="number" expr="dc:fromValue(dc:get('ld_mode'), dc:get('ld_locations'), dc:get('ld_from'))"/>
+      <dc:variable name="tokm" type="number" expr="dc:toValue(dc:get('ld_mode'), dc:get('ld_locations'), dc:get('ld_to'))"/>
+      <dc:macro-body/>
     </dc:macro>
 
   </datacage>

http://dive4elements.wald.intevation.org