Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java @ 1704:e8627d1e2db6
Cosmetics, docs.
flys-artifacts/trunk@2948 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 12 Oct 2011 10:59:12 +0000 |
parents | efe1b8545f5c |
children | 70ef5fdc7414 |
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 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 extends DefaultFacet |
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 |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 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
|
35 this(name, description, type, null); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 } |
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 public DataFacet( |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 String name, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
40 String description, |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 ComputeType type, |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 String hash |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 ) { |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 super(name, description); |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 this.type = type; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 this.hash = hash; |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
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
|
49 |
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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 ) { |
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 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
|
58 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
|
59 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
|
60 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
|
61 } |
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 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
63 |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
64 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
65 * Return computation result. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
66 */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
67 @Override |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 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
|
69 FLYSArtifact flys = (FLYSArtifact)artifact; |
1070
b1ed0ec0236f
Smaller Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
70 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
|
71 |
1136
8da5f5a9ed3c
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1117
diff
changeset
|
72 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
|
73 ? 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
|
74 : 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
|
75 } |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
76 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
77 |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
78 /** |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
79 * Return a deep copy. |
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1136
diff
changeset
|
80 */ |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
81 @Override |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
82 public Facet deepCopy() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
83 DataFacet copy = new DataFacet(); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
84 copy.set(this); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
85 copy.type = type; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
86 copy.hash = hash; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
87 copy.stateId = stateId; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
88 return copy; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
930
diff
changeset
|
89 } |
702
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
32ed5d789e50
Add facet to access raw computed data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |