Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java @ 2149:b5f3b29544ea
Added cache definition for hyks.
flys-artifacts/trunk@3731 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 20 Jan 2012 08:30:50 +0000 |
parents | 767ce9d1991f |
children | 0fa37d4de13d |
rev | line source |
---|---|
2133
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.DataProvider; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.Facet; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.HYKArtifact; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.model.FastCrossSectionLine; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 /** |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 * Trival Facet for HYKs |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 */ |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 public class HYKFacet |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 extends DataFacet |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 implements FacetTypes { |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 private static Logger logger = Logger.getLogger(HYKFacet.class); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 /** Trivial constructor, set (maybe localized) description. */ |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 public HYKFacet(int idx, String description) { |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 super(idx, HYK, description, ComputeType.FEED, null, null); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 } |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 /** |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 * |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 * @param art artifact to get data from. |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 * @param context ignored |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 */ |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 public Object getData(Artifact art, CallContext context) { |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 logger.debug("HYKFacet.getData"); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 String dataKey = CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 List<DataProvider> providers = context.getDataProvider(dataKey); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 if (providers.size() < 1) { |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 logger.warn("Could not find Cross-Section data provider to get master cs km."); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 return null; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 } |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 FastCrossSectionLine crossSection = (FastCrossSectionLine) providers.get(0) |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 .provideData(dataKey, null, context); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 double km = crossSection.getKm(); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 logger.debug("HYKFacet.getData: Master Cross Section is at km: " + km); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 // Set this km at hyk artifact to be evaluated. |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 HYKArtifact hyk = (HYKArtifact) art; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 hyk.setKm(km); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 return hyk.compute(context, hash, stateId, type, false); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 } |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 /** Do a deep copy. */ |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 @Override |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 public Facet deepCopy() { |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 HYKFacet copy = new HYKFacet(this.index, this.description); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 copy.set(this); |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 return copy; |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 } |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 } |
767ce9d1991f
Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |