Mercurial > dive4elements > framework
changeset 109:ab646e0f5569
Improved the ProtocolUtils - there are new functions to append a current state and the reachable states to a root node.
artifacts/trunk@1298 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 07 Feb 2011 11:24:07 +0000 |
parents | 9ece61d918b1 |
children | 33271242e303 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java |
diffstat | 2 files changed, 50 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Feb 07 11:20:31 2011 +0000 +++ b/ChangeLog Mon Feb 07 11:24:07 2011 +0000 @@ -1,3 +1,9 @@ +2011-02-07 Ingo Weinzierl <ingo@intevation.de> + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java: + Added new methods to append the current state and the reachable states to + a root node. + 2011-02-07 Ingo Weinzierl <ingo@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java Mon Feb 07 11:20:31 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java Mon Feb 07 11:24:07 2011 +0000 @@ -7,13 +7,14 @@ */ package de.intevation.artifactdatabase; -import org.apache.log4j.Logger; +import java.util.List; import org.w3c.dom.Element; -import org.w3c.dom.Node; import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.artifactdatabase.state.State; + /** * This class provides methods that help creating the artifact protocol @@ -102,5 +103,46 @@ new String[] {"value"}, new String[] {hash})); } + + + /** + * This method appends a node that describes the current state to + * <i>root</i>. + * + * @param creator The ElementCreator used to create new elements. + * @param root The parent node for new elements. + * @param state The state to be appended. + */ + public static void appendState( + XMLUtils.ElementCreator creator, Element root, State state) + { + root.appendChild(createArtNode( + creator, "state", + new String[] { "description", "name" }, + new String[] { state.getDescription(), state.getID() })); + } + + + /** + * This method appends a node with reachable states to <i>root</i>. + * + * @param creator The ElementCreator used to create new elements. + * @param root The parent node for new elements. + * @param states The reachable states to be appended. + */ + public static void appendReachableStates( + XMLUtils.ElementCreator creator, + Element root, + List<State> states) + { + Element reachable = createArtNode( + creator, "reachable-states", null, null); + + for (State s: states) { + appendState(creator, reachable, s); + } + + root.appendChild(reachable); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: