Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/GaugeInfoServiceImpl.java @ 5737:ce002608992d
Backend: Forget to increment index.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 16 Apr 2013 18:50:45 +0200 |
parents | 52a98e1653c1 |
children |
rev | line source |
---|---|
2466
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import javax.xml.xpath.XPathConstants; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.NodeList; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import org.apache.log4j.Logger; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.common.utils.XMLUtils; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifacts.httpclient.http.HttpClient; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.exceptions.ServerException; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.client.services.GaugeInfoService; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.shared.model.Gauge; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.client.shared.model.GaugeImpl; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 */ |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public class GaugeInfoServiceImpl |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 extends RemoteServiceServlet |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 implements GaugeInfoService |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 private static final Logger logger = |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 Logger.getLogger(GaugeInfoServiceImpl.class); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public static final String ERROR_NO_GAUGES_FOUND = |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 "error_no_gaugeinfo_found"; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public static final String XPATH_GAUGES = "art:service/art:gauge"; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 public List<Gauge> getGaugeInfo(String rivername, String refnumber) |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 throws ServerException |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 logger.info("GaugeInfoServiceImpl.getGaugeInfo"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 String url = getServletContext().getInitParameter("server-url"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 Document doc = XMLUtils.newDocument(); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 doc, |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 ArtifactNamespaceContext.NAMESPACE_URI, |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 Element river = ec.create("river"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 ec.addAttr(river, "name", rivername); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 if (refnumber != null && refnumber.length() > 0) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 Element filter = ec.create("filter"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 Element gauge = ec.create("gauge"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 gauge.setTextContent(refnumber); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 filter.appendChild(gauge); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 river.appendChild(filter); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 doc.appendChild(river); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 HttpClient client = new HttpClientImpl(url); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 try { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 Document result = client.callService(url, "gaugeinfo", doc); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 logger.debug("Extract gauge info now."); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 List<Gauge> gauges = extractGauges(result); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 if (gauges != null && gauges.size() > 0) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 return gauges; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 catch (ConnectionException ce) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 logger.error(ce, ce); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 throw new ServerException(ERROR_NO_GAUGES_FOUND); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 /** |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 * Extracts all wq info objects from <i>result</i> document. |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 * |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 * @param result The document retrieved by the server. |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 * |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 * @return a list of WQInfoObjects. |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 */ |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 protected List<Gauge> extractGauges(Document result) |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 throws ServerException |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 List<Gauge> gauges = new ArrayList<Gauge>(); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 NodeList list = (NodeList) XMLUtils.xpath( |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 result, |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 XPATH_GAUGES, |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 XPathConstants.NODESET, |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 ArtifactNamespaceContext.INSTANCE); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 if (list == null || list.getLength() == 0) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 logger.warn("No gauges found."); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 throw new ServerException(ERROR_NO_GAUGES_FOUND); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 int num = list.getLength(); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 logger.debug("Response contains " + num + " objects."); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 for (int i = 0; i < num; i++) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 Gauge obj = buildGauge((Element) list.item(i)); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 if (obj != null) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 gauges.add(obj); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 logger.debug("Retrieved " + gauges.size() + " gauges."); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 return gauges; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 protected Gauge buildGauge(Element ele) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 String name = ele.getAttribute("name"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 String lowerStr = ele.getAttribute("lower"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 String upperStr = ele.getAttribute("upper"); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 if (lowerStr != null && upperStr != null) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 try { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 return new GaugeImpl( |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 name, |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 Double.valueOf(lowerStr), |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 Double.valueOf(upperStr)); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 catch (NumberFormatException nfe) { |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 logger.warn("Error while Gauge creation: " + nfe.getMessage()); |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 return null; |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 } |
52a98e1653c1
Added a new RPC service to fetch gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |