comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/DataFacet.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/DataFacet.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.model;
2
3 import org.dive4elements.artifacts.Artifact;
4 import org.dive4elements.artifacts.CallContext;
5
6 import org.dive4elements.artifactdatabase.state.Facet;
7
8 import org.dive4elements.river.artifacts.FLYSArtifact;
9
10 import org.dive4elements.river.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 :

http://dive4elements.wald.intevation.org