# HG changeset patch # User Ingo Weinzierl # Date 1306243464 0 # Node ID a9af60c84dcae39ca4e9195d8196183c8d6c0b2a # Parent 40d3039f85acaa36db9947605d210a66040bd7a0 Small bugfixes in the WQ selection state. flys-artifacts/trunk@1996 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 40d3039f85ac -r a9af60c84dca flys-artifacts/ChangeLog --- 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 + + * 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 ISSUE-40 (part I/II) diff -r 40d3039f85ac -r a9af60c84dca flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- 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 { diff -r 40d3039f85ac -r a9af60c84dca flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java --- 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); }