Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | 79a94c4171cb |
children |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import de.intevation.artifacts.Artifact; | |
4 import de.intevation.artifacts.CallContext; | |
5 | |
6 import de.intevation.artifactdatabase.state.Facet; | |
7 | |
8 import de.intevation.flys.artifacts.FLYSArtifact; | |
9 | |
10 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
11 | |
12 public class DataFacet | |
13 extends BlackboardDataFacet | |
14 { | |
15 protected ComputeType type; | |
16 protected String hash; | |
17 protected String stateId; | |
18 | |
19 | |
20 /** Trivial constructor. */ | |
21 public DataFacet() { | |
22 } | |
23 | |
24 /** | |
25 * Defaults to ADVANCE Compute type. | |
26 * @param name Name of the facet. | |
27 * @param description maybe localized description of the facet. | |
28 */ | |
29 public DataFacet(String name, String description) { | |
30 this(name, description, ComputeType.ADVANCE); | |
31 } | |
32 | |
33 | |
34 public DataFacet(String name, String description, ComputeType type) { | |
35 this(name, description, type, null); | |
36 } | |
37 | |
38 | |
39 public DataFacet( | |
40 String name, | |
41 String description, | |
42 ComputeType type, | |
43 String hash | |
44 ) { | |
45 super(name, description); | |
46 this.type = type; | |
47 this.hash = hash; | |
48 } | |
49 | |
50 | |
51 public DataFacet( | |
52 String name, | |
53 String description, | |
54 ComputeType type, | |
55 String hash, | |
56 String stateId | |
57 ) { | |
58 super(name, description); | |
59 this.type = type; | |
60 this.hash = hash; | |
61 this.stateId = stateId; | |
62 } | |
63 | |
64 | |
65 public DataFacet( | |
66 int index, | |
67 String name, | |
68 String description, | |
69 ComputeType type, | |
70 String hash, | |
71 String stateId | |
72 ) { | |
73 super(index, name, description); | |
74 this.type = type; | |
75 this.hash = hash; | |
76 this.stateId = stateId; | |
77 } | |
78 | |
79 | |
80 /** | |
81 * Return computation result. | |
82 */ | |
83 @Override | |
84 public Object getData(Artifact artifact, CallContext context) { | |
85 FLYSArtifact flys = (FLYSArtifact)artifact; | |
86 String theHash = (hash != null) ? hash : flys.hash(); | |
87 | |
88 return (stateId != null && stateId.length() > 0) | |
89 ? flys.compute(context, theHash, stateId, type, false) | |
90 : flys.compute(context, theHash, type, false); | |
91 } | |
92 | |
93 | |
94 /** | |
95 * Return a deep copy. | |
96 */ | |
97 @Override | |
98 public Facet deepCopy() { | |
99 DataFacet copy = new DataFacet(); | |
100 copy.set(this); | |
101 copy.type = type; | |
102 copy.hash = hash; | |
103 copy.stateId = stateId; | |
104 return copy; | |
105 } | |
106 } | |
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |