Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java @ 565:a078ba1c139d
Introduced a client side input validation for the adapted WQ panel.
flys-client/trunk@2112 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 14 Jun 2011 14:00:19 +0000 |
parents | 27ffaf628b54 |
children | 653ae84533e7 |
comparison
equal
deleted
inserted
replaced
564:55a90afaf513 | 565:a078ba1c139d |
---|---|
19 import de.intevation.flys.client.shared.model.DefaultArtifactDescription; | 19 import de.intevation.flys.client.shared.model.DefaultArtifactDescription; |
20 import de.intevation.flys.client.shared.model.DefaultData; | 20 import de.intevation.flys.client.shared.model.DefaultData; |
21 import de.intevation.flys.client.shared.model.DefaultDataItem; | 21 import de.intevation.flys.client.shared.model.DefaultDataItem; |
22 import de.intevation.flys.client.shared.model.DefaultOutputMode; | 22 import de.intevation.flys.client.shared.model.DefaultOutputMode; |
23 import de.intevation.flys.client.shared.model.OutputMode; | 23 import de.intevation.flys.client.shared.model.OutputMode; |
24 import de.intevation.flys.client.shared.model.WQDataItem; | |
24 | 25 |
25 | 26 |
26 /** | 27 /** |
27 * This factory class helps creating an {@link ArtifactDescription} based on the | 28 * This factory class helps creating an {@link ArtifactDescription} based on the |
28 * DESCRIBE document of an artifact returned by the artifact server. Use the | 29 * DESCRIBE document of an artifact returned by the artifact server. Use the |
173 for (int i = 0; i < count; i++) { | 174 for (int i = 0; i < count; i++) { |
174 Node item = items.item(i); | 175 Node item = items.item(i); |
175 String label = ClientProtocolUtils.getLabel(item); | 176 String label = ClientProtocolUtils.getLabel(item); |
176 String value = ClientProtocolUtils.getValue(item); | 177 String value = ClientProtocolUtils.getValue(item); |
177 | 178 |
178 dataItems.add(new DefaultDataItem(label, null, value)); | 179 double[] mmQ = extractMinMaxQValues(item); |
180 double[] mmW = extractMinMaxWValues(item); | |
181 | |
182 if (mmQ != null || mmW != null) { | |
183 dataItems.add(new WQDataItem(label, null, value, mmQ, mmW)); | |
184 } | |
185 else { | |
186 dataItems.add(new DefaultDataItem(label, null, value)); | |
187 } | |
179 } | 188 } |
180 | 189 |
181 return (DataItem[]) dataItems.toArray(new DataItem[count]); | 190 return (DataItem[]) dataItems.toArray(new DataItem[count]); |
191 } | |
192 | |
193 | |
194 protected static double[] extractMinMaxQValues(Node item) { | |
195 System.out.println("ArtifactDescriptionFactory - extractMinMaxQValues"); | |
196 | |
197 if (item == null) { | |
198 System.err.println("This node is empty - no min/max Q values."); | |
199 return null; | |
200 } | |
201 | |
202 Node node = (Node) XMLUtils.xpath( | |
203 item, | |
204 "art:range[@art:type='Q']", | |
205 XPathConstants.NODE, | |
206 ArtifactNamespaceContext.INSTANCE); | |
207 | |
208 if (node == null) { | |
209 System.out.println("No min/max Q values found."); | |
210 return null; | |
211 } | |
212 | |
213 return extractMinMaxValues(node); | |
214 } | |
215 | |
216 | |
217 protected static double[] extractMinMaxWValues(Node item) { | |
218 System.out.println("ArtifactDescriptionFactory - extractMinMaxWValues"); | |
219 | |
220 if (item == null) { | |
221 System.err.println("This node is empty - no min/max W values."); | |
222 return null; | |
223 } | |
224 | |
225 Node node = (Node) XMLUtils.xpath( | |
226 item, | |
227 "art:range[@art:type='W']", | |
228 XPathConstants.NODE, | |
229 ArtifactNamespaceContext.INSTANCE); | |
230 | |
231 if (node == null) { | |
232 System.out.println("No min/max W values found."); | |
233 return null; | |
234 } | |
235 | |
236 return extractMinMaxValues(node); | |
237 } | |
238 | |
239 | |
240 protected static double[] extractMinMaxValues(Node node) { | |
241 System.out.println("ArtifactDescriptionFactory.extractMinMaxValues"); | |
242 | |
243 String minStr = XMLUtils.xpathString( | |
244 node, "art:min/text()", ArtifactNamespaceContext.INSTANCE); | |
245 | |
246 String maxStr = XMLUtils.xpathString( | |
247 node, "art:max/text()", ArtifactNamespaceContext.INSTANCE); | |
248 | |
249 if (maxStr == null || minStr == null) { | |
250 System.err.println("No min/max values found."); | |
251 return null; | |
252 } | |
253 | |
254 try { | |
255 double min = Double.valueOf(minStr); | |
256 double max = Double.valueOf(maxStr); | |
257 | |
258 return new double[] { min, max }; | |
259 } | |
260 catch (NumberFormatException nfe) { | |
261 System.err.println("Error while parsing min/max values."); | |
262 } | |
263 | |
264 return null; | |
182 } | 265 } |
183 | 266 |
184 | 267 |
185 /** | 268 /** |
186 * This method extracts the data objects from the data node of the static ui | 269 * This method extracts the data objects from the data node of the static ui |