annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 696:708b270dfd30 facets-slt

OutGenerators use now facets to fetch necessary data. flys-artifacts/branches/facets-slt@2140 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Jun 2011 09:19:43 +0000
parents af393c5eb2c8
children b972eba2ed8a
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
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
3 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
4 import java.util.Collection;
650
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
5 import java.util.Collections;
691
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
6 import java.util.HashMap;
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
7 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
8 import java.util.List;
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
9 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
10 import java.util.Set;
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
11
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
12 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
13
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
14 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
15
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
16 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
17
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 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
19
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.w3c.dom.Document;
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
21 import org.w3c.dom.Element;
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
22 import org.w3c.dom.Node;
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
23 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
24
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 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
26 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
27
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 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
29 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
30
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import de.intevation.artifactdatabase.DefaultArtifact;
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
32 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
33 import de.intevation.artifactdatabase.data.StateData;
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
34 import de.intevation.artifactdatabase.state.Facet;
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 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
36 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
37 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
38
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
39 import de.intevation.flys.utils.DoubleUtil;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
40
317
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
41 import de.intevation.flys.model.Gauge;
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
42 import de.intevation.flys.model.Range;
317
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
43 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
44
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 import de.intevation.flys.artifacts.context.FLYSContext;
650
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
46
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
47 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
48
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
49 import de.intevation.flys.artifacts.model.ComputeCallback;
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
50 import de.intevation.flys.artifacts.model.ComputeCallback.ComputeType;
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
51 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
52 import de.intevation.flys.artifacts.model.RiverFactory;
650
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
53 import de.intevation.flys.artifacts.model.Segment;
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
54
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
55 import de.intevation.flys.artifacts.states.DefaultState;
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
56 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
57
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 /**
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 * 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
61 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 * @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
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 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
65
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 /** 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
67 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
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
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
70 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
71
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
72 /** 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
73 public static final String XPATH_FEED_INPUT =
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
74 "/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
75
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
76 /** 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
77 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
78 "/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
79
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
80 /** 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
81 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
82
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
83 /** 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
84 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
85
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
86 /** 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
87 * range.*/
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
88 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
89
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
90 /** 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
91 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
92
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 /** 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
95 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
96
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
97 /** 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
98 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
99
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 /** 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
101 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
102
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
103 /** The data that have been inserted into this artifact.*/
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
104 protected Map<String, StateData> data;
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
105
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
106 /** 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
107 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
108
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
109
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
110 /**
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
111 * The default constructor that creates an empty FLYSArtifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
112 */
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
113 public FLYSArtifact() {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
114 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
115 previousStateIds = new ArrayList<String>();
691
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
116 facets = new HashMap<String, List<Facet>>();
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
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 * Returns the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
122 *
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
123 * @return the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
124 */
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
125 public abstract String getName();
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 FLYSContext from context object.
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 * @param context The CallContext or the FLYSContext.
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 * @return the FLYSContext.
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 protected FLYSContext getFlysContext(Object context) {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
136 return context instanceof FLYSContext
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
137 ? (FLYSContext) context
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
138 : (FLYSContext) ((CallContext) context).globalContext();
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
139 }
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
140
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 /**
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 * 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
144 * 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
145 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 * @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
147 * @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
148 * @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
149 * @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
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 @Override
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 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
153 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
154 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
155 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
156 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
157 {
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 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
159
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 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
161
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 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
163 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
164 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
165
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
166 String name = getName();
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
167
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
168 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
169 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
170
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 setCurrentState(states.get(0));
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 }
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 /**
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 * 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
177 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 * @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
179 * @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
180 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 * @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
182 */
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 @Override
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 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
185 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
186
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
187 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
188
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
189 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
190 doc,
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
191 ArtifactNamespaceContext.NAMESPACE_URI,
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
192 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
193
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
194 Element result = creator.create("result");
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
195 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
196
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
197 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
198 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
199
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
200 compute(context, ComputeType.FEED);
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
201
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
202 return describe(target, context);
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
203 }
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
204 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
205 // 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
206 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
207 creator.addAttr(result, "type", OPERATION_FAILED, true);
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
208
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
209 result.setTextContent(iae.getMessage());
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
210 }
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
211
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
212 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
213 }
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 /**
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
217 * 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
218 * 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
219 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
220 * @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
221 * @param context The CallContext.
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
222 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
223 * @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
224 */
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
225 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
226 Document doc = XMLUtils.newDocument();
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
227
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
228 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
229 doc,
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
230 ArtifactNamespaceContext.NAMESPACE_URI,
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
231 ArtifactNamespaceContext.NAMESPACE_PREFIX);
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
232
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
233 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
234
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
235 String targetState = XMLUtils.xpathString(
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
236 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
237
140
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
238 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
239
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
240 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
241 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
242
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
243 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
244 prev.add(getCurrentStateId());
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
245
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
246 setCurrentStateId(targetState);
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
247
693
af393c5eb2c8 Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 692
diff changeset
248 logger.debug("Compute data for state: " + targetState);
af393c5eb2c8 Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 692
diff changeset
249 compute(context, ComputeType.ADVANCE);
af393c5eb2c8 Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 692
diff changeset
250
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
251 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
252 }
140
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
253 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
254 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
255
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
256 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
257 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
258 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
259
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
260 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
261 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
262 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
263 prevs.remove(prev);
691
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
264 facets.remove(prev);
140
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
265 }
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
266
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
267 setCurrentStateId(targetState);
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
268
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
269 return describe(target, context);
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
270 }
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
271
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
272 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
273 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
274
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
275 doc.appendChild(result);
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
276
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
277 return doc;
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
278 }
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
279
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
280
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
281 /**
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 * 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
283 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 * @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
285 */
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 protected String getCurrentStateId() {
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 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
288 }
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 /**
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 * 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
293 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 * @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
295 */
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296 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
297 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
298 }
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
301 /**
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302 * 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
303 * 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
304 * 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
305 * 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
306 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
307 * @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
308 */
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
309 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
310 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
311 }
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
312
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 /**
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 * 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
316 *
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 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
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 protected State getCurrentState(Object context) {
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
320 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
321 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
322 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
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 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
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
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
327
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
328 /**
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
329 * 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
330 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
331 * @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
332 */
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
333 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
334 return previousStateIds;
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
335 }
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
336
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
337
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
338 /**
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
339 * 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
340 *
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
341 * @param name the name of the data object.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
342 * @param data the data object itself.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
343 */
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
344 protected void addData(String name, StateData data) {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
345 this.data.put(name, data);
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
346 }
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
347
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
348
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
349 /**
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
350 * 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
351 * 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
352 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
353 * @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
354 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
355 * @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
356 */
298
fc694a43a7e5 Changed the visibility of getData() method of FLYSArtifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 140
diff changeset
357 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
358 return data.get(name);
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
359 }
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
360
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
361
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
362 public Facet getNativeFacet(Facet facet) {
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
363 String name = facet.getName();
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
364 int index = facet.getIndex();
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
365
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
366 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
367 for (Facet f: entry.getValue()) {
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
368 if (f.getName().equals(name) && f.getIndex() == index) {
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
369 return f;
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
370 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
371 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
372 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
373
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
374 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
375 return null;
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
376 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
377
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
378
122
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
379 /**
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
380 * 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
381 *
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
382 * @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
383 * @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
384 */
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
385 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
386 throws IllegalArgumentException
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
387 {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
388 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
389 throw new IllegalArgumentException("error_feed_no_data");
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
390 }
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
391
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
392 NodeList nodes = (NodeList) XMLUtils.xpath(
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
393 feed,
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
394 xpath,
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
395 XPathConstants.NODESET,
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
396 ArtifactNamespaceContext.INSTANCE);
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
397
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
398 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
399 throw new IllegalArgumentException("error_feed_no_data");
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
400 }
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
401
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
402 int count = nodes.getLength();
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
403 logger.debug("Try to save " + count + " data items.");
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
404
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
405 for (int i = 0; i < count; i++) {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
406 Node node = nodes.item(i);
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
407
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
408 String name = XMLUtils.xpathString(
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
409 node, "@art:name", ArtifactNamespaceContext.INSTANCE);
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
410 String value = XMLUtils.xpathString(
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
411 node, "@art:value", ArtifactNamespaceContext.INSTANCE);
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
412
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
413 if (name != null && value != null) {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
414 logger.debug("Save data item for '" + name + "' : " + value);
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
415
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
416 addData(name, new DefaultStateData(name, null, null, value));
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
417 }
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
418 }
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
419
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
420 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
421 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
422 }
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
423
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
424
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
425 /**
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
426 * 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
427 * 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
428 * TransitionEngine.
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
429 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
430 * @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
431 * @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
432 *
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
433 * @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
434 * otherwise false.
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
435 */
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
436 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
437 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
438
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
439 FLYSContext flysContext = getFlysContext(context);
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
440
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
441 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
442 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
443 FLYSContext.STATE_ENGINE_KEY);
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
444
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
445 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
446 FLYSContext.TRANSITION_ENGINE_KEY);
d3b8b0b1d010 Implemented the step-forward part of the advance operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
447
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
448 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
449 }
140
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
450
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
451
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
452 /**
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
453 * 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
454 * 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
455 *
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
456 * @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
457 * @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
458 */
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
459 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
460 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
461
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
462 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
463 if (prevs.contains(stateId)) {
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
464 return true;
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
465 }
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
466
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
467 return false;
43f03f6047b9 Implemented the step-back part of the advance() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 123
diff changeset
468 }
317
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
469
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
470
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
471 /**
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
472 * 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
473 * 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
474 *
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
475 * @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
476 */
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
477 public River getRiver() {
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
478 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
479
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
480 return dRiver != null
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
481 ? 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
482 : null;
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
483 }
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
484
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
485
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
486 /**
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
487 * 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
488 *
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
489 * @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
490 */
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
491 public double[] getDistance() {
383
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
492 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
493 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
494 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
495
383
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
496 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
497 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
498 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
499 else if (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
500 double[] locations = getLocations();
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
501 return new double[] { locations[0], locations[locations.length-1] };
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
502 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
503
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
504 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
505
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
506 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
507 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
508
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
509
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
510 /**
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
511 * 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
512 *
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
513 * @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
514 */
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
515 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
516 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
517
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
518 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
519 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
520 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
521 }
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
522
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
523 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
524
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
525 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
526 }
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
527
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
528
833290f16f09 ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
529 /**
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
530 * This method returns the given distance
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
531 *
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
532 * @return an array with lower and upper kilometer range for each
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
533 * intersected gauge.
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
534 */
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
535 public double[][] getSplittedDistance() {
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
536 double[] dist = getDistance();
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
537 List<Gauge> gauges = getGauges();
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
538
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
539 int num = gauges != null ? gauges.size() : 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
540
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
541 double[][] res = new double[num][2];
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
542
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
543 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
544 Range range = gauges.get(i).getRange();
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
545
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
546 double lower = range.getA().doubleValue();
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
547 double upper = range.getB().doubleValue();
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
548
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
549 res[i][0] = dist[0] < lower ? lower : dist[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
550 res[i][1] = dist[1] > upper ? 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
551 }
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
552
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
553 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
554 }
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
555
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
556
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
557 /**
383
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
558 * 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
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 * @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
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 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
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 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
565 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
566 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
567 ? (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
568 : "";
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
569
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
570 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
571 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
572 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
573 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
574
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
575 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
576 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
577
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
578 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
579 try {
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
580 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
581 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
582 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
583 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
584 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
585 }
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
586
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
587 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
588
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
589 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
590 }
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
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
593 /**
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
594 * 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
595 *
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
596 * @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
597 * @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
598 *
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
599 * @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
600 */
dcc3cd962c0e Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
601 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
602 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
603 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
604
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
605 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
606 }
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
607
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
608
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
609 /**
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
610 * 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
611 *
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
612 * @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
613 *
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
614 * @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
615 */
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
616 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
617 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
618
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
619 if (dStep == null) {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
620 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
621 return null;
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
622 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
623
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
624 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
625
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
626 // 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
627 step = step / 1000;
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
628
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
629 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
630 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
631 }
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
632
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
633 return getExplodedValues(distance[0], distance[1], step);
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
634 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
635
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
636
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
637 /**
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
638 * 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
639 *
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 * @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
641 */
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
642 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
643 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
644 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
645 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
646
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
647 }
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
648 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
649 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
650 }
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
651 }
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
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
653 public double [] getFromToStep() {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
654 if (!isRange()) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
655 return null;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
656 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
657 double [] fromTo = getDistance();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
658
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
659 if (fromTo == null) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
660 return null;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
661 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
662
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
663 StateData dStep = getData("ld_step");
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
664 if (dStep == null) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
665 return null;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
666 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
667
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
668 double [] result = new double[3];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
669 result[0] = fromTo[0];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
670 result[1] = fromTo[1];
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
671
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
672 try {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
673 String step = (String)dStep.getValue();
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
674 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
675 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
676 catch (NumberFormatException nfe) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
677 return null;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
678 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
679
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
680 return result;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
681 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
682
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
683
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
684 /**
317
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
685 * 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
686 *
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
687 * @return the gauge.
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
688 */
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
689 public Gauge getGauge() {
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
690 River river = getRiver();
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
691 double[] dist = getDistance();
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
692
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
693 if (logger.isDebugEnabled()) {
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
694 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
695 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
696 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
697 }
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
698
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
699 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
700
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
701 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
702 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
703
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
704 return gauge;
317
8f40a57229c3 FLYSArtifact provides methods to retrieve the real River, Gauge objects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
705 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
706
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
707
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
708 /**
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
709 * 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
710 *
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
711 * @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
712 */
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
713 public List<Gauge> getGauges() {
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
714 River river = getRiver();
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
715 double[] dist = getDistance();
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
716
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
717 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
718 }
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
719
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
720
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
721 /**
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
722 * 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
723 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
724 * @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
725 */
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
726 public double[] getQs() {
631
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 628
diff changeset
727 StateData dMode = getData("wq_mode");
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 628
diff changeset
728 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
729
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
730 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
731 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
732
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
733 if (mode.equals("Q")) {
631
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 628
diff changeset
734 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
735 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
736 }
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
737 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
738 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
739 }
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
740 }
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
741 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
742 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
743 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
744 }
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
745 }
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
746
455
7137ef65c17c Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
747 public boolean isQ() {
7137ef65c17c Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
748 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
749 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
750 }
7137ef65c17c Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 451
diff changeset
751
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
752
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
753 /**
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
754 * 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
755 *
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
756 * @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
757 *
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
758 * @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
759 */
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
760 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
761 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
762 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
763
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
764 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
765
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
766 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
767 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
768 }
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
769
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
770 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
771 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
772 }
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
773
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
774
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
775 /**
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
776 * 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
777 *
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
778 * @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
779 *
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
780 * @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
781 */
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
782 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
783 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
784 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
785
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
786 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
787
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
788 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
789 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
790 }
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
791
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
792 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
793 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
794 }
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
795
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
796
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
797 /**
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
798 * 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
799 *
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 * @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
801 */
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
802 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
803 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
804 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
805
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
806 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
807
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
808 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
809 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
810 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
811 }
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
812 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
813 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
814 }
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
815 }
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
816 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
817 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
818 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
819 }
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
820 }
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
821
650
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
822 public List<Segment> getSegments() {
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
823 StateData wqValues = getData("wq_values");
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
824 if (wqValues == null) {
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
825 logger.warn("no wq_values given");
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
826 return Collections.emptyList();
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
827 }
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
828 String input = (String)wqValues.getValue();
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
829 if (input == null || (input = input.trim()).length() == 0) {
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
830 logger.warn("wq_values are empty");
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
831 return Collections.emptyList();
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
832 }
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
833 return Segment.parseSegments(input);
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
834 }
6695e03e9b82 Added parser for segments
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 637
diff changeset
835
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
836
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
837 /**
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
838 * 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
839 * 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
840 *
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
841 * @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
842 *
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
843 * @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
844 */
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
845 public double[] getQsForWs(double[] ws) {
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
846 logger.debug("FLYSArtifact.getQsForWs");
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
847
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
848 River r = getRiver();
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
849 Gauge g = getGauge();
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
850
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
851 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
852 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
853
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
854 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
855 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
856
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
857 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
858 qs[i] = dt.getQForW(values, ws[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
859 }
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
860
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
861 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
862 }
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
863
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
864 protected double [][] getRanges() {
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
865 logger.debug("getRanges");
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
866
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
867 StateData data = getData("wq_values");
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
868
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
869 if (data == null) {
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
870 logger.warn("Missing wq values!");
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
871 return new double [0][0];
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
872 }
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
873
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
874 String dataString = (String)data.getValue();
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
875 String [] ranges = dataString.split(":");
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
876
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
877 ArrayList<double []> rs = new ArrayList<double []>();
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
878
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
879 for (String range: ranges) {
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
880 String [] parts = range.split(";");
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
881
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
882 if (parts.length < 2) {
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
883 logger.warn("invalid number of parts in range line");
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
884 continue;
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
885 }
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
886 try {
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
887 double from = Double.parseDouble(parts[0]);
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
888 double to = Double.parseDouble(parts[1]);
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
889 rs.add(new double [] { from, to });
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
890 }
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
891 catch (NumberFormatException nfe) {
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
892 logger.warn("invalid double values in range line");
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
893 }
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
894 }
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
895
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
896 return rs.toArray(new double [rs.size()][]);
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
897 }
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
898
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
899
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
900 /**
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
901 * 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
902 * (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
903 *
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
904 * @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
905 *
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
906 * @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
907 */
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
908 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
909 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
910 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
911
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
912 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
913 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
914 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
915 }
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
916
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
917 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
918 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
919
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
920 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
921 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
922
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
923 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
924 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
925
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
926 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
927 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
928
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
929 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
930 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
931
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
932 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
933 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
934 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
935 }
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
936 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
937 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
938 }
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
939 }
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
940
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
941 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
942 }
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
943 }
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
944
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
945 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
946
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
947 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
948 }
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
949
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
950
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
951 /**
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
952 * 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
953 * 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
954 *
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 * @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
956 */
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 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
958 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
959 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
960
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
961 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
962 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
963 return null;
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
964 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
965
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
966 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
967 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
968
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
969 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
970
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
971 if (dStep == null) {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
972 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
973 return null;
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
974 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
975
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
976 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
977
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
978 // 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
979 // 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
980 if (step == 0d) {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
981 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
982 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
983 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
984
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
985 return getExplodedValues(from, to, step);
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
986 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
987
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
988
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
989 /**
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
990 * 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
991 * 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
992 *
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
993 * @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
994 */
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
995 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
996 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
997
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
998 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
999 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
1000 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
1001 }
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
1002
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
1003 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
1004 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
1005
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
1006 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
1007
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
1008 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
1009 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
1010 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
1011 }
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
1012 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
1013 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
1014 }
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
1015 }
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
1016
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
1017 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
1018
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
1019 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
1020 }
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
1021
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
1022
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
1023 /**
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1024 * Returns an array of double values. The values contained in this array
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1025 * begin with the value <i>from</i> and end with the value <i>to</i>. The
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1026 * number of values in the result array depends on the <i>step</i> width.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1027 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1028 * @param from The lower value.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1029 * @param to The upper value.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1030 * @param step The step width between two values in the result array.
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 * @return an array of double values.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
1033 */
634
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1034 public static double[] getExplodedValues(
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1035 double from,
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1036 double to,
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1037 double step
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1038 ) {
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 650
diff changeset
1039 return DoubleUtil.explode(from, to, step);
634
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1040 }
d8c47520c726 Round exploded values to a precision of 1e-6.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
1041
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1042
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1043 /**
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1044 * 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
1045 *
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1046 * @return a hash code.
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1047 */
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1048 @Override
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1049 public String hash() {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1050 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
1051
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1052 int hash = 0;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1053 int shift = 3;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1054
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1055 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
1056 String key = entry.getKey();
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1057 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
1058
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1059 hash ^= (key.hashCode() << shift) | (value.hashCode() << 2 * shift);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1060 shift += 2;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1061 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1062
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1063 return getCurrentStateId() + hash;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1064 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1065
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1066
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
1067 /**
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
1068 * 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
1069 * 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
1070 * 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
1071 *
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
1072 * @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
1073 */
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1074 public Object compute(CallContext context, ComputeType type) {
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1075 return compute(context, hash(), type);
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
1076 }
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
1077
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
1078
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
1079 /**
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
1080 * 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
1081 * 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
1082 * 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
1083 *
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
1084 * @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
1085 * @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
1086 * 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
1087 *
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
1088 * @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
1089 */
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1090 public Object compute(CallContext context, String hash, ComputeType type) {
693
af393c5eb2c8 Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 692
diff changeset
1091 DefaultState current = (DefaultState) getCurrentState(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
1092
693
af393c5eb2c8 Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 692
diff changeset
1093 logger.debug("Create ComputeCallback for state: " + current.getID());
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
1094
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
1095 ComputeCallback callback = current.createComputeCallback(hash(), this);
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
1096
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
1097 if (callback == null) {
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
1098 logger.info("There is no data which needs to be computed.");
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
1099 return null;
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
1100 }
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
1101
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 691
diff changeset
1102 return compute(context, hash, callback, type);
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
1103 }
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
1104
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
1105
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1106 public Object compute(
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 691
diff changeset
1107 CallContext context,
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1108 String key,
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1109 ComputeCallback callback,
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1110 ComputeType type)
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1111 {
691
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1112 String stateId = getCurrentStateId();
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1113 List<Facet> fs = facets.get(stateId);
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1114 if (fs == null) {
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1115 fs = new ArrayList<Facet>();
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1116 facets.put(stateId, fs);
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1117 }
2600aa2c7319 Store facets for each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 690
diff changeset
1118
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1119 Cache cache = CacheFactory.getCache(COMPUTING_CACHE);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1120 if (cache == null) {
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1121 switch (type) {
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1122 case FEED:
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 691
diff changeset
1123 return callback.computeFeed(context, fs);
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1124
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1125 case ADVANCE:
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 691
diff changeset
1126 return callback.computeAdvance(context, fs);
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1127 }
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1128 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1129
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1130 net.sf.ehcache.Element element = cache.get(key);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1131 if (element != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1132 logger.debug("Got computation values from cache.");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1133 return element.getValue();
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1134 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1135
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1136 Object result = null;
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1137 switch (type) {
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1138 case FEED:
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 691
diff changeset
1139 result = callback.computeFeed(context, fs);
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1140 break;
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1141
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1142 case ADVANCE:
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 691
diff changeset
1143 result = callback.computeAdvance(context, fs);
690
3481cd37e609 Use enums to dispatch computeFeed() and computeAdvance().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
1144 }
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1145
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1146 if (result != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1147 cache.put(new net.sf.ehcache.Element(key, result));
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1148 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1149
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1150 return result;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1151 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1152
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
1153
623
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1154 /**
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1155 * 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
1156 */
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1157 protected void dumpArtifact() {
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1158 if (logger.isDebugEnabled()) {
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1159 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
1160
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1161 logger.debug("------ DUMP DATA ------");
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1162 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
1163
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1164 for (StateData d: allData) {
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1165 String name = d.getName();
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1166 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
1167
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1168 logger.debug("- " + name + ": " + value);
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1169 }
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1170
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1171 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
1172 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
1173
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1174 for (String id: stateIds) {
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1175 logger.debug("- State: " + id);
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1176 }
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1177
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1178 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
1179
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1180 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
1181 }
aa64fe4df8ab Added a method to dump the artifacts state/data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 459
diff changeset
1182 }
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1183 }
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1184 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org