comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java @ 2424:092e519ff461

merged flys-artifacts/2.6.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:26 +0200
parents f008c3335a77
children 5642a83420f2
comparison
equal deleted inserted replaced
2392:8112ec686a9a 2424:092e519ff461
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.apache.log4j.Logger;
7
8 import de.intevation.artifacts.Artifact;
9 import de.intevation.artifacts.CallContext;
10
11 import de.intevation.artifactdatabase.state.Facet;
12
13 import de.intevation.flys.artifacts.CrossSectionArtifact;
14
15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
16
17
18 /**
19 * Trival Facet for Cross Sections (profiles).
20 */
21 public class CrossSectionFacet
22 extends BlackboardDataFacet
23 implements FacetTypes {
24
25 public static String BLACKBOARD_CS_MASTER_DATA
26 = "crosssection.masterprofile.data";
27
28 private static Logger logger = Logger.getLogger(CrossSectionFacet.class);
29
30 protected ComputeType type;
31
32
33 /** Trivial constructor, set (maybe localized) description. */
34 public CrossSectionFacet(int idx, String description) {
35 super(idx, CROSS_SECTION, description);
36 type = ComputeType.ADVANCE;
37 }
38
39
40 /** Tell world we know about crosssection masters data and its index. */
41 public List getStaticDataProviderKeys(Artifact art) {
42 CrossSectionArtifact artifact = (CrossSectionArtifact) art;
43 List keys = new ArrayList();
44 if (artifact.isMaster()) {
45 keys.add(BLACKBOARD_CS_MASTER_DATA);
46 }
47 keys.add(artifact.identifier() + getIndex());
48 keys.addAll(super.getStaticDataProviderKeys(art));
49 return keys;
50 }
51
52
53 /**
54 * Can provide the master cross section lines or its index.
55 * @param artifact crosssection-artifact
56 * @param key will respond on BLACKBOARD_CS_MASTER_DATA
57 * @param param ignored
58 * @param context ignored
59 * @return data from artifact (cross section master track).
60 */
61 public Object provideBlackboardData(Artifact artifact,
62 Object key,
63 Object param,
64 CallContext context
65 ) {
66 CrossSectionArtifact crossSection = (CrossSectionArtifact) artifact;
67
68 if (key.equals(BLACKBOARD_CS_MASTER_DATA)) {
69 return crossSection.searchCrossSectionLine();
70 }
71 else if (key.equals(artifact.identifier() + getIndex())) {
72 return getData(artifact, context);
73 }
74 else {
75 Object obj = super.provideBlackboardData(artifact, key, param,
76 context);
77 if (obj == null) {
78 logger.warn("Cannot provide data for key: " + key);
79 }
80 return obj;
81 }
82 }
83
84
85 /**
86 * Gets Cross Section (profile).
87 * @param art artifact to get data from.
88 * @param context ignored
89 */
90 public Object getData(Artifact art, CallContext context) {
91 logger.debug("Get data for cross section");
92
93 CrossSectionArtifact artifact = (CrossSectionArtifact)art;
94
95 return artifact.getCrossSectionData();
96 }
97
98
99 /** Do a deep copy. */
100 @Override
101 public Facet deepCopy() {
102 CrossSectionFacet copy = new CrossSectionFacet(this.index, this.description);
103 copy.set(this);
104 return copy;
105 }
106 }
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org