annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java @ 3187:1e2733f749b5

SQ: Added specialized outlier test for the S/Q relation. flys-artifacts/trunk@4802 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 26 Jun 2012 16:00:59 +0000
parents 0b86b005bb9a
children
rev   line source
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
3 import de.intevation.artifactdatabase.data.StateData;
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
4
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
5 import de.intevation.flys.artifacts.model.fixings.DateRange;
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
6
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
7 import de.intevation.flys.utils.FLYSUtils;
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
8
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
9 import gnu.trove.TDoubleArrayList;
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
10
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
11 import java.util.ArrayList;
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import java.util.Arrays;
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
13 import java.util.Date;
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 import org.apache.log4j.Logger;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public class FixationArtifactAccess
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 private static Logger log = Logger.getLogger(FixationArtifactAccess.class);
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 protected FLYSArtifact artifact;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 protected String river;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 protected String calculationMode;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 protected Double from;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 protected Double to;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 protected Double step;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 protected Long start;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 protected Long end;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 protected Integer qSectorStart;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 protected Integer qSectorEnd;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
3121
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
37 protected DateRange referencePeriod;
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
38 protected DateRange [] analysisPeriods;
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 protected int [] events;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 protected Boolean preprocessing;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 protected String function;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 protected double [] qs;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 public FixationArtifactAccess() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 public FixationArtifactAccess(FLYSArtifact artifact) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 this.artifact = artifact;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 public FLYSArtifact getArtifact() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 return artifact;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 public String getRiver() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 if (river == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 StateData sd = artifact.getData("river");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 log.warn("missing 'river' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 river = (String)sd.getValue();
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 log.debug("river: '" + river + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 return river;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 public String getCalculationMode() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 if (calculationMode == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 StateData sd = artifact.getData("calculation.mode");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 log.warn("missing 'calculation.mode' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 calculationMode = (String)sd.getValue();
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 log.debug("calculationMode: '" + calculationMode + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 return calculationMode;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 public Double getFrom() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 if (from == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 StateData sd = artifact.getData("from");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 log.warn("missing 'from' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 from = Double.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 log.warn("from '" + sd.getValue() + "' is not numeric.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 log.debug("from: '" + from + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 return from;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 public Double getTo() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 if (to == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 StateData sd = artifact.getData("to");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 log.warn("missing 'to' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 to = Double.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 log.warn("to '" + sd.getValue() + "' is not numeric.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 log.debug("to: '" + to + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 return to;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 public Double getStep() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 if (step == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 StateData sd = artifact.getData("step");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 log.warn("missing 'step' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 step = Double.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 log.warn("step '" + sd.getValue() + "' is not numeric.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 log.debug("step: '" + step + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 return step;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 public Long getStart() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 if (start == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 StateData sd = artifact.getData("start");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 log.warn("missing 'start' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 start = Long.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
171 log.warn("start '" + sd.getValue() + "' is not an integer.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
172 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
173 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
174
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
175 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 log.debug("start: '" + start + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 return start;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 public Long getEnd() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 if (end == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 StateData sd = artifact.getData("end");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187 log.warn("missing 'end' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
191 end = Long.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
192 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 log.warn("end '" + sd.getValue() + "' is not an integer.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 log.debug("end: '" + end + "'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 return end;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205 public Integer getQSectorStart() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 if (qSectorStart == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 StateData sd = artifact.getData("q1");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 log.warn("missing 'q1' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214 qSectorStart = Integer.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 log.warn("q1 '" + sd.getValue() + "' is not an integer.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221 return qSectorStart;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 public Integer getQSectorEnd() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226 if (qSectorEnd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 StateData sd = artifact.getData("q2");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229 log.warn("missing 'q2' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
232 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
233 qSectorEnd = Integer.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 log.warn("q2 '" + sd.getValue() + "' is not an integer.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
237 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 return qSectorEnd;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
241 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
243 public int [] getEvents() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244 if (events == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
245 StateData sd = artifact.getData("events");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 log.warn("missing 'events' value");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 events = FLYSUtils.intArrayFromString((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
252 return events;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
253 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
254
3121
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
255 public DateRange getReferencePeriod() {
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
256 if (referencePeriod == null) {
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
257 StateData refStart = artifact.getData("ref_start");
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
258 StateData refEnd = artifact.getData("ref_end");
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
259
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
260 if (refStart == null || refEnd == null) {
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
261 log.warn("missing 'ref_start' or 'ref_start' value");
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
263 }
3121
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
264
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265 try {
3121
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
266 long rs = Long.parseLong((String)refStart.getValue());
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
267 long re = Long.parseLong((String)refEnd .getValue());
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
268
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
269 if (rs > re) { long t = rs; rs = re; re = t; }
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
270
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
271 Date from = new Date(rs);
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
272 Date to = new Date(re);
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
273 referencePeriod = new DateRange(from, to);
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
274 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 catch (NumberFormatException nfe) {
3121
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
276 log.warn("ref_start or ref_end is not an integer.");
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
277 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
278 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
279
3121
0b86b005bb9a FixA: Respect the selected events and reference period correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3056
diff changeset
280 return referencePeriod;
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
281 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
282
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
283 public DateRange [] getAnalysisPeriods() {
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
284 if (analysisPeriods == null) {
3000
3dd1c320cf81 Changed data fields in fixings analysisperiods state.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2726
diff changeset
285 StateData sd = artifact.getData("ana_data");
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
286
3000
3dd1c320cf81 Changed data fields in fixings analysisperiods state.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2726
diff changeset
287 if (sd == null) {
3dd1c320cf81 Changed data fields in fixings analysisperiods state.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2726
diff changeset
288 log.warn("missing 'ana_data'");
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
289 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
290 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
291
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
292 String data = (String)sd.getValue();
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
293 String[] pairs = data.split("\\s*;\\s*");
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
294
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
295 ArrayList<DateRange> aPs = new ArrayList<DateRange>(pairs.length);
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
296
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
297 for (int i = 0; i < pairs.length; i++) {
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
298 String[] fromTo = pairs[i].split("\\s*,\\s*");
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
299 if (fromTo.length >= 2) {
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
300 try {
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
301 Date from = new Date(Long.parseLong(fromTo[0]));
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
302 Date to = new Date(Long.parseLong(fromTo[1]));
3025
5d286d7e54cd FixA: Prevent duplicates in analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3003
diff changeset
303 DateRange aP = new DateRange(from, to);
5d286d7e54cd FixA: Prevent duplicates in analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3003
diff changeset
304 if (!aPs.contains(aP)) {
5d286d7e54cd FixA: Prevent duplicates in analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3003
diff changeset
305 aPs.add(aP);
5d286d7e54cd FixA: Prevent duplicates in analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3003
diff changeset
306 }
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
307 }
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
308 catch (NumberFormatException nfe) {
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
309 log.warn("ana_data contains no long values.", nfe);
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
310 }
3000
3dd1c320cf81 Changed data fields in fixings analysisperiods state.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2726
diff changeset
311 }
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
312 }
3001
619fe13e2397 FixA: Fixed access to analysis periods.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3000
diff changeset
313
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
314 analysisPeriods = aPs.toArray(new DateRange[aPs.size()]);
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
315 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
316
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
317 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
318 for (int i = 0; i < analysisPeriods.length; ++i) {
3003
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
319 DateRange ap = analysisPeriods[i];
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
320 log.debug("analysis period " +
e5e6363e6cba FixA: Explicit model for date ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3001
diff changeset
321 ap.getFrom() + " - " + ap.getTo());
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
322 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
323 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
324
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
325 return analysisPeriods;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
326 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
327
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
328 public Boolean getPreprocessing() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
329 if (preprocessing == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
330 StateData sd = artifact.getData("preprocessing");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
332 log.warn("missing 'preprocessing'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
333 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 preprocessing = Boolean.valueOf((String)sd.getValue());
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
336 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
337 return preprocessing;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
338 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 public String getFunction() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 if (function == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342 StateData sd = artifact.getData("function");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
343 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
344 log.warn("missing 'function'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
345 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
346 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347 function = (String)sd.getValue();
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
348 }
2726
f53173a8736b Fixings state access: Added more debug putput
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2725
diff changeset
349 if (log.isDebugEnabled()) {
f53173a8736b Fixings state access: Added more debug putput
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2725
diff changeset
350 log.debug("function: " + function);
f53173a8736b Fixings state access: Added more debug putput
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2725
diff changeset
351 }
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
352 return function;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
353 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
354
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
355 public double [] getQs() {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
356 if (qs == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
357 StateData sd = artifact.getData("qs");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
358 if (sd == null) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
359 log.warn("missing 'qs'");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
360 return null;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
361 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
362 String [] parts = ((String)sd.getValue()).split("[\\s;]");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
363 TDoubleArrayList list = new TDoubleArrayList(parts.length);
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
364 for (String part: parts) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
365 try {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
366 list.add(Double.parseDouble(part));
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
367 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
368 catch (NumberFormatException nfe) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
369 log.warn("'" + part + "' is not numeric.");
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
370 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
371 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
372 qs = list.toNativeArray();
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
373 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
374 if (log.isDebugEnabled()) {
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
375 log.debug("qs: " + Arrays.toString(qs));
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
376 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
377 return qs;
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
378 }
3028
77b5f5a26700 Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3025
diff changeset
379
77b5f5a26700 Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3025
diff changeset
380
77b5f5a26700 Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3025
diff changeset
381 public double getCurrentKm() {
77b5f5a26700 Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3025
diff changeset
382 //TODO: get the current km.
3056
0b5a7a2c3724 Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents: 3055
diff changeset
383 return getFrom().doubleValue();
3028
77b5f5a26700 Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3025
diff changeset
384 }
2725
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
385 }
8dbc86a0948d Fixing analysis: Access to state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
386 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org