[Dive4elements-commits] [PATCH 3 of 8] Add id, kmup and operator to MeasurementStation in RiverInfoServiceImpl

Wald Commits scm-commit at wald.intevation.org
Fri Oct 26 12:27:39 CEST 2012


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1351246568 -7200
# Node ID 06d9098a609af1fd934281101979d5e1141351e0
# Parent  d5d68c5bf0852afa1261bfeb08c14cb09bedcd82
Add id, kmup and operator to MeasurementStation in RiverInfoServiceImpl

Parse new variables from the artifactserver xml response and set them at the
MeasurementStation object.

diff -r d5d68c5bf085 -r 06d9098a609a flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java
--- 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);


More information about the Dive4elements-commits mailing list