annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java @ 5633:5fb103635427

ComputedDischargeCurveState: Cosmetics.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 02 Apr 2013 10:28:14 +0200
parents c1f445b94d03
children b56422246f3a
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 {
5633
5fb103635427 ComputedDischargeCurveState: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3265
diff changeset
37 /** The logger that is used in this state. */
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
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
5633
5fb103635427 ComputedDischargeCurveState: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3265
diff changeset
41
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 392
diff changeset
42 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
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
3265
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
46 /**
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
47 * Get computed discharge curve data from cache (if available) or
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
48 * compute anew. Create Waterlevel and DataFacets.
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
49 */
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
50 @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
51 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
52 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
53 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
54 CallContext context,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 731
diff changeset
55 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
56 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
57 ) {
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
58 logger.debug("ComputedDischargeCurveState.computeAdvance");
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
59 if(artifact instanceof WINFOArtifact) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
60 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
61
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
62 CalculationResult res = old instanceof CalculationResult
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
63 ? (CalculationResult)old
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
64 : 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
65
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
66 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
67
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
68 if (facets != null && wqkms.length > 0) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
69 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
70
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
71 Object[] args = new Object[] {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
72 FLYSUtils.getRiver(winfo).getName(),
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
73 wqkms[i].getName()
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
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
76 String name = Resources.getMsg(
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
77 context.getMeta(),
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
78 "chart.computed.discharge.curve.curve.label",
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
79 "",
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
80 args);
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
81
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
82 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
83 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
84 }
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
85
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
86 facets.add(new DataFacet(CSV, "CSV data"));
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2132
diff changeset
87 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
88
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
89 if (res.getReport().hasProblems()) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
90 facets.add(new ReportFacet());
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
91 }
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
92 }
711
69c8541edcc7 Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
93
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
94 return res;
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 703
diff changeset
95 }
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
96 else if(artifact instanceof ChartArtifact) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
97 ChartArtifact chart = (ChartArtifact)artifact;
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
98 facets.add(new EmptyFacet());
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
99 return null;
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
100 }
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
101 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
102 }
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
103 }
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
104 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org