changeset 7864:d9d2bd78eff6

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 08 May 2014 13:52:47 +0200
parents 082284c4e0ad (diff) 3fda73d9dc56 (current diff)
children 8d4a4c645e61 5ec28ef7026b
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/PorosityFactory.java backend/src/main/java/org/dive4elements/river/importer/ImportPorosity.java backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java
diffstat 6 files changed, 61 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/PorosityFactory.java	Tue May 06 17:24:59 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/PorosityFactory.java	Thu May 08 13:52:47 2014 +0200
@@ -32,7 +32,8 @@
         "SELECT pv.station AS station, pv.porosity AS porosity " +
         "   FROM porosity p" +
         "       JOIN porosity_values pv on pv.porosity_id = p.id" +
-        "   WHERE p.id = :porosity_id";
+        "   WHERE p.id = :porosity_id" +
+        "   ORDER BY station";
 
     private PorosityFactory() {
     }
--- a/backend/doc/schema/oracle-minfo.sql	Tue May 06 17:24:59 2014 +0200
+++ b/backend/doc/schema/oracle-minfo.sql	Thu May 08 13:52:47 2014 +0200
@@ -147,6 +147,35 @@
 );
 
 
+CREATE SEQUENCE POROSITY_ID_SEQ;
+
+CREATE TABLE porosity (
+    id               NUMBER NOT NULL,
+    river_id         NUMBER NOT NULL,
+    depth_id         NUMBER NOT NULL,
+    description      VARCHAR(256),
+    time_interval_id NUMBER NOT NULL,
+    PRIMARY KEY(id),
+    CONSTRAINT fk_p_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE,
+    CONSTRAINT fk_p_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id),
+    CONSTRAINT fk_p_time_interval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id)
+);
+
+
+CREATE SEQUENCE POROSITY_VALUES_ID_SEQ;
+
+CREATE TABLE porosity_values (
+    id                  NUMBER NOT NULL,
+    porosity_id         NUMBER NOT NULL,
+    station             NUMBER NOT NULL,
+    shore_offset        NUMBER,
+    porosity            NUMBER NOT NULL,
+    description         VARCHAR(256),
+    PRIMARY KEY(id),
+    CONSTRAINT fk_pv_porosity_id FOREIGN KEY(porosity_id) REFERENCES porosity(id) ON DELETE CASCADE
+);
+
+
 CREATE SEQUENCE MORPHOLOGIC_WIDTH_ID_SEQ;
 
 CREATE TABLE morphologic_width (
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportDepth.java	Tue May 06 17:24:59 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportDepth.java	Thu May 08 13:52:47 2014 +0200
@@ -52,11 +52,11 @@
 
             Query query = session.createQuery(
                 "from Depth where " +
-                "   lower=:lower and " +
-                "   upper=:upper");
+                "   lower between :lower - 0.0001f and :lower + 0.00001f and " +
+                "   upper between :upper - 0.0001f and :upper + 0.00001f");
 
-            query.setParameter("lower", lower);
-            query.setParameter("upper", upper);
+            query.setParameter("lower", lower.floatValue());
+            query.setParameter("upper", upper.floatValue());
 
             List<Depth> depths = query.list();
 
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportPorosity.java	Tue May 06 17:24:59 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportPorosity.java	Thu May 08 13:52:47 2014 +0200
@@ -85,10 +85,13 @@
                 .getDatabaseSession();
 
             Query query = session.createQuery("from Porosity where "
-                + "   river=:river and " + "   depth=:depth");
+                + "   river=:river and "
+                + "   depth=:depth and "
+                + "   description=:description");
 
             query.setParameter("river", river);
             query.setParameter("depth", depth.getPeer());
+            query.setParameter("description", description);
 
             List<Porosity> porosity = query.list();
 
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportPorosityValue.java	Tue May 06 17:24:59 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportPorosityValue.java	Thu May 08 13:52:47 2014 +0200
@@ -67,15 +67,13 @@
             Query query = session.createQuery(
                 "from PorosityValue where " +
                 "   porosity=:porosity and " +
-                "   station=:station and " +
-                "   shoreOffset=:shoreOffset and " +
-                "   porosityValue=:poros and " +
+                "   station between :station - 0.0001f and :station + 0.0001f and" +
+                "   porosityValue between :poros -0.0001f and :poros + 0.0001f and" +
                 "   description=:description");
 
             query.setParameter("porosity", porosity);
-            query.setParameter("station", station);
-            query.setParameter("shoreOffset", shoreOffset);
-            query.setParameter("poros", this.porosity);
+            query.setParameter("station", station.floatValue());
+            query.setParameter("poros", this.porosity.floatValue());
             query.setParameter("description", description);
 
             List<PorosityValue> values = query.list();
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java	Tue May 06 17:24:59 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/PorosityParser.java	Thu May 08 13:52:47 2014 +0200
@@ -135,19 +135,22 @@
 
             log.info("Found porosity depth: " + lo + " - " + up + " cm");
 
+            ImportDepth depth = null;
             try {
-                ImportDepth depth = new ImportDepth(
-                    new BigDecimal(nf.parse(lo).doubleValue()),
-                    new BigDecimal(nf.parse(up).doubleValue())
+                depth = new ImportDepth(
+                    new BigDecimal(lo),
+                    new BigDecimal(up)
                 );
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("Unparsable number for depth: " + line, nfe);
+            }
 
+            if (depth != null) {
                 current.setDepth(depth);
-
                 return true;
             }
-            catch (ParseException pe) {
-                log.warn("Unparseable numbers in: '" + line + "'");
-            }
+            return false;
         }
         else {
             log.debug("Meta line doesn't contain depth information: " + line);
@@ -168,15 +171,18 @@
         BigDecimal km = null;
         BigDecimal shoreOffset = null;
         BigDecimal porosity = null;
+        vals[0] = vals[0].replace(",", ".");
+        vals[2] = vals[2].replace(",", ".");
         try {
-            km          = new BigDecimal(nf.parse(vals[0]).doubleValue());
-            porosity     = new BigDecimal(nf.parse(vals[2]).doubleValue());
+            km          = new BigDecimal(vals[0]);
+            porosity     = new BigDecimal(vals[2]);
             if (!vals[1].isEmpty()) {
-                shoreOffset = new BigDecimal(nf.parse(vals[1]).doubleValue());
+                vals[1] = vals[1].replace(",", ".");
+                shoreOffset = new BigDecimal(vals[1]);
             }
         }
-        catch (ParseException pe) {
-            log.warn("Unparseable numbers in '" + line + "'");
+        catch(NumberFormatException nfe) {
+            log.warn("Unparsable number in line: " + line, nfe);
         }
 
         if (km == null || porosity == null) {

http://dive4elements.wald.intevation.org