Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java @ 4693:a91d3bde7255
Change parameters of updateCollectionName
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 17 Dec 2012 16:15:05 +0100 |
parents | 9ea3ac23bd9d |
children | 7887112c37cc |
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 |
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
|
11 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
|
12 import de.intevation.flys.artifacts.WINFOArtifact; |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
13 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
|
14 |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
692
diff
changeset
|
15 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
|
16 import de.intevation.flys.artifacts.model.FacetTypes; |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
17 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
|
18 |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
19 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
|
20 import de.intevation.flys.artifacts.model.ReportFacet; |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
21 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
|
22 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
|
23 |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
24 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
|
25 |
1103
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1029
diff
changeset
|
26 import de.intevation.flys.utils.FLYSUtils; |
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1029
diff
changeset
|
27 |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
28 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * 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
|
31 * 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
|
32 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * @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
|
34 */ |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
35 public class DurationCurveState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
36 extends DefaultState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
37 implements FacetTypes |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
38 { |
1029
3f3988bb6284
Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
39 /** 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
|
40 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
|
41 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
383
diff
changeset
|
42 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
|
43 } |
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
|
44 |
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 @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
|
47 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
|
48 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
|
49 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
|
50 CallContext context, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
711
diff
changeset
|
51 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
|
52 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
|
53 ) { |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
54 if (artifact instanceof WINFOArtifact) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
55 WINFOArtifact winfo = (WINFOArtifact)artifact; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
56 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
57 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
|
58 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
59 if (old instanceof CalculationResult) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
60 res = (CalculationResult)old; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
61 } |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
62 else { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
63 res = winfo.getDurationCurveData(); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
64 } |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
65 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
66 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
|
67 |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
68 if (wqday != null && facets != null) { |
2718
9ea3ac23bd9d
Include km in duration curve facets names.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2178
diff
changeset
|
69 // 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
|
70 Object[] args = new Object[] { |
2718
9ea3ac23bd9d
Include km in duration curve facets names.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2178
diff
changeset
|
71 FLYSUtils.getRiver(winfo).getName(), |
9ea3ac23bd9d
Include km in duration curve facets names.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2178
diff
changeset
|
72 FLYSUtils.getLocations(winfo)[0] |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
73 }; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
74 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
75 String nameW = Resources.getMsg( |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
76 context.getMeta(), |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
77 "chart.duration.curve.curve.w", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
78 "", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
79 args); |
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 String nameQ = Resources.getMsg( |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
82 context.getMeta(), |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
83 "chart.duration.curve.curve.q", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
84 "", |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
85 args); |
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 Facet w = new DurationCurveFacet(DURATION_W, nameW); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
88 Facet q = new DurationCurveFacet(DURATION_Q, nameQ); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
89 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
90 facets.add(w); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
91 facets.add(q); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
92 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
93 facets.add(new DataFacet(CSV, "CSV data")); |
2178
1d7fb2cabfc7
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2134
diff
changeset
|
94 facets.add(new DataFacet(PDF, "PDF data")); |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
95 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
96 if (res.getReport().hasProblems()) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
97 facets.add(new ReportFacet()); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
98 } |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
99 } |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
100 |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
101 return res; |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
102 } |
2134
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
103 else if (artifact instanceof ChartArtifact) { |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
104 ChartArtifact chart = (ChartArtifact)artifact; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
105 facets.add(new EmptyFacet()); |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
106 return null; |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
107 } |
024d986b4f5b
'New Chart' for duration curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
108 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
|
109 } |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |