Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 119:84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
flys-artifacts/trunk@1438 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 09 Mar 2011 11:29:07 +0000 |
parents | b51e92fef704 |
children | e0ded17a4846 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Mar 08 17:22:37 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Wed Mar 09 11:29:07 2011 +0000 @@ -7,11 +7,9 @@ import org.apache.log4j.Logger; -import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.CallContext; -import de.intevation.artifactdatabase.DefaultArtifact; import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.artifactdatabase.state.State; import de.intevation.artifactdatabase.state.StateEngine; @@ -27,20 +25,11 @@ * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class WINFOArtifact extends DefaultArtifact { +public class WINFOArtifact extends FLYSArtifact { /** 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. @@ -50,46 +39,6 @@ /** - * 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. - * - * @param identifier The UUID. - * @param factory The factory that is used to create this artifact. - * @param context The CallContext. - * @param data Some optional data. - */ - @Override - public void setup( - String identifier, - ArtifactFactory factory, - Object context, - Document data) - { - logger.debug("Setup this artifact with the uuid: " + identifier); - - super.setup(identifier, factory, context, data); - - FLYSContext flysContext = (FLYSContext) context; - StateEngine engine = (StateEngine) flysContext.get( - FLYSContext.STATE_ENGINE_KEY); - - List<State> states = engine.getStates(ARTIFACT_NAME); - - setCurrentState(states.get(0)); - } - - - /** * This method returns a description of this artifact. * * @param data Some data. @@ -98,7 +47,7 @@ * @return the description of this artifact. */ public Document describe(Document data, CallContext context) { - logger.debug("Describe: the current state is: " + currentState.getID()); + logger.debug("Describe: the current state is: " + getCurrentStateId()); FLYSContext flysContext = null; if (context instanceof FLYSContext) { @@ -115,7 +64,7 @@ FLYSContext.TRANSITION_ENGINE_KEY); List<State> reachable = transitionEngine.getReachableStates( - currentState, stateEngine); + getCurrentState(context), stateEngine); Document description = XMLUtils.newDocument(); XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( @@ -126,11 +75,13 @@ Element root = ProtocolUtils.createRootNode(creator); description.appendChild(root); + State current = getCurrentState(context); + ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); - ProtocolUtils.appendState(creator, root, currentState); + ProtocolUtils.appendState(creator, root, current); ProtocolUtils.appendReachableStates(creator, root, reachable); - currentState.describe(description, root, context, identifier()); + current.describe(description, root, context, identifier()); return description; }