changeset 3297:79c8e0d9fdea

SQ relation: Use only first time period. flys-artifacts/trunk@4982 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 13 Jul 2012 10:12:45 +0000 (2012-07-13)
parents 45af081061e7
children b92e86a78895
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQResult.java
diffstat 3 files changed, 32 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jul 13 09:45:11 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jul 13 10:12:45 2012 +0000
@@ -1,3 +1,11 @@
+2012-07-13	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java:
+	  Only use first period of the time periods given by the UI.
+
+	* src/main/java/de/intevation/flys/artifacts/model/sq/SQResult.java:
+	  Added some more index checking.
+
 2012-07-13  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/sq/SQOverviewFacet.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java	Fri Jul 13 09:45:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java	Fri Jul 13 10:12:45 2012 +0000
@@ -40,7 +40,7 @@
             addProblem("sq.missing.location");
         }
 
-        if (periods == null) {
+        if (periods == null || periods.length == 0) {
             // TODO: i18n
             addProblem("sq.missing.periods");
         }
@@ -79,20 +79,24 @@
 
         boolean debug = log.isDebugEnabled();
 
-        for (DateRange period: periods) {
-            Measurements measurements =
-                MeasurementFactory.getMeasurements(river, location, period);
+        // XXX: We can only produce one SQResult.
+        DateRange period = periods[0];
 
-            if (debug) {
-                log.debug(measurements.toString());
-            }
+        Measurements measurements =
+            MeasurementFactory.getMeasurements(river, location, period);
+
+        if (debug) {
+            log.debug(measurements.toString());
         }
 
-        // TODO: Implement me!
+        SQFractionResult [] fractionResults =
+            new SQFractionResult[SQResult.NUMBER_FRACTIONS];
 
-        SQResult [] result = null;
+        for (int i = 0; i < fractionResults.length; ++i) {
+            // TODO: Implement me!
+        }
 
-        return new CalculationResult(result, this);
+        return new CalculationResult(new SQResult(fractionResults), this);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQResult.java	Fri Jul 13 09:45:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQResult.java	Fri Jul 13 10:12:45 2012 +0000
@@ -6,6 +6,8 @@
 
 public class SQResult implements Serializable {
 
+    public static final int NUMBER_FRACTIONS = 6;
+
     public static final int FRACTION_A = 0;
     public static final int FRACTION_B = 1;
     public static final int FRACTION_C = 2;
@@ -13,25 +15,24 @@
     public static final int FRACTION_E = 4;
     public static final int FRACTION_F = 5;
 
-
     protected SQFractionResult[] fractions;
 
-
     public SQResult() {
-        fractions = new SQFractionResult[6];
+        this(new SQFractionResult[NUMBER_FRACTIONS]);
     }
 
+    public SQResult(SQFractionResult [] fractions) {
+        this.fractions = fractions;
+    }
 
     public SQFractionResult getFraction(int idx) {
-        if (idx < fractions.length) {
-            return fractions[idx];
-        }
-
-        return null;
+        return idx >= 0 && idx < fractions.length
+            ? fractions[idx]
+            : null;
     }
 
     public void setFraction(int idx, SQFractionResult fraction) {
-        if (idx < fractions.length) {
+        if (idx >= 0 && idx < fractions.length) {
             this.fractions[idx] = fraction;
         }
     }

http://dive4elements.wald.intevation.org