changeset 631:a9af60c84dca

Small bugfixes in the WQ selection state. flys-artifacts/trunk@1996 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 24 May 2011 13:24:24 +0000
parents 40d3039f85ac
children 07640ab913fd
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java
diffstat 3 files changed, 31 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 24 12:58:55 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 24 13:24:24 2011 +0000
@@ -1,3 +1,12 @@
+2011-05-24  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/WQSelect.java:
+	  Improved the validation of WQ values.
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Use the
+	  correct input data object to determine the selected WQ mode (range or
+	  single input).
+
 2011-05-24  Ingo Weinzierl <ingo@intevation.de>
 
 	  ISSUE-40 (part I/II)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Tue May 24 12:58:55 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Tue May 24 13:24:24 2011 +0000
@@ -648,13 +648,14 @@
      * @return the selected Q values or null, if no Q values are selected.
      */
     public double[] getQs() {
-        StateData dMode   = getData("wq_mode");
-        StateData dSingle = getData("wq_single");
+        StateData dMode      = getData("wq_mode");
+        StateData dSelection = getData("wq_selection");
 
         String mode = dMode != null ? (String) dMode.getValue() : "";
+        String sel  = dSelection != null ? (String)dSelection.getValue() : null;
 
         if (mode.equals("Q")) {
-            if (dSingle != null) {
+            if (sel != null && sel.equals("single")) {
                 return getSingleWQValues();
             }
             else {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Tue May 24 12:58:55 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java	Tue May 24 13:24:24 2011 +0000
@@ -271,23 +271,33 @@
     throws    IllegalArgumentException
     {
         logger.debug("WQSelect.validateRange");
+        FLYSArtifact flys = (FLYSArtifact) artifact;
 
-        String mode = (String) data.get(WQ_MODE).getValue();
+        StateData data = flys.getData(WQ_MODE);
+        String    mode = data != null ? (String) data.getValue() : null;
         logger.debug("WQ Mode: " + mode);
 
-        String fromStr = (String) data.get(WQ_FROM).getValue();
-        String toStr   = (String) data.get(WQ_TO).getValue();
-        String stepStr = (String) data.get(WQ_STEP).getValue();
+        if (mode == null || mode.length() == 0) {
+            throw new IllegalArgumentException("error_feed_invalid_wq_mode");
+        }
+
+        StateData dFrom = flys.getData(WQ_FROM);
+        StateData dTo   = flys.getData(WQ_TO);
+        StateData dStep = flys.getData(WQ_STEP);
+
+        String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
+        String toStr   = dTo != null ? (String) dTo.getValue() : null;
+        String stepStr = dStep != null ? (String) dStep.getValue() : null;
 
         if (fromStr == null || toStr == null || stepStr == null) {
             throw new IllegalArgumentException("error_empty_state");
         }
 
-        double from = Double.parseDouble(fromStr);
-        double to   = Double.parseDouble(toStr);
-        double step = Double.parseDouble(stepStr);
+        try {
+            double from = Double.parseDouble(fromStr);
+            double to   = Double.parseDouble(toStr);
+            double step = Double.parseDouble(stepStr);
 
-        try {
             if (mode != null && mode.trim().toLowerCase().equals("w")) {
                 return validateW(artifact, context, from, to, step);
             }

http://dive4elements.wald.intevation.org