annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java @ 3095:6ea299c208cd

Themes for fixing curves and debug output flys-artifacts/trunk@4694 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Mon, 18 Jun 2012 14:37:10 +0000
parents 960307cf2adc
children 1b9f791937c3
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();
3095
6ea299c208cd Themes for fixing curves and debug output
Christian Lins <christian.lins@intevation.de>
parents: 3088
diff changeset
72 double currentKm =
3088
960307cf2adc Moved current km to context and added an abstract generator for fix analysis
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3080
diff changeset
73 ((Double)context.getContextValue("currentKm")).doubleValue();
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
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();
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3062
diff changeset
76 KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry =
3080
dc2765e31e1f Added getData method with an additional km parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3076
diff changeset
77 kmPeriods.binarySearch(currentKm);
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) {
3095
6ea299c208cd Themes for fixing curves and debug output
Christian Lins <christian.lins@intevation.de>
parents: 3088
diff changeset
80 logger.debug("getData: kmPeriodsEntry == null");
3062
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
81 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
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
7660cfe5e8f6 FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents: 3043
diff changeset
84 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
85 if (periods == null) {
3095
6ea299c208cd Themes for fixing curves and debug output
Christian Lins <christian.lins@intevation.de>
parents: 3088
diff changeset
86 logger.debug("getData: periods == 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
87 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
88 }
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 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
90 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
91 }
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 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
93 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
94 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
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
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 /**
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 * 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
101 * @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
102 */
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 @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
104 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
105 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
106 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
107 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
108 }
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
109 }
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
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org