comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java @ 2122:81312f84689a

Refactored to easier enjoy benefits of caching. flys-artifacts/trunk@3692 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 17 Jan 2012 08:01:22 +0000
parents 9d79f6ceefca
children 7a8f52267a5c
comparison
equal deleted inserted replaced
2121:70ef5fdc7414 2122:81312f84689a
5 import de.intevation.artifacts.Artifact; 5 import de.intevation.artifacts.Artifact;
6 import de.intevation.artifacts.CallContext; 6 import de.intevation.artifacts.CallContext;
7 7
8 import de.intevation.artifactdatabase.state.Facet; 8 import de.intevation.artifactdatabase.state.Facet;
9 9
10 import de.intevation.flys.artifacts.WINFOArtifact; 10 import de.intevation.flys.artifacts.FLYSArtifact;
11 11
12 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; 12 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
13 13
14 14
15 /** 15 /**
16 * Facet of a Waterlevel (WQKms). 16 * Facet of a Waterlevel (WQKms).
17 */ 17 */
18 public class WaterlevelFacet extends BlackboardDataFacet { 18 public class WaterlevelFacet extends DataFacet {
19 19
20 private static Logger logger = Logger.getLogger(WaterlevelFacet.class); 20 private static Logger logger = Logger.getLogger(WaterlevelFacet.class);
21 21
22 protected ComputeType type;
23 protected String stateID;
24 protected String hash;
25
26
27 public WaterlevelFacet(int index, String name, String description) { 22 public WaterlevelFacet(int index, String name, String description) {
28 this(index, name, description, ComputeType.ADVANCE, null, null); 23 super(index, name, description, ComputeType.ADVANCE, null, null);
29 } 24 }
30
31
32 public WaterlevelFacet() {
33 }
34
35 25
36 public WaterlevelFacet( 26 public WaterlevelFacet(
37 int index, 27 int index,
38 String name, 28 String name,
39 String description, 29 String description,
40 ComputeType type, 30 ComputeType type,
41 String stateID, 31 String stateID,
42 String hash 32 String hash
43 33
44 ) { 34 ) {
45 super(index, name, description); 35 super(index, name, description, type, stateID, hash);
46 this.type = type; 36 }
47 this.stateID = stateID; 37
48 this.hash = hash; 38 public WaterlevelFacet() {
49 } 39 }
50 40
51 41
52 /** 42 /**
53 * Get waterlevel data. 43 * Get waterlevel data.
54 * @return a WQKms at given index. 44 * @return a WQKms at given index.
55 */ 45 */
56 public Object getData(Artifact artifact, CallContext context) { 46 public Object getData(Artifact artifact, CallContext context) {
57 logger.debug("Get data for waterlevels at index: " + index); 47 logger.debug("Get data for waterlevels at index: " + index);
58 48
59 WINFOArtifact winfo = (WINFOArtifact)artifact; 49 FLYSArtifact winfo = (FLYSArtifact)artifact;
60 50
61 CalculationResult res = (CalculationResult) 51 CalculationResult res = (CalculationResult)
62 winfo.compute(context, hash, stateID, type, false); 52 winfo.compute(context, hash, stateId, type, false);
63 53
64 WQKms [] wqkms = (WQKms [])res.getData(); 54 WQKms [] wqkms = (WQKms [])res.getData();
65 55
66 return wqkms[index]; 56 return wqkms[index];
67 } 57 }
71 @Override 61 @Override
72 public Facet deepCopy() { 62 public Facet deepCopy() {
73 WaterlevelFacet copy = new WaterlevelFacet(); 63 WaterlevelFacet copy = new WaterlevelFacet();
74 copy.set(this); 64 copy.set(this);
75 copy.type = type; 65 copy.type = type;
76 copy.stateID = stateID; 66 copy.stateId = stateId;
77 copy.hash = hash; 67 copy.hash = hash;
78 return copy; 68 return copy;
79 } 69 }
80 } 70 }
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org