annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java @ 4507:976ff4b74b96

QSectorFacet: Guard access to curentKm in context.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 14 Nov 2012 12:26:45 +0100
parents 8160e62bbb3a
children acfd48384835
rev   line source
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.access;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import de.intevation.artifactdatabase.data.StateData;
3411
0ef83077c93f FixA: Renamed FixCalculation to FixAnalysisCalculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3408
diff changeset
4
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import de.intevation.flys.artifacts.FLYSArtifact;
3411
0ef83077c93f FixA: Renamed FixCalculation to FixAnalysisCalculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3408
diff changeset
6
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import de.intevation.flys.artifacts.model.DateRange;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import java.util.Arrays;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import java.util.Date;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import org.apache.log4j.Logger;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 public class FixAnalysisAccess
3418
21c1d1d25919 FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3411
diff changeset
15 extends FixAccess
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 private static Logger log = Logger.getLogger(FixAnalysisAccess.class);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 protected DateRange referencePeriod;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 protected DateRange [] analysisPeriods;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 protected double [] qs;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 public FixAnalysisAccess() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 public FixAnalysisAccess(FLYSArtifact artifact) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 super(artifact);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 public DateRange getReferencePeriod() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 if (referencePeriod == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 StateData refStart = artifact.getData("ref_start");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 StateData refEnd = artifact.getData("ref_end");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 if (refStart == null || refEnd == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 log.warn("missing 'ref_start' or 'ref_start' value");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 return null;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 try {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 long rs = Long.parseLong((String)refStart.getValue());
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 long re = Long.parseLong((String)refEnd .getValue());
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 if (rs > re) { long t = rs; rs = re; re = t; }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 Date from = new Date(rs);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 Date to = new Date(re);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 referencePeriod = new DateRange(from, to);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 catch (NumberFormatException nfe) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 log.warn("ref_start or ref_end is not an integer.");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 return referencePeriod;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 public DateRange [] getAnalysisPeriods() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 if (analysisPeriods == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 analysisPeriods = getDateRange("ana_data");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 return analysisPeriods;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 /**
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 * @return DateRange object ranging from eldest to youngest date
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 * of analysis and reference periods.
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 */
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 public DateRange getDateRange() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 DateRange refP = getReferencePeriod();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73
3466
8160e62bbb3a Registered new output 'fix_vollmer_wq_curve' for the vollmer path of fixings analysis module; create required Facets for it after calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3418
diff changeset
74 if (refP == null) {
8160e62bbb3a Registered new output 'fix_vollmer_wq_curve' for the vollmer path of fixings analysis module; create required Facets for it after calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3418
diff changeset
75 return null;
8160e62bbb3a Registered new output 'fix_vollmer_wq_curve' for the vollmer path of fixings analysis module; create required Facets for it after calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3418
diff changeset
76 }
8160e62bbb3a Registered new output 'fix_vollmer_wq_curve' for the vollmer path of fixings analysis module; create required Facets for it after calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3418
diff changeset
77
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 Date from = refP.getFrom();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 Date to = refP.getTo();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 DateRange[] rs = getAnalysisPeriods();
3418
21c1d1d25919 FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3411
diff changeset
82 for (DateRange r: rs) {
21c1d1d25919 FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3411
diff changeset
83 if (r.getFrom().before(from)) {
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 from = r.getFrom();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 }
3418
21c1d1d25919 FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3411
diff changeset
86 if (r.getTo().after(to)) {
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 to = r.getTo();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 return new DateRange(from, to);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 public double [] getQs() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 if (qs == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 qs = getDoubleArray("qs");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 if (log.isDebugEnabled() && qs != null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 log.debug("qs: " + Arrays.toString(qs));
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 return qs;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org