annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/ComputedDischargeCurveState.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
9 package org.dive4elements.river.artifacts.states;
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
10
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
11 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
12
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
13 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
14 import org.apache.logging.log4j.LogManager;
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
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
16 import org.dive4elements.artifacts.CallContext;
703
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
18 import org.dive4elements.artifactdatabase.state.Facet;
703
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
19
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
20 import org.dive4elements.river.artifacts.D4EArtifact;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
21 import org.dive4elements.river.artifacts.WINFOArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
22 import org.dive4elements.river.artifacts.ChartArtifact;
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
23
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
24 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
25 import org.dive4elements.river.artifacts.model.WaterlevelFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
26 import org.dive4elements.river.artifacts.model.DataFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
27 import org.dive4elements.river.artifacts.model.ReportFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
28 import org.dive4elements.river.artifacts.model.EmptyFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
29 import org.dive4elements.river.artifacts.model.WQKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
30 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
31
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
32 import org.dive4elements.river.artifacts.resources.Resources;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5634
diff changeset
33
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
34 import org.dive4elements.river.utils.RiverUtils;
703
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
35
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
36 /**
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 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
38 * 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
39 *
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 * @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
41 */
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
42 public class ComputedDischargeCurveState
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
43 extends DefaultState
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
44 implements FacetTypes
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
45 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
46 /** The log that is used in this state. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
47 private static Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
48 LogManager.getLogger(ComputedDischargeCurveState.class);
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
49
5633
5fb103635427 ComputedDischargeCurveState: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3265
diff changeset
50
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 392
diff changeset
51 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
52 }
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
53
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
54
3265
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
55 /**
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
56 * Get computed discharge curve data from cache (if available) or
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
57 * compute anew. Create Waterlevel and DataFacets.
c1f445b94d03 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2177
diff changeset
58 */
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
59 @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
60 public Object computeAdvance(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
61 D4EArtifact artifact,
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
62 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
63 CallContext context,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 731
diff changeset
64 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
65 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
66 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
67 log.debug("ComputedDischargeCurveState.computeAdvance");
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
68 if(artifact instanceof WINFOArtifact) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
69 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
70
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
71 CalculationResult res = old instanceof CalculationResult
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
72 ? (CalculationResult)old
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
73 : 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
74
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
75 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
76
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
77 if (facets != null && wqkms.length > 0) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
78 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
79
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
80 Object[] args = new Object[] {
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
81 RiverUtils.getRiver(winfo).getName(),
5634
b56422246f3a Fix issue697 (i18n).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5633
diff changeset
82 // Parse Double to allow i18n.
b56422246f3a Fix issue697 (i18n).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5633
diff changeset
83 Double.parseDouble(wqkms[i].getName())
2132
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 String name = Resources.getMsg(
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
87 context.getMeta(),
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
88 "chart.computed.discharge.curve.curve.label",
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
89 args);
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
90
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8436
diff changeset
91 facets.add(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8436
diff changeset
92 new WaterlevelFacet(i, COMPUTED_DISCHARGE_Q, name));
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
93 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
94 }
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
95
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
96 facets.add(new DataFacet(CSV, "CSV data"));
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2132
diff changeset
97 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
98
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
99 if (res.getReport().hasProblems()) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
100 facets.add(new ReportFacet());
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
101 }
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
102 }
711
69c8541edcc7 Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
103
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
104 return res;
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 703
diff changeset
105 }
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
106 else if(artifact instanceof ChartArtifact) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
107 ChartArtifact chart = (ChartArtifact)artifact;
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
108 facets.add(new EmptyFacet());
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
109 return null;
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
110 }
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1103
diff changeset
111 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
112 }
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
113 }
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
114 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org