Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixingsFacet.java @ 9415:9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
The facets also put the valid station range into their xml-metadata
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:27:53 +0200 |
parents | 5e38e2924c07 |
children |
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:
4736
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.fixings; |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
11 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
12 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
13 import org.dive4elements.artifacts.CallContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
14 import org.dive4elements.river.artifacts.model.DataFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
15 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 /** |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 * Facet to access the current Km from the context safely |
4736
b195fede1c3b
Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4442
diff
changeset
|
19 * |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 */ |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
22 public abstract class FixingsFacet extends DataFacet { |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
23 |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
24 private static final long serialVersionUID = 1L; |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 public static final Double INVALID_KM = Double.valueOf(-1d); |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 public FixingsFacet() { |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 } |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
31 public FixingsFacet(final int index, final String name, final String description, final ComputeType type, final String hash, final String stateId) { |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 super(index, name, description, type, hash, stateId); |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 } |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 /** |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 * Returns the current km from the context. |
8856 | 37 * If the context is null or doesn't contain a currentKm |
38 * then a double value of -1 will be returned. | |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
39 * |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
40 * @param context |
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
41 * The CallContext instance |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 * @return the current km as double |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 */ |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
44 protected final double getCurrentKm(final CallContext context) { |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 if (context == null) { |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 return INVALID_KM; |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 } |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
48 final Double dkm = (Double) context.getContextValue(CURRENT_KM); |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 if (dkm == null) { |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 return INVALID_KM; |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 } |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 return dkm.doubleValue(); |
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 } |
9415
9744ce3c3853
Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets.
gernotbelger
parents:
8856
diff
changeset
|
54 } |