Mercurial > dive4elements > river
changeset 109:9891d133f08d
Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
flys-artifacts/trunk@1294 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 Feb 2011 11:18:59 +0000 |
parents | 50273a391e53 |
children | ff3335057f11 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java |
diffstat | 5 files changed, 147 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Feb 04 11:11:03 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 04 11:18:59 2011 +0000 @@ -1,3 +1,17 @@ +2011-02-04 Ingo Weinzierl <ingo@intevation.de> + + * doc/conf/artifacts/winfo.xml: Removed useless config stuff. + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: Removed + useless methods, and improved the init process - the first state is set as + the current state for this artifact. + + * src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java, + src/main/java/de/intevation/flys/artifacts/states/GaugeSelect.java: New. + The states are used in the first two steps of the WINFOArtifact. + Currently, they just implement stubs of the necessary methods setup() and + describe(). + 2011-02-04 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/states/State.java,
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml Fri Feb 04 11:11:03 2011 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Fri Feb 04 11:18:59 2011 +0000 @@ -2,35 +2,17 @@ <artifact name="winfo"> <states> - <state id="winfo_gauge" description="winfo_gauge" state="de.intevation.flys.artifacts.state.GaugeState"> - <!-- - <inputvalues> - <inputvalue name="sourceid" type="Integer" multiselect="false" usedinquery="0"/> - <inputvalue name="fisname" type="String" multiselect="false" usedinquery="0"/> - </inputvalues> - --> + <state id="winfo_river" description="winfo_river" state="de.intevation.flys.artifacts.states.RiverSelect"> + <inputvalue name="river" type="String" /> </state> <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition"> - <from state="winfo_gauge"/> - <to state="winfo_calculation_type"/> + <from state="winfo_river"/> + <to state="winfo_gauge"/> </transition> - <state id="winfo_calculation_type" description="winfo_calculation_type" state="de.intevation.gnv.state.timeseries.TimeSeriesOutputState"> - <!-- - <inputvalues> - <inputvalue name="maxvalue" type="Date" multiselect="false"/> - </inputvalues> - --> - <outputsModes> - <outputsMode name="discharge_curve" description="Chartrepresentation of a discharge curve" mime-type="image/png"> - <exportModes> - <export name="img" description="IMG-Export der Daten" mime-type="image/png" /> - <export name="pdf" description="PDF-Export der Daten" mime-type="application/pdf" /> - <export name="svg" description="SVG-Export der Daten" mime-type="image/svg+xml" /> - </exportModes> - </outputsMode> - </outputsModes> + <state id="winfo_gauge" description="winfo_gauge" state="de.intevation.flys.artifacts.states.GaugeSelect"> + <inputvalue name="gauge" type="String" /> </state> </states>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Feb 04 11:11:03 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Feb 04 11:18:59 2011 +0000 @@ -2,6 +2,9 @@ import java.io.IOException; import java.io.OutputStream; +import java.util.List; + +import javax.xml.xpath.XPathConstants; import org.w3c.dom.Document; @@ -10,7 +13,13 @@ import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.common.utils.XMLUtils; + import de.intevation.artifactdatabase.DefaultArtifact; +import de.intevation.artifactdatabase.state.State; +import de.intevation.artifactdatabase.state.StateEngine; + +import de.intevation.flys.artifacts.context.FLYSContext; /** @@ -23,6 +32,15 @@ /** The logger for this class */ private static Logger logger = Logger.getLogger(WINFOArtifact.class); + /** The name of the artifact. */ + public static final String ARTIFACT_NAME = "winfo"; + + /** The XPath to the name of the artifact in its configuration. */ + public static final String XPATH_ARTIFACT_NAME = "@name"; + + /** The current state. */ + protected State currentState; + /** * The default constructor. @@ -33,6 +51,16 @@ /** + * Set the current state of this artifact. + * + * @param state The new current state. + */ + protected void setCurrentState(State state) { + currentState = state; + } + + + /** * Initialize the artifact and insert new data if <code>data</code> contains * information necessary for this artifact. * @@ -51,39 +79,14 @@ logger.debug("Setup this artifact with the uuid: " + identifier); super.setup(identifier, factory, context, data); - } - - - /** - * This method handles requests for changing the current state of an - * artifact. - * - * @param target The target of the advance action. - * @param context The CallContext. - * - * @return the result of the advance action. - */ - @Override - public Document advance(Document target, CallContext context) { - logger.debug("Advance to another state."); - return super.advance(target, context); - } - + FLYSContext flysContext = (FLYSContext) context; + StateEngine engine = (StateEngine) flysContext.get( + FLYSContext.STATE_ENGINE_KEY); - /** - * This methods introduces new data to the current artifact. - * - * @param data A document containing the new data. - * @param context The CallContext. - * - * @return the result of the feed action. - */ - @Override - public Document feed(Document data, CallContext context) { - logger.debug("Feed the artifact with new data."); + List<State> states = engine.getStates(ARTIFACT_NAME); - return super.feed(data, context); + setCurrentState(states.get(0)); } @@ -97,27 +100,9 @@ */ public Document describe(Document data, CallContext context) { logger.debug("Describe the artifact."); + logger.debug("The current state is: " + currentState.getID()); return super.describe(data, context); } - - - /** - * Call an output target. - * - * @param format The format for the output. - * @param outStream The output stream. - * @param context The CallContext. - * @throws IOException if an error occured while writing the result to the - * output stream. - */ - public void out( - Document format, OutputStream outStream, CallContext context) - throws IOException - { - logger.debug("Call an out target."); - - super.out(format, outStream, context); - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeSelect.java Fri Feb 04 11:18:59 2011 +0000 @@ -0,0 +1,44 @@ +package de.intevation.flys.artifacts.states; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import de.intevation.artifacts.CallContext; + +import de.intevation.artifactdatabase.state.AbstractState; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class GaugeSelect extends AbstractState { + + /** The logger used in this class. */ + private static Logger logger = Logger.getLogger(GaugeSelect.class); + + /** + * The default constructor that initializes an empty GaugeState object. + */ + public GaugeSelect() { + super(null, null); + } + + + public void setup(Node config) { + super.setup(config); + } + + + public void describe( + Document document, + Node root, + CallContext context, + String uuid) + { + // TODO Implement me + logger.error("Currently not implemented."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java Fri Feb 04 11:18:59 2011 +0000 @@ -0,0 +1,49 @@ +package de.intevation.flys.artifacts.states; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import de.intevation.artifacts.CallContext; + +import de.intevation.artifactdatabase.state.AbstractState; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class RiverSelect extends AbstractState { + + /** The logger used in this class. */ + private static Logger logger = Logger.getLogger(RiverSelect.class); + + /** + * The default constructor that initializes an empty State object. + */ + public RiverSelect() { + super(null, null); + } + + + /** + * Initialize the state based on the state node in the configuration. + * + * @param config The state configuration node. + */ + public void setup(Node config) { + super.setup(config); + } + + + public void describe( + Document document, + Node root, + CallContext context, + String uuid) + { + // TODO Implement me + logger.error("Currently not implemented."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :