Mercurial > dive4elements > gnv-client
changeset 78:969faa37a11b
Added Multiselectsupport for InputValues
gnv-artifacts/trunk@94 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 16 Sep 2009 12:38:24 +0000 |
parents | 0e38f512f7e4 |
children | e33c61735a4e |
files | gnv-artifacts/Changelog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputData.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputData.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java gnv-artifacts/src/test/ressources/conf.xml |
diffstat | 9 files changed, 70 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/Changelog Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/Changelog Wed Sep 16 12:38:24 2009 +0000 @@ -1,3 +1,15 @@ +2009-09-16 Tim Englich <tim.englich@intevation.de> + + * src/test/ressources/conf.xml Edited, + src/main/java/de/intevation/gnv/transition/TransitionBase.java (describe) Edited, + src/main/java/de/intevation/gnv/transition/InputValue.java (isMultiselect) Edited, + src/main/java/de/intevation/gnv/transition/InputData.java (concartValue) Edited, + src/main/java/de/intevation/gnv/transition/DefaultInputValue.java (isMultiselect) Edited, + src/main/java/de/intevation/gnv/transition/DefaultInputData.java (concartValue)Edited, + src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java (createUserInterface) Edited, + src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java (parseInputData) Edited: + Added Multiselectsupport for InputValues + 2009-09-16 Tim Englich <tim.englich@intevation.de> * src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java (setup) Edited:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Wed Sep 16 12:38:24 2009 +0000 @@ -305,21 +305,31 @@ protected Collection<InputData> parseInputData(Document document){ log.debug("GNVArtifactBase.parseInputData"); - Collection<InputData> returnValue = null; + HashMap<String,InputData> returnValue = null; log.debug(new ArtifactXMLUtilities().writeDocument2String(document)); NodeList inputElemets = (NodeList)XMLUtils.xpath(document, "/action/data/input",XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);//Config.getNodeSetXPath(document, ""); if(inputElemets != null){ - returnValue = new ArrayList<InputData>(inputElemets.getLength()); + returnValue = new HashMap<String,InputData>(inputElemets.getLength()); for (int i = 0; i < inputElemets.getLength(); i++){ Node inputDataNode = inputElemets.item(i); - InputData inputData = new DefaultInputData(Config.getStringXPath(inputDataNode,"@name"), Config.getStringXPath(inputDataNode,"@value")); - log.debug(inputData.toString()); - returnValue.add(inputData); + String name = Config.getStringXPath(inputDataNode,"@name"); + String value = Config.getStringXPath(inputDataNode,"@value"); + + if (returnValue.containsKey(name)){ + InputData inputData = returnValue.get(name); + inputData.concartValue(value); + log.debug(inputData.toString()); + returnValue.put(name, inputData); + }else{ + InputData inputData = new DefaultInputData(name,value); + + returnValue.put(name,inputData); + } } } - return returnValue; + return returnValue.values(); } /** * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, java.lang.Object)
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Wed Sep 16 12:38:24 2009 +0000 @@ -331,7 +331,7 @@ if (this.products != null && !this.products.isEmpty()){ String selectboxName = "product"; Iterator<Product> it = this.products.values().iterator(); - Element selectNode = xmlUtilities.createXFormElement(document,"select"); + Element selectNode = xmlUtilities.createXFormElement(document,"select1"); selectNode.setAttribute("ref", selectboxName); uiNode.appendChild(selectNode);
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputData.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputData.java Wed Sep 16 12:38:24 2009 +0000 @@ -9,6 +9,10 @@ public class DefaultInputData implements InputData { + /** + * + */ + private static final long serialVersionUID = 4308041648698108066L; private String name = null; private String value = null; /** @@ -41,4 +45,11 @@ return this.name + "==> "+ this.value; } + /** + * @see de.intevation.gnv.transition.InputData#concartValue(java.lang.String) + */ + public void concartValue(String value) { + this.value = this.value +" , "+value; + } + }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java Wed Sep 16 12:38:24 2009 +0000 @@ -8,16 +8,22 @@ */ public class DefaultInputValue implements InputValue { + /** + * The UID of this Class. + */ + private static final long serialVersionUID = -8518824299166180986L; private String name = null; private String type = null; + private boolean multiselect = false; /** * Constructor */ - public DefaultInputValue(String name, String type){ + public DefaultInputValue(String name, String type, boolean multiselect){ this.name = name; this.type = type; + this.multiselect = multiselect; } /** @@ -39,7 +45,14 @@ */ @Override public String toString() { - return "InputValue "+name+" ==> "+type; + return "InputValue "+this.name+" ==> "+this.type+ "==> multiselect: "+this.multiselect; + } + + /** + * @see de.intevation.gnv.transition.InputValue#isMultiselect() + */ + public boolean isMultiselect() { + return this.multiselect; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputData.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputData.java Wed Sep 16 12:38:24 2009 +0000 @@ -13,4 +13,5 @@ public String getName(); public String getValue(); + public void concartValue(String value); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java Wed Sep 16 12:38:24 2009 +0000 @@ -13,5 +13,6 @@ public String getName(); public String getType(); + public boolean isMultiselect(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java Wed Sep 16 12:38:24 2009 +0000 @@ -124,7 +124,7 @@ this.inputValueNames = new ArrayList<String>(inputValuesNodes.getLength()); for (int i = 0 ; i < inputValuesNodes.getLength(); i++){ Node inputValueNode = inputValuesNodes.item(i); - InputValue inputValue = new DefaultInputValue(Config.getStringXPath(inputValueNode,"@name"), Config.getStringXPath(inputValueNode,"@type")); + InputValue inputValue = new DefaultInputValue(Config.getStringXPath(inputValueNode,"@name"), Config.getStringXPath(inputValueNode,"@type"), Boolean.parseBoolean(Config.getStringXPath(inputValueNode,"@multiselect"))); log.debug(inputValue.toString()); this.inputValues.put(inputValue.getName(),inputValue); this.inputValueNames.add(inputValue.getName()); @@ -248,12 +248,13 @@ Object o = it.next(); if (!it.hasNext()){ if (o instanceof Collection<?>){ - Element selectNode = xmlutilities.createXFormElement(document,"select"); // TODO: HACK: // BESSERE LÖSUNG FINDEN Object[] names = this.inputValueNames.toArray(); String name = names[names.length-1].toString(); + boolean multiselect = this.inputValues.get(name).isMultiselect(); + Element selectNode = xmlutilities.createXFormElement(document,multiselect ? "select" : "select1"); selectNode.setAttribute("ref", name); Element lableNode = xmlutilities.createXFormElement(document, "label");
--- a/gnv-artifacts/src/test/ressources/conf.xml Wed Sep 16 07:49:46 2009 +0000 +++ b/gnv-artifacts/src/test/ressources/conf.xml Wed Sep 16 12:38:24 2009 +0000 @@ -60,7 +60,7 @@ <transition>timeseries_parameter</transition> </reachableTransitions> <inputvalues> - <inputvalue name="sourceid" type="Integer"/> + <inputvalue name="sourceid" type="Integer" multiselect="false"/> </inputvalues> </transition> @@ -70,7 +70,7 @@ <transition>timeseries_depth_height</transition> </reachableTransitions> <inputvalues> - <inputvalue name="featureid" type="Integer"/> + <inputvalue name="featureid" type="Integer" multiselect="false"/> </inputvalues> </transition> @@ -80,8 +80,8 @@ <transition>timeseries_interval</transition> </reachableTransitions> <inputvalues> - <inputvalue name="featureid" type="Integer"/> - <inputvalue name="parameterid" type="Integer"/> + <inputvalue name="featureid" type="Integer" multiselect="false"/> + <inputvalue name="parameterid" type="Integer" multiselect="true"/> </inputvalues> </transition> @@ -91,18 +91,18 @@ <transition>timeseries_calculate_results</transition> </reachableTransitions> <inputvalues> - <inputvalue name="parameterid" type="Integer"/> - <inputvalue name="measurementid" type="Integer"/> + <inputvalue name="parameterid" type="Integer" multiselect="true"/> + <inputvalue name="measurementid" type="Integer" multiselect="true"/> </inputvalues> </transition> <transition id="timeseries_calculate_results" description="timeseries_interval" transition="de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition"> <queryID>timeseries_chart_data</queryID> <inputvalues> - <inputvalue name="parameterid" type="Integer"/> - <inputvalue name="measurementid" type="Integer"/> - <inputvalue name="minvalue" type="Integer"/> - <inputvalue name="maxvalue" type="Integer"/> + <inputvalue name="parameterid" type="Integer" multiselect="true"/> + <inputvalue name="measurementid" type="Integer" multiselect="true"/> + <inputvalue name="minvalue" type="Integer" multiselect="false"/> + <inputvalue name="maxvalue" type="Integer" multiselect="false"/> </inputvalues> <outputsModes> <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/>