# HG changeset patch # User Sascha L. Teichmann # Date 1349802159 -7200 # Node ID f02aa4ff3c0f360f243334d31ccb694dd4c97442 # Parent 9d404069f3619358176dd6c4afc16f0993ae177f S/Q relation: Fixed problem with loosing meassurement points. diff -r 9d404069f361 -r f02aa4ff3c0f flys-artifacts/ChangeLog --- 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 + + * 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 * flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java, diff -r 9d404069f361 -r f02aa4ff3c0f flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.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 measuments = (List)query.list(); + if (debug) { + log.debug("num fraction results: " + measuments.size()); + } + List same = new ArrayList(); 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 separateByDate(List measurements) { diff -r 9d404069f361 -r f02aa4ff3c0f flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java --- 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 measuments, List 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 result = new ArrayList(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; }