changeset 5452:5287440b57b3

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 27 Mar 2013 11:48:53 +0100
parents 278d8759c92b (diff) 504a62887217 (current diff)
children 303701ab73c6
files flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java
diffstat 5 files changed, 44 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Wed Mar 27 10:59:55 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Wed Mar 27 11:48:53 2013 +0100
@@ -156,8 +156,7 @@
             Range theRange = range != null ? range.getPeer(river) : null;
 
             if (theRange == null) {
-                log.warn("BHE: Skip file - invalid km range.");
-                return null;
+                log.warn("BHE: invalid km range.");
             }
 
             Session session = ImporterSession.getInstance()
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java	Wed Mar 27 10:59:55 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java	Wed Mar 27 11:48:53 2013 +0100
@@ -148,9 +148,8 @@
             }
 
             if (theRange == null) {
-                log.warn("BHS: No km-range given. Skip file '" + 
+                log.warn("BHS: No km-range given: '" + 
 			 description + "'");
-                return null;
             }
 
             Session session = ImporterSession.getInstance().getDatabaseSession();
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java	Wed Mar 27 10:59:55 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java	Wed Mar 27 11:48:53 2013 +0100
@@ -56,10 +56,8 @@
             try {
                 gauge = getGaugeFromDB();
                 if (gauge == null) {
-                    log.warn("Skip measurement station '" + name
-                        + "': unable to find gauge with name '" + this.gauge
+                    log.warn("No gauge found for measurement station '" + name
                         + "'");
-                    return null;
                 }
             }
             catch (Exception e) {
@@ -68,28 +66,29 @@
 
             Range range = this.range.getPeer(river);
             if (range == null) {
-                log.warn("Skip measurement station '" + name
-                    + "': unable to get range");
-                return null;
+                log.warn("No range found for measurement station'" + name + "'");
             }
 
             TimeInterval observationTimerange = this.observationTimerange
                 .getPeer();
             if (observationTimerange == null) {
-                log.warn("Skip measurement station '" + name
-                    + "': unable to get time interval for observation time");
-                return null;
+                log.warn("No time range found for measurement station '"
+                    + name + "'");
             }
 
             Session session = ImporterSession.getInstance()
                 .getDatabaseSession();
 
             org.hibernate.Query query = session
-                .createQuery("FROM MeasurementStation "
-                    + "   WHERE river=:river AND station=:station");
+                .createQuery(
+                    "FROM MeasurementStation " +
+                    "WHERE river=:river" +
+                    "   AND station=:station " +
+                    "   AND measurement_type=:measurement_type ");
 
             query.setParameter("river", river);
             query.setParameter("station", station);
+            query.setParameter("measurement_type", measurementType);
 
             List<MeasurementStation> stations = query.list();
 
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java	Wed Mar 27 10:59:55 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java	Wed Mar 27 11:48:53 2013 +0100
@@ -75,7 +75,7 @@
                 new BigDecimal(nf.parse(values[1]).doubleValue()),
                 new BigDecimal(nf.parse(values[2]).doubleValue()),
                 new BigDecimal(nf.parse(values[3]).doubleValue()),
-                new BigDecimal(nf.parse(values[4]).doubleValue()),
+                parseBigDecimal(values[4], line),
                 new BigDecimal(nf.parse(values[5]).doubleValue())
             );
 
@@ -85,5 +85,21 @@
             log.warn("BSP: Error while parsing data row.", e);
         }
     }
+    
+    private BigDecimal parseBigDecimal(String value, String line) {
+        BigDecimal result = null;
+        try {
+            Double dValue = Double.valueOf(value.replace(",", "."));
+            result = new BigDecimal(dValue.doubleValue());
+        }
+        catch (NumberFormatException nfe) {
+            log.warn(
+                "Error parsing " +
+                value +
+                " in bed heigt single row: "
+                + line);
+        }
+        return result;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java	Wed Mar 27 10:59:55 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java	Wed Mar 27 11:48:53 2013 +0100
@@ -112,16 +112,15 @@
         }
     }
 
-    protected ImportRange getRange(String[] cols)
-        throws MeasurementStationParserException {
+    protected ImportRange getRange(String[] cols) {
         if (cols[4] == null || cols[4].length() == 0) {
-            throw new MeasurementStationParserException("invalid lower range '"
-                + cols[4] + "'");
+            log.warn("No upper value for range found in '" + cols[4] + "'");
+            return null;
         }
 
         if (cols[5] == null || cols[5].length() == 0) {
-            throw new MeasurementStationParserException("invalid lower range '"
-                + cols[5] + "'");
+            log.warn("No upper value for range found in '" + cols[5] + "'");
+            return null;
         }
 
         try {
@@ -131,8 +130,8 @@
             return new ImportRange(new BigDecimal(lower), new BigDecimal(upper));
         }
         catch (ParseException e) {
-            throw new MeasurementStationParserException(
-                "unable to parse range: " + e.getMessage());
+            log.warn("unable to parse range: " + e.getMessage());
+            return null;
         }
     }
 
@@ -150,21 +149,17 @@
         return cols[3];
     }
 
-    protected String getGauge(String[] cols)
-        throws MeasurementStationParserException {
+    protected String getGauge(String[] cols) {
         if (cols[6] == null || cols[6].length() == 0) {
-            throw new MeasurementStationParserException("invalid gauge '"
-                + cols[6] + "'");
+            log.warn("invalid gauge found: '" + cols[6] + "'");
         }
 
         return cols[6];
     }
 
-    protected ImportTimeInterval getObservationTimerange(String[] cols)
-        throws MeasurementStationParserException {
+    protected ImportTimeInterval getObservationTimerange(String[] cols) {
         if (cols[8] == null || cols[8].length() == 0) {
-            throw new MeasurementStationParserException(
-                "invalid observation time '" + cols[8] + "'");
+                log.warn("Found invalid observation time '" + cols[8] + "'");
         }
 
         try {
@@ -173,13 +168,13 @@
             if (date != null) {
                 return new ImportTimeInterval(date);
             }
-
-            throw new MeasurementStationParserException(
-                "invalid observation time '" + cols[8] + "'");
+            log.warn("Observation time date invalid: '" + cols[8] + "'");
         }
         catch (ParseException pe) {
-            throw new MeasurementStationParserException(pe.getMessage());
+            log.warn("Observation time date not parseable: '" + cols[8] + "'");
+            return null;
         }
+        return null;
     }
 
     protected String getOperator(String[] cols) {

http://dive4elements.wald.intevation.org