Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.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 | 5642a83420f2 |
children |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.List; | |
4 import java.util.ArrayList; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import de.intevation.artifacts.Artifact; | |
9 import de.intevation.artifacts.CallContext; | |
10 | |
11 import de.intevation.artifactdatabase.state.DefaultFacet; | |
12 import de.intevation.artifactdatabase.state.Facet; | |
13 | |
14 import de.intevation.flys.artifacts.FLYSArtifact; | |
15 import de.intevation.flys.artifacts.WINFOArtifact; | |
16 | |
17 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
18 | |
19 | |
20 /** | |
21 * Data of a duration curve. | |
22 */ | |
23 public class DurationCurveFacet extends DefaultFacet { | |
24 | |
25 private static Logger logger = Logger.getLogger(DurationCurveFacet.class); | |
26 | |
27 /** Blackboard data provider key for durationcurve (wqday) data. */ | |
28 public static String BB_DURATIONCURVE = "durationcurve"; | |
29 | |
30 /** Blackboard data provider key for km of durationcurve. */ | |
31 public static String BB_DURATIONCURVE_KM = "durationcurve.km"; | |
32 | |
33 public DurationCurveFacet() { | |
34 } | |
35 | |
36 public DurationCurveFacet(String name, String description) { | |
37 super(0, name, description); | |
38 } | |
39 | |
40 | |
41 /** | |
42 * Expose state computation from WINFOArtifact. | |
43 */ | |
44 public Object getData(Artifact artifact, CallContext context) { | |
45 logger.debug("Get data for duration curve data"); | |
46 | |
47 WINFOArtifact winfo = (WINFOArtifact)artifact; | |
48 | |
49 CalculationResult cr = (CalculationResult)winfo.compute( | |
50 context, ComputeType.ADVANCE, false); | |
51 | |
52 return cr.getData(); | |
53 } | |
54 | |
55 | |
56 @Override | |
57 public List getStaticDataProviderKeys(Artifact art) { | |
58 List list = new ArrayList(); | |
59 list.add(BB_DURATIONCURVE); | |
60 list.add(BB_DURATIONCURVE_KM); | |
61 return list; | |
62 } | |
63 | |
64 | |
65 /** | |
66 * Can provide whatever getData returns and additionally the location. | |
67 * @param key will respond on BB_DURATIONCURVE +KM | |
68 * @param param ignored | |
69 * @param context ignored | |
70 * @return whatever getData delivers or location. | |
71 */ | |
72 @Override | |
73 public Object provideBlackboardData(Artifact artifact, | |
74 Object key, | |
75 Object param, | |
76 CallContext context | |
77 ) { | |
78 if (key.equals(BB_DURATIONCURVE)) { | |
79 return getData(artifact, context); | |
80 } | |
81 else if (key.equals(BB_DURATIONCURVE_KM)) { | |
82 return ((FLYSArtifact)artifact).getDataAsString("ld_locations"); | |
83 } | |
84 else { | |
85 return null; | |
86 } | |
87 } | |
88 | |
89 | |
90 /** Create a deep copy. */ | |
91 @Override | |
92 public Facet deepCopy() { | |
93 DurationCurveFacet copy = new DurationCurveFacet(); | |
94 copy.set(this); | |
95 return copy; | |
96 } | |
97 } | |
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |