Mercurial > dive4elements > gnv-client
changeset 610:6484464d2059
Changed the mechanism for searching for specific parameter collections.
gnv-artifacts/trunk@676 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 11 Feb 2010 11:58:39 +0000 |
parents | 22e65fb4c64a |
children | 4b818f13e20a |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java |
diffstat | 4 files changed, 145 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Thu Feb 11 08:54:58 2010 +0000 +++ b/gnv-artifacts/ChangeLog Thu Feb 11 11:58:39 2010 +0000 @@ -1,3 +1,20 @@ +2010-02-11 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/state/StateBase.java: Declared method as + 'protected' to be allowed to use it in derived classes. + + * src/main/java/de/intevation/gnv/state/OutputStateBase.java: Changed the + key to store into cache and restore data from it. Added a workarround to + find min and max value fields in InputData. + + * src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java: + Adapted the search mechanism for specific parameter collections. This is + required, because the the former mechanism searched in the big cache blob + - which doesn't exist anymore. + + TODO: Repair chart generation. Although there are results existing for + chart generation, no chart in drawn. + 2010-02-11 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/java/de/intevation/gnv/state/StateBase.java: Improved hash
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java Thu Feb 11 08:54:58 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java Thu Feb 11 11:58:39 2010 +0000 @@ -19,12 +19,18 @@ import de.intevation.gnv.geobackend.base.query.exception.QueryException; +import de.intevation.gnv.state.describedata.MinMaxDescribeData; + import de.intevation.gnv.state.exception.StateException; +import de.intevation.gnv.utils.InputValidator; + import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.Locale; import org.apache.log4j.Logger; @@ -170,7 +176,7 @@ log.debug("OutputStateBase.getChartResult"); Object result = null; if (CacheFactory.getInstance().isInitialized()) { - String key = uuid + super.getID(); + String key = "chart_" + getHash(); log.debug("Hash for Queryelements: " + key); net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); if (value != null) { @@ -190,7 +196,7 @@ log.debug("Fetch chart [" + uuid + "] from cache"); CacheFactory cacheFactory = CacheFactory.getInstance(); if (cacheFactory.isInitialized()) { - String key = "chart_" + uuid + super.getID(); + String key = "chart_" + getHash(); net.sf.ehcache.Element object = cacheFactory.getCache().get(key); if (object != null) { @@ -238,7 +244,7 @@ protected void removeChartResult(String uuid) { log.debug("OutputStateBase.getChartResult"); if (CacheFactory.getInstance().isInitialized()) { - String key = uuid + super.getID(); + String key = "chart_" + getHash(); log.debug("Hash for Queryelements: " + key); net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); if (value != null) { @@ -252,7 +258,7 @@ CacheFactory cacheFactory = CacheFactory.getInstance(); if (cacheFactory.isInitialized()) { - String key = "chart_" + uuid + super.getID(); + String key = "chart_" + getHash(); net.sf.ehcache.Element object = cacheFactory.getCache().get(key); if (object != null) cacheFactory.getCache().remove(key); @@ -263,11 +269,19 @@ log.debug("Prufify chart [" + uuid + "]"); CacheFactory cacheFactory = CacheFactory.getInstance(); if (cacheFactory.isInitialized()) { - String key = "chart_" + uuid + getID(); + String key = "chart_" + getHash(); cacheFactory.getCache().put(new net.sf.ehcache.Element(key, chart)); } } + + @Override + public void feed(Collection<InputData> inputData, String uuid) + throws StateException + { + putInputData(inputData, uuid); + } + /** * @see de.intevation.gnv.state.StateBase#putInputData(java.util.Collection, java.lang.String) */ @@ -278,7 +292,94 @@ log.debug("OutputStateBase.putInputData"); this.removeChartResult(uuid); this.removeChart(uuid); - super.putInputData(inputData, uuid); + + if (inputData != null) { + Iterator<InputData> it = inputData.iterator(); + InputValidator iv = new InputValidator(); + while (it.hasNext()) { + InputData tmpItem = it.next(); + Object tmpObj = tmpItem.getObject(); + InputValue inputValue = this.inputValues.get(tmpItem.getName()); + if (inputValue != null) { + if (this.inputData == null) { + this.inputData = new HashMap<String, InputData>( + inputData.size()); + } + + boolean valid = iv.isInputValid(tmpItem.getValue(), + inputValue.getType()); + if (valid) { + if (tmpItem.getName().equals(MINVALUEFIELDNAME)){ + String minValue = tmpItem.getValue(); + String maxValue = getInputValue4ID(inputData, MAXVALUEFIELDNAME); + valid = iv.isInputValid(maxValue,inputValue.getType()); + if (!valid){ + String errMsg = "Wrong input for " + tmpItem.getValue() + + " is not an " + inputValue.getType() + + " Value."; + log.warn(errMsg); + throw new StateException(errMsg); + } + + valid = iv.isInputValid(minValue, + maxValue, + inputValue.getType()); + if (!valid){ + String errMsg = "MaxValue-Input is less than MinValue-Input "; + log.warn(errMsg); + throw new StateException(errMsg); + } + }else if (tmpItem.getName().equals(MAXVALUEFIELDNAME)){ + String minValue = getInputValue4ID(inputData, MINVALUEFIELDNAME); + String maxValue = tmpItem.getValue(); + valid = iv.isInputValid(minValue,inputValue.getType()); + if (!valid){ + String errMsg = "Wrong input for " + tmpItem.getValue() + + " is not an " + inputValue.getType() + + " Value."; + log.warn(errMsg); + throw new StateException(errMsg); + } + + valid = iv.isInputValid(minValue, + maxValue, + inputValue.getType()); + if (!valid){ + String errMsg = "MaxValue-Input is less than MinValue-Input "; + log.warn(errMsg); + throw new StateException(errMsg); + } + } + this.inputData.put(tmpItem.getName(), tmpItem); + } else { + String errMsg = "Wrong input for " + tmpItem.getValue() + + " is not an " + inputValue.getType() + + " Value."; + log.warn(errMsg); + throw new StateException(errMsg); + } + + } + else if (tmpObj != null && tmpObj instanceof MinMaxDescribeData) { + MinMaxDescribeData data = (MinMaxDescribeData) tmpObj; + if (this.inputData == null) { + this.inputData = new HashMap<String, InputData>(inputData.size()); + } + this.inputData.put(tmpItem.getName(), tmpItem); + this.inputData.put("minvalue", new DefaultInputData("minvalue", (String) data.getMinValue())); + this.inputData.put("maxvalue", new DefaultInputData("maxvalue", (String) data.getMaxValue())); + } + else { + + String errMsg = "No Inputvalue given for Inputdata " + + tmpItem.getName(); + log.warn(errMsg + "Value will be ignored"); + + } + } + } else { + log.warn("No Inputdata given"); + } } public void out(String outputMode, Collection<InputData> inputData,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Thu Feb 11 08:54:58 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Thu Feb 11 11:58:39 2010 +0000 @@ -366,7 +366,7 @@ this.preSettings = preSettings; } - private String getInputValue4ID(Collection<InputData> inputData, String inputName){ + protected String getInputValue4ID(Collection<InputData> inputData, String inputName){ Iterator<InputData> it = inputData.iterator(); while (it.hasNext()) { InputData tmpItem = it.next();
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Thu Feb 11 08:54:58 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Thu Feb 11 11:58:39 2010 +0000 @@ -38,7 +38,9 @@ import de.intevation.gnv.state.InputData; import de.intevation.gnv.state.OutputStateBase; +import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData; import de.intevation.gnv.state.describedata.KeyValueDescibeData; +import de.intevation.gnv.state.describedata.NamedArrayList; import de.intevation.gnv.state.describedata.NamedCollection; import de.intevation.gnv.state.exception.StateException; @@ -530,13 +532,12 @@ while (it.hasNext()) { KeyValueDescibeData data = (KeyValueDescibeData) it.next(); + return data.getValue(); + } - if (data.isSelected()) { - return data.getValue(); - } - } + return ""; } - return null; + return ""; } @@ -870,32 +871,31 @@ value)); } } - } } } } - + /** * @param collectionName * @return */ protected Collection<KeyValueDescibeData> getCollection( - String collectionName, - String uuid) { - Iterator<Object> it = this.getDescibeData(uuid).iterator(); - while (it.hasNext()) { - - Object o = it.next(); + String collectionName, + String uuid) + { + NamedCollection<KeyValueDescibeData> c = new NamedArrayList<KeyValueDescibeData>(collectionName); - if (o instanceof NamedCollection<?>) { - NamedCollection<KeyValueDescibeData> nc = (NamedCollection<KeyValueDescibeData>) o; - if (nc.getName().equals(collectionName)) { - return nc; - } - } + InputData data = inputData.get(collectionName); + if (data == null) { + log.warn("No collection found with name: " + collectionName); + return c; } - return null; + + c.add(new DefaultKeyValueDescribeData( + data.getValue(), data.getDescription(), getID())); + + return c; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :