changeset 4904:aa67a88314f2 dc-km-filter

[branch: dc-km-filter]: Merge with tip.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Jan 2013 08:26:54 +0100
parents 137ff80f0a01 (diff) 5ab87837622f (current diff)
children 4d1e2a0c283a
files
diffstat 2 files changed, 45 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/meta-data.xml	Tue Jan 29 17:42:04 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Wed Jan 30 08:26:54 2013 +0100
@@ -1,19 +1,23 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage">
 <datacage>
-<dc:macro name="SQL-wst_columns_statement">
-    <dc:statement>
-        SELECT wst_columns.id          AS prot_column_id,
-               wst_columns.name        AS prot_column_name,
-               wst_columns.position    AS prot_rel_pos,
-               wst_columns.description AS info,
-               wst_ranges.a            AS deffrom,
-               wst_ranges.b            AS defto
-        FROM wst_columns, wst_ranges
-        WHERE wst_columns.wst_id = ${prot_id} AND wst_ranges.wst_column_id = wst_columns.id
-        ORDER by wst_columns.position
-    </dc:statement>
-</dc:macro>
+  <dc:macro name="SQL-wst_columns_statement">
+      <dc:statement>
+          SELECT wst_columns.id          AS prot_column_id,
+                 wst_columns.name        AS prot_column_name,
+                 wst_columns.position    AS prot_rel_pos,
+                 wst_columns.description AS info,
+                 wst_ranges.a            AS deffrom,
+                 wst_ranges.b            AS defto
+          FROM wst_columns, wst_ranges
+          WHERE wst_columns.wst_id = ${prot_id} AND wst_ranges.wst_column_id = wst_columns.id
+          AND ( CAST(${startkm} AS DOUBLE PRECISION) BETWEEN wst_ranges.a AND wst_ranges.b
+           OR CAST(${endkm} AS DOUBLE PRECISION) BETWEEN wst_ranges.a AND wst_ranges.b
+           OR wst_ranges.a BETWEEN CAST(${startkm} AS DOUBLE PRECISION) AND CAST(${endkm} AS DOUBLE PRECISION)
+          )
+          ORDER by wst_columns.position
+      </dc:statement>
+  </dc:macro>
   <dc:macro name="load-system">
     <dc:context connection="system">
       <dc:statement>
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Tue Jan 29 17:42:04 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Wed Jan 30 08:26:54 2013 +0100
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.client.ui;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import com.google.gwt.core.client.GWT;
@@ -68,11 +69,37 @@
         setWidth(400);
         setHeight(500);
 
+        String startKm =
+            artifact.getArtifactDescription().getDataValueAsString("ld_from");
+        String endKm =
+            artifact.getArtifactDescription().getDataValueAsString("ld_to");
+        String parameter = "load-system:true";
+
+        if (startKm == null || startKm.equals("") || endKm == null
+            || endKm.equals("")) {
+            String locations =
+                artifact.getArtifactDescription().getDataValueAsString("ld_locations");
+            if (locations != null && !locations.equals("")) {
+                String[] ls = locations.split(" ");
+                Double locs[] = new Double[ls.length];
+                for (int i = 0; i < ls.length ; i++) {
+                    locs[i] = Double.parseDouble(ls[i]);
+                }
+                Arrays.sort(locs);
+                parameter = parameter + ";startkm:" + locs[0] +
+                    ";endkm:" + locs[locs.length-1];
+            }
+        }
+        else {
+            parameter = parameter + ";startkm:" + startKm +
+                ";endkm:" + endKm;
+        }
+        GWT.log("parameter " + parameter);
         DatacageWidget dw = new DatacageWidget(
             artifact,
             user,
             outs,
-            "load-system:true",
+            parameter,
             true);
         dw.addDatacageHandler(this);
         dw.addDatacageDoubleClickHandler(this);

http://dive4elements.wald.intevation.org