Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 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 | ff3335057f11 |
children | b51e92fef704 |
comparison
equal
deleted
inserted
replaced
111:7222d8fb53ea | 112:0fab16cb4d44 |
---|---|
13 | 13 |
14 import de.intevation.artifactdatabase.DefaultArtifact; | 14 import de.intevation.artifactdatabase.DefaultArtifact; |
15 import de.intevation.artifactdatabase.ProtocolUtils; | 15 import de.intevation.artifactdatabase.ProtocolUtils; |
16 import de.intevation.artifactdatabase.state.State; | 16 import de.intevation.artifactdatabase.state.State; |
17 import de.intevation.artifactdatabase.state.StateEngine; | 17 import de.intevation.artifactdatabase.state.StateEngine; |
18 import de.intevation.artifactdatabase.transition.TransitionEngine; | |
18 | 19 |
19 import de.intevation.artifacts.common.utils.XMLUtils; | 20 import de.intevation.artifacts.common.utils.XMLUtils; |
20 | 21 |
21 import de.intevation.flys.artifacts.context.FLYSContext; | 22 import de.intevation.flys.artifacts.context.FLYSContext; |
22 | 23 |
97 * @return the description of this artifact. | 98 * @return the description of this artifact. |
98 */ | 99 */ |
99 public Document describe(Document data, CallContext context) { | 100 public Document describe(Document data, CallContext context) { |
100 logger.debug("Describe: the current state is: " + currentState.getID()); | 101 logger.debug("Describe: the current state is: " + currentState.getID()); |
101 | 102 |
102 Document description = XMLUtils.newDocument(); | 103 FLYSContext flysContext = null; |
104 if (context instanceof FLYSContext) { | |
105 flysContext = (FLYSContext) context; | |
106 } | |
107 else { | |
108 flysContext = (FLYSContext) context.globalContext(); | |
109 } | |
103 | 110 |
111 StateEngine stateEngine = (StateEngine) flysContext.get( | |
112 FLYSContext.STATE_ENGINE_KEY); | |
113 | |
114 TransitionEngine transitionEngine = (TransitionEngine) flysContext.get( | |
115 FLYSContext.TRANSITION_ENGINE_KEY); | |
116 | |
117 List<State> reachable = transitionEngine.getReachableStates( | |
118 currentState, stateEngine); | |
119 | |
120 Document description = XMLUtils.newDocument(); | |
104 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( | 121 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
105 description, | 122 description, |
106 ArtifactNamespaceContext.NAMESPACE_URI, | 123 ArtifactNamespaceContext.NAMESPACE_URI, |
107 ArtifactNamespaceContext.NAMESPACE_PREFIX); | 124 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
108 | 125 |
109 Element root = ProtocolUtils.createRootNode(creator); | 126 Element root = ProtocolUtils.createRootNode(creator); |
110 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); | 127 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); |
128 ProtocolUtils.appendState(creator, root, currentState); | |
129 ProtocolUtils.appendReachableStates(creator, root, reachable); | |
111 | 130 |
112 logger.warn("TODO: Implement the whole description!"); | 131 logger.warn("TODO: Implement the model and ui description!"); |
132 description.appendChild(root); | |
113 | 133 |
114 description.appendChild(root); | |
115 | 134 |
116 return description; | 135 return description; |
117 } | 136 } |
118 } | 137 } |
119 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 138 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |