annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java @ 5662:7e3cde8b564c

Cosmetics, docs, vimlines.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 11 Apr 2013 12:43:02 +0200
parents acfd48384835
children
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;
4866
acfd48384835 Changed data field names in fix analsis to ld_from, ld_to, ld step.
Raimund Renkert <rrenkert@intevation.de>
parents: 3466
diff changeset
4 import de.intevation.artifacts.CallContext;
3411
0ef83077c93f FixA: Renamed FixCalculation to FixAnalysisCalculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3408
diff changeset
5
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import de.intevation.flys.artifacts.FLYSArtifact;
3411
0ef83077c93f FixA: Renamed FixCalculation to FixAnalysisCalculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3408
diff changeset
7
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import de.intevation.flys.artifacts.model.DateRange;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import java.util.Arrays;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import java.util.Date;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 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
16 extends FixAccess
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 private static Logger log = Logger.getLogger(FixAnalysisAccess.class);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 protected DateRange referencePeriod;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 protected DateRange [] analysisPeriods;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 protected double [] qs;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
4866
acfd48384835 Changed data field names in fix analsis to ld_from, ld_to, ld step.
Raimund Renkert <rrenkert@intevation.de>
parents: 3466
diff changeset
25 public FixAnalysisAccess(FLYSArtifact artifact, CallContext context) {
acfd48384835 Changed data field names in fix analsis to ld_from, ld_to, ld step.
Raimund Renkert <rrenkert@intevation.de>
parents: 3466
diff changeset
26 super(artifact, context);
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 public DateRange getReferencePeriod() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 if (referencePeriod == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 StateData refStart = artifact.getData("ref_start");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 StateData refEnd = artifact.getData("ref_end");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 if (refStart == null || refEnd == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 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
36 return null;
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 try {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 long rs = Long.parseLong((String)refStart.getValue());
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 long re = Long.parseLong((String)refEnd .getValue());
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 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
44
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 Date from = new Date(rs);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 Date to = new Date(re);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 referencePeriod = new DateRange(from, to);
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 catch (NumberFormatException nfe) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 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
51 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 }
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 return referencePeriod;
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
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 public DateRange [] getAnalysisPeriods() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 if (analysisPeriods == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 analysisPeriods = getDateRange("ana_data");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 return analysisPeriods;
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
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 * @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
67 * of analysis and reference periods.
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 */
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 public DateRange getDateRange() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 DateRange refP = getReferencePeriod();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71
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
72 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
73 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
74 }
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
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 Date from = refP.getFrom();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 Date to = refP.getTo();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 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
80 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
81 if (r.getFrom().before(from)) {
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 from = r.getFrom();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
3418
21c1d1d25919 FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3411
diff changeset
84 if (r.getTo().after(to)) {
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 to = r.getTo();
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 }
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 return new DateRange(from, to);
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
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 public double [] getQs() {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 if (qs == null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 qs = getDoubleArray("qs");
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 if (log.isDebugEnabled() && qs != null) {
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 log.debug("qs: " + Arrays.toString(qs));
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 return 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 }
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org