Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java @ 32:88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
flys-client/trunk@1451 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Mar 2011 10:53:41 +0000 |
parents | a85bac235069 |
children | bf84bcd4e11b |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java Wed Mar 09 09:51:02 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java Thu Mar 10 10:53:41 2011 +0000 @@ -35,6 +35,8 @@ public static final String XPATH_UIPROVIDER = "@art:uiprovider"; + public static final String XPATH_REACHABLE_STATE = "art:state"; + /** * This method creates the {@link ArtifactDescription} of the DESCRIBE * document <i>doc</i>. @@ -49,6 +51,7 @@ Node currentState = ClientProtocolUtils.getCurrentState(doc); Node staticNode = ClientProtocolUtils.getStaticUI(doc); Node dynamicNode = ClientProtocolUtils.getDynamicUI(doc); + Node reachable = ClientProtocolUtils.getReachableStates(doc); String state = (String) XMLUtils.xpath( currentState, @@ -58,9 +61,10 @@ System.out.println("Current state name: " + state); Data currentData = extractCurrentData(dynamicNode); + String[] states = extractReachableStates(reachable); // TODO parse the static ui part - return new DefaultArtifactDescription(null, currentData, state, null); + return new DefaultArtifactDescription(null, currentData, state, states); } @@ -134,5 +138,42 @@ XPathConstants.STRING, ArtifactNamespaceContext.INSTANCE); } + + + /** + * This method extracts the reachable states of the current artifact. + * + * @param reachable The reachable states node. + * + * @return an array with identifiers of reachable states. + */ + protected static String[] extractReachableStates(Node reachable) { + System.out.println("ArtifactDescriptionFactory - extractReachableStates()"); + + NodeList list = (NodeList) XMLUtils.xpath( + reachable, + XPATH_REACHABLE_STATE, + XPathConstants.NODESET, + ArtifactNamespaceContext.INSTANCE); + + if (list == null || list.getLength() == 0) { + return null; + } + + int count = list.getLength(); + + String[] states = new String[count]; + + for (int i = 0; i < count; i++) { + Node state = list.item(i); + + String name = XMLUtils.xpathString( + state, "@art:name", ArtifactNamespaceContext.INSTANCE); + + states[i] = name; + } + + return states; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :