# HG changeset patch # User Ingo Weinzierl # Date 1265988965 0 # Node ID 01054ddccb0f677f24c4e20009c4fb0f3303ef82 # Parent e80e37b783027807b9b729878a0e9af8e862b8d6 Repaired multi parameter selection. gnv-artifacts/trunk@685 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e80e37b78302 -r 01054ddccb0f gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Fri Feb 12 11:16:37 2010 +0000 +++ b/gnv-artifacts/ChangeLog Fri Feb 12 15:36:05 2010 +0000 @@ -1,3 +1,20 @@ +2010-02-12 Ingo Weinzierl + + * src/main/java/de/intevation/gnv/state/InputData.java, + src/main/java/de/intevation/gnv/state/DefaultInputData.java: Descriptions + of values are stored in an array, because one InputData object can contain + many data. + + * src/main/java/de/intevation/gnv/state/StateBase.java: Get a description + for each input parameter and use an array to store all descriptions in an + InputData object. Result of this is, that all user selected parameters are + displayed and charts are well drawn again. + + * src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java: + Split up data values stored in InputData objects in search mechanism for + specific parameters and put them all as KeyValueDescibeData objects into a + collection. + 2010-02-12 Ingo Weinzierl * src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java: Removed diff -r e80e37b78302 -r 01054ddccb0f gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java Fri Feb 12 11:16:37 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java Fri Feb 12 15:36:05 2010 +0000 @@ -16,10 +16,10 @@ private final static String VALUE_SEPARATOR = " , "; - protected String name; - protected String value; - protected String description; - protected Object object; + protected String name; + protected String value; + protected String[] description; + protected Object object; /** @@ -57,11 +57,11 @@ return object; } - public String getDescription() { + public String[] getDescription() { return description; } - public void setDescription(String description) { + public void setDescription(String[] description) { this.description = description; } diff -r e80e37b78302 -r 01054ddccb0f gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.java Fri Feb 12 11:16:37 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.java Fri Feb 12 15:36:05 2010 +0000 @@ -19,9 +19,9 @@ public Object getObject(); - public void setDescription(String description); + public void setDescription(String[] description); - public String getDescription(); + public String[] getDescription(); public void concartValue(String value); diff -r e80e37b78302 -r 01054ddccb0f gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Fri Feb 12 11:16:37 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Fri Feb 12 15:36:05 2010 +0000 @@ -225,7 +225,7 @@ boolean valid = iv.isInputValid(tmpItem.getValue(), inputValue.getType()); if (valid) { - String desc = getDescriptionForInputData(tmpItem, uuid); + String[] desc = getDescriptionForInputData(tmpItem, uuid); tmpItem.setDescription(desc); this.inputData.put(tmpItem.getName(), tmpItem); } else { @@ -249,24 +249,31 @@ } - private String getDescriptionForInputData(InputData data, String uuid) { + private String[] getDescriptionForInputData(InputData data, String uuid) { // there is only one element in the list, so take the first Object obj = getDescibeData(uuid).get(0); + List descs = new ArrayList(); if (obj instanceof NamedArrayList) { NamedArrayList list = (NamedArrayList) obj; + String[] selected = data.splitValue(); int size = list.size(); + int ssize = selected.length; for (int i = 0; i < size; i++) { KeyValueDescibeData kv = (KeyValueDescibeData) list.get(i); - if (kv.getKey().equals(data.getValue())) { - return kv.getValue(); + // values are concatinated in InputData, so one InputData object can + // contain many input + for (int j = 0; j < ssize; j++) { + if (kv.getKey().equals(selected[j])) { + descs.add(kv.getValue()); + } } } } - return data.getValue(); + return (String[]) descs.toArray(new String[descs.size()]); } @@ -675,32 +682,28 @@ .getRessource(callMeta.getLanguages(), dataName, dataName)); Element choiceNode = creator.create("choices"); - /* TODO InputData can have more than 1 value if multiselect, implement a - * loop over these values - - while (resultIt.hasNext()) { - KeyValueDescibeData result = resultIt.next(); - */ - artCreator.addAttr( selectNode, "state", getID(), true ); - Element itemNode = creator.create("item"); - - creator.addAttr(itemNode, "selected", "true"); + String[] descriptions = data.getDescription(); + int size = descriptions.length; - Element choiceLableNode = creator.create("label"); - choiceLableNode.setTextContent(data.getDescription()); - itemNode.appendChild(choiceLableNode); + for (int i = 0; i < size; i++) { + Element itemNode = creator.create("item"); - Element choiceValueNode = creator.create("value"); - choiceValueNode.setTextContent(dataName); - itemNode.appendChild(choiceValueNode); - choiceNode.appendChild(itemNode); - /* + creator.addAttr(itemNode, "selected", "true"); + + Element choiceLableNode = creator.create("label"); + choiceLableNode.setTextContent(descriptions[i]); + itemNode.appendChild(choiceLableNode); + + Element choiceValueNode = creator.create("value"); + choiceValueNode.setTextContent(dataName); + itemNode.appendChild(choiceValueNode); + choiceNode.appendChild(itemNode); } - */ + selectNode.appendChild(lableNode); selectNode.appendChild(choiceNode); @@ -922,7 +925,6 @@ List data = queryDatabase(filterValues, uuid); cache.put(new net.sf.ehcache.Element(key, data)); - return data; } catch (QueryException qe) { diff -r e80e37b78302 -r 01054ddccb0f gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Fri Feb 12 11:16:37 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Fri Feb 12 15:36:05 2010 +0000 @@ -892,8 +892,14 @@ return c; } - c.add(new DefaultKeyValueDescribeData( - data.getValue(), data.getDescription(), getID())); + String[] descs = data.getDescription(); + String[] values = data.splitValue(); + int size = values.length; + + for (int i = 0; i < size; i++){ + c.add(new DefaultKeyValueDescribeData( + values[i], descs[i], getID())); + } return c; }