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