comparison flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java @ 4266:06d9098a609a

Add id, kmup and operator to MeasurementStation in RiverInfoServiceImpl Parse new variables from the artifactserver xml response and set them at the MeasurementStation object.
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 26 Oct 2012 12:16:08 +0200
parents ef154fbf58f1
children b6f2ecaa6704
comparison
equal deleted inserted replaced
4265:d5d68c5bf085 4266:06d9098a609a
110 try { 110 try {
111 Document result = client.callService(url, "measurementstationinfo", doc); 111 Document result = client.callService(url, "measurementstationinfo", doc);
112 112
113 DefaultRiverInfo riverinfo = getRiverInfo(result); 113 DefaultRiverInfo riverinfo = getRiverInfo(result);
114 List<MeasurementStation> mstations = createMeasurementStations( 114 List<MeasurementStation> mstations = createMeasurementStations(
115 result, riverinfo.getName()); 115 result, riverinfo.getName(), riverinfo.isKmUp());
116 116
117 riverinfo.setMeasurementStations(mstations); 117 riverinfo.setMeasurementStations(mstations);
118 118
119 logger.debug("Finished MeasurementStationInfoService."); 119 logger.debug("Finished MeasurementStationInfoService.");
120 120
155 logger.error(e, e); 155 logger.error(e, e);
156 return null; 156 return null;
157 } 157 }
158 } 158 }
159 159
160 private Integer parseInteger(String value) {
161 if (value == null || value.isEmpty()) {
162 return null;
163 }
164 try {
165 return Integer.valueOf(value);
166 }
167 catch(NumberFormatException e) {
168 logger.error(e, e);
169 return null;
170 }
171 }
172
160 private List<MeasurementStation> createMeasurementStations( 173 private List<MeasurementStation> createMeasurementStations(
161 Document result, String rivername) { 174 Document result, String rivername, boolean kmup) {
175
162 NodeList stationnodes = (NodeList) XMLUtils.xpath( 176 NodeList stationnodes = (NodeList) XMLUtils.xpath(
163 result, 177 result,
164 XPATH_STATIONS, 178 XPATH_STATIONS,
165 XPathConstants.NODESET, 179 XPathConstants.NODESET,
166 ArtifactNamespaceContext.INSTANCE); 180 ArtifactNamespaceContext.INSTANCE);
188 ArtifactNamespaceContext.NAMESPACE_URI, "station"); 202 ArtifactNamespaceContext.NAMESPACE_URI, "station");
189 String mtype = stationele.getAttributeNS( 203 String mtype = stationele.getAttributeNS(
190 ArtifactNamespaceContext.NAMESPACE_URI, "type"); 204 ArtifactNamespaceContext.NAMESPACE_URI, "type");
191 String riverside = stationele.getAttributeNS( 205 String riverside = stationele.getAttributeNS(
192 ArtifactNamespaceContext.NAMESPACE_URI, "riverside"); 206 ArtifactNamespaceContext.NAMESPACE_URI, "riverside");
207 String mid = stationele.getAttributeNS(
208 ArtifactNamespaceContext.NAMESPACE_URI, "id");
209 String moperator = stationele.getAttributeNS(
210 ArtifactNamespaceContext.NAMESPACE_URI, "operator");
193 211
194 logger.debug("Found measurement station with name " + mname); 212 logger.debug("Found measurement station with name " + mname);
195 213
196 MeasurementStation station = new DefaultMeasurementStation( 214 MeasurementStation station = new DefaultMeasurementStation(
197 rivername, 215 rivername,
198 mname, 216 mname,
217 parseInteger(mid),
199 parseDouble(mstation), 218 parseDouble(mstation),
200 parseDouble(mstart), 219 parseDouble(mstart),
201 parseDouble(mend), 220 parseDouble(mend),
221 kmup,
202 riverside, 222 riverside,
203 mtype 223 mtype,
224 moperator
204 ); 225 );
205 226
206 mstations.add(station); 227 mstations.add(station);
207 } 228 }
208 } 229 }

http://dive4elements.wald.intevation.org