Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeFacet.java @ 3441:bfbd478bd607
FixA: Moved Q -> W conversion code into segments to be reusable.
flys-artifacts/trunk@5104 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 23 Jul 2012 14:19:07 +0000 |
parents | d20215a0afd8 |
children |
rev | line source |
---|---|
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.artifacts.Artifact; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.CallContext; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifactdatabase.state.Facet; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.artifacts.FLYSArtifact; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 /** |
2733
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
15 * Access Discharge Curve of a gauge. |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 */ |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 public class GaugeDischargeFacet extends DataFacet { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
3047
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
19 /** Private logger. */ |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 private static final Logger logger = |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 Logger.getLogger(GaugeDischargeFacet.class); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 public GaugeDischargeFacet() { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 |
3047
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
28 /** |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
29 * @param index Index translates to index of WQ-array. |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
30 * @param name Name of the facet. |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
31 * @param desc Description of the facet (visible in client). |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
32 */ |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 public GaugeDischargeFacet(int index, String name, String desc) { |
3047
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
34 super(index, name, desc, ComputeType.ADVANCE, null, |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
35 "state.gaugedischarge.init"); |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 public GaugeDischargeFacet( |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 int index, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 String name, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 String description, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 ComputeType type, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 String stateID, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 String hash |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 ) { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 super(index, name, description, type, hash, stateID); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 @Override |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 public Facet deepCopy() { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 GaugeDischargeFacet copy = new GaugeDischargeFacet(); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 copy.set(this); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 copy.type = type; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 copy.hash = hash; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 copy.stateId = stateId; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 return copy; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 |
3047
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
63 /** |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
64 * @return wqkms corresponding to gauge of artifact and index of facet. |
d20215a0afd8
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3045
diff
changeset
|
65 */ |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 @Override |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 public Object getData(Artifact artifact, CallContext context) { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 if (logger.isDebugEnabled()) { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 logger.debug("Get data for discharge curves at index: " + |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 index + " / stateId: " + stateId); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 |
2733
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
73 if (stateId == null) { |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
74 logger.error("GaugeDischargeFacet.getData: stateId is null."); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
75 } |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 FLYSArtifact flys = (FLYSArtifact) artifact; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 CalculationResult res = (CalculationResult) |
3045
0905d1e7b37e
Fix certain GaugeDischargeArtifact issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2733
diff
changeset
|
79 flys.compute(context, hash, stateId, type, true); |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 WQKms[] discharge = (WQKms[]) res.getData(); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 return discharge[index]; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |