annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFacet.java @ 5662:7e3cde8b564c

Cosmetics, docs, vimlines.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 11 Apr 2013 12:43:02 +0200
parents e1fd2dfdcb80
children
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
3602
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
3 import de.intevation.artifactdatabase.state.Facet;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
4 import de.intevation.artifacts.Artifact;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
5 import de.intevation.artifacts.CallContext;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
6 import de.intevation.artifacts.DataProvider;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
7 import de.intevation.flys.artifacts.HYKArtifact;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
8 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
9 import de.intevation.flys.model.FastCrossSectionLine;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
10
2133
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.List;
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 org.apache.log4j.Logger;
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
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 /**
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 * Trival Facet for HYKs
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 public class HYKFacet
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 extends DataFacet
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 implements FacetTypes {
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22
2150
0fa37d4de13d Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2133
diff changeset
23 /** House logger. */
2133
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 private static Logger logger = Logger.getLogger(HYKFacet.class);
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 /** Trivial constructor, set (maybe localized) description. */
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 public HYKFacet(int idx, String description) {
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 super(idx, HYK, description, ComputeType.FEED, null, null);
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 }
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 /**
2150
0fa37d4de13d Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2133
diff changeset
33 * Set km from cross section- master to HYKArtifact, then fire up
0fa37d4de13d Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2133
diff changeset
34 * computation.
0fa37d4de13d Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2133
diff changeset
35 *
2133
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 * @param art artifact to get data from.
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 * @param context ignored
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 */
3602
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
39 @Override
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
40 public Object getData(Artifact art, CallContext context) {
2133
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 }
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2150
diff changeset
50
2133
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
3602
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
54 if(crossSection == null) {
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
55 logger.debug("getData: crossSection is null");
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
56 return null;
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
57 }
e1fd2dfdcb80 Issue #806 and NullPointerExceptions in CrossSectionGenerator fixed
Christian Lins <christian.lins@intevation.de>
parents: 3442
diff changeset
58
2133
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 double km = crossSection.getKm();
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 logger.debug("HYKFacet.getData: Master Cross Section is at km: " + km);
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 // Set this km at hyk artifact to be evaluated.
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 HYKArtifact hyk = (HYKArtifact) art;
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 hyk.setKm(km);
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 return hyk.compute(context, hash, stateId, type, false);
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 }
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 /** Do a deep copy. */
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2150
diff changeset
71 @Override
2133
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 public Facet deepCopy() {
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 HYKFacet copy = new HYKFacet(this.index, this.description);
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 copy.set(this);
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 return copy;
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 }
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 }
767ce9d1991f Added HYKFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org