Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java @ 4253:a1bc5b8cff0f
Refactor GaugePanel to create it's own SectionStackSection
The GaugePanel constructor now creates a SectionStackSection instead of
using a provided one.
Improve the rendering of the GaugePanel by having access to the SmartGWT wrapper
(WidgetCanvas) object for the GWT Tree (GaugeTree) directly.
Add methods to close and open the section. Also add a getter for the section.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Thu, 25 Oct 2012 13:52:58 +0200 |
parents | ef154fbf58f1 |
children | 06d9098a609a |
rev | line source |
---|---|
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
4 import java.util.List; |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 import javax.xml.xpath.XPathConstants; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Document; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Element; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import org.w3c.dom.NodeList; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.common.utils.XMLUtils; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.httpclient.http.HttpClient; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
19 import de.intevation.flys.client.client.services.RiverInfoService; |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.client.shared.exceptions.ServerException; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.shared.model.DefaultGaugeInfo; |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
22 import de.intevation.flys.client.shared.model.DefaultMeasurementStation; |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.DefaultRiverInfo; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.model.GaugeInfo; |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
25 import de.intevation.flys.client.shared.model.MeasurementStation; |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.client.shared.model.RiverInfo; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
28 |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 /** |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 */ |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
32 public class RiverInfoServiceImpl |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 extends RemoteServiceServlet |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
34 implements RiverInfoService |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 private static final Logger logger = |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
37 Logger.getLogger(RiverInfoServiceImpl.class); |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
39 public static final String ERROR_NO_RIVER_INFO_FOUND = |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
40 "error_no_riverinfo_found"; |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
41 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
42 private static final String XPATH_RIVER = |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
43 "/art:river-info/art:river"; |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
44 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
45 private static final String XPATH_STATIONS = |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
46 "/art:river-info/art:measurement-stations/art:measurement-station"; |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
47 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
48 private static final String XPATH_GAUGES = "/art:river-info/art:gauges/art:gauge"; |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
49 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
50 public RiverInfo getGauges(String river) throws ServerException { |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 logger.info("RiverInfoServiceImpl.getRiverInfo"); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 String url = getServletContext().getInitParameter("server-url"); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 Document doc = XMLUtils.newDocument(); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 doc, |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 ArtifactNamespaceContext.NAMESPACE_URI, |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
60 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
61 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
62 Element riverele = ec.create("river"); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 riverele.setTextContent(river); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
64 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 doc.appendChild(riverele); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 HttpClient client = new HttpClientImpl(url); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
69 try { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 Document result = client.callService(url, "gaugeoverviewinfo", doc); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
72 DefaultRiverInfo riverinfo = getRiverInfo(result); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
73 List<GaugeInfo>gauges = createGauges(result, riverinfo.getName(), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
74 riverinfo.isKmUp(), riverinfo.getWstUnit()); |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
75 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
77 riverinfo.setGauges(gauges); |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
79 logger.debug("Finished RiverInfoService.getGauges."); |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
80 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 return riverinfo; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 } |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 catch (ConnectionException ce) { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 logger.error(ce, ce); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
85 } |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 logger.warn("No gauge found"); |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
88 throw new ServerException(ERROR_NO_RIVER_INFO_FOUND); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
89 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
90 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
91 public RiverInfo getMeasurementStations(String river) throws ServerException { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
92 logger.info("RiverInfoServiceImpl.getMeasurementStations"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
93 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
94 String url = getServletContext().getInitParameter("server-url"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
95 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
96 Document doc = XMLUtils.newDocument(); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
97 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
98 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
99 doc, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
100 ArtifactNamespaceContext.NAMESPACE_URI, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
101 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
102 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
103 Element riverele = ec.create("river"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
104 riverele.setTextContent(river); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
105 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
106 doc.appendChild(riverele); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
107 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
108 HttpClient client = new HttpClientImpl(url); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
109 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
110 try { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
111 Document result = client.callService(url, "measurementstationinfo", doc); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
112 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
113 DefaultRiverInfo riverinfo = getRiverInfo(result); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
114 List<MeasurementStation> mstations = createMeasurementStations( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
115 result, riverinfo.getName()); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
116 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
117 riverinfo.setMeasurementStations(mstations); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
118 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
119 logger.debug("Finished MeasurementStationInfoService."); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
120 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
121 return riverinfo; |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
122 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
123 catch (ConnectionException ce) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
124 logger.error(ce, ce); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
125 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
126 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
127 logger.warn("No measurement station found"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
128 throw new ServerException(ERROR_NO_RIVER_INFO_FOUND); |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
129 } |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
130 |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
131 /** |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
132 * Avoids NullPointerException when parsing double value |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
133 */ |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
134 private Double parseDouble(String value) { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
135 if (value == null || value.isEmpty()) { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
136 return null; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
137 } |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
138 try { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
139 return Double.valueOf(value); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
140 } |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
141 catch(NumberFormatException e) { |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
142 logger.error(e, e); |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
143 return null; |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
144 } |
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
145 } |
3843
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
146 |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
147 private Long parseLong(String value) { |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
148 if (value == null || value.isEmpty()) { |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
149 return null; |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
150 } |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
151 try { |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
152 return Long.valueOf(value); |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
153 } |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
154 catch(NumberFormatException e) { |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
155 logger.error(e, e); |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
156 return null; |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
157 } |
8e169e4e1b57
Add the official gauge number to the GaugeInfo class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3838
diff
changeset
|
158 } |
4250
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
159 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
160 private List<MeasurementStation> createMeasurementStations( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
161 Document result, String rivername) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
162 NodeList stationnodes = (NodeList) XMLUtils.xpath( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
163 result, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
164 XPATH_STATIONS, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
165 XPathConstants.NODESET, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
166 ArtifactNamespaceContext.INSTANCE); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
167 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
168 int num = stationnodes == null ? 0 : stationnodes.getLength(); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
169 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
170 ArrayList<MeasurementStation> mstations = new ArrayList<MeasurementStation>(num); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
171 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
172 if (num == 0) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
173 logger.warn("No measurement station found."); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
174 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
175 else { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
176 logger.debug("Found " + num + " measurement stations."); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
177 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
178 for (int i = 0; i < num; i++) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
179 Element stationele = (Element)stationnodes.item(i); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
180 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
181 String mname = stationele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
182 ArtifactNamespaceContext.NAMESPACE_URI, "name"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
183 String mstart = stationele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
184 ArtifactNamespaceContext.NAMESPACE_URI, "start"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
185 String mend = stationele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
186 ArtifactNamespaceContext.NAMESPACE_URI, "end"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
187 String mstation = stationele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
188 ArtifactNamespaceContext.NAMESPACE_URI, "station"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
189 String mtype = stationele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
190 ArtifactNamespaceContext.NAMESPACE_URI, "type"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
191 String riverside = stationele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
192 ArtifactNamespaceContext.NAMESPACE_URI, "riverside"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
193 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
194 logger.debug("Found measurement station with name " + mname); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
195 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
196 MeasurementStation station = new DefaultMeasurementStation( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
197 rivername, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
198 mname, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
199 parseDouble(mstation), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
200 parseDouble(mstart), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
201 parseDouble(mend), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
202 riverside, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
203 mtype |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
204 ); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
205 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
206 mstations.add(station); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
207 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
208 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
209 return mstations; |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
210 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
211 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
212 private List<GaugeInfo> createGauges( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
213 Document result, String rivername, Boolean kmup, String rwstunit) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
214 NodeList gaugenodes = (NodeList) XMLUtils.xpath( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
215 result, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
216 XPATH_GAUGES, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
217 XPathConstants.NODESET, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
218 ArtifactNamespaceContext.INSTANCE); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
219 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
220 int num = gaugenodes == null ? 0 : gaugenodes.getLength(); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
221 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
222 ArrayList<GaugeInfo> gauges = new ArrayList<GaugeInfo>(num); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
223 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
224 if (num == 0) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
225 logger.warn("No gauge info found."); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
226 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
227 else { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
228 logger.debug("Found " + num + " gauges."); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
229 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
230 for (int i = 0; i < num; i++) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
231 Element gaugeele = (Element)gaugenodes.item(i); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
232 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
233 String gname = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
234 ArtifactNamespaceContext.NAMESPACE_URI, "name"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
235 String gstart = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
236 ArtifactNamespaceContext.NAMESPACE_URI, "start"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
237 String gend = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
238 ArtifactNamespaceContext.NAMESPACE_URI, "end"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
239 String gdatum = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
240 ArtifactNamespaceContext.NAMESPACE_URI, "datum"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
241 String gaeo = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
242 ArtifactNamespaceContext.NAMESPACE_URI, "aeo"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
243 String gminq = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
244 ArtifactNamespaceContext.NAMESPACE_URI, "minq"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
245 String gminw = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
246 ArtifactNamespaceContext.NAMESPACE_URI, "minw"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
247 String gmaxq = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
248 ArtifactNamespaceContext.NAMESPACE_URI, "maxq"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
249 String gmaxw = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
250 ArtifactNamespaceContext.NAMESPACE_URI, "maxw"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
251 String gstation = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
252 ArtifactNamespaceContext.NAMESPACE_URI, "station"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
253 String gofficial = gaugeele.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
254 ArtifactNamespaceContext.NAMESPACE_URI, "official"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
255 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
256 logger.debug("Found gauge with name " + gname); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
257 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
258 GaugeInfo gaugeinfo = new DefaultGaugeInfo( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
259 rivername, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
260 gname, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
261 kmup, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
262 parseDouble(gstation), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
263 parseDouble(gstart), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
264 parseDouble(gend), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
265 parseDouble(gdatum), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
266 parseDouble(gaeo), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
267 parseDouble(gminq), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
268 parseDouble(gmaxq), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
269 parseDouble(gminw), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
270 parseDouble(gmaxw), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
271 rwstunit, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
272 parseLong(gofficial) |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
273 ); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
274 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
275 gauges.add(gaugeinfo); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
276 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
277 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
278 return gauges; |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
279 } |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
280 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
281 private DefaultRiverInfo getRiverInfo(Document result) { |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
282 Element riverresp = (Element) XMLUtils.xpath( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
283 result, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
284 XPATH_RIVER, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
285 XPathConstants.NODE, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
286 ArtifactNamespaceContext.INSTANCE); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
287 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
288 String rname = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
289 ArtifactNamespaceContext.NAMESPACE_URI, "name"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
290 String rkmup = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
291 ArtifactNamespaceContext.NAMESPACE_URI, "kmup"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
292 String rstart = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
293 ArtifactNamespaceContext.NAMESPACE_URI, "start"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
294 String rend = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
295 ArtifactNamespaceContext.NAMESPACE_URI, "end"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
296 String rwstunit = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
297 ArtifactNamespaceContext.NAMESPACE_URI, "wstunit"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
298 String rminq = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
299 ArtifactNamespaceContext.NAMESPACE_URI, "minq"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
300 String rmaxq = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
301 ArtifactNamespaceContext.NAMESPACE_URI, "maxq"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
302 String rofficial = riverresp.getAttributeNS( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
303 ArtifactNamespaceContext.NAMESPACE_URI, "official"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
304 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
305 logger.debug("River is " + rname); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
306 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
307 boolean kmup = rkmup.equalsIgnoreCase("true"); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
308 DefaultRiverInfo riverinfo = new DefaultRiverInfo( |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
309 rname, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
310 kmup, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
311 parseDouble(rstart), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
312 parseDouble(rend), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
313 rwstunit, |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
314 parseDouble(rminq), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
315 parseDouble(rmaxq), |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
316 parseLong(rofficial) |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
317 ); |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
318 |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
319 return riverinfo; |
ef154fbf58f1
Add method to get the MeasurementStations from the RiverInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3974
diff
changeset
|
320 } |
3713
79ad33f41977
Implement a gauge service
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
321 } |