changeset 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 d5d68c5bf085
children 8f9f80db46f3
files flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java	Fri Oct 26 12:13:38 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java	Fri Oct 26 12:16:08 2012 +0200
@@ -112,7 +112,7 @@
 
             DefaultRiverInfo riverinfo = getRiverInfo(result);
             List<MeasurementStation> mstations = createMeasurementStations(
-                    result, riverinfo.getName());
+                    result, riverinfo.getName(), riverinfo.isKmUp());
 
             riverinfo.setMeasurementStations(mstations);
 
@@ -157,8 +157,22 @@
         }
     }
 
+    private Integer parseInteger(String value) {
+        if (value == null || value.isEmpty()) {
+            return null;
+        }
+        try {
+            return Integer.valueOf(value);
+        }
+        catch(NumberFormatException e) {
+            logger.error(e, e);
+            return null;
+        }
+    }
+
     private List<MeasurementStation> createMeasurementStations(
-            Document result, String rivername) {
+            Document result, String rivername, boolean kmup) {
+
         NodeList stationnodes = (NodeList) XMLUtils.xpath(
                 result,
                 XPATH_STATIONS,
@@ -190,17 +204,24 @@
                         ArtifactNamespaceContext.NAMESPACE_URI, "type");
                 String riverside = stationele.getAttributeNS(
                         ArtifactNamespaceContext.NAMESPACE_URI, "riverside");
+                String mid = stationele.getAttributeNS(
+                        ArtifactNamespaceContext.NAMESPACE_URI, "id");
+                String moperator = stationele.getAttributeNS(
+                        ArtifactNamespaceContext.NAMESPACE_URI, "operator");
 
                 logger.debug("Found measurement station with name " + mname);
 
                 MeasurementStation station = new DefaultMeasurementStation(
                         rivername,
                         mname,
+                        parseInteger(mid),
                         parseDouble(mstation),
                         parseDouble(mstart),
                         parseDouble(mend),
+                        kmup,
                         riverside,
-                        mtype
+                        mtype,
+                        moperator
                         );
 
                 mstations.add(station);

http://dive4elements.wald.intevation.org