Mercurial > dive4elements > gnv-client
changeset 64:5db77e0a8594
Integrated Output Methods and Interfacsstructure
gnv-artifacts/trunk@47 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 09 Sep 2009 11:01:55 +0000 (2009-09-09) |
parents | 6ae2d4134da3 |
children | 8b75d01fa5b5 |
files | gnv-artifacts/Changelog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputMode.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java |
diffstat | 7 files changed, 238 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/Changelog Wed Sep 09 09:39:43 2009 +0000 +++ b/gnv-artifacts/Changelog Wed Sep 09 11:01:55 2009 +0000 @@ -1,3 +1,21 @@ +2009-09-09 Tim Englich <tim.englich@intevation.de> + + * src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Added: + The specifed OutputTransition for the Product TimeSeries. + + * src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Edited: + Integration of the OutputModes in the DescriberesultDocument. + + * src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Added, + src/main/java/de/intevation/gnv/transition/OutputTransition.java Added: + The Interface and the abstract Basicimplementation of an Transition which + can produce different outputs. + + * src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java Added, + src/main/java/de/intevation/gnv/transition/OutputMode.java Added: + Interfacestructur and Defaultimplementation for the Representation of the + Different OutputModes given in an Artifact. + 2009-09-09 Tim Englich <tim.englich@intevation.de> * src/main/java/de/intevation/gnv/transition/TransitionBase.java (describe) Edited:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Wed Sep 09 09:39:43 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Wed Sep 09 11:01:55 2009 +0000 @@ -21,6 +21,8 @@ import de.intevation.gnv.transition.DefaultInputData; import de.intevation.gnv.transition.InputData; import de.intevation.gnv.transition.InputValue; +import de.intevation.gnv.transition.OutputMode; +import de.intevation.gnv.transition.OutputTransition; import de.intevation.gnv.transition.Transition; import de.intevation.gnv.transition.TransitionFactory; import de.intevation.gnv.transition.exception.TransitionException; @@ -259,10 +261,25 @@ } protected void createOutputs(Element parent, Document document){ + log.debug("GNVArtifactBase.createOutputs"); Element outputsNode = createElement(document,"outputs"); - - // TODO_ Mit Leben f�llen. - + if (this.current instanceof OutputTransition){ + Collection<OutputMode> outputModes = ((OutputTransition)this.current).getOutputModes(); + if (outputModes != null){ + Iterator<OutputMode> it = outputModes.iterator(); + while(it.hasNext()){ + OutputMode outputMode = it.next(); + log.debug("Write Outputnode for "+ outputMode.toString()); + Element outputModeNode = createElement(document,"output"); + outputModeNode.setAttribute("name", outputMode.getName()); + outputModeNode.setAttribute("description", outputMode.getDescription()); + outputModeNode.setAttribute("mime-type", outputMode.getMimeType()); + outputsNode.appendChild(outputModeNode); + } + }else{ + log.warn("No Outputmodes given."); + } + } parent.appendChild(outputsNode); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java Wed Sep 09 11:01:55 2009 +0000 @@ -0,0 +1,57 @@ +/** + * + */ +package de.intevation.gnv.transition; +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class DefaultOutputMode implements OutputMode { + + private String name = null; + private String description = null; + private String mimeType = null; + + /** + * Constructor + * @param name + * @param description + * @param mimeType + */ + public DefaultOutputMode(String name, String description, String mimeType) { + super(); + this.name = name; + this.description = description; + this.mimeType = mimeType; + } + + /** + * @see de.intevation.gnv.transition.OutputMode#getDescription() + */ + public String getDescription() { + return this.description; + } + + /** + * @see de.intevation.gnv.transition.OutputMode#getMimeType() + */ + public String getMimeType() { + return this.mimeType; + } + + /** + * @see de.intevation.gnv.transition.OutputMode#getName() + */ + public String getName() { + return this.name; + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Name: "+this.name+" ; Description: "+this.description+" ; Mime-Type: "+this.mimeType; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputMode.java Wed Sep 09 11:01:55 2009 +0000 @@ -0,0 +1,16 @@ +/** + * + */ +package de.intevation.gnv.transition; +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public interface OutputMode { + + public String getName(); + + public String getDescription(); + + public String getMimeType(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Wed Sep 09 11:01:55 2009 +0000 @@ -0,0 +1,26 @@ +/** + * + */ +package de.intevation.gnv.transition; + +import java.util.Collection; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public interface OutputTransition extends Transition { + + /** + * Returns the Rendered Result of an Transition. + * @param outputMode The Mode that should be produces (Chart, Map, ...) + * @return The Bytecode of the Result + */ + public byte[] out( String outputMode); + + /** + * Delivers the provided OutputModes of an Transition + * @return the provided OutputModes of an Transition + */ + public Collection<OutputMode> getOutputModes(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Wed Sep 09 11:01:55 2009 +0000 @@ -0,0 +1,66 @@ +/** + * + */ +package de.intevation.gnv.transition; + +import java.util.ArrayList; +import java.util.Collection; + +import org.apache.log4j.Logger; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import de.intevation.artifactdatabase.Config; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public abstract class OutputTransitionBase extends TransitionBase implements + OutputTransition { + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(OutputTransitionBase.class); + + protected Collection<OutputMode> outputModes = null; + /** + * Constructor + */ + public OutputTransitionBase() { + super(); + } + + /** + * @see de.intevation.gnv.transition.OutputTransition#getOutputModes() + */ + public Collection<OutputMode> getOutputModes() { + log.debug("OutputTransitionBase.getOutputModes"); + return this.outputModes; + } + + /** + * @see de.intevation.gnv.transition.TransitionBase#setup(org.w3c.dom.Node) + */ + @Override + public void setup(Node configuration) { + log.debug("OutputTransitionBase.setup"); + super.setup(configuration); + NodeList outputModeList = Config.getNodeSetXPath(configuration, "outputsModes/outputsMode"); + if (outputModeList != null){ + log.debug(outputModeList.getLength()+ " were found."); + this.outputModes = new ArrayList<OutputMode>(outputModeList.getLength()); + for (int i = 0; i < outputModeList.getLength(); i++){ + Node currentNode = outputModeList.item(i); + 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); + log.debug(outputMode.toString()); + this.outputModes.add(outputMode); + + } + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Wed Sep 09 11:01:55 2009 +0000 @@ -0,0 +1,35 @@ +/** + * + */ +package de.intevation.gnv.transition.timeseries; + +import de.intevation.gnv.transition.OutputTransitionBase; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class TimeSeriesOutputTransition extends OutputTransitionBase{ + + /** + * Constructor + */ + public TimeSeriesOutputTransition() { + super(); + } + + /** + * @see de.intevation.gnv.transition.Transition#validate() + */ + public boolean validate() { + return true; + } + + /** + * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String) + */ + public byte[] out(String outputMode) { + return null; + } + +}