comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.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 afc7bfb4800b
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
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
15 import de.intevation.flys.artifacts.states.DefaultState;
16
17 import de.intevation.artifactdatabase.state.Facet;
18
19
20 /**
21 * Artifact to get hydr zones (HYKs).
22 */
23 public class HYKArtifact extends StaticFLYSArtifact {
24
25 /** Name of Artifact. */
26 public static final String HYK_ARTIFACT_NAME = "hyk";
27
28 /** Name of data item keeping the hyk id to load formations from. */
29 public static final String HYK_ID = "hyk_artifact.data.id";
30
31 /** Name of data item keeping the km of cs master. */
32 public static final String HYK_KM = "hyk_artifact.data.km";
33
34 /** Own logger. */
35 private static final Logger logger =
36 Logger.getLogger(HYKArtifact.class);
37
38
39 /** Return given name. */
40 @Override
41 public String getName() {
42 return HYK_ARTIFACT_NAME;
43 }
44
45
46 /** Store ids, do super.setup. */
47 @Override
48 public void setup(
49 String identifier,
50 ArtifactFactory factory,
51 Object context,
52 CallMeta callMeta,
53 Document data)
54 {
55 logger.info("HYKArtifact.setup");
56
57 String ids = getDatacageIDValue(data);
58
59 logger.info("HYKArtifact.setup: id is " + ids);
60
61 addStringData(HYK_ID, ids);
62
63 super.setup(identifier, factory, context, callMeta, data);
64 }
65
66
67 /** Set km as Data. */
68 public void setKm(double km) {
69 addStringData(HYK_KM, Double.toString(km));
70 }
71
72
73 /** Get km from state data. */
74 public double getKm() {
75 Double km = getDataAsDouble(HYK_KM);
76 if (km == null) {
77 // XXX returning 0 is to be compatible to older versions that had an
78 // own method getDataAsDouble that returned 0 if parsing the
79 // parameter failed.
80 return 0;
81 }
82 else {
83 return km;
84 }
85 }
86
87
88 /** Get hyk-id from state data. */
89 public int getHykId() {
90 return getDataAsInteger(HYK_ID);
91 }
92
93
94 /** Do not copy data from daddyfact. */
95 @Override
96 protected void initialize(
97 Artifact artifact,
98 Object context,
99 CallMeta callMeta)
100 {
101 logger.debug("HYKArtifact.initialize");
102 WINFOArtifact winfo = (WINFOArtifact) artifact;
103 importData(winfo, "river");
104
105 List<Facet> fs = new ArrayList<Facet>();
106
107 DefaultState state = (DefaultState) getCurrentState(context);
108 state.computeInit(this, hash(), context, callMeta, fs);
109 if (!fs.isEmpty()) {
110 logger.debug("Facets to add in HYKArtifact.initialize .");
111 facets.put(getCurrentStateId(), fs);
112 }
113 else {
114 logger.debug("No facets to add in HYKArtifact.initialize ("
115 + state.getID() + ").");
116 }
117 }
118
119
120 /**
121 * Determines Facets initial disposition regarding activity (think of
122 * selection in Client ThemeList GUI). This will be checked one time
123 * when the facet enters a collections describe document.
124 *
125 * @param facetName name of the facet.
126 * @param index index of the facet.
127 *
128 * @return Always 0. Hyk Data will enter plots inactive.
129 */
130 @Override
131 public int getInitialFacetActivity(
132 String outputName,
133 String facetName,
134 int index)
135 {
136 return 0;
137 }
138 }
139 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org