Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java @ 2276:2966787b5188
Added service for discharge infos at a specific gauge.
flys-artifacts/trunk@3935 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 06 Feb 2012 15:37:54 +0000 |
parents | dd93a8e1377a |
children | d4330439be3a |
rev | line source |
---|---|
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
2256
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
3 import java.util.List; |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
4 import java.util.Arrays; |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
5 |
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifactdatabase.state.Facet; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.Artifact; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.CallContext; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.FLYSArtifact; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
2221
fdeb6d61c24c
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2198
diff
changeset
|
17 /** Facet for W-over-Ws. */ |
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 public class ReferenceCurveFacet |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 extends DataFacet |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 { |
2256
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
21 public static final String BLACK_BOARD_KEY = "reference.curve.axis.scale"; |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
22 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
23 public static final List BLACK_BOARD_KEY_LIST = |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
24 Arrays.asList(new String [] { BLACK_BOARD_KEY }); |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
25 |
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 private static Logger log = Logger.getLogger(ReferenceCurveFacet.class); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public ReferenceCurveFacet() { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 public ReferenceCurveFacet(int index, String name, String description) { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 super(index, name, description, ComputeType.ADVANCE, null, null); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 public ReferenceCurveFacet( |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 int index, |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 String name, |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 String description, |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 ComputeType type, |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 String stateID, |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 String hash |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 ) { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 super(index, name, description, type, hash, stateID); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 public Object getData(Artifact artifact, CallContext context) { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 if (log.isDebugEnabled()) { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 log.debug("Get data for reference curve at index: " + index + |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 " /stateId: " + stateId); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 |
2256
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
53 return getWW(artifact, context); |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
54 } |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
55 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
56 protected WW getWW(Artifact artifact, CallContext context) { |
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 FLYSArtifact winfo = (FLYSArtifact)artifact; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 CalculationResult res = (CalculationResult) |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 winfo.compute(context, hash, stateId, type, false); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
2256
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
62 return ((WW [])res.getData())[index]; |
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 @Override |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 public void set(Facet other) { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 super.set(other); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 ReferenceCurveFacet o= (ReferenceCurveFacet)other; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 type = o.type; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 hash = o.hash; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 stateId = o.stateId; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 /** Copy deeply. */ |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 @Override |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 public Facet deepCopy() { |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 ReferenceCurveFacet copy = new ReferenceCurveFacet(); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 copy.set(this); |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 return copy; |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 } |
2256
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
81 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
82 @Override |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
83 public List getDataProviderKeys(Artifact art) { |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
84 return BLACK_BOARD_KEY_LIST; |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
85 } |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
86 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
87 @Override |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
88 public Object provideBlackboardData( |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
89 Artifact artifact, |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
90 Object key, |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
91 Object param, |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
92 CallContext context |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
93 ) { |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
94 if (!key.equals(BLACK_BOARD_KEY)) { |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
95 return null; |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
96 } |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
97 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
98 Object obj = context.getContextValue("reference.curve.axis.scale"); |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
99 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
100 if (!(obj instanceof WWAxisTypes)) { |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
101 obj = new WWAxisTypes(getWW(artifact, context)); |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
102 } |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
103 else { |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
104 ((WWAxisTypes)obj).classify(getWW(artifact, context)); |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
105 } |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
106 |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
107 return obj; |
dd93a8e1377a
First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2221
diff
changeset
|
108 } |
2196
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 } |
5f3726f31f00
"Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |