changeset 4066:f02aa4ff3c0f

S/Q relation: Fixed problem with loosing meassurement points.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 09 Oct 2012 19:02:39 +0200
parents 9d404069f361
children ae5119da92cd
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java
diffstat 3 files changed, 44 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Oct 09 12:30:13 2012 +0200
+++ b/flys-artifacts/ChangeLog	Tue Oct 09 19:02:39 2012 +0200
@@ -1,3 +1,11 @@
+2012-10-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java:
+	  Added debug output to detect where data got lost.
+
+	* src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java:
+    Fixed problem with losing meassurement points. There are still bugs left.
+
 2012-10-08	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java	Tue Oct 09 12:30:13 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java	Tue Oct 09 19:02:39 2012 +0200
@@ -9,6 +9,8 @@
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.log4j.Logger;
+
 import org.hibernate.SQLQuery;
 import org.hibernate.Session;
 
@@ -22,6 +24,9 @@
 
 public class MeasurementFactory
 {
+    private static final Logger log =
+        Logger.getLogger(MeasurementFactory.class);
+
     public static final String SQL_TOTALS =
         "SELECT " +
             "m.Q_BPEGEL AS Q_BPEGEL,"+
@@ -215,6 +220,8 @@
         double    location,
         DateRange dateRange
     ) {
+        boolean debug = log.isDebugEnabled();
+
         SQLQuery query = session.createSQLQuery(SQL_FACTIONS)
             .addScalar("Q_BPEGEL",     StandardBasicTypes.DOUBLE)
             .addScalar("DATUM",        StandardBasicTypes.DATE)
@@ -280,6 +287,10 @@
         @SuppressWarnings("unchecked")
         List<Measurement> measuments = (List<Measurement>)query.list();
 
+        if (debug) {
+            log.debug("num fraction results: " + measuments.size());
+        }
+
         List<Measurement> same = new ArrayList<Measurement>();
 
         Integer lastLR = null;
@@ -298,6 +309,8 @@
                 same.clear();
             }
 
+            same.add(m);
+
             lastLR = currentLR;
         }
 
@@ -309,7 +322,17 @@
             m.adjustSieves();
         }
 
-        return separateByDate(accumulated);
+        if (debug) {
+            log.debug("Before date separation: " + accumulated.size());
+        }
+
+        accumulated = separateByDate(accumulated);
+
+        if (debug) {
+            log.debug("After date separation: " + accumulated.size());
+        }
+
+        return accumulated;
     }
 
     protected static List<Measurement> separateByDate(List<Measurement> measurements) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java	Tue Oct 09 12:30:13 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java	Tue Oct 09 19:02:39 2012 +0200
@@ -65,6 +65,10 @@
         List<Measurement> measuments,
         List<Measurement> accumulated
     ) {
+        if (log.isDebugEnabled()) {
+            log.debug("number of measuments: " + measuments.size());
+            log.debug("number of accumulated: " + accumulated.size());
+        }
         this.measuments = measuments;
         this.accumulated = accumulated;
     }
@@ -74,11 +78,19 @@
         SExtractor extractor
     ) {
         List<SQ> result = new ArrayList<SQ>(measuments.size());
+        int invalid = 0;
         for (Measurement measument: measuments) {
             SQ sq = new SQ(extractor.getS(measument), measument.Q());
             if (sq.isValid()) {
                 result.add(sq);
             }
+            else {
+                ++invalid;
+            }
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("Removed num invalid: " + invalid
+                + " of " + measuments.size());
         }
         return result;
     }

http://dive4elements.wald.intevation.org