Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java @ 2793:6310b1582f2d
merged flys-artifacts/2.7
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:30 +0200 |
parents | 2f7fed1eb4bf |
children | 5642a83420f2 |
comparison
equal
deleted
inserted
replaced
2548:ada02bbd3b7f | 2793:6310b1582f2d |
---|---|
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.artifactdatabase.state.Facet; | |
11 | |
12 import de.intevation.artifacts.Artifact; | |
13 import de.intevation.artifacts.ArtifactFactory; | |
14 import de.intevation.artifacts.CallMeta; | |
15 | |
16 import de.intevation.artifacts.common.utils.XMLUtils; | |
17 | |
18 import de.intevation.flys.artifacts.model.FacetTypes; | |
19 import de.intevation.flys.artifacts.model.WQKms; | |
20 import de.intevation.flys.artifacts.model.WKmsFactory; | |
21 import de.intevation.flys.artifacts.model.WQKmsFactory; | |
22 | |
23 import de.intevation.flys.artifacts.states.DefaultState; | |
24 | |
25 | |
26 /** | |
27 * Artifact to access additional "waterlevel/discharge"-type of data, like | |
28 * fixation measurements. | |
29 * | |
30 * This artifact neglects (Static)FLYSArtifacts capabilities of interaction | |
31 * with the StateEngine by overriding the getState*-methods. | |
32 */ | |
33 public class StaticWQKmsArtifact | |
34 extends StaticFLYSArtifact | |
35 implements FacetTypes | |
36 { | |
37 /** The logger for this class. */ | |
38 private static Logger logger = | |
39 Logger.getLogger(StaticWQKmsArtifact.class); | |
40 | |
41 public static final String STATIC_STATE_NAME = | |
42 "state.additional_wqkms.static"; | |
43 | |
44 | |
45 /** | |
46 * Trivial Constructor. | |
47 */ | |
48 public StaticWQKmsArtifact() { | |
49 logger.debug("StaticWQKmsArtifact.StaticWQKmsArtifact"); | |
50 } | |
51 | |
52 | |
53 /** | |
54 * Gets called from factory, to set things up. | |
55 */ | |
56 @Override | |
57 public void setup( | |
58 String identifier, | |
59 ArtifactFactory factory, | |
60 Object context, | |
61 CallMeta callMeta, | |
62 Document data) | |
63 { | |
64 logger.debug("StaticWQKmsArtifact.setup"); | |
65 | |
66 // Store the 'ids' (from datacage). | |
67 logger.debug("StaticWQKmsArtiact.setup" + XMLUtils.toString(data)); | |
68 | |
69 String code = getDatacageIDValue(data); | |
70 addStringData("ids", code); | |
71 if (code != null) { | |
72 String [] parts = code.split("-"); | |
73 | |
74 if (parts.length >= 4) { | |
75 int col = Integer.valueOf(parts[2]); | |
76 int wst = Integer.valueOf(parts[3]); | |
77 | |
78 addStringData("col_pos", parts[2]); | |
79 addStringData("wst_id", parts[3]); | |
80 } | |
81 } | |
82 | |
83 // Do this AFTER we have set the col_pos etc. | |
84 super.setup(identifier, factory, context, callMeta, data); | |
85 } | |
86 | |
87 | |
88 /** | |
89 * Called via setup. | |
90 * | |
91 * @param artifact The master-artifact. | |
92 */ | |
93 @Override | |
94 protected void initialize( | |
95 Artifact artifact, | |
96 Object context, | |
97 CallMeta meta) | |
98 { | |
99 logger.debug("StaticWQKmsArtifact.initialize"); | |
100 WINFOArtifact winfo = (WINFOArtifact) artifact; | |
101 // TODO: The river is of no interest, so far., also use importData | |
102 importData(winfo, "river"); | |
103 | |
104 List<Facet> fs = new ArrayList<Facet>(); | |
105 | |
106 DefaultState state = (DefaultState) getCurrentState(context); | |
107 state.computeInit(this, hash(), context, meta, fs); | |
108 if (!fs.isEmpty()) { | |
109 logger.debug("Facets to add in StaticWQKmsArtifact.initialize ."); | |
110 facets.put(getCurrentStateId(), fs); | |
111 } | |
112 else { | |
113 logger.debug("No facets to add in StaticWQKmsArtifact.initialize (" | |
114 + state.getID() + ")."); | |
115 } | |
116 } | |
117 | |
118 | |
119 /** | |
120 * Get WQKms from factory. | |
121 * @return WQKms according to parameterization (can be null); | |
122 */ | |
123 public WQKms getWQKms() { | |
124 logger.debug("StaticWQKmsArtifact.getWQKms"); | |
125 | |
126 int col = Integer.valueOf(getDataAsString("col_pos")); | |
127 int wst = Integer.valueOf(getDataAsString("wst_id")); | |
128 | |
129 /** TODO do not run twice against db to do this. */ | |
130 String wkmsName = WKmsFactory.getWKmsName(col, wst); | |
131 | |
132 WQKms res = WQKmsFactory.getWQKms( | |
133 Integer.valueOf(getDataAsString("col_pos")), | |
134 Integer.valueOf(getDataAsString("wst_id"))); | |
135 res.setName(wkmsName); | |
136 return res; | |
137 } | |
138 | |
139 | |
140 /** | |
141 * Determines Facets initial disposition regarding activity (think of | |
142 * selection in Client ThemeList GUI). This will be checked one time | |
143 * when the facet enters a collections describe document. | |
144 * | |
145 * @param facetName name of the facet. | |
146 * @param index index of the facet. | |
147 * | |
148 * @return Always 0. Static Data will enter plots inactive. | |
149 */ | |
150 @Override | |
151 public int getInitialFacetActivity( | |
152 String outputName, | |
153 String facetName, | |
154 int index) | |
155 { | |
156 return 0; | |
157 } | |
158 | |
159 | |
160 /** Return specific name. */ | |
161 public String getName() { | |
162 return "staticwqkms"; | |
163 } | |
164 | |
165 // TODO implement deepCopy. | |
166 } | |
167 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |