comparison 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
comparison
equal deleted inserted replaced
31:e8745ca02f2b 32:88c530c25968
33 33
34 public static final String XPATH_STATE_NAME = "@art:name"; 34 public static final String XPATH_STATE_NAME = "@art:name";
35 35
36 public static final String XPATH_UIPROVIDER = "@art:uiprovider"; 36 public static final String XPATH_UIPROVIDER = "@art:uiprovider";
37 37
38 public static final String XPATH_REACHABLE_STATE = "art:state";
39
38 /** 40 /**
39 * This method creates the {@link ArtifactDescription} of the DESCRIBE 41 * This method creates the {@link ArtifactDescription} of the DESCRIBE
40 * document <i>doc</i>. 42 * document <i>doc</i>.
41 * 43 *
42 * @param doc A DESCRIBE document. 44 * @param doc A DESCRIBE document.
47 System.out.println("ArtifactDescriptionFactory - create()"); 49 System.out.println("ArtifactDescriptionFactory - create()");
48 50
49 Node currentState = ClientProtocolUtils.getCurrentState(doc); 51 Node currentState = ClientProtocolUtils.getCurrentState(doc);
50 Node staticNode = ClientProtocolUtils.getStaticUI(doc); 52 Node staticNode = ClientProtocolUtils.getStaticUI(doc);
51 Node dynamicNode = ClientProtocolUtils.getDynamicUI(doc); 53 Node dynamicNode = ClientProtocolUtils.getDynamicUI(doc);
54 Node reachable = ClientProtocolUtils.getReachableStates(doc);
52 55
53 String state = (String) XMLUtils.xpath( 56 String state = (String) XMLUtils.xpath(
54 currentState, 57 currentState,
55 XPATH_STATE_NAME, 58 XPATH_STATE_NAME,
56 XPathConstants.STRING, 59 XPathConstants.STRING,
57 ArtifactNamespaceContext.INSTANCE); 60 ArtifactNamespaceContext.INSTANCE);
58 System.out.println("Current state name: " + state); 61 System.out.println("Current state name: " + state);
59 62
60 Data currentData = extractCurrentData(dynamicNode); 63 Data currentData = extractCurrentData(dynamicNode);
64 String[] states = extractReachableStates(reachable);
61 65
62 // TODO parse the static ui part 66 // TODO parse the static ui part
63 return new DefaultArtifactDescription(null, currentData, state, null); 67 return new DefaultArtifactDescription(null, currentData, state, states);
64 } 68 }
65 69
66 70
67 /** 71 /**
68 * This method extracts the data that the user is able to enter in the 72 * This method extracts the data that the user is able to enter in the
132 data, 136 data,
133 XPATH_UIPROVIDER, 137 XPATH_UIPROVIDER,
134 XPathConstants.STRING, 138 XPathConstants.STRING,
135 ArtifactNamespaceContext.INSTANCE); 139 ArtifactNamespaceContext.INSTANCE);
136 } 140 }
141
142
143 /**
144 * This method extracts the reachable states of the current artifact.
145 *
146 * @param reachable The reachable states node.
147 *
148 * @return an array with identifiers of reachable states.
149 */
150 protected static String[] extractReachableStates(Node reachable) {
151 System.out.println("ArtifactDescriptionFactory - extractReachableStates()");
152
153 NodeList list = (NodeList) XMLUtils.xpath(
154 reachable,
155 XPATH_REACHABLE_STATE,
156 XPathConstants.NODESET,
157 ArtifactNamespaceContext.INSTANCE);
158
159 if (list == null || list.getLength() == 0) {
160 return null;
161 }
162
163 int count = list.getLength();
164
165 String[] states = new String[count];
166
167 for (int i = 0; i < count; i++) {
168 Node state = list.item(i);
169
170 String name = XMLUtils.xpathString(
171 state, "@art:name", ArtifactNamespaceContext.INSTANCE);
172
173 states[i] = name;
174 }
175
176 return states;
177 }
137 } 178 }
138 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org