Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 1127:6b9877a9f6c1
Added infrastructure to start WSPLGEN calculations - the FloodMapState already start such calculations.
flys-artifacts/trunk@2639 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 02 Sep 2011 13:12:05 +0000 |
parents | 111794adf285 |
children | d90f5bfa3ddf |
rev | line source |
---|---|
688
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifactdatabase.state.Facet; |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.FLYSArtifact; |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.artifacts.WINFOArtifact; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
13 import de.intevation.flys.artifacts.model.FacetTypes; |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
14 import de.intevation.flys.artifacts.model.ReportFacet; |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
15 import de.intevation.flys.artifacts.model.WaterlevelFacet; |
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.WQKms; |
688
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
18 import de.intevation.flys.artifacts.model.DataFacet; |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1111
diff
changeset
|
19 import de.intevation.flys.artifacts.model.CrossSectionFacet; |
1122
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1116
diff
changeset
|
20 import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; |
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; |
1111
b96ce07ba56c
Added dummy sceleton for Cross Sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1051
diff
changeset
|
22 import de.intevation.artifactdatabase.state.DefaultFacet; |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
23 |
688
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
25 public class WaterlevelState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
26 extends DefaultState |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
27 implements FacetTypes |
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
28 { |
1111
b96ce07ba56c
Added dummy sceleton for Cross Sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1051
diff
changeset
|
29 /** The logger that is used in this state. */ |
688
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 private static Logger logger = Logger.getLogger(WaterlevelState.class); |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 @Override |
927
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
34 protected String getUIProvider() { |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
35 return "continue"; |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
36 } |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
37 |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
38 |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
39 @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
|
40 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
|
41 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
|
42 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
|
43 CallContext context, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
711
diff
changeset
|
44 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
|
45 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
|
46 ) { |
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 WINFOArtifact winfo = (WINFOArtifact)artifact; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
48 |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
49 String id = getID(); |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
50 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
51 CalculationResult res = old instanceof CalculationResult |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
52 ? (CalculationResult)old |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
53 : winfo.getWaterlevelData(); |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
54 |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
55 if (facets == null) { |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
56 return res; |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
57 } |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
703
diff
changeset
|
58 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
59 WQKms [] wqkms = (WQKms [])res.getData(); |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
60 |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
61 for (int i = 0; i < wqkms.length; i++) { |
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 nameW = null; |
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 String nameQ = null; |
692
22e4bffbe240
Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
64 |
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 if (winfo.isQ()) { |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
66 nameQ = wqkms[i].getName(); |
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
|
67 nameW = "W(" + nameQ + ")"; |
688
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 } |
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
|
69 else { |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
70 nameW = wqkms[i].getName(); |
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
|
71 nameQ = "Q(" + nameQ + ")"; |
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
|
72 } |
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
|
73 |
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
|
74 logger.debug("Create facet: " + nameW); |
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
|
75 logger.debug("Create facet: " + nameQ); |
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
|
76 |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
77 Facet w = new WaterlevelFacet( |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
78 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash); |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
79 Facet q = new WaterlevelFacet( |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
80 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash); |
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
|
81 |
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
|
82 facets.add(w); |
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
|
83 facets.add(q); |
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
|
84 } |
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
|
85 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
86 if (wqkms.length > 0) { |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
87 Facet wst = new DataFacet( |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
88 WST, "WST data", ComputeType.ADVANCE, hash, id); |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
89 Facet csv = new DataFacet( |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
90 CSV, "CSV data", ComputeType.ADVANCE, hash, id); |
703
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
91 |
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
92 facets.add(wst); |
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
93 facets.add(csv); |
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
94 } |
af3b5d9e91a4
Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
95 |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
96 if (res.getReport().hasProblems()) { |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
929
diff
changeset
|
97 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); |
711
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
98 } |
69c8541edcc7
Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
99 |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1111
diff
changeset
|
100 // Also register the CrossSectionFacet (added to respective out). |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1111
diff
changeset
|
101 facets.add(new CrossSectionFacet("facet.cross_section")); |
1122
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1116
diff
changeset
|
102 facets.add(new CrossSectionWaterLineFacet("facet.cross_section_water_line")); |
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
|
103 return res; |
688
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 } |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 } |
dc3613c4daf6
Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |