[PATCH 09 of 45] (issue1753) Carry measurement date through SQ values

Wald Commits scm-commit at wald.intevation.org
Tue Mar 10 17:05:37 CET 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1423827246 -3600
# Node ID 84929f882fa235bd1896c74b6f8f28149021cbbc
# Parent  c25a8066d99f7e266924cc82bc7425a3902af66a
(issue1753) Carry measurement date through SQ values

diff -r c25a8066d99f -r 84929f882fa2 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/LogSQ.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/LogSQ.java	Fri Feb 13 12:31:59 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/LogSQ.java	Fri Feb 13 12:34:06 2015 +0100
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.artifacts.model.sq;
 
+import java.util.Date;
+
 public class LogSQ extends SQ {
 
     public static final View LOG_SQ_VIEW = new View() {
@@ -20,12 +22,17 @@
         public double getQ(SQ sq) {
             return ((LogSQ)sq).getLogQ();
         }
+
+        @Override
+        public Date getDate(SQ sq) {
+            return sq.getDate();
+        }
     };
 
     public static final Factory LOG_SQ_FACTORY = new Factory() {
         @Override
-        public SQ createSQ(double s, double q) {
-            return new LogSQ(s, q);
+        public SQ createSQ(double s, double q, Date d) {
+            return new LogSQ(s, q, d);
         }
     };
 
@@ -37,8 +44,8 @@
     public LogSQ() {
     }
 
-    public LogSQ(double s, double q) {
-        super(s, q);
+    public LogSQ(double s, double q, Date d) {
+        super(s, q, d);
     }
 
     /** important: We cannot process negative s/q. */
diff -r c25a8066d99f -r 84929f882fa2 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Measurement.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Measurement.java	Fri Feb 13 12:31:59 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Measurement.java	Fri Feb 13 12:34:06 2015 +0100
@@ -10,6 +10,7 @@
 
 import java.util.List;
 import java.util.Map;
+import java.util.Date;
 
 import org.apache.log4j.Logger;
 
@@ -109,6 +110,10 @@
         return S_SS() + S_BL_S() + S_BL_FG() + S_BL_CG();
     }
 
+    public Date getDate() {
+        return  (Date)data.get("DATUM");
+    }
+
     @Override
     public String toString() {
         return "Measurement: " + data;
diff -r c25a8066d99f -r 84929f882fa2 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/MeasurementFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/MeasurementFactory.java	Fri Feb 13 12:31:59 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/MeasurementFactory.java	Fri Feb 13 12:34:06 2015 +0100
@@ -46,7 +46,8 @@
         "SELECT " +
             "m.Q_BPEGEL AS Q_BPEGEL,"+
             "m.TSCHWEB  AS TSCHWEB," +
-            "m.TSAND    AS TSAND " +
+            "m.TSAND    AS TSAND, " +
+            "m.DATUM    AS DATUM " +
         "FROM MESSUNG m " +
             "JOIN STATION   s ON m.STATIONID   = s.STATIONID " +
             "JOIN GEWAESSER r ON s.GEWAESSERID = r.GEWAESSERID " +
@@ -281,7 +282,8 @@
         SQLQuery query = session.createSQLQuery(SQL_TOTALS)
             .addScalar("Q_BPEGEL", StandardBasicTypes.DOUBLE)
             .addScalar("TSCHWEB",  StandardBasicTypes.DOUBLE)
-            .addScalar("TSAND",    StandardBasicTypes.DOUBLE);
+            .addScalar("TSAND",    StandardBasicTypes.DOUBLE)
+            .addScalar("DATUM",    StandardBasicTypes.DATE);
 
         query.setString("river_name", river);
         query.setDouble("location", location);
diff -r c25a8066d99f -r 84929f882fa2 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Measurements.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Measurements.java	Fri Feb 13 12:31:59 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/Measurements.java	Fri Feb 13 12:34:06 2015 +0100
@@ -99,7 +99,8 @@
         List<SQ> result = new ArrayList<SQ>(measuments.size());
         int invalid = 0;
         for (Measurement measument: measuments) {
-            SQ sq = sqFactory.createSQ(extractor.getS(measument), measument.Q());
+            SQ sq = sqFactory.createSQ(extractor.getS(measument), measument.Q(),
+                    measument.getDate());
             if (sq.isValid()) {
                 result.add(sq);
             }
diff -r c25a8066d99f -r 84929f882fa2 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQ.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQ.java	Fri Feb 13 12:31:59 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQ.java	Fri Feb 13 12:34:06 2015 +0100
@@ -10,24 +10,27 @@
 
 import java.io.Serializable;
 
+import java.util.Date;
+
 
 /** Represents S/Q pairs. They are immutable! */
 public class SQ implements Serializable {
 
     public interface Factory {
-        SQ createSQ(double s, double q);
+        SQ createSQ(double s, double q, Date d);
     }
 
     public static final Factory SQ_FACTORY = new Factory() {
         @Override
-        public SQ createSQ(double s, double q) {
-            return new SQ(s, q);
+        public SQ createSQ(double s, double q, Date d) {
+            return new SQ(s, q, d);
         }
     };
 
     public interface View {
         double getS(SQ sq);
         double getQ(SQ sq);
+        Date getDate(SQ sq);
     }
 
     public static final View SQ_VIEW = new View() {
@@ -40,17 +43,24 @@
         public double getQ(SQ sq) {
             return sq.getQ();
         }
+
+        @Override
+        public Date getDate(SQ sq) {
+            return sq.getDate();
+        }
     };
 
     protected double s;
     protected double q;
+    protected Date d;
 
     public SQ() {
     }
 
-    public SQ(double s, double q) {
+    public SQ(double s, double q, Date d) {
         this.s = s;
         this.q = q;
+        this.d = d;
     }
 
 
@@ -62,6 +72,10 @@
         return q;
     }
 
+    public Date getDate() {
+        return d;
+    }
+
     public boolean isValid() {
         return !Double.isNaN(s) && !Double.isNaN(q);
     }


More information about the Dive4Elements-commits mailing list