Mercurial > dive4elements > gnv-client
changeset 91:bd284d8306db
Added Support for Patameters in OutputModes
gnv-artifacts/trunk@135 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/APP.java Fri Sep 25 14:37:10 2009 +0000 @@ -0,0 +1,21 @@ +/** + * + */ +package de.intevation.gnv.artifacts; + +import de.intevation.artifactdatabase.App; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class APP { + + /** + * @param args + */ + public static void main(String[] args) { + App.main(args); + } + +}
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Fri Sep 25 14:37:10 2009 +0000 @@ -160,7 +160,7 @@ Document result = XMLUtils.newDocument(); try { if (this.current != null){ - this.current.putInputData(this.parseInputData(target)); + this.current.putInputData(this.parseInputData(target, "/action/data/input")); result = new ArtifactXMLUtilities().createSuccessReport("Feed success", XMLUtils.newDocument()); }else{ String msg = "No Transition instantiated"; @@ -308,6 +308,21 @@ outputModeNode.setAttribute("description", outputMode.getDescription()); outputModeNode.setAttribute("mime-type", outputMode.getMimeType()); outputsNode.appendChild(outputModeNode); + + Collection<InputValue> inputParameters = outputMode.getInputParameters(); + if (inputParameters != null){ + Element inputParametersNode = xmlUtilities.createArtifactElement(document,"parameter"); + outputModeNode.appendChild(inputParametersNode); + Iterator<InputValue> it2 = inputParameters.iterator(); + while (it2.hasNext()){ + InputValue inputValue = it2.next(); + Element inputParameterNode = xmlUtilities.createArtifactElement(document,"parameter"); + inputParametersNode.appendChild(inputParameterNode); + inputParameterNode.setAttribute("name", inputValue.getName()); + inputParameterNode.setAttribute("type", inputValue.getType()); + inputParameterNode.setAttribute("value", inputValue.getDefaultValue()); + } + } } }else{ log.warn("No Outputmodes given."); @@ -317,13 +332,13 @@ } - protected Collection<InputData> parseInputData(Document document){ + protected Collection<InputData> parseInputData(Document document, String xPath){ log.debug("GNVArtifactBase.parseInputData"); 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, ""); + NodeList inputElemets = (NodeList)XMLUtils.xpath(document, xPath,XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);//Config.getNodeSetXPath(document, ""); if(inputElemets != null){ returnValue = new HashMap<String,InputData>(inputElemets.getLength()); for (int i = 0; i < inputElemets.getLength(); i++){ @@ -360,7 +375,7 @@ try { if (current != null && current instanceof OutputTransition){ - ((OutputTransition)current).out(this.readOutputType(format), outputStream); + ((OutputTransition)current).out(this.readOutputType(format),this.parseInputData(format, "/action/out/params/input"), outputStream); context.afterCall(CallContext.STORE); // TODO: FIXME Schmutzige Lösung: Besser einen weiteren Transitionsschritt zwischenschalten. } } catch (TransitionException e) { @@ -369,6 +384,7 @@ } } + protected String readOutputType(Document document){ String value = Config.getStringXPath(document,"action/out/@name"); return value;
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java Fri Sep 25 14:37:10 2009 +0000 @@ -16,8 +16,14 @@ private String type = null; private boolean multiselect = false; private int usedInQueries = 1; + private String defaultValue = "N/N"; + public DefaultInputValue(String name, String type, String defaultValue, boolean multiselect){ + this(name, type, multiselect, 1); + this.defaultValue = defaultValue; + + } /** * Constructor */ @@ -61,4 +67,8 @@ return this.usedInQueries; } + public String getDefaultValue() { + return this.defaultValue; + } + }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java Fri Sep 25 14:37:10 2009 +0000 @@ -2,15 +2,23 @@ * */ package de.intevation.gnv.transition; + +import java.util.Collection; + /** * @author Tim Englich <tim.englich@intevation.de> * */ public class DefaultOutputMode implements OutputMode { + /** + * The UID of this Class. + */ + private static final long serialVersionUID = -6459085460904827056L; private String name = null; private String description = null; private String mimeType = null; + private Collection<InputValue> inputParameters = null; /** * Constructor @@ -18,11 +26,12 @@ * @param description * @param mimeType */ - public DefaultOutputMode(String name, String description, String mimeType) { + public DefaultOutputMode(String name, String description, String mimeType, Collection<InputValue> inputParameters) { super(); this.name = name; this.description = description; this.mimeType = mimeType; + this.inputParameters = inputParameters; } /** @@ -54,4 +63,11 @@ return "Name: "+this.name+" ; Description: "+this.description+" ; Mime-Type: "+this.mimeType; } + /** + * @see de.intevation.gnv.transition.OutputMode#getInputParameters() + */ + public Collection<InputValue> getInputParameters() { + return this.inputParameters; + } + }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java Fri Sep 25 14:37:10 2009 +0000 @@ -13,6 +13,7 @@ public String getName(); public String getType(); + public String getDefaultValue(); public boolean isMultiselect(); public int usedInQueries();
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputMode.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputMode.java Fri Sep 25 14:37:10 2009 +0000 @@ -4,6 +4,7 @@ package de.intevation.gnv.transition; import java.io.Serializable; +import java.util.Collection; /** * @author Tim Englich <tim.englich@intevation.de> @@ -16,4 +17,6 @@ public String getDescription(); public String getMimeType(); + + public Collection<InputValue> getInputParameters(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Fri Sep 25 14:37:10 2009 +0000 @@ -20,7 +20,7 @@ * @return The Bytecode of the Result * @throws TransitionException */ - public void out( String outputMode, OutputStream outputStream) throws TransitionException; + public void out( String outputMode, Collection<InputData> inputData, OutputStream outputStream) throws TransitionException; /** * Delivers the provided OutputModes of an Transition
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Fri Sep 25 14:37:10 2009 +0000 @@ -23,7 +23,7 @@ /** - * Thie UID of this Class + * The UID of this Class */ private static final long serialVersionUID = -1718732895737303823L; @@ -80,7 +80,23 @@ String name = Config.getStringXPath(currentNode, "@name"); String description = Config.getStringXPath(currentNode, "@description"); String mimeType = Config.getStringXPath(currentNode, "@mime-type"); - OutputMode outputMode = new DefaultOutputMode(name, description, mimeType); + + NodeList inputValuesList = Config.getNodeSetXPath(currentNode, "parameters/inputvalue"); + Collection<InputValue> inputParameters = null; + if (inputValuesList != null){ + inputParameters = new ArrayList<InputValue>(inputValuesList.getLength()); + for (int j = 0 ; j < inputValuesList.getLength(); j++){ + Node currentInputValuesNode = inputValuesList.item(j); + String inputValueName = Config.getStringXPath(currentInputValuesNode, "@name"); + String inputValueType = Config.getStringXPath(currentInputValuesNode, "@type"); + String defaultValue = Config.getStringXPath(currentInputValuesNode, "@value"); + boolean isMultiselect = false; + InputValue inputValue = new DefaultInputValue(inputValueName, inputValueType, defaultValue, isMultiselect); + inputParameters.add(inputValue); + } + } + + OutputMode outputMode = new DefaultOutputMode(name, description, mimeType,inputParameters); log.debug(outputMode.toString()); this.outputModes.add(outputMode);
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Fri Sep 25 14:37:10 2009 +0000 @@ -20,6 +20,7 @@ import de.intevation.gnv.chart.ChartStyle; import de.intevation.gnv.chart.exception.TechnicalChartException; import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.transition.InputData; import de.intevation.gnv.transition.OutputTransitionBase; import de.intevation.gnv.transition.describedata.KeyValueDescibeData; import de.intevation.gnv.transition.describedata.NamedCollection; @@ -58,17 +59,35 @@ } /** - * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, java.io.OutputStream) + * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, java.util.Collection, java.io.OutputStream) */ - public void out(String outputMode, OutputStream outputStream) throws TransitionException { + public void out(String outputMode, Collection<InputData> inputData, OutputStream outputStream) throws TransitionException { log.debug("TimeSeriesOutputTransition.out"); try { this.advance(); if (outputMode.equalsIgnoreCase("chart")){ log.debug("Chart will be generated."); + int chartWidth = 600; + int chartHeight = 400; + try { + if (inputData != null){ + Iterator<InputData> it = inputData.iterator(); + while (it.hasNext()){ + InputData ip = it.next(); + if (ip.getName().equalsIgnoreCase("width")){ + chartWidth = Integer.parseInt(ip.getValue()); + }else if (ip.getName().equalsIgnoreCase("height")){ + chartHeight = Integer.parseInt(ip.getValue()); + } + } + } + } catch (NumberFormatException e) { + log.error(e,e); + throw new TransitionException(e); + } Collection<KeyValueDescibeData> parameters = this.getParameters(); Collection<KeyValueDescibeData> measurements = this.getMeasurements(); - ChartStyle chartStyle = this.creatStyle(600,400); + ChartStyle chartStyle = this.creatStyle(chartWidth,chartHeight); ChartLabels chartLables = new ChartLabels(this.getSelectedFeatureName(),this.domainLable); this.createChart(outputStream, parameters, measurements, chartStyle, chartLables);
--- a/gnv-artifacts/src/test/ressources/conf.xml Thu Sep 24 15:27:33 2009 +0000 +++ b/gnv-artifacts/src/test/ressources/conf.xml Fri Sep 25 14:37:10 2009 +0000 @@ -186,7 +186,12 @@ <inputvalue name="maxvalue" type="Integer" multiselect="false" usedinquery="1"/> </inputvalues> <outputsModes> - <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/> + <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"> + <parameters> + <inputvalue name="width" type="Integer" value="600"/> + <inputvalue name="height" type="Integer" value="400"/> + </parameters> + </outputsMode> <outputsMode name="csv" description="CSV-Export der Daten" mime-type="test/plain"/> <outputsMode name="statistics" description="Statistik zu den Daten" mime-type="test/plain"/> </outputsModes> @@ -257,7 +262,12 @@ <inputvalue name="maxvalue" type="Integer" multiselect="false"/> </inputvalues> <outputsModes> - <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/> + <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"> + <parameters> + <inputvalue name="width" type="Integer" value="600"/> + <inputvalue name="height" type="Integer" value="400"/> + </parameters> + </outputsMode> <outputsMode name="csv" description="CSV-Export der Daten" mime-type="test/plain"/> <outputsMode name="statistics" description="Statistik zu den Daten" mime-type="test/plain"/> </outputsModes> @@ -313,7 +323,12 @@ <inputvalue name="dateid" type="Date" multiselect="true"/> </inputvalues> <outputsModes> - <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/> + <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"> + <parameters> + <inputvalue name="width" type="Integer" value="600"/> + <inputvalue name="height" type="Integer" value="400"/> + </parameters> + </outputsMode> <outputsMode name="csv" description="CSV-Export der Daten" mime-type="test/plain"/> <outputsMode name="statistics" description="Statistik zu den Daten" mime-type="test/plain"/> </outputsModes> @@ -394,7 +409,12 @@ <inputvalue name="mesh_point" type="Integer" multiselect="false" usedinquery="2"/> </inputvalues> <outputsModes> - <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/> + <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"> + <parameters> + <inputvalue name="width" type="Integer" value="600"/> + <inputvalue name="height" type="Integer" value="400"/> + </parameters> + </outputsMode> <outputsMode name="csv" description="CSV-Export der Daten" mime-type="test/plain"/> <outputsMode name="statistics" description="Statistik zu den Daten" mime-type="test/plain"/> </outputsModes> @@ -445,7 +465,12 @@ <inputvalue name="parameterid" type="Integer" multiselect="true" usedinquery="1"/> </inputvalues> <outputsModes> - <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"/> + <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png"> + <parameters> + <inputvalue name="width" type="Integer" value="600"/> + <inputvalue name="height" type="Integer" value="400"/> + </parameters> + </outputsMode> <outputsMode name="csv" description="CSV-Export der Daten" mime-type="test/plain"/> <outputsMode name="statistics" description="Statistik zu den Daten" mime-type="test/plain"/> </outputsModes>