Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java @ 5272:da3101abc9da
Use river name as layername in new map projects.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 13 Mar 2013 12:47:51 +0100 |
parents | 5642a83420f2 |
children |
rev | line source |
---|---|
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
2746
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
3 import java.util.List; |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
4 import java.util.ArrayList; |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
5 |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.Artifact; |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.CallContext; |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.DefaultFacet; |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
12 import de.intevation.artifactdatabase.state.Facet; |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
2746
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
14 import de.intevation.flys.artifacts.FLYSArtifact; |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.artifacts.WINFOArtifact; |
697
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
16 |
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
696
diff
changeset
|
17 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
2746
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
20 /** |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
21 * Data of a duration curve. |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
22 */ |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 public class DurationCurveFacet extends DefaultFacet { |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 private static Logger logger = Logger.getLogger(DurationCurveFacet.class); |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
2746
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
27 /** Blackboard data provider key for durationcurve (wqday) data. */ |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
28 public static String BB_DURATIONCURVE = "durationcurve"; |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
29 |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
30 /** Blackboard data provider key for km of durationcurve. */ |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
31 public static String BB_DURATIONCURVE_KM = "durationcurve.km"; |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
32 |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
33 public DurationCurveFacet() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
34 } |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
36 public DurationCurveFacet(String name, String description) { |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
37 super(0, name, description); |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 } |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
2746
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
41 /** |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
42 * Expose state computation from WINFOArtifact. |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
43 */ |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 public Object getData(Artifact artifact, CallContext context) { |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
45 logger.debug("Get data for duration curve data"); |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
47 WINFOArtifact winfo = (WINFOArtifact)artifact; |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
49 CalculationResult cr = (CalculationResult)winfo.compute( |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
50 context, ComputeType.ADVANCE, false); |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
51 |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
52 return cr.getData(); |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 } |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
54 |
2746
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
55 |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
56 @Override |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
57 public List getStaticDataProviderKeys(Artifact art) { |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
58 List list = new ArrayList(); |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
59 list.add(BB_DURATIONCURVE); |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
60 list.add(BB_DURATIONCURVE_KM); |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
61 return list; |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
62 } |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
63 |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
64 |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
65 /** |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
66 * Can provide whatever getData returns and additionally the location. |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
67 * @param key will respond on BB_DURATIONCURVE +KM |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
68 * @param param ignored |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
69 * @param context ignored |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
70 * @return whatever getData delivers or location. |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
71 */ |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
72 @Override |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
73 public Object provideBlackboardData(Artifact artifact, |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
74 Object key, |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
75 Object param, |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
76 CallContext context |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
77 ) { |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
78 if (key.equals(BB_DURATIONCURVE)) { |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
79 return getData(artifact, context); |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
80 } |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
81 else if (key.equals(BB_DURATIONCURVE_KM)) { |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
82 return ((FLYSArtifact)artifact).getDataAsString("ld_locations"); |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
83 } |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
84 else { |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
85 return null; |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
86 } |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
87 } |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
88 |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
89 |
4634cf5574f7
Let DurationCurveFacet provide relevant data via Blackboard.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1061
diff
changeset
|
90 /** Create a deep copy. */ |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2746
diff
changeset
|
91 @Override |
1061
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
92 public Facet deepCopy() { |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
93 DurationCurveFacet copy = new DurationCurveFacet(); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
94 copy.set(this); |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
95 return copy; |
b1b0a0b61845
Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
96 } |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 } |
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |