Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java @ 4927:eb1cde786abf
HistoricalDischargeComputeState: Cosmetic.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 31 Jan 2013 11:21:37 +0100 |
parents | c1f445b94d03 |
children | 5fb103635427 |
rev | line source |
---|---|
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
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 |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
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; |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
13 import de.intevation.flys.artifacts.ChartArtifact; |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
14 |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
15 import de.intevation.flys.artifacts.model.FacetTypes; |
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.WaterlevelFacet; |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
17 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
|
18 import de.intevation.flys.artifacts.model.ReportFacet; |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
19 import de.intevation.flys.artifacts.model.EmptyFacet; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
20 import de.intevation.flys.artifacts.model.WQKms; |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
21 import de.intevation.flys.artifacts.model.CalculationResult; |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
22 |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
23 import de.intevation.flys.artifacts.resources.Resources; |
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
|
24 |
1103
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
25 import de.intevation.flys.utils.FLYSUtils; |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
26 |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 /** |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 * The final state that will be reached after the discharge curve calculation |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * mode has been chosen. |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 */ |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
33 public class ComputedDischargeCurveState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
34 extends DefaultState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
35 implements FacetTypes |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
36 { |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 /** The logger that is used in this state.*/ |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 private static Logger logger = |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 Logger.getLogger(ComputedDischargeCurveState.class); |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
392
diff
changeset
|
41 public ComputedDischargeCurveState() { |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 } |
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
|
43 |
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 |
3265
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2177
diff
changeset
|
45 /** |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2177
diff
changeset
|
46 * Get computed discharge curve data from cache (if available) or |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2177
diff
changeset
|
47 * compute anew. Create Waterlevel and DataFacets. |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2177
diff
changeset
|
48 */ |
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
|
49 @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
|
50 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
|
51 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
|
52 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
|
53 CallContext context, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
731
diff
changeset
|
54 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
|
55 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
|
56 ) { |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
57 logger.debug("ComputedDischargeCurveState.computeAdvance"); |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
58 if(artifact instanceof WINFOArtifact) { |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
59 WINFOArtifact winfo = (WINFOArtifact)artifact; |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
60 |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
61 CalculationResult res = old instanceof CalculationResult |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
62 ? (CalculationResult)old |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
63 : winfo.getComputedDischargeCurveData(); |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
64 |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
65 WQKms [] wqkms = (WQKms [])res.getData(); |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
66 |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
67 if (facets != null && wqkms.length > 0) { |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
68 for (int i = 0; i < wqkms.length; ++i) { |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
69 |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
70 Object[] args = new Object[] { |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
71 FLYSUtils.getRiver(winfo).getName(), |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
72 wqkms[i].getName() |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
73 }; |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
74 |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
75 String name = Resources.getMsg( |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
76 context.getMeta(), |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
77 "chart.computed.discharge.curve.curve.label", |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
78 "", |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
79 args); |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
80 |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
81 facets.add(new WaterlevelFacet(i, COMPUTED_DISCHARGE_Q, name)); |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
82 facets.add(new WaterlevelFacet(i, AT, "AT data")); |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
83 } |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
84 |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
85 facets.add(new DataFacet(CSV, "CSV data")); |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2132
diff
changeset
|
86 facets.add(new DataFacet(PDF, "PDF data")); |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
87 |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
88 if (res.getReport().hasProblems()) { |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
89 facets.add(new ReportFacet()); |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
90 } |
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
|
91 } |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
92 |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
93 return res; |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
94 } |
2132
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
95 else if(artifact instanceof ChartArtifact) { |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
96 ChartArtifact chart = (ChartArtifact)artifact; |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
97 facets.add(new EmptyFacet()); |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
98 return null; |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
99 } |
e8fc770d2f8c
'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1103
diff
changeset
|
100 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
|
101 } |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 } |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |