Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java @ 3537:45f2b0778a3a
Do not show labels in logo selection combo box.
flys-client/trunk@5349 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 03 Sep 2012 13:12:02 +0000 |
parents | bc06a671ef60 |
children | e70ff0a600a3 |
rev | line source |
---|---|
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import javax.xml.xpath.XPathConstants; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Node; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import org.w3c.dom.NodeList; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
13 import org.apache.log4j.Logger; |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
14 |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.common.utils.XMLUtils; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifacts.httpclient.http.HttpClient; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.exceptions.ServerException; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.client.services.WQInfoService; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.client.shared.model.WQInfoObject; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.flys.client.shared.model.WQInfoObjectImpl; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 /** |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 */ |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 public class WQInfoServiceImpl |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 extends RemoteServiceServlet |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 implements WQInfoService |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
37 private static final Logger logger = |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
38 Logger.getLogger(WQInfoServiceImpl.class); |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
39 |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
40 |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 public static final String ERROR_NO_WQINFO_FOUND = |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 "error_no_wqinfo_found"; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 public static final String XPATH_WQS = "art:service/art:mainvalues/art:mainvalue"; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 public WQInfoObject[] getWQInfo( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 String locale, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 String river, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 double from, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 double to) |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 throws ServerException |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
54 logger.info("WQInfoServiceImpl.getWQInfo"); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
56 String url = getServletContext().getInitParameter("server-url"); |
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
57 |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 Document doc = XMLUtils.newDocument(); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 doc, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 ArtifactNamespaceContext.NAMESPACE_URI, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 Element mainvalues = ec.create("mainvalues"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 Element riverEl = ec.create("river"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 Element startEl = ec.create("start"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 Element endEl = ec.create("end"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 riverEl.setTextContent(river); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 startEl.setTextContent(Double.valueOf(from).toString()); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 endEl.setTextContent(Double.valueOf(to).toString()); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 mainvalues.appendChild(riverEl); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 mainvalues.appendChild(startEl); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 mainvalues.appendChild(endEl); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 doc.appendChild(mainvalues); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 HttpClient client = new HttpClientImpl(url, locale); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 try { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 Document result = client.callService(url, "mainvalues", doc); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
85 logger.debug("Extract wq info objects now."); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 WQInfoObject[] objects = extractWQInfoObjects(result); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 if (objects != null && objects.length > 0) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 return objects; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 catch (ConnectionException ce) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
93 logger.error(ce, ce); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 throw new ServerException(ERROR_NO_WQINFO_FOUND); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 /** |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 * Extracts all wq info objects from <i>result</i> document. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 * @param result The document retrieved by the server. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 * @return a list of WQInfoObjects. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 */ |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 protected WQInfoObject[] extractWQInfoObjects(Document result) |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 throws ServerException |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 NodeList list = (NodeList) XMLUtils.xpath( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 result, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 XPATH_WQS, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 XPathConstants.NODESET, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 if (list == null || list.getLength() == 0) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
117 logger.warn("No wq info found."); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 throw new ServerException(ERROR_NO_WQINFO_FOUND); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 int num = list.getLength(); |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
123 logger.debug("Response contains " + num + " objects."); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 List<WQInfoObject> objects = |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 new ArrayList<WQInfoObject>(num); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 for (int i = 0; i < num; i++) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 WQInfoObject obj = buildWQInfoObject(list.item(i)); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 if (obj != null) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 objects.add(obj); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
136 logger.debug("Retrieved " + objects.size() + " wq values"); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 return (WQInfoObject[]) |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 objects.toArray(new WQInfoObject[num]); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 /** |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 * Extracts information for a single wq info object and intializes an |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 * WQInfoObject with them. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 * @param node The node that contains the information. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 * @return a valid WQInfoObject. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 */ |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 protected WQInfoObject buildWQInfoObject(Node node) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 String name = XMLUtils.xpathString( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 node, "@name", ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 String type = XMLUtils.xpathString( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 node, "@type", ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 String value = XMLUtils.xpathString( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 node, "@value", ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 if (name != null && type != null) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 try { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 return new WQInfoObjectImpl( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 name, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 type, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 new Double(value)); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 catch (NumberFormatException nfe) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
170 logger.warn(nfe.getLocalizedMessage()); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
245
diff
changeset
|
174 logger.warn("Invalid wq info object found."); |
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 return null; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |