Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 123:ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
flys-artifacts/trunk@1449 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Mar 2011 08:38:05 +0000 |
parents | e0ded17a4846 |
children | b7a9557957d1 |
line wrap: on
line source
package de.intevation.flys.artifacts; import java.util.List; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.apache.log4j.Logger; import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.CallContext; import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.artifactdatabase.state.State; import de.intevation.artifactdatabase.state.StateEngine; import de.intevation.artifactdatabase.transition.TransitionEngine; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.context.FLYSContext; /** * The default WINFO artifact. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ 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 default constructor. */ public WINFOArtifact() { } /** * This method returns a description of this artifact. * * @param data Some data. * @param CallContext The CallContext. * * @return the description of this artifact. */ public Document describe(Document data, CallContext context) { logger.debug("Describe: the current state is: " + getCurrentStateId()); FLYSContext flysContext = null; if (context instanceof FLYSContext) { flysContext = (FLYSContext) context; } else { flysContext = (FLYSContext) context.globalContext(); } StateEngine stateEngine = (StateEngine) flysContext.get( FLYSContext.STATE_ENGINE_KEY); TransitionEngine transitionEngine = (TransitionEngine) flysContext.get( FLYSContext.TRANSITION_ENGINE_KEY); List<State> reachable = transitionEngine.getReachableStates( getCurrentState(context), stateEngine); Document description = XMLUtils.newDocument(); XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( description, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); Element root = ProtocolUtils.createRootNode(creator); description.appendChild(root); State current = getCurrentState(context); ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); ProtocolUtils.appendState(creator, root, current); ProtocolUtils.appendReachableStates(creator, root, reachable); current.describe(description, root, context, identifier()); return description; } /** * Returns the name of the concrete artifact. * * @return the name of the concrete artifact. */ public String getName() { return ARTIFACT_NAME; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :