# HG changeset patch # User Sascha L. Teichmann # Date 1342174365 0 # Node ID 79c8e0d9fdea369d132b316015856cf031862101 # Parent 45af081061e74503a88d6ad4f0af7b88496e91e7 SQ relation: Use only first time period. flys-artifacts/trunk@4982 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 45af081061e7 -r 79c8e0d9fdea flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/artifacts/model/sq/SQOverviewFacet.java: diff -r 45af081061e7 -r 79c8e0d9fdea flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.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 : diff -r 45af081061e7 -r 79c8e0d9fdea flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQResult.java --- 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; } }