Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java @ 2125:7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
flys-artifacts/trunk@3695 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 17 Jan 2012 09:00:30 +0000 |
parents | 81312f84689a |
children | d626ae185305 |
rev | line source |
---|---|
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.Artifact; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.artifacts.CallContext; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifactdatabase.state.DefaultFacet; |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
7 import de.intevation.artifactdatabase.state.Facet; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.artifacts.FLYSArtifact; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 public class DataFacet |
2122
81312f84689a
Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2121
diff
changeset
|
14 extends BlackboardDataFacet |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 protected ComputeType type; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 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
|
18 protected String stateId; |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
20 |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
21 /** Trivial constructor. */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
22 public DataFacet() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
23 } |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
24 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
25 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
26 * Defaults to ADVANCE Compute type. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
27 * @param name Name of the facet. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
28 * @param description maybe localized description of the facet. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
29 */ |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 public DataFacet(String name, String description) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 this(name, description, ComputeType.ADVANCE); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
2121
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
34 |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 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
|
36 this(name, description, type, null); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
2121
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
39 |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public DataFacet( |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 String name, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
42 String description, |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 ComputeType type, |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 String hash |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 ) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 super(name, description); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 this.type = type; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 this.hash = hash; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
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
|
51 |
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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
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 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
|
60 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
|
61 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
|
62 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
|
63 } |
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 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
65 |
2121
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
66 public DataFacet( |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
67 int index, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
68 String name, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
69 String description, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
70 ComputeType type, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
71 String hash, |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
72 String stateId |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
73 ) { |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
74 super(index, name, description); |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
75 this.type = type; |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
76 this.hash = hash; |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
77 this.stateId = stateId; |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
78 } |
70ef5fdc7414
Cosmetics, added new DataFacet constructor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1160
diff
changeset
|
79 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
80 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
81 * Return computation result. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
82 */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
83 @Override |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 public Object getData(Artifact artifact, CallContext context) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 FLYSArtifact flys = (FLYSArtifact)artifact; |
1070
b1ed0ec0236f
Smaller Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
86 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
|
87 |
1136
8da5f5a9ed3c
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1117
diff
changeset
|
88 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
|
89 ? 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
|
90 : 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
|
91 } |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
92 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
93 |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
94 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
95 * Return a deep copy. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
96 */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
97 @Override |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
98 public Facet deepCopy() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
99 DataFacet copy = new DataFacet(); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
100 copy.set(this); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
101 copy.type = type; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
102 copy.hash = hash; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
103 copy.stateId = stateId; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
104 return copy; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
105 } |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |