annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixingsFacet.java @ 7300:83bb52fa0c32

(issue1529) Be more tolerant in the fitting. The invalid value warning is removed because invalid data is expected there when datapoints are not valid for this KM
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 11 Oct 2013 18:40:33 +0200
parents af13ceeba52a
children a5bd0a5b8efd
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
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
11 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
12 import org.dive4elements.river.artifacts.model.DataFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
13 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
14
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
15 /**
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 * 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
17 *
4442
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18 * @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
19 */
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
20 public class FixingsFacet extends DataFacet {
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
21
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
22 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
23 public static final String CURRENT_KM = "currentKm";
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
24
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25 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
26 }
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(String name, String description) {
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
29 super(0, name, description, ComputeType.ADVANCE, null, null);
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30 }
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
31
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32 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
33 int index,
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 String name,
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 String description,
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 ComputeType type,
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 String hash,
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
38 String stateId
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39 ) {
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
40 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
41 }
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
43 /**
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44 * Returns the current km from the context.
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 the context is null or doesn't contain a currentKm then a double value of -1 will
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46 * be returned.
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47 * @param context The CallContext instance
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
48 * @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
49 */
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50 protected double getCurrentKm(CallContext context) {
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 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
52 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
53 }
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
54 Double dkm = (Double)context.getContextValue(CURRENT_KM);
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
55 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
56 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
57 }
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 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
59 }
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
60 }

http://dive4elements.wald.intevation.org