annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java @ 3062:7660cfe5e8f6

FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete) flys-artifacts/trunk@4642 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Tue, 12 Jun 2012 12:40:44 +0000
parents 22da13d1b180
children 5642a83420f2
rev   line source
3035
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model.fixings;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.Artifact;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 import de.intevation.artifacts.CallContext;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 import de.intevation.flys.utils.KMIndex;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import de.intevation.flys.artifacts.FLYSArtifact;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import de.intevation.flys.artifacts.FixationArtifactAccess;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.artifacts.model.FacetTypes;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import de.intevation.flys.artifacts.model.DataFacet;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.artifacts.model.CalculationResult;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 /**
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 * Facet to show W values for Q values at km for a date.
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 *
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 */
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 public class FixAnalysisEventsFacet
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 extends DataFacet
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 implements FacetTypes {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 /** House logger. */
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 private static Logger logger = Logger.getLogger(FixAnalysisEventsFacet.class);
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 /** Trivial Constructor. */
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 public FixAnalysisEventsFacet() {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 /**
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 * @param name
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 */
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3039
diff changeset
40 public FixAnalysisEventsFacet(int index, String name, String description) {
3039
7db919b1bc1e Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3035
diff changeset
41 super(index,
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3039
diff changeset
42 name,
3039
7db919b1bc1e Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3035
diff changeset
43 description,
7db919b1bc1e Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3035
diff changeset
44 ComputeType.ADVANCE,
7db919b1bc1e Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3035
diff changeset
45 null,
7db919b1bc1e Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3035
diff changeset
46 null);
3035
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 /**
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 * Returns the data this facet requires.
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 *
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 * @param artifact the owner artifact.
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 * @param context the CallContext (ignored).
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 *
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 * @return the data.
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 */
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 @Override
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 public Object getData(Artifact artifact, CallContext context) {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 logger.debug("FixAnalysisEventsFacet.getData");
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 if (artifact instanceof FLYSArtifact) {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 FLYSArtifact flys = (FLYSArtifact)artifact;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 FixationArtifactAccess access = new FixationArtifactAccess(flys);
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 CalculationResult res =
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 (CalculationResult) flys.compute(context,
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 ComputeType.ADVANCE,
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 false);
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 FixResult result = (FixResult) res.getData();
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 double km = access.getCurrentKm();
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods();
3062
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
76 KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry =
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
77 kmPeriods.binarySearch(km);
3035
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78
3062
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
79 if(kmPeriodsEntry == null) {
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
80 return null;
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
81 }
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
82
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
83 AnalysisPeriod[] periods = kmPeriodsEntry.getValue();
3035
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 if (periods == null) {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 return null;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 QWD[] qwdData = periods[index].getQWDs();
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 return qwdData;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 else {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 logger.debug("Not an instance of FixationArtifact.");
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 return null;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 /**
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 * Create a deep copy of this Facet.
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 * @return a deep copy.
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 */
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 @Override
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 public FixAnalysisEventsFacet deepCopy() {
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 FixAnalysisEventsFacet copy = new FixAnalysisEventsFacet();
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 copy.set(this);
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 return copy;
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 }
b388d888330d Implemented facets and splitted up the event facet.Implemented facets and splitted up the event facet.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org