Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/DataFacet.java @ 6351:2c7a16d59f67
Use Double.NaN for missing values in middle bedheight calculation and write empty strings in csv export.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 17 Jun 2013 15:37:26 +0200 |
parents | af13ceeba52a |
children | 8c64617a7991 |
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:
5867
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:
5867
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:
2141
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2141
diff
changeset
|
11 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2141
diff
changeset
|
12 import org.dive4elements.artifacts.CallContext; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2141
diff
changeset
|
14 import org.dive4elements.artifactdatabase.state.Facet; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
16 import org.dive4elements.river.artifacts.D4EArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2141
diff
changeset
|
17 |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2141
diff
changeset
|
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 public class DataFacet |
2122
81312f84689a
Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2121
diff
changeset
|
21 extends BlackboardDataFacet |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 protected ComputeType type; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 protected String hash; |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
25 protected String stateId; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
27 |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
28 /** Trivial constructor. */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
29 public DataFacet() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
30 } |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
31 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
32 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
33 * Defaults to ADVANCE Compute type. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
34 * @param name Name of the facet. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
35 * @param description maybe localized description of the facet. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
36 */ |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public DataFacet(String name, String description) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 this(name, description, ComputeType.ADVANCE); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
2121
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
41 |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 public DataFacet(String name, String description, ComputeType type) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 this(name, description, type, null); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
2121
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
46 |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 public DataFacet( |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 String name, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
49 String description, |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 ComputeType type, |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 String hash |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 ) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 super(name, description); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 this.type = type; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 this.hash = hash; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
58 |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
59 public DataFacet( |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
60 String name, |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
61 String description, |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
62 ComputeType type, |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
63 String hash, |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
64 String stateId |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
65 ) { |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
66 super(name, description); |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
67 this.type = type; |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
68 this.hash = hash; |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
69 this.stateId = stateId; |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
70 } |
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
71 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
72 |
2121
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
73 public DataFacet( |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
74 int index, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
75 String name, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
76 String description, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
77 ComputeType type, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
78 String hash, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
79 String stateId |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
80 ) { |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
81 super(index, name, description); |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
82 this.type = type; |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
83 this.hash = hash; |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
84 this.stateId = stateId; |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
85 } |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
86 |
2141
79a94c4171cb
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2126
diff
changeset
|
87 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
88 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
89 * Return computation result. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
90 */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
91 @Override |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 public Object getData(Artifact artifact, CallContext context) { |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
93 D4EArtifact flys = (D4EArtifact)artifact; |
1070
b1ed0ec0236f
Smaller Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
94 String theHash = (hash != null) ? hash : flys.hash(); |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
95 |
1136
8da5f5a9ed3c
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1117
diff
changeset
|
96 return (stateId != null && stateId.length() > 0) |
1117
ea80e652f033
Reordered some parameters in a FLYSArtifact method.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1070
diff
changeset
|
97 ? flys.compute(context, theHash, stateId, type, false) |
930
3fd891d5228d
The DataFacets are now able to store the ID of the create which created them.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
98 : flys.compute(context, theHash, type, false); |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 } |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
100 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
101 |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
102 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
103 * Return a deep copy. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
104 */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
105 @Override |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
106 public Facet deepCopy() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
107 DataFacet copy = new DataFacet(); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
108 copy.set(this); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
109 copy.type = type; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
110 copy.hash = hash; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
111 copy.stateId = stateId; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
112 return copy; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
113 } |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |