Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java @ 3419:da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
flys-artifacts/trunk@5072 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 16:35:14 +0000 |
parents | e3c7a3228bc2 |
children | 7f7ab030a4e3 |
comparison
equal
deleted
inserted
replaced
3418:21c1d1d25919 | 3419:da7cf0e3ccaa |
---|---|
3 import de.intevation.flys.artifacts.access.FixAnalysisAccess; | 3 import de.intevation.flys.artifacts.access.FixAnalysisAccess; |
4 | 4 |
5 import de.intevation.flys.artifacts.math.fitting.Function; | 5 import de.intevation.flys.artifacts.math.fitting.Function; |
6 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; | 6 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; |
7 | 7 |
8 import de.intevation.flys.artifacts.model.Calculation; | |
9 import de.intevation.flys.artifacts.model.CalculationResult; | 8 import de.intevation.flys.artifacts.model.CalculationResult; |
10 import de.intevation.flys.artifacts.model.DateRange; | 9 import de.intevation.flys.artifacts.model.DateRange; |
11 import de.intevation.flys.artifacts.model.FixingsColumn; | 10 import de.intevation.flys.artifacts.model.FixingsColumn; |
12 import de.intevation.flys.artifacts.model.FixingsColumnFactory; | 11 import de.intevation.flys.artifacts.model.FixingsColumnFactory; |
13 | 12 |
40 import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; | 39 import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; |
41 | 40 |
42 import org.apache.log4j.Logger; | 41 import org.apache.log4j.Logger; |
43 | 42 |
44 public class FixAnalysisCalculation | 43 public class FixAnalysisCalculation |
45 extends Calculation | 44 extends FixCalculation |
46 { | 45 { |
47 private static Logger log = Logger.getLogger(FixAnalysisCalculation.class); | 46 private static Logger log = Logger.getLogger(FixAnalysisCalculation.class); |
48 | 47 |
49 public static final double EPSILON = 1e-4; | 48 public static final double EPSILON = 1e-4; |
50 | 49 |
51 protected String river; | |
52 protected double from; | |
53 protected double to; | |
54 protected double step; | |
55 protected boolean preprocessing; | |
56 protected String function; | |
57 protected int [] events; | |
58 protected DateRange referencePeriod; | 50 protected DateRange referencePeriod; |
59 protected DateRange [] analysisPeriods; | 51 protected DateRange [] analysisPeriods; |
60 protected int qSectorStart; | |
61 protected int qSectorEnd; | |
62 | 52 |
63 public FixAnalysisCalculation() { | 53 public FixAnalysisCalculation() { |
64 } | 54 } |
65 | 55 |
66 public FixAnalysisCalculation(FixAnalysisAccess access) { | 56 public FixAnalysisCalculation(FixAnalysisAccess access) { |
67 | 57 super(access); |
68 String river = access.getRiver(); | 58 |
69 Double from = access.getFrom(); | |
70 Double to = access.getTo(); | |
71 Double step = access.getStep(); | |
72 String function = access.getFunction(); | |
73 int [] events = access.getEvents(); | |
74 DateRange referencePeriod = access.getReferencePeriod(); | 59 DateRange referencePeriod = access.getReferencePeriod(); |
75 DateRange [] analysisPeriods = access.getAnalysisPeriods(); | 60 DateRange [] analysisPeriods = access.getAnalysisPeriods(); |
76 Integer qSectorStart = access.getQSectorStart(); | |
77 Integer qSectorEnd = access.getQSectorEnd(); | |
78 Boolean preprocessing = access.getPreprocessing(); | |
79 | |
80 if (river == null) { | |
81 addProblem("fix.missing.river"); | |
82 } | |
83 | |
84 if (from == null) { | |
85 addProblem("fix.missing.from"); | |
86 } | |
87 | |
88 if (to == null) { | |
89 addProblem("fix.missing.to"); | |
90 } | |
91 | |
92 if (step == null) { | |
93 addProblem("fix.missing.step"); | |
94 } | |
95 | |
96 if (function == null) { | |
97 addProblem("fix.missing.function"); | |
98 } | |
99 | |
100 if (events == null || events.length < 1) { | |
101 addProblem("fix.missing.events"); | |
102 } | |
103 | 61 |
104 if (referencePeriod == null) { | 62 if (referencePeriod == null) { |
105 addProblem("fix.missing.reference.period"); | 63 addProblem("fix.missing.reference.period"); |
106 } | 64 } |
107 | 65 |
108 if (analysisPeriods == null || analysisPeriods.length < 1) { | 66 if (analysisPeriods == null || analysisPeriods.length < 1) { |
109 addProblem("fix.missing.analysis.periods"); | 67 addProblem("fix.missing.analysis.periods"); |
110 } | 68 } |
111 | 69 |
112 if (qSectorStart == null) { | |
113 addProblem("fix.missing.qstart.sector"); | |
114 } | |
115 | |
116 if (qSectorEnd == null) { | |
117 addProblem("fix.missing.qend.sector"); | |
118 } | |
119 | |
120 if (preprocessing == null) { | |
121 addProblem("fix.missing.preprocessing"); | |
122 } | |
123 | |
124 if (!hasProblems()) { | 70 if (!hasProblems()) { |
125 this.river = river; | |
126 this.from = from; | |
127 this.to = to; | |
128 this.step = step; | |
129 this.function = function; | |
130 this.events = events; | |
131 this.referencePeriod = referencePeriod; | 71 this.referencePeriod = referencePeriod; |
132 this.analysisPeriods = analysisPeriods; | 72 this.analysisPeriods = analysisPeriods; |
133 this.qSectorStart = qSectorStart; | |
134 this.qSectorEnd = qSectorEnd; | |
135 this.preprocessing = preprocessing; | |
136 } | 73 } |
137 } | 74 } |
138 | 75 |
139 public CalculationResult calculate() { | 76 public CalculationResult calculate() { |
140 | 77 |