Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalDischargeWQFacet.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | 0beb34d55630 |
children | 0a5239a1e46e |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4260
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4260
diff
changeset
|
11 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4260
diff
changeset
|
12 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4260
diff
changeset
|
13 import org.dive4elements.artifacts.CallContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4260
diff
changeset
|
14 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
8442
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
16 import org.apache.log4j.Logger; |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
17 |
8393
47e96ce9bd79
If context contains pnp, transform W to m.
Raimund Renkert <rrenkert@intevation.de>
parents:
5994
diff
changeset
|
18 import static org.dive4elements.river.exports.injector.InjectorConstants.PNP; |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 /** |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 */ |
8442
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
23 public class HistoricalDischargeWQFacet |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
24 extends DataFacet |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
25 implements FacetTypes { |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
26 private static final Logger log = Logger |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
27 .getLogger(HistoricalDischargeWQFacet.class); |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 private double value; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 public HistoricalDischargeWQFacet() { |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
4260
e4a415773b0a
Added the 'index' parameter to HistoricalDischargeWQFacet to avoid loosing facets during the merge process in the FLYSArtifactCollection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
34 public HistoricalDischargeWQFacet(int index, String name, |
e4a415773b0a
Added the 'index' parameter to HistoricalDischargeWQFacet to avoid loosing facets during the merge process in the FLYSArtifactCollection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
35 String description, ComputeType type, String hash, String stateId, |
e4a415773b0a
Added the 'index' parameter to HistoricalDischargeWQFacet to avoid loosing facets during the merge process in the FLYSArtifactCollection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
36 double value) { |
e4a415773b0a
Added the 'index' parameter to HistoricalDischargeWQFacet to avoid loosing facets during the merge process in the FLYSArtifactCollection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
37 |
e4a415773b0a
Added the 'index' parameter to HistoricalDischargeWQFacet to avoid loosing facets during the merge process in the FLYSArtifactCollection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
38 super(index, name, description, type, hash, stateId); |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 this.value = value; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 @Override |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public Facet deepCopy() { |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 HistoricalDischargeWQFacet copy = new HistoricalDischargeWQFacet(); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 copy.set(this); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 copy.value = value; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 return copy; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 @Override |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 public Object getData(Artifact artifact, CallContext context) { |
8393
47e96ce9bd79
If context contains pnp, transform W to m.
Raimund Renkert <rrenkert@intevation.de>
parents:
5994
diff
changeset
|
52 double v = this.value; |
8442
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
53 if (HISTORICAL_DISCHARGE_WQ_W.equals(name)) { |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
54 if (context.getContextValue(PNP) instanceof Number) { |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
55 v = value/100 + |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
56 ((Number)context.getContextValue(PNP)).doubleValue(); |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
57 } |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
58 else { |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
59 log.error("Missing datum. Cannot calculate W value."); |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
60 return null; |
e65aad00b3a1
Do not transform Q values from cm to m.
"Tom Gottfried <tom@intevation.de>"
parents:
8393
diff
changeset
|
61 } |
8393
47e96ce9bd79
If context contains pnp, transform W to m.
Raimund Renkert <rrenkert@intevation.de>
parents:
5994
diff
changeset
|
62 } |
47e96ce9bd79
If context contains pnp, transform W to m.
Raimund Renkert <rrenkert@intevation.de>
parents:
5994
diff
changeset
|
63 return v; |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |