Mercurial > dive4elements > river
changeset 3437:e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
flys-artifacts/trunk@5100 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 23 Jul 2012 09:09:49 +0000 |
parents | 0d63581c5df1 |
children | b9aff8d6ff74 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java |
diffstat | 4 files changed, 56 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Jul 23 08:38:23 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Jul 23 09:09:49 2012 +0000 @@ -1,3 +1,14 @@ +2012-07-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java: + Made abstract. Sub classes have to overwrite innerCalculate() + calculate() now figures out the fixings overview and the function + to fit and passes it to innerCalculate() + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java: + Overrides innerCalculate() now. + 2012-07-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java Mon Jul 23 08:38:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java Mon Jul 23 09:09:49 2012 +0000 @@ -3,7 +3,6 @@ import de.intevation.flys.artifacts.access.FixAnalysisAccess; import de.intevation.flys.artifacts.math.fitting.Function; -import de.intevation.flys.artifacts.math.fitting.FunctionFactory; import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DateRange; @@ -19,7 +18,6 @@ import de.intevation.flys.artifacts.model.FixingsOverview.SectorFilter; import de.intevation.flys.artifacts.model.FixingsOverview; -import de.intevation.flys.artifacts.model.FixingsOverviewFactory; import de.intevation.flys.artifacts.model.Parameters; import de.intevation.flys.artifacts.model.Range; @@ -65,26 +63,11 @@ } } - public CalculationResult calculate() { - - FixingsOverview overview = - FixingsOverviewFactory.getOverview(river); - - if (overview == null) { - addProblem("fix.no.overview.available"); - } - - Function func = FunctionFactory.getInstance() - .getFunction(function); - - if (func == null) { - addProblem("fix.invalid.function.name"); - } - - if (hasProblems()) { - return new CalculationResult(this); - } - + @Override + public CalculationResult innerCalculate( + FixingsOverview overview, + Function func + ) { FitResult fitResult = doFitting(overview, func); if (fitResult == null) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java Mon Jul 23 08:38:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java Mon Jul 23 09:09:49 2012 +0000 @@ -5,8 +5,10 @@ import de.intevation.flys.artifacts.access.FixAccess; import de.intevation.flys.artifacts.math.fitting.Function; +import de.intevation.flys.artifacts.math.fitting.FunctionFactory; import de.intevation.flys.artifacts.model.Calculation; +import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.FixingsColumn; import de.intevation.flys.artifacts.model.FixingsColumnFactory; @@ -16,6 +18,7 @@ import de.intevation.flys.artifacts.model.FixingsOverview.IdsFilter; import de.intevation.flys.artifacts.model.FixingsOverview; +import de.intevation.flys.artifacts.model.FixingsOverviewFactory; import de.intevation.flys.artifacts.model.Parameters; import de.intevation.flys.utils.DoubleUtil; @@ -29,8 +32,8 @@ import org.apache.log4j.Logger; -public class FixCalculation -extends Calculation +public abstract class FixCalculation +extends Calculation { private static Logger log = Logger.getLogger(FixCalculation.class); @@ -373,5 +376,32 @@ referenced, outliers); } + + public CalculationResult calculate() { + FixingsOverview overview = + FixingsOverviewFactory.getOverview(river); + + if (overview == null) { + addProblem("fix.no.overview.available"); + } + + Function func = FunctionFactory.getInstance() + .getFunction(function); + + if (func == null) { + addProblem("fix.invalid.function.name"); + } + + if (hasProblems()) { + return new CalculationResult(this); + } + + return innerCalculate(overview, func); + } + + protected abstract CalculationResult innerCalculate( + FixingsOverview overview, + Function function + ); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java Mon Jul 23 08:38:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixRealizingCalculation.java Mon Jul 23 09:09:49 2012 +0000 @@ -2,7 +2,10 @@ import de.intevation.flys.artifacts.access.FixRealizingAccess; +import de.intevation.flys.artifacts.math.fitting.Function; + import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.artifacts.model.FixingsOverview; import de.intevation.flys.artifacts.model.Segment; import java.util.List; @@ -43,10 +46,11 @@ } } - public CalculationResult calculate() { - if (hasProblems()) { - return new CalculationResult(this); - } + @Override + protected CalculationResult innerCalculate( + FixingsOverview overview, + Function func + ) { // TODO: Implement me! return new CalculationResult(this); }