comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java @ 3814:8083f6384023

merged flys-artifacts/pre2.6-2012-01-04
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:56 +0200
parents efe1b8545f5c
children 70ef5fdc7414
comparison
equal deleted inserted replaced
1491:2a00f4849738 3814:8083f6384023
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.DefaultFacet;
7 import de.intevation.artifactdatabase.state.Facet;
8
9 import de.intevation.flys.artifacts.FLYSArtifact;
10
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
12
13 public class DataFacet
14 extends DefaultFacet
15 {
16 protected ComputeType type;
17 protected String hash;
18 protected String stateId;
19
20
21 /** Trivial constructor. */
22 public DataFacet() {
23 }
24
25 /**
26 * Defaults to ADVANCE Compute type.
27 * @param name Name of the facet.
28 * @param description maybe localized description of the facet.
29 */
30 public DataFacet(String name, String description) {
31 this(name, description, ComputeType.ADVANCE);
32 }
33
34 public DataFacet(String name, String description, ComputeType type) {
35 this(name, description, type, null);
36 }
37
38 public DataFacet(
39 String name,
40 String description,
41 ComputeType type,
42 String hash
43 ) {
44 super(name, description);
45 this.type = type;
46 this.hash = hash;
47 }
48
49
50 public DataFacet(
51 String name,
52 String description,
53 ComputeType type,
54 String hash,
55 String stateId
56 ) {
57 super(name, description);
58 this.type = type;
59 this.hash = hash;
60 this.stateId = stateId;
61 }
62
63
64 /**
65 * Return computation result.
66 */
67 @Override
68 public Object getData(Artifact artifact, CallContext context) {
69 FLYSArtifact flys = (FLYSArtifact)artifact;
70 String theHash = (hash != null) ? hash : flys.hash();
71
72 return (stateId != null && stateId.length() > 0)
73 ? flys.compute(context, theHash, stateId, type, false)
74 : flys.compute(context, theHash, type, false);
75 }
76
77
78 /**
79 * Return a deep copy.
80 */
81 @Override
82 public Facet deepCopy() {
83 DataFacet copy = new DataFacet();
84 copy.set(this);
85 copy.type = type;
86 copy.hash = hash;
87 copy.stateId = stateId;
88 return copy;
89 }
90 }
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org