changeset 112:0fab16cb4d44

Added the current state and reachable states description to the describe document of the WINFO artifact. flys-artifacts/trunk@1300 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 07 Feb 2011 11:37:33 +0000
parents 7222d8fb53ea
children f077df8ad54c
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java
diffstat 2 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Feb 07 11:32:59 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Feb 07 11:37:33 2011 +0000
@@ -1,3 +1,9 @@
+2011-02-07  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: The
+	  describe document returned by this artifact now contains the current state
+	  and the reachable states.
+
 2011-02-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Mon Feb 07 11:32:59 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Mon Feb 07 11:37:33 2011 +0000
@@ -15,6 +15,7 @@
 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;
 
@@ -99,8 +100,24 @@
     public Document describe(Document data, CallContext context) {
         logger.debug("Describe: the current state is: " + currentState.getID());
 
-        Document description = XMLUtils.newDocument();
+        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(
+            currentState, stateEngine);
+
+        Document description            = XMLUtils.newDocument();
         XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
             description,
             ArtifactNamespaceContext.NAMESPACE_URI,
@@ -108,10 +125,12 @@
 
         Element root = ProtocolUtils.createRootNode(creator);
         ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash());
+        ProtocolUtils.appendState(creator, root, currentState);
+        ProtocolUtils.appendReachableStates(creator, root, reachable);
 
-        logger.warn("TODO: Implement the whole description!");
+        logger.warn("TODO: Implement the model and ui description!");
+        description.appendChild(root);
 
-        description.appendChild(root);
 
         return description;
     }

http://dive4elements.wald.intevation.org