Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java @ 5567:42692d6868e6
Order Qs before Ds and values ascending
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Apr 2013 09:54:07 +0200 |
parents | 7887112c37cc |
children |
rev | line source |
---|---|
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
687
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
3 import java.util.List; |
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
4 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
8 |
687
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
9 import de.intevation.artifactdatabase.state.Facet; |
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
10 |
4848
7887112c37cc
DurationCurveState: Use RangeAccess.getLocations instead of FLYSUtils.getLocations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2718
diff
changeset
|
11 import de.intevation.flys.artifacts.access.RangeAccess; |
687
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
12 import de.intevation.flys.artifacts.FLYSArtifact; |
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
13 import de.intevation.flys.artifacts.WINFOArtifact; |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
14 import de.intevation.flys.artifacts.ChartArtifact; |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
15 |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
692
diff
changeset
|
16 import de.intevation.flys.artifacts.model.DurationCurveFacet; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
17 import de.intevation.flys.artifacts.model.FacetTypes; |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
18 import de.intevation.flys.artifacts.model.WQDay; |
687
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
19 |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
20 import de.intevation.flys.artifacts.model.DataFacet; |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
21 import de.intevation.flys.artifacts.model.ReportFacet; |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
22 import de.intevation.flys.artifacts.model.EmptyFacet; |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
23 import de.intevation.flys.artifacts.model.CalculationResult; |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
24 |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
25 import de.intevation.flys.artifacts.resources.Resources; |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
26 |
1103
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1029
diff
changeset
|
27 import de.intevation.flys.utils.FLYSUtils; |
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1029
diff
changeset
|
28 |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
29 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 /** |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 * The final state that will be reached after the duration curve calculation |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 * mode has been chosen. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 */ |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
36 public class DurationCurveState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
37 extends DefaultState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
38 implements FacetTypes |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
39 { |
1029
3f3988bb6284
Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
40 /** The logger that is used in this state. */ |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 private static Logger logger = Logger.getLogger(DurationCurveState.class); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
383
diff
changeset
|
43 public DurationCurveState() { |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 } |
687
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
45 |
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
46 |
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
47 @Override |
697
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
48 public Object computeAdvance( |
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
49 FLYSArtifact artifact, |
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
50 String hash, |
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
51 CallContext context, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
711
diff
changeset
|
52 List<Facet> facets, |
697
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
53 Object old |
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
54 ) { |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
55 if (artifact instanceof WINFOArtifact) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
56 WINFOArtifact winfo = (WINFOArtifact)artifact; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
57 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
58 CalculationResult res; |
697
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
59 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
60 if (old instanceof CalculationResult) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
61 res = (CalculationResult)old; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
62 } |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
63 else { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
64 res = winfo.getDurationCurveData(); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
65 } |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
66 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
67 WQDay wqday = (WQDay)res.getData(); |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
68 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
69 if (wqday != null && facets != null) { |
4848
7887112c37cc
DurationCurveState: Use RangeAccess.getLocations instead of FLYSUtils.getLocations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2718
diff
changeset
|
70 RangeAccess rangeAccess = new RangeAccess(winfo, context); |
2718
9ea3ac23bd9d
Include km in duration curve facets names.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2178
diff
changeset
|
71 // Create an i18ed name for a (w or q) duration curve facet. |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
72 Object[] args = new Object[] { |
2718
9ea3ac23bd9d
Include km in duration curve facets names.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2178
diff
changeset
|
73 FLYSUtils.getRiver(winfo).getName(), |
4848
7887112c37cc
DurationCurveState: Use RangeAccess.getLocations instead of FLYSUtils.getLocations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2718
diff
changeset
|
74 rangeAccess.getLocations()[0] |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
75 }; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
76 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
77 String nameW = Resources.getMsg( |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
78 context.getMeta(), |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
79 "chart.duration.curve.curve.w", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
80 "", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
81 args); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
82 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
83 String nameQ = Resources.getMsg( |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
84 context.getMeta(), |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
85 "chart.duration.curve.curve.q", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
86 "", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
87 args); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
88 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
89 Facet w = new DurationCurveFacet(DURATION_W, nameW); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
90 Facet q = new DurationCurveFacet(DURATION_Q, nameQ); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
91 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
92 facets.add(w); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
93 facets.add(q); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
94 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
95 facets.add(new DataFacet(CSV, "CSV data")); |
2178
1d7fb2cabfc7
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2134
diff
changeset
|
96 facets.add(new DataFacet(PDF, "PDF data")); |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
97 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
98 if (res.getReport().hasProblems()) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
99 facets.add(new ReportFacet()); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
100 } |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
101 } |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
102 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
103 return res; |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
104 } |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
105 else if (artifact instanceof ChartArtifact) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
106 ChartArtifact chart = (ChartArtifact)artifact; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
107 facets.add(new EmptyFacet()); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
108 return null; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
109 } |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
110 return null; |
687
06689035024c
Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
111 } |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |