Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | 5642a83420f2 |
children | cd5eb8f5f6f1 |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import de.intevation.artifacts.Artifact; | |
8 import de.intevation.artifacts.CallContext; | |
9 import de.intevation.artifacts.DataProvider; | |
10 | |
11 import de.intevation.artifactdatabase.state.Facet; | |
12 | |
13 import de.intevation.flys.artifacts.HYKArtifact; | |
14 | |
15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
16 import de.intevation.flys.model.FastCrossSectionLine; | |
17 | |
18 | |
19 /** | |
20 * Trival Facet for HYKs | |
21 */ | |
22 public class HYKFacet | |
23 extends DataFacet | |
24 implements FacetTypes { | |
25 | |
26 /** House logger. */ | |
27 private static Logger logger = Logger.getLogger(HYKFacet.class); | |
28 | |
29 | |
30 /** Trivial constructor, set (maybe localized) description. */ | |
31 public HYKFacet(int idx, String description) { | |
32 super(idx, HYK, description, ComputeType.FEED, null, null); | |
33 } | |
34 | |
35 | |
36 /** | |
37 * Set km from cross section- master to HYKArtifact, then fire up | |
38 * computation. | |
39 * | |
40 * @param art artifact to get data from. | |
41 * @param context ignored | |
42 */ | |
43 public Object getData(Artifact art, CallContext context) { | |
44 logger.debug("HYKFacet.getData"); | |
45 | |
46 String dataKey = CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA; | |
47 | |
48 List<DataProvider> providers = context.getDataProvider(dataKey); | |
49 if (providers.size() < 1) { | |
50 logger.warn("Could not find Cross-Section data provider to get master cs km."); | |
51 return null; | |
52 } | |
53 | |
54 FastCrossSectionLine crossSection = (FastCrossSectionLine) providers.get(0) | |
55 .provideData(dataKey, null, context); | |
56 | |
57 double km = crossSection.getKm(); | |
58 logger.debug("HYKFacet.getData: Master Cross Section is at km: " + km); | |
59 | |
60 // Set this km at hyk artifact to be evaluated. | |
61 HYKArtifact hyk = (HYKArtifact) art; | |
62 hyk.setKm(km); | |
63 | |
64 return hyk.compute(context, hash, stateId, type, false); | |
65 } | |
66 | |
67 | |
68 /** Do a deep copy. */ | |
69 @Override | |
70 public Facet deepCopy() { | |
71 HYKFacet copy = new HYKFacet(this.index, this.description); | |
72 copy.set(this); | |
73 return copy; | |
74 } | |
75 } | |
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |