Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.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 | 1481322efc02 |
children | 6aea625190da |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import de.intevation.artifactdatabase.state.Facet; | |
4 | |
5 import de.intevation.artifacts.Artifact; | |
6 import de.intevation.artifacts.CallContext; | |
7 | |
8 import de.intevation.flys.artifacts.FLYSArtifact; | |
9 | |
10 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
11 | |
12 import org.apache.log4j.Logger; | |
13 | |
14 /** | |
15 * Facet of a Waterlevel (WQKms). | |
16 */ | |
17 public class WaterlevelFacet extends DataFacet { | |
18 | |
19 private static Logger logger = Logger.getLogger(WaterlevelFacet.class); | |
20 | |
21 public WaterlevelFacet(int index, String name, String description) { | |
22 super(index, name, description, ComputeType.ADVANCE, null, null); | |
23 } | |
24 | |
25 public WaterlevelFacet( | |
26 int index, | |
27 String name, | |
28 String description, | |
29 ComputeType type, | |
30 String stateID, | |
31 String hash | |
32 ) { | |
33 super(index, name, description, type, hash, stateID); | |
34 } | |
35 | |
36 public WaterlevelFacet() { | |
37 } | |
38 | |
39 protected WQKms [] getWQKms(CalculationResult res) { | |
40 return (WQKms [])res.getData(); | |
41 } | |
42 | |
43 /** | |
44 * Get waterlevel data. | |
45 * @return a WQKms at given index. | |
46 */ | |
47 public Object getData(Artifact artifact, CallContext context) { | |
48 | |
49 if (logger.isDebugEnabled()) { | |
50 logger.debug("Get data for waterlevels at index: " + index + | |
51 " /stateId: " + stateId); | |
52 } | |
53 | |
54 FLYSArtifact winfo = (FLYSArtifact) artifact; | |
55 | |
56 CalculationResult res = (CalculationResult) | |
57 winfo.compute(context, hash, stateId, type, false); | |
58 | |
59 if (res == null) { | |
60 logger.error("WaterlevelFacet.getData: null result"); | |
61 return null; | |
62 } | |
63 | |
64 if (winfo == null) { | |
65 logger.error("WaterlevelFacet.getData: artifact is null"); | |
66 return null; | |
67 } | |
68 | |
69 WQKms [] wqkms = getWQKms(res); | |
70 | |
71 return wqkms != null ? wqkms[index] : null; | |
72 } | |
73 | |
74 | |
75 /** Copy deeply. */ | |
76 @Override | |
77 public Facet deepCopy() { | |
78 WaterlevelFacet copy = new WaterlevelFacet(); | |
79 copy.set(this); | |
80 copy.type = type; | |
81 copy.hash = hash; | |
82 copy.stateId = stateId; | |
83 return copy; | |
84 } | |
85 } | |
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |