comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java @ 2001:28a5c163f9cd

Added partial area-infrastructure. flys-artifacts/trunk@3442 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 16 Dec 2011 14:02:59 +0000
parents
children 7f99845e9499
comparison
equal deleted inserted replaced
2000:e71719483546 2001:28a5c163f9cd
1 package de.intevation.flys.artifacts;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.apache.log4j.Logger;
7
8 import org.w3c.dom.Document;
9
10 import de.intevation.artifacts.Artifact;
11 import de.intevation.artifacts.ArtifactFactory;
12 import de.intevation.artifacts.CallMeta;
13
14 import de.intevation.flys.artifacts.model.AreaFacet;
15
16 import de.intevation.artifacts.common.ArtifactNamespaceContext;
17 import de.intevation.artifacts.common.utils.XMLUtils;
18
19 import de.intevation.flys.artifacts.states.AreaCreationState;
20 import de.intevation.flys.artifacts.states.StaticState;
21
22 import de.intevation.artifactdatabase.state.Facet;
23 import de.intevation.artifactdatabase.state.State;
24
25 import de.intevation.flys.utils.FLYSUtils;
26
27 /**
28 * Artifact describing the area between two WKms.
29 */
30 public class AreaArtifact extends StaticFLYSArtifact {
31
32 /** Access ids of doc. */
33 public static final String XPATH_IDS = "/art:action/art:ids/@value";
34
35 /** Name of Artifact. */
36 public static final String AREA_ARTIFACT_NAME = "area_artifact";
37
38 /** Name of state. */
39 public static final String STATIC_STATE_NAME = "state.area_artifact";
40
41 /** data item name to access upper curve. */
42 public static final String AREA_CURVE_OVER = "area.curve_over";
43
44 /** data item name to access lower curve. */
45 public static final String AREA_CURVE_UNDER = "area.curve_under";
46
47 /** Own logger. */
48 private static final Logger logger =
49 Logger.getLogger(AreaArtifact.class);
50
51
52 /** Return given name. */
53 @Override
54 public String getName() {
55 return AREA_ARTIFACT_NAME;
56 }
57
58
59 /** Store ids, create an AreaFacet. */
60 @Override
61 public void setup(
62 String identifier,
63 ArtifactFactory factory,
64 Object context,
65 CallMeta callMeta,
66 Document data)
67 {
68 logger.info("AreaArtifact.setup");
69
70 super.setup(identifier, factory, context, callMeta, data);
71
72 // TODO ye unused.
73 String ids = XMLUtils.xpathString(
74 data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
75
76 List<Facet> fs = new ArrayList<Facet>();
77 fs.add(new AreaFacet(0, "TODO: I am an AreaFacet"));
78
79 AreaCreationState state = (AreaCreationState) getCurrentState(context);
80
81 if (!fs.isEmpty()) {
82 facets.put(getCurrentStateId(), fs);
83 }
84 }
85
86 // TODO Data is not cached in this way.
87
88 /** Do not copy data from daddyfact. */
89 @Override
90 protected void initialize(
91 Artifact artifact,
92 Object context,
93 CallMeta callMeta)
94 {
95 // do nothing
96 }
97
98
99 /**
100 * Get dataprovider key for the 'lower' curve (we got that information fed
101 * from the client and store it as data).
102 */
103 public String getLowerDPKey() {
104 return getDataAsString(AREA_CURVE_UNDER);
105 }
106
107
108 /**
109 * Get dataprovider key for the 'upper' curve (we got that information fed
110 * from the client and store it as data).
111 */
112 public String getUpperDPKey() {
113 return getDataAsString(AREA_CURVE_OVER);
114 }
115
116
117 /**
118 * Create and return a new AreaCreationState with charting output.
119 */
120 @Override
121 public State getCurrentState(Object cc) {
122 final List<Facet> fs = facets.get(getCurrentStateId());
123
124 AreaCreationState state = new AreaCreationState();
125
126 StaticState.addDefaultChartOutput(state, "cross_section", fs);
127
128 return state;
129 }
130
131
132 /**
133 * Get a list containing the one and only State.
134 * @param context ignored.
135 * @return list with one and only state.
136 */
137 @Override
138 protected List<State> getStates(Object context) {
139 ArrayList<State> states = new ArrayList<State>();
140 states.add(getCurrentState(context));
141
142 return states;
143 }
144
145 /** Trivia. */
146 protected State getState(Object context, String stateID) {
147 return getCurrentState(null);
148 }
149 }
150 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org