changeset 615:01054ddccb0f

Repaired multi parameter selection. gnv-artifacts/trunk@685 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 12 Feb 2010 15:36:05 +0000
parents e80e37b78302
children 93978859fa9e
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultInputData.java gnv-artifacts/src/main/java/de/intevation/gnv/state/InputData.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 5 files changed, 60 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- 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 <ingo.weinzierl@intevation.de>
+
+	* 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 <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java: Removed
--- 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;
     }
 
--- 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);
     
--- 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<Object> data     = queryDatabase(filterValues, uuid);
 
                     cache.put(new net.sf.ehcache.Element(key, data));
-
                     return data;
                 }
                 catch (QueryException qe) {
--- 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;
     }

http://dive4elements.wald.intevation.org