Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 950:22bc87a42a0d
First step to factor out the "Datenkorb" logic into a service independent singleton.
flys-artifacts/trunk@2367 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 09:56:39 +0000 |
parents | c256061287d7 |
children | 7399401f728c |
rev | line source |
---|---|
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
3 import java.util.Arrays; |
637
f0c1250d1e7b
Make "Berechnungsart 4" work independent of flow direction. Commented out back jump correction temporarily.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
635
diff
changeset
|
4 import java.util.ArrayList; |
623
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
5 import java.util.Collection; |
650
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
6 import java.util.Collections; |
691
2600aa2c7319
Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
690
diff
changeset
|
7 import java.util.HashMap; |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
8 import java.util.HashSet; |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
9 import java.util.TreeMap; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import java.util.List; |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
11 import java.util.Map; |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
12 import java.util.Set; |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
13 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
14 import javax.xml.xpath.XPathConstants; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
16 import gnu.trove.TDoubleArrayList; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
17 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
18 import net.sf.ehcache.Cache; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
19 |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import org.w3c.dom.Document; |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
23 import org.w3c.dom.Element; |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
24 import org.w3c.dom.NodeList; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
940
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
26 import de.intevation.artifacts.Artifact; |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
27 import de.intevation.artifacts.ArtifactDatabase; |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
28 import de.intevation.artifacts.ArtifactDatabaseException; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.artifacts.ArtifactFactory; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.artifacts.CallContext; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.artifacts.common.utils.XMLUtils; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
940
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
35 import de.intevation.artifactdatabase.ArtifactDatabaseImpl; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 import de.intevation.artifactdatabase.DefaultArtifact; |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
37 import de.intevation.artifactdatabase.data.DefaultStateData; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 import de.intevation.artifactdatabase.data.StateData; |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
39 import de.intevation.artifactdatabase.state.DefaultOutput; |
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:
686
diff
changeset
|
40 import de.intevation.artifactdatabase.state.Facet; |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
41 import de.intevation.artifactdatabase.state.Output; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 import de.intevation.artifactdatabase.state.State; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 import de.intevation.artifactdatabase.state.StateEngine; |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
44 import de.intevation.artifactdatabase.transition.TransitionEngine; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
46 import de.intevation.flys.utils.DoubleUtil; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
47 |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
48 import de.intevation.flys.model.Gauge; |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
49 import de.intevation.flys.model.River; |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
50 |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 import de.intevation.flys.artifacts.context.FLYSContext; |
650
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
52 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
53 import de.intevation.flys.artifacts.cache.CacheFactory; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
54 |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
55 import de.intevation.flys.artifacts.model.DischargeTables; |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
56 import de.intevation.flys.artifacts.model.RiverFactory; |
650
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
57 import de.intevation.flys.artifacts.model.Segment; |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
58 |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
321
diff
changeset
|
59 import de.intevation.flys.artifacts.states.DefaultState; |
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 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
61 import de.intevation.flys.artifacts.states.LocationDistanceSelect; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 /** |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 * The defaul FLYS artifact. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 public abstract class FLYSArtifact extends DefaultArtifact { |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 /** The logger that is used in this artifact.*/ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 private static Logger logger = Logger.getLogger(FLYSArtifact.class); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
75 public static final String COMPUTING_CACHE = "computed.values"; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
76 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
77 /** The XPath that points to the input data elements of the FEED document.*/ |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
78 public static final String XPATH_FEED_INPUT = |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
79 "/art:action/art:data/art:input"; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
81 /** The XPath that points to the name of the target state of ADVANCE.*/ |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
82 public static final String XPATH_ADVANCE_TARGET = |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
83 "/art:action/art:target/@art:name"; |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
84 |
940
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
85 public static final String XPATH_MODEL_ARTIFACT = |
941
1b509e4cf99b
Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
940
diff
changeset
|
86 "/art:action/art:template/@uuid"; |
940
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
87 |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
88 /** The constant string that shows that an operation was successful.*/ |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
89 public static final String OPERATION_SUCCESSFUL = "SUCCESS"; |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
90 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
91 /** The constant string that shows that an operation failed.*/ |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
92 public static final String OPERATION_FAILED = "FAILURE"; |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
93 |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
94 /** The default number of steps between the start end end of a selected Q |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
95 * range.*/ |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
96 public static final int DEFAULT_Q_STEPS = 30; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
97 |
398
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
98 /** The default step width between the start end end kilometer.*/ |
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
99 public static final double DEFAULT_KM_STEPS = 0.1; |
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
100 |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 /** The identifier of the current state. */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 protected String currentStateId; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
105 /** The identifiers of previous states on a stack.*/ |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
106 protected List<String> previousStateIds; |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
107 |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 /** The name of the artifact.*/ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 protected String name; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
111 /** The data that have been inserted into this artifact.*/ |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
112 protected Map<String, StateData> data; |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
113 |
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:
686
diff
changeset
|
114 /** The list of facets supported by this artifact.*/ |
691
2600aa2c7319
Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
690
diff
changeset
|
115 protected Map<String, List<Facet>> facets; |
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:
686
diff
changeset
|
116 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
117 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
118 /** |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
119 * The default constructor that creates an empty FLYSArtifact. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
120 */ |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
121 public FLYSArtifact() { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
122 data = new TreeMap<String, StateData>(); |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
123 previousStateIds = new ArrayList<String>(); |
691
2600aa2c7319
Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
690
diff
changeset
|
124 facets = new HashMap<String, List<Facet>>(); |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
125 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
126 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
127 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
128 /** |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
129 * Returns the name of the concrete artifact. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
130 * |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
131 * @return the name of the concrete artifact. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
132 */ |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
133 public abstract String getName(); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
134 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
135 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
136 /** |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
137 * Returns the FLYSContext from context object. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
138 * |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
139 * @param context The CallContext or the FLYSContext. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
140 * |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
141 * @return the FLYSContext. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
142 */ |
706
ddd8b37d5cd3
Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
143 protected static FLYSContext getFlysContext(Object context) { |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
144 return context instanceof FLYSContext |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
145 ? (FLYSContext) context |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
146 : (FLYSContext) ((CallContext) context).globalContext(); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
147 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
148 |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 /** |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 * Initialize the artifact and insert new data if <code>data</code> contains |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 * information necessary for this artifact. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 * @param identifier The UUID. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 * @param factory The factory that is used to create this artifact. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 * @param context The CallContext. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 * @param data Some optional data. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 @Override |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 public void setup( |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 String identifier, |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 ArtifactFactory factory, |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 Object context, |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 Document data) |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 { |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 logger.debug("Setup this artifact with the uuid: " + identifier); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 super.setup(identifier, factory, context, data); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 FLYSContext flysContext = (FLYSContext) context; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 StateEngine engine = (StateEngine) flysContext.get( |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 FLYSContext.STATE_ENGINE_KEY); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
174 String name = getName(); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
175 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
176 logger.debug("Set initial state for artifact '" + name + "'"); |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 List<State> states = engine.getStates(name); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 setCurrentState(states.get(0)); |
940
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
180 |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
181 String model = XMLUtils.xpathString( |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
182 data, |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
183 XPATH_MODEL_ARTIFACT, |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
184 ArtifactNamespaceContext.INSTANCE); |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
185 |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
186 if (model != null && model.length() > 0) { |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
187 ArtifactDatabase db = (ArtifactDatabase) flysContext.get( |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
188 ArtifactDatabaseImpl.GLOBAL_CONTEXT_KEY); |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
189 |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
190 try { |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
191 initialize(db.getRawArtifact(model), context); |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
192 } |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
193 catch (ArtifactDatabaseException adbe) { |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
194 logger.error(adbe, adbe); |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
195 } |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
196 } |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
197 } |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
198 |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
199 |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
200 protected void initialize(Artifact artifact, Object context) { |
f4439e015278
Append artifact recommendations to the artifact's describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
201 // do nothing here |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 /** |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 * Insert new data included in <code>input</code> into the current state. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 * @param target XML document that contains new data. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 * @param context The CallContext. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 * @return a document that contains a SUCCESS or FAILURE message. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 @Override |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 public Document feed(Document target, CallContext context) { |
123
ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
122
diff
changeset
|
215 logger.info("FLYSArtifact.feed()"); |
ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
122
diff
changeset
|
216 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
217 Document doc = XMLUtils.newDocument(); |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
219 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
220 doc, |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
221 ArtifactNamespaceContext.NAMESPACE_URI, |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
222 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
224 Element result = creator.create("result"); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
225 doc.appendChild(result); |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
227 try { |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
321
diff
changeset
|
228 saveData(target, XPATH_FEED_INPUT, context); |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
229 |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
230 compute(context, ComputeType.FEED, true); |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
231 |
123
ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
122
diff
changeset
|
232 return describe(target, context); |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
233 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
234 catch (IllegalArgumentException iae) { |
658
ed7c901ee712
If Artifact.feed() fails do not store invalid values in database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
655
diff
changeset
|
235 // do not store state if validation fails. |
ed7c901ee712
If Artifact.feed() fails do not store invalid values in database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
655
diff
changeset
|
236 context.afterCall(CallContext.NOTHING); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
237 creator.addAttr(result, "type", OPERATION_FAILED, true); |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
238 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
239 result.setTextContent(iae.getMessage()); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
240 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
241 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
242 return doc; |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
244 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
245 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 /** |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
247 * This method handles request for changing the current state of an |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
248 * artifact. It is possible to step forward or backward. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
249 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
250 * @param target The incoming ADVANCE document. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
251 * @param context The CallContext. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
252 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
253 * @return a document that contains a SUCCESS or FAILURE message. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
254 */ |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
255 public Document advance(Document target, CallContext context) { |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
256 Document doc = XMLUtils.newDocument(); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
257 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
258 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
259 doc, |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
260 ArtifactNamespaceContext.NAMESPACE_URI, |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
261 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
262 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
263 Element result = ec.create("result"); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
264 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
265 String targetState = XMLUtils.xpathString( |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
266 target, XPATH_ADVANCE_TARGET, ArtifactNamespaceContext.INSTANCE); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
267 |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
268 logger.info("FLYSArtifact.advance() to '" + targetState + "'"); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
269 |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
270 if (isStateReachable(targetState, context)) { |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
271 logger.info("Advance: Step forward"); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
272 |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
273 List<String> prev = getPreviousStateIds(); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
274 prev.add(getCurrentStateId()); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
275 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
276 setCurrentStateId(targetState); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
277 |
693
af393c5eb2c8
Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
692
diff
changeset
|
278 logger.debug("Compute data for state: " + targetState); |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
279 compute(context, ComputeType.ADVANCE, true); |
693
af393c5eb2c8
Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
692
diff
changeset
|
280 |
123
ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
122
diff
changeset
|
281 return describe(target, context); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
282 } |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
283 else if (isPreviousState(targetState, context)) { |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
284 logger.info("Advance: Step back to"); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
285 |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
286 List<String> prevs = getPreviousStateIds(); |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
287 int targetIdx = prevs.indexOf(targetState); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
288 int start = prevs.size() - 1; |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
289 |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
290 for (int i = start; i >= targetIdx; i--) { |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
291 String prev = prevs.get(i); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
292 logger.debug("Remove state id '" + prev + "'"); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
293 prevs.remove(prev); |
691
2600aa2c7319
Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
690
diff
changeset
|
294 facets.remove(prev); |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
295 } |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
296 |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
297 setCurrentStateId(targetState); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
298 |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
299 return describe(target, context); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
300 } |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
301 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
302 logger.warn("Advance: Cannot advance to '" + targetState + "'"); |
123
ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
122
diff
changeset
|
303 ec.addAttr(result, "type", OPERATION_FAILED, true); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
304 |
123
ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
122
diff
changeset
|
305 doc.appendChild(result); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
306 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
307 return doc; |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
308 } |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
309 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
310 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
311 /** |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
312 * Returns the identifier of the current state. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
313 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
314 * @return the identifier of the current state. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
315 */ |
722
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
316 public String getCurrentStateId() { |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
317 return currentStateId; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
318 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
319 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
320 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
321 /** |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
322 * Sets the identifier of the current state. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
323 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
324 * @param id the identifier of a state. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
325 */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
326 protected void setCurrentStateId(String id) { |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
327 currentStateId = id; |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
328 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
329 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
330 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
331 /** |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
332 * Set the current state of this artifact. <b>NOTE</b>We don't store the |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
333 * State object itself - which is not necessary - but its identifier. So |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
334 * this method will just call the setCurrentStateId() method with the |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
335 * identifier of <i>state</i>. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
336 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
337 * @param state The new current state. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
338 */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
339 protected void setCurrentState(State state) { |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
340 setCurrentStateId(state.getID()); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
341 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
342 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
343 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
344 /** |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
345 * Returns the current state of the artifact. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
346 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
347 * @return the current State of the artifact. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
348 */ |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
349 protected State getCurrentState(Object context) { |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
350 FLYSContext flysContext = getFlysContext(context); |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
351 StateEngine engine = (StateEngine) flysContext.get( |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
352 FLYSContext.STATE_ENGINE_KEY); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
353 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
354 return engine.getState(getCurrentStateId()); |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
355 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
356 |
722
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
357 protected State getState(Object context, String stateID) { |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
358 FLYSContext flysContext = getFlysContext(context); |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
359 StateEngine engine = (StateEngine) flysContext.get( |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
360 FLYSContext.STATE_ENGINE_KEY); |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
361 return engine.getState(stateID); |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
362 } |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
363 |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
364 |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
365 /** |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
366 * Returns the vector of previous state identifiers. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
367 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
368 * @return the vector of previous state identifiers. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
369 */ |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
370 protected List<String> getPreviousStateIds() { |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
371 return previousStateIds; |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
372 } |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
373 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
374 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
375 /** |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
376 * Adds a new StateData item to the data pool of this artifact. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
377 * |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
378 * @param name the name of the data object. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
379 * @param data the data object itself. |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
380 */ |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
381 protected void addData(String name, StateData data) { |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
382 this.data.put(name, data); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
383 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
384 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
385 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
386 /** |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
387 * This method returns a specific StateData object that is stored in the |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
388 * data pool of this artifact. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
389 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
390 * @param name The name of the data object. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
391 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
392 * @return the StateData object if existing, otherwise null. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
393 */ |
298
fc694a43a7e5
Changed the visibility of getData() method of FLYSArtifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
140
diff
changeset
|
394 public StateData getData(String name) { |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
395 return data.get(name); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
396 } |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
397 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
398 |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
399 public String getDataAsString(String name) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
400 StateData data = getData(name); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
401 return data != null ? (String) data.getValue() : null; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
402 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
403 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
404 |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
405 public Facet getNativeFacet(Facet facet) { |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
406 String name = facet.getName(); |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
407 int index = facet.getIndex(); |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
408 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
409 for (Map.Entry<String, List<Facet>> entry: facets.entrySet()) { |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
410 for (Facet f: entry.getValue()) { |
699
3c70aa595724
mico opt: inter cmps are faster than str cmps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
698
diff
changeset
|
411 if (f.getIndex() == index && f.getName().equals(name)) { |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
412 return f; |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
413 } |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
414 } |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
415 } |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
416 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
417 logger.warn("Could not find facet: " + name + " at " + index); |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
418 return null; |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
419 } |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
420 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
693
diff
changeset
|
421 |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
422 /** |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
423 * This method stores the data that is contained in the FEED document. |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
424 * |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
425 * @param feed The FEED document. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
426 * @param xpath The XPath that points to the data nodes. |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
427 */ |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
321
diff
changeset
|
428 public void saveData(Document feed, String xpath, CallContext context) |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
429 throws IllegalArgumentException |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
430 { |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
431 if (feed == null || xpath == null || xpath.length() == 0) { |
325
7a0907742cc0
Changed the error key that is written to the result document of the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
432 throw new IllegalArgumentException("error_feed_no_data"); |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
433 } |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
434 |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
435 NodeList nodes = (NodeList) XMLUtils.xpath( |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
436 feed, |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
437 xpath, |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
438 XPathConstants.NODESET, |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
439 ArtifactNamespaceContext.INSTANCE); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
440 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
441 if (nodes == null || nodes.getLength() == 0) { |
325
7a0907742cc0
Changed the error key that is written to the result document of the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
442 throw new IllegalArgumentException("error_feed_no_data"); |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
443 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
444 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
445 int count = nodes.getLength(); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
446 logger.debug("Try to save " + count + " data items."); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
447 |
708
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
448 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
449 |
708
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
450 for (int i = 0; i < count; i++) { |
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
451 Element node = (Element)nodes.item(i); |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
452 |
708
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
453 String name = node.getAttributeNS(uri, "name"); |
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
454 String value = node.getAttributeNS(uri, "value"); |
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
455 |
757ff56b43b3
Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
707
diff
changeset
|
456 if (name.length() > 0 && value.length() > 0) { |
121
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
457 logger.debug("Save data item for '" + name + "' : " + value); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
458 |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
459 addData(name, new DefaultStateData(name, null, null, value)); |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
460 } |
e0ded17a4846
Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
119
diff
changeset
|
461 } |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
321
diff
changeset
|
462 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
463 DefaultState current = (DefaultState) getCurrentState(context); |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
464 current.validate(this, context); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
465 } |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
466 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
467 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
468 /** |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
469 * Determines if the state with the identifier <i>stateId</i> is reachable |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
470 * from the current state. The determination itself takes place in the |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
471 * TransitionEngine. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
472 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
473 * @param stateId The identifier of a state. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
474 * @param context The context object. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
475 * |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
476 * @return true, if the state specified by <i>stateId</i> is reacahble, |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
477 * otherwise false. |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
478 */ |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
479 protected boolean isStateReachable(String stateId, Object context) { |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
480 logger.debug("Determine if the state '" + stateId + "' is reachable."); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
481 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
482 FLYSContext flysContext = getFlysContext(context); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
483 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
484 State currentState = getCurrentState(context); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
485 StateEngine sEngine = (StateEngine) flysContext.get( |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
486 FLYSContext.STATE_ENGINE_KEY); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
487 |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
488 TransitionEngine tEngine = (TransitionEngine) flysContext.get( |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
489 FLYSContext.TRANSITION_ENGINE_KEY); |
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
490 |
355
d97982627596
Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
325
diff
changeset
|
491 return tEngine.isStateReachable(this, stateId, currentState, sEngine); |
122
d3b8b0b1d010
Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
121
diff
changeset
|
492 } |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
493 |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
494 |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
495 /** |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
496 * Determines if the state with the identifier <i>stateId</i> is a previous |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
497 * state of the current state. |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
498 * |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
499 * @param stateId The target state identifier. |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
500 * @param context The context object. |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
501 */ |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
502 protected boolean isPreviousState(String stateId, Object context) { |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
503 logger.debug("Determine if the state '" + stateId + "' is old."); |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
504 |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
505 List<String> prevs = getPreviousStateIds(); |
140
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
506 if (prevs.contains(stateId)) { |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
507 return true; |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
508 } |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
509 |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
510 return false; |
43f03f6047b9
Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
123
diff
changeset
|
511 } |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
512 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
513 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
514 /** |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
515 * Returns the selected River object based on the 'river' data that might |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
516 * have been inserted by the user. |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
517 * |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
518 * @return the selected River or null if no river has been chosen yet. |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
519 */ |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
520 public River getRiver() { |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
521 StateData dRiver = getData("river"); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
522 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
523 return dRiver != null |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
524 ? RiverFactory.getRiver((String) dRiver.getValue()) |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
525 : null; |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
526 } |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
527 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
528 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
529 /** |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
530 * Returns the selected distance of points. |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
531 * |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
532 * @return the selected distance or points. |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
533 */ |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
534 public double[] getDistance() { |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
535 StateData dMode = getData("ld_mode"); |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
536 StateData dFrom = getData("ld_from"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
537 StateData dTo = getData("ld_to"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
538 StateData dLocations = getData("ld_locations"); |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
539 |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
540 if (dMode != null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
541 String mode = (String)dMode.getValue(); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
542 if ("location".equals(mode)) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
543 double[] locations = getLocations(); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
544 return new double[] { locations[0], locations[locations.length-1] }; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
545 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
546 if (dFrom != null && dTo != null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
547 return getDistanceByRange(dFrom, dTo); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
548 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
549 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
550 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
551 if (dLocations != null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
552 double[] locations = getLocations(); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
553 return new double[] { locations[0], locations[locations.length-1] }; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
554 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
555 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
556 if (dFrom != null && dTo != null) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
557 return getDistanceByRange(dFrom, dTo); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
558 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
559 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
560 logger.warn("No data found for distance determination!"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
561 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
562 return null; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
563 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
564 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
565 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
566 /** |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
567 * Determines the selected mode of distance/range input. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
568 * |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
569 * @return true, if the range mode is selected otherwise false. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
570 */ |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
571 public boolean isRange() { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
572 StateData mode = getData("ld_mode"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
573 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
574 if (mode == null) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
575 logger.warn("No mode location/range chosen. Defaults to range."); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
576 return true; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
577 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
578 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
579 String value = (String) mode.getValue(); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
580 |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
581 return value.equals("distance"); |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
582 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
583 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
584 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
585 /** |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
586 * Returns the selected locations based on a given array of locations. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
587 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
588 * @param locations The StateData that contains the locations. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
589 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
590 * @return the selected locations. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
591 */ |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
592 public double[] getLocations() { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
593 StateData dLocations = getData("ld_locations"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
594 String locationStr = dLocations != null |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
595 ? (String) dLocations.getValue() |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
596 : ""; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
597 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
598 if (locationStr == null || locationStr.length() == 0) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
599 logger.warn("No valid location string found!"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
600 return null; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
601 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
602 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
603 String[] tmp = locationStr.split(" "); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
604 TDoubleArrayList locations = new TDoubleArrayList(); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
605 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
606 for (String l: tmp) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
607 try { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
608 locations.add(Double.parseDouble(l)); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
609 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
610 catch (NumberFormatException nfe) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
611 logger.warn(nfe, nfe); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
612 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
613 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
614 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
615 locations.sort(); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
616 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
617 return locations.toNativeArray(); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
618 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
619 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
620 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
621 /** |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
622 * Returns the selected distance based on a given range (from, to). |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
623 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
624 * @param dFrom The StateData that contains the lower value. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
625 * @param dTo The StateData that contains the upper value. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
626 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
627 * @return the selected distance. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
628 */ |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
629 protected double[] getDistanceByRange(StateData dFrom, StateData dTo) { |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
630 double from = Double.parseDouble((String) dFrom.getValue()); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
631 double to = Double.parseDouble((String) dTo.getValue()); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
632 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
633 return new double[] { from, to }; |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
634 } |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
635 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
636 |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
637 /** |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
638 * Returns the selected Kms. |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
639 * |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
640 * @param distance An 2dim array with [lower, upper] values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
641 * |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
642 * @return the selected Kms. |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
643 */ |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
644 public double[] getKms(double[] distance) { |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
645 StateData dStep = getData("ld_step"); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
646 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
647 if (dStep == null) { |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
648 logger.warn("No step width given. Cannot compute Kms."); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
649 return null; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
650 } |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
651 |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
652 double step = Double.parseDouble((String) dStep.getValue()); |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
653 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
654 // transform step from 'm' into 'km' |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
655 step = step / 1000; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
656 |
398
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
657 if (step == 0d) { |
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
658 step = DEFAULT_KM_STEPS; |
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
659 } |
435058da0eae
Use a default step width (100m) between two kilometers if no width is given.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
660 |
707
b6f57d927905
Removed more dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
706
diff
changeset
|
661 return DoubleUtil.explode(distance[0], distance[1], step); |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
662 } |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
663 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
664 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
665 /** |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
666 * Returns the selected Kms. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
667 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
668 * @return the selected kms. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
669 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
670 public double[] getKms() { |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
671 if (isRange()) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
672 double[] distance = getDistance(); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
673 return getKms(distance); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
674 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
675 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
676 else { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
677 return LocationDistanceSelect.getLocations(this); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
678 } |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
679 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
680 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
681 public double [] getFromToStep() { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
682 if (!isRange()) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
683 return null; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
684 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
685 double [] fromTo = getDistance(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
686 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
687 if (fromTo == null) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
688 return null; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
689 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
690 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
691 StateData dStep = getData("ld_step"); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
692 if (dStep == null) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
693 return null; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
694 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
695 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
696 double [] result = new double[3]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
697 result[0] = fromTo[0]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
698 result[1] = fromTo[1]; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
699 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
700 try { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
701 String step = (String)dStep.getValue(); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
702 result[2] = DoubleUtil.round(Double.parseDouble(step) / 1000d); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
703 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
704 catch (NumberFormatException nfe) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
705 return null; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
706 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
707 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
708 return result; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
709 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
650
diff
changeset
|
710 |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
711 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
712 /** |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
713 * Returns the gauge based on the current distance and river. |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
714 * |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
715 * @return the gauge. |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
716 */ |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
717 public Gauge getGauge() { |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
718 River river = getRiver(); |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
719 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
720 if (river == null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
721 logger.debug("no river found"); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
722 return null; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
723 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
724 |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
725 double[] dist = getDistance(); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
726 |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
727 if (dist == null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
728 logger.debug("no range found"); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
729 return null; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
730 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
731 |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
732 if (logger.isDebugEnabled()) { |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
733 logger.debug("Determine gauge for:"); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
734 logger.debug("... river: " + river.getName()); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
735 logger.debug("... distance: " + dist[0] + " - " + dist[1]); |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
736 } |
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
737 |
320
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
317
diff
changeset
|
738 Gauge gauge = river.determineGauge(dist[0], dist[1]); |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
739 |
320
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
317
diff
changeset
|
740 String name = gauge != null ? gauge.getName() : "'n/a"; |
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
317
diff
changeset
|
741 logger.debug("Found gauge: " + name); |
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
317
diff
changeset
|
742 |
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
317
diff
changeset
|
743 return gauge; |
317
8f40a57229c3
FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
298
diff
changeset
|
744 } |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
745 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
746 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
747 /** |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
748 * Returns the gauges that match the selected kilometer range. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
749 * |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
750 * @return the gauges based on the selected kilometer range. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
751 */ |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
752 public List<Gauge> getGauges() { |
698
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
753 |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
754 River river = getRiver(); |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
755 if (river == null) { |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
756 return null; |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
757 } |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
758 |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
759 double [] dist = getDistance(); |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
760 if (dist == null) { |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
761 return null; |
dae37cbe4ae2
make getGauges() more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
697
diff
changeset
|
762 } |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
763 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
764 return river.determineGauges(dist[0], dist[1]); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
765 } |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
766 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
767 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
398
diff
changeset
|
768 /** |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
769 * This method returns the Q values. |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
770 * |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
771 * @return the selected Q values or null, if no Q values are selected. |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
772 */ |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
773 public double[] getQs() { |
631
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
628
diff
changeset
|
774 StateData dMode = getData("wq_mode"); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
628
diff
changeset
|
775 StateData dSelection = getData("wq_selection"); |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
776 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
777 String mode = dMode != null ? (String) dMode.getValue() : ""; |
631
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
628
diff
changeset
|
778 String sel = dSelection != null ? (String)dSelection.getValue() : null; |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
779 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
780 if (mode.equals("Q")) { |
631
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
628
diff
changeset
|
781 if (sel != null && sel.equals("single")) { |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
782 return getSingleWQValues(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
783 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
784 else { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
785 return getWQTriple(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
786 } |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
787 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
788 else { |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
789 logger.warn("You try to get Qs, but W has been inserted."); |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
790 return null; |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
791 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
792 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
793 |
685
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
794 |
455
7137ef65c17c
Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
451
diff
changeset
|
795 public boolean isQ() { |
7137ef65c17c
Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
451
diff
changeset
|
796 StateData mode = getData("wq_mode"); |
7137ef65c17c
Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
451
diff
changeset
|
797 return mode != null && mode.getValue().equals("Q"); |
7137ef65c17c
Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
451
diff
changeset
|
798 } |
7137ef65c17c
Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
451
diff
changeset
|
799 |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
800 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
801 /** |
685
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
802 * Returns true, if the parameter is set to compute data on a free range. |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
803 * Otherwise it returns false, which tells the calculation that it is bound |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
804 * to a gauge. |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
805 * |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
806 * @return true, if the calculation should compute on a free range otherwise |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
807 * false and the calculation is bound to a gauge. |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
808 */ |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
809 public boolean isFreeQ() { |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
810 StateData mode = getData("wq_free"); |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
811 String value = mode != null ? (String) mode.getValue() : null; |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
812 |
738
5abdb2fa8eb1
Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
735
diff
changeset
|
813 logger.debug("isFreeQ: " + value); |
5abdb2fa8eb1
Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
735
diff
changeset
|
814 |
5abdb2fa8eb1
Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
735
diff
changeset
|
815 if (value == null) { |
685
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
816 return false; |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
817 } |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
818 |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
819 return Boolean.valueOf(value); |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
820 } |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
821 |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
822 |
d45c3ddaed1b
Added a parameter 'wq_free' that determines that mode of calculation 1 (specifies if the calculation is bound to a gauge or not).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
823 /** |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
824 * Returns the Q values based on a specified kilometer range. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
825 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
826 * @param range A 2dim array with lower and upper kilometer range. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
827 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
828 * @return an array of Q values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
829 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
830 public double[] getQs(double[] range) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
831 StateData dMode = getData("wq_mode"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
832 StateData dValues = getData("wq_values"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
833 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
834 String mode = dMode != null ? (String) dMode.getValue() : ""; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
835 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
836 if (mode.equals("Q")) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
837 return getWQForDist(range); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
838 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
839 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
840 logger.warn("You try to get Qs, but Ws has been inserted."); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
841 return null; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
842 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
843 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
844 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
845 /** |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
846 * Returns the W values based on a specified kilometer range. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
847 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
848 * @param range A 2dim array with lower and upper kilometer range. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
849 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
850 * @return an array of W values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
851 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
852 public double[] getWs(double[] range) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
853 StateData dMode = getData("wq_mode"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
854 StateData dValues = getData("wq_values"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
855 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
856 String mode = dMode != null ? (String) dMode.getValue() : ""; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
857 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
858 if (mode.equals("W")) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
859 return getWQForDist(range); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
860 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
861 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
862 logger.warn("You try to get Ws, but Qs has been inserted."); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
863 return null; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
864 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
865 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
866 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
867 /** |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
868 * This method returns the W values. |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
869 * |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
870 * @return the selected W values or null, if no W values are selected. |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
871 */ |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
872 public double[] getWs() { |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
873 StateData dMode = getData("wq_mode"); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
874 StateData dSingle = getData("wq_single"); |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
875 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
876 String mode = dMode != null ? (String) dMode.getValue() : ""; |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
877 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
878 if (mode.equals("W")) { |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
879 if (dSingle != null) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
880 return getSingleWQValues(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
881 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
882 else { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
883 return getWQTriple(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
884 } |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
885 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
886 else { |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
887 logger.warn("You try to get Qs, but W has been inserted."); |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
888 return null; |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
889 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
890 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
891 |
650
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
892 public List<Segment> getSegments() { |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
893 StateData wqValues = getData("wq_values"); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
894 if (wqValues == null) { |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
895 logger.warn("no wq_values given"); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
896 return Collections.emptyList(); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
897 } |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
898 String input = (String)wqValues.getValue(); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
899 if (input == null || (input = input.trim()).length() == 0) { |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
900 logger.warn("wq_values are empty"); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
901 return Collections.emptyList(); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
902 } |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
903 return Segment.parseSegments(input); |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
904 } |
6695e03e9b82
Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
637
diff
changeset
|
905 |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
906 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
907 /** |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
908 * Returns the Qs for a number of Ws. This method makes use of |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
909 * DischargeTables.getQForW(). |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
910 * |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
911 * @param ws An array of W values. |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
912 * |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
913 * @return an array of Q values. |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
914 */ |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
915 public double[] getQsForWs(double[] ws) { |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
916 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
917 boolean debug = logger.isDebugEnabled(); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
918 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
919 if (debug) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
920 logger.debug("FLYSArtifact.getQsForWs"); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
921 } |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
922 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
923 River r = getRiver(); |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
924 if (r == null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
925 logger.warn("no river found"); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
926 return null; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
927 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
928 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
929 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
930 double [] range = getDistance(); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
931 if (range == null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
932 logger.warn("no ranges found"); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
933 return null; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
934 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
935 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
936 if (debug) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
937 logger.debug("range: " + Arrays.toString(range)); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
938 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
939 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
940 Gauge g = r.determineGaugeByPosition(range[0]); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
941 if (g == null) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
942 logger.warn("no gauge found for km: " + range[0]); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
943 return null; |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
944 } |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
945 |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
946 if (debug) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
947 logger.debug("convert w->q with gauge '" + g.getName() + "'"); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
948 } |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
949 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
950 DischargeTables dt = new DischargeTables(r.getName(), g.getName()); |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
951 Map<String, double [][]> tmp = dt.getValues(); |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
952 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
953 double[][] values = tmp.get(g.getName()); |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
954 double[] qs = new double[ws.length]; |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
955 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
956 for (int i = 0; i < ws.length; i++) { |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
957 qs[i] = dt.getQForW(values, ws[i]); |
735
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
958 if (debug) { |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
959 logger.debug("w: " + ws[i] + " -> q: " + qs[i]); |
db68806e6563
Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
960 } |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
961 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
962 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
963 return qs; |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
964 } |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
965 |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
966 /** |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
967 * This method returns the given W or Q values for a specific range |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
968 * (inserted in the WQ input panel for discharge longitudinal sections). |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
969 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
970 * @param dist A 2dim array with lower und upper kilometer values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
971 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
972 * @return an array of W or Q values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
973 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
974 protected double[] getWQForDist(double[] dist) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
975 logger.debug("Search wq values for range: " + dist[0] + " - " + dist[1]); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
976 StateData data = getData("wq_values"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
977 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
978 if (data == null) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
979 logger.warn("Missing wq values!"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
980 return null; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
981 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
982 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
983 String dataString = (String) data.getValue(); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
984 String[] ranges = dataString.split(":"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
985 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
986 for (String range: ranges) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
987 String[] parts = range.split(";"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
988 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
989 double lower = Double.parseDouble(parts[0]); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
990 double upper = Double.parseDouble(parts[1]); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
991 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
992 if (lower <= dist[0] && upper >= dist[1]) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
993 String[] values = parts[2].split(","); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
994 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
995 int num = values.length; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
996 double[] res = new double[num]; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
997 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
998 for (int i = 0; i < num; i++) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
999 try { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1000 res[i] = Double.parseDouble(values[i]); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1001 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1002 catch (NumberFormatException nfe) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1003 logger.warn(nfe, nfe); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1004 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1005 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1006 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1007 return res; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1008 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1009 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1010 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1011 logger.warn("Specified range for WQ not found!"); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1012 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1013 return null; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1014 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1015 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1016 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
1017 /** |
377
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
1018 * This method returns an array of inserted WQ triples that consist of from, |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
1019 * to and the step width. |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
1020 * |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
1021 * @return an array of from, to and step width. |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
1022 */ |
0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
368
diff
changeset
|
1023 protected double[] getWQTriple() { |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1024 StateData dFrom = getData("wq_from"); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1025 StateData dTo = getData("wq_to"); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1026 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1027 if (dFrom == null || dTo == null) { |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1028 logger.warn("Missing start or end value for range."); |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1029 return null; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1030 } |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1031 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1032 double from = Double.parseDouble((String) dFrom.getValue()); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1033 double to = Double.parseDouble((String) dTo.getValue()); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1034 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1035 StateData dStep = getData("wq_step"); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1036 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1037 if (dStep == null) { |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1038 logger.warn("No step width given. Cannot compute Qs."); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1039 return null; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1040 } |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1041 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1042 double step = Double.parseDouble((String) dStep.getValue()); |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1043 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1044 // if no width is given, the DEFAULT_Q_STEPS is used to compute the step |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1045 // width. Maybe, we should round the value to a number of digits. |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1046 if (step == 0d) { |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1047 double diff = to - from; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1048 step = diff / DEFAULT_Q_STEPS; |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1049 } |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1050 |
707
b6f57d927905
Removed more dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
706
diff
changeset
|
1051 return DoubleUtil.explode(from, to, step); |
362
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1052 } |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1053 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1054 |
d79a51fc4f1d
Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
355
diff
changeset
|
1055 /** |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1056 * Returns an array of inserted WQ double values stored as whitespace |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1057 * separated list. |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1058 * |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1059 * @return an array of W or Q values. |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1060 */ |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1061 protected double[] getSingleWQValues() { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1062 StateData dSingle = getData("wq_single"); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1063 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1064 if (dSingle == null) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1065 logger.warn("Cannot determine single WQ values. No data given."); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1066 return null; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1067 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1068 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1069 String tmp = (String) dSingle.getValue(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1070 String[] strValues = tmp.split(" "); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1071 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1072 TDoubleArrayList values = new TDoubleArrayList(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1073 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1074 for (String strValue: strValues) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1075 try { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1076 values.add(Double.parseDouble(strValue)); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1077 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1078 catch (NumberFormatException nfe) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1079 logger.warn(nfe, nfe); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1080 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1081 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1082 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1083 values.sort(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1084 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1085 return values.toNativeArray(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1086 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1087 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1088 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
377
diff
changeset
|
1089 /** |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1090 * Computes the hash code of the entered values. |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1091 * |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1092 * @return a hash code. |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1093 */ |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1094 @Override |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1095 public String hash() { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1096 Set<Map.Entry<String, StateData>> entries = data.entrySet(); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1097 |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1098 long hash = 0L; |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1099 int shift = 3; |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1100 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1101 for (Map.Entry<String, StateData> entry: entries) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1102 String key = entry.getKey(); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1103 Object value = entry.getValue().getValue(); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1104 |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
741
diff
changeset
|
1105 hash ^= ((long)key.hashCode() << shift) |
722
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1106 | ((long)value.hashCode() << (shift + 3)); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1107 shift += 2; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1108 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1109 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1110 return getCurrentStateId() + hash; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1111 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1112 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1113 |
944
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1114 public List<Output> getOutputs(CallContext context) { |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1115 List<String> stateIds = getPreviousStateIds(); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1116 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1117 DefaultState cur = (DefaultState) getCurrentState(context); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1118 try { |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1119 if (cur.validate(this, context)) { |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1120 stateIds.add(cur.getID()); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1121 } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1122 } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1123 catch (IllegalArgumentException iae) { } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1124 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1125 List<Output> generated = new ArrayList<Output>(); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1126 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1127 FLYSContext flysContext = getFlysContext(context); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1128 StateEngine engine = (StateEngine) flysContext.get( |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1129 FLYSContext.STATE_ENGINE_KEY); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1130 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1131 for (String stateId: stateIds) { |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1132 DefaultState state = (DefaultState) engine.getState(stateId); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1133 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1134 List<Output> list = state.getOutputs(); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1135 if (list == null || list.size() == 0) { |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1136 logger.debug("-> No output modes for this state."); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1137 continue; |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1138 } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1139 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1140 List<Facet> fs = facets.get(stateId); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1141 if (fs == null || fs.size() == 0) { |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1142 logger.debug("No facets found."); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1143 continue; |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1144 } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1145 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1146 List<Output> o = generateOutputs(list, fs); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1147 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1148 generated.addAll(o); |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1149 } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1150 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1151 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1152 return generated; |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1153 } |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1154 |
c256061287d7
Simplified the code to read all provided Outputs of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
942
diff
changeset
|
1155 |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1156 protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1157 List<Output> generated = new ArrayList<Output>(); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1158 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1159 boolean debug = logger.isDebugEnabled(); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1160 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1161 for (Output out: list) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1162 Output o = new DefaultOutput( |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1163 out.getName(), |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1164 out.getDescription(), |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1165 out.getMimeType(), |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1166 out.getType()); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1167 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1168 Set<String> outTypes = new HashSet<String>(); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1169 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1170 for (Facet f: out.getFacets()) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1171 if (outTypes.add(f.getName()) && debug) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1172 logger.debug("configured facet " + f); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1173 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1174 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1175 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1176 boolean facetAdded = false; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1177 for (Facet f: fs) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1178 String type = f.getName(); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1179 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1180 if (outTypes.contains(type)) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1181 if (debug) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1182 logger.debug("Add facet " + f); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1183 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1184 facetAdded = true; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1185 o.addFacet(f); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1186 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1187 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1188 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1189 if (facetAdded) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1190 generated.add(o); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1191 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1192 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1193 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1194 return generated; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1195 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1196 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
1197 |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1198 /** |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1199 * Dispatches the computation request to compute(CallContext context, String |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1200 * hash) with the current hash value of the artifact which is provided by |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1201 * hash(). |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1202 * |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1203 * @param context The CallContext. |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1204 */ |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1205 public Object compute( |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
741
diff
changeset
|
1206 CallContext context, |
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
741
diff
changeset
|
1207 ComputeType type, |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1208 boolean generateFacets |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1209 ) { |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1210 return compute(context, hash(), type, generateFacets); |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1211 } |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1212 |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1213 |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1214 /** |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1215 * Dispatches computation requests to the current state which needs to |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1216 * implement a createComputeCallback(String hash, FLYSArtifact artifact) |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1217 * method. |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1218 * |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1219 * @param context The CallContext. |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1220 * @param hash The hash value which is used to fetch computed data from |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1221 * cache. |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1222 * |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1223 * @return the computed data. |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1224 */ |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1225 public Object compute( |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1226 CallContext context, |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1227 String hash, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
741
diff
changeset
|
1228 ComputeType type, |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1229 boolean generateFacets |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1230 ) { |
693
af393c5eb2c8
Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
692
diff
changeset
|
1231 DefaultState current = (DefaultState) getCurrentState(context); |
722
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1232 return compute(context, hash, current, type, generateFacets); |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1233 } |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1234 |
722
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1235 public Object compute( |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1236 CallContext context, |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1237 String stateID, |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1238 String hash, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
741
diff
changeset
|
1239 ComputeType type, |
722
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1240 boolean generateFacets |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1241 ) { |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1242 DefaultState current = stateID == null |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1243 ? (DefaultState)getCurrentState(context) |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1244 : (DefaultState)getState(context, stateID); |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1245 |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1246 if (hash == null) { |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1247 hash = hash(); |
4800230fba8a
Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
708
diff
changeset
|
1248 } |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1249 |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1250 return compute(context, hash, current, type, generateFacets); |
689
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1251 } |
f8ac04b2dbd0
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
687
diff
changeset
|
1252 |
690
3481cd37e609
Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
1253 public Object compute( |
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
|
1254 CallContext context, |
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
|
1255 String key, |
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
|
1256 DefaultState state, |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1257 ComputeType type, |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1258 boolean generateFacets |
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
|
1259 ) { |
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
|
1260 String stateID = state.getID(); |
691
2600aa2c7319
Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
690
diff
changeset
|
1261 |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1262 List<Facet> fs = generateFacets ? new ArrayList<Facet>() : null; |
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
|
1263 |
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
|
1264 try { |
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
|
1265 Cache cache = CacheFactory.getCache(COMPUTING_CACHE); |
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
|
1266 |
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
|
1267 Object old = 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
|
1268 |
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
|
1269 if (cache != 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
|
1270 net.sf.ehcache.Element element = cache.get(key); |
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
|
1271 if (element != 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
|
1272 logger.debug("Got computation result from cache."); |
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
|
1273 old = element.getValue(); |
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
|
1274 } |
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
|
1275 } |
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
|
1276 |
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
|
1277 Object res; |
690
3481cd37e609
Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
1278 switch (type) { |
3481cd37e609
Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
1279 case FEED: |
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
|
1280 res = state.computeFeed(this, key, context, fs, 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
|
1281 break; |
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
|
1282 case ADVANCE: |
700
94f0f91be11c
call computeAdvance() if we want to advance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
699
diff
changeset
|
1283 res = state.computeAdvance(this, key, context, fs, old); |
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
|
1284 break; |
942
796c54058dc4
Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
941
diff
changeset
|
1285 case INIT: |
796c54058dc4
Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
941
diff
changeset
|
1286 res = state.computeInit(this, key, context.getMeta(), fs); |
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
|
1287 default: |
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
|
1288 res = 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
|
1289 } |
690
3481cd37e609
Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
1290 |
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
|
1291 if (cache != null && old != res && res != 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
|
1292 logger.debug("Store computation result to cache."); |
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
|
1293 net.sf.ehcache.Element element = |
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
|
1294 new net.sf.ehcache.Element(key, res); |
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
|
1295 cache.put(element); |
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
|
1296 } |
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
|
1297 |
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
|
1298 return res; |
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
|
1299 } |
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
|
1300 finally { |
705
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1301 if (generateFacets) { |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1302 if (fs.isEmpty()) { |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1303 facets.remove(stateID); |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1304 } |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1305 else { |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1306 facets.put(stateID, fs); |
853dceead0f4
Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
1307 } |
690
3481cd37e609
Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
689
diff
changeset
|
1308 } |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1309 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1310 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1311 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
661
diff
changeset
|
1312 |
623
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1313 /** |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1314 * Method to dump the artifacts state/data. |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1315 */ |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1316 protected void dumpArtifact() { |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1317 if (logger.isDebugEnabled()) { |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1318 logger.debug("++++++++++++++ DUMP ARTIFACT DATA +++++++++++++++++"); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1319 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1320 logger.debug("------ DUMP DATA ------"); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1321 Collection<StateData> allData = data.values(); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1322 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1323 for (StateData d: allData) { |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1324 String name = d.getName(); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1325 String value = (String) d.getValue(); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1326 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1327 logger.debug("- " + name + ": " + value); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1328 } |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1329 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1330 logger.debug("------ DUMP PREVIOUS STATES ------"); |
661
fdc898a134a7
Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
658
diff
changeset
|
1331 List<String> stateIds = getPreviousStateIds(); |
623
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1332 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1333 for (String id: stateIds) { |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1334 logger.debug("- State: " + id); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1335 } |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1336 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1337 logger.debug("CURRENT STATE: " + getCurrentStateId()); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1338 |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1339 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++"); |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1340 } |
aa64fe4df8ab
Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
459
diff
changeset
|
1341 } |
119
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1342 } |
84c0b151203e
Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1343 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |