annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 1116:05e4ef0f9489

Improved stub for CrossSections (including Factory and Facet). flys-artifacts/trunk@2623 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 31 Aug 2011 12:23:05 +0000
parents b96ce07ba56c
children 111794adf285
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;
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
20 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
21 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
22
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
24 public class WaterlevelState
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
25 extends DefaultState
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
26 implements FacetTypes
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
27 {
1111
b96ce07ba56c Added dummy sceleton for Cross Sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1051
diff changeset
28 /** 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
29 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
30
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 @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
33 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
34 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
35 }
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 @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
39 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
40 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
41 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
42 CallContext context,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 711
diff changeset
43 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
44 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
45 ) {
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 WINFOArtifact winfo = (WINFOArtifact)artifact;
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
47
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
48 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
49
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
50 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
51 ? (CalculationResult)old
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
52 : winfo.getWaterlevelData();
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
53
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 703
diff changeset
54 if (facets == null) {
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 703
diff changeset
55 return res;
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 703
diff changeset
56 }
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 703
diff changeset
57
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
58 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
59
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
60 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
61 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
62 String nameQ = null;
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
63
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
64 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
65 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
66 nameW = "W(" + nameQ + ")";
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 }
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
68 else {
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
69 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
70 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
71 }
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 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
74 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
75
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
76 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
77 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
78 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
79 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
80
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 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
82 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
83 }
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
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
85 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
86 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
87 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
88 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
89 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
90
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
91 facets.add(wst);
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
92 facets.add(csv);
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
93 }
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
94
711
69c8541edcc7 Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
95 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
96 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
97 }
69c8541edcc7 Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
98
1116
05e4ef0f9489 Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1111
diff changeset
99 // 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
100 facets.add(new CrossSectionFacet("facet.cross_section"));
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
101 return res;
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 }
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 }
dc3613c4daf6 Moved Waterlevel state into the correct package.
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