Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java @ 2683:f5af3adb3b95
Improved datacage configuration for floodmaps and maps and modified the WMS layer artifacts to support names for layers.
flys-artifacts/trunk@4383 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 May 2012 11:14:17 +0000 |
parents | 5afccab9aac1 |
children | 64dc2997b2dd |
comparison
equal
deleted
inserted
replaced
2682:0795c296f718 | 2683:f5af3adb3b95 |
---|---|
25 import de.intevation.artifacts.common.ArtifactNamespaceContext; | 25 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
26 import de.intevation.artifacts.common.utils.XMLUtils; | 26 import de.intevation.artifacts.common.utils.XMLUtils; |
27 | 27 |
28 import de.intevation.flys.backend.SessionFactoryProvider; | 28 import de.intevation.flys.backend.SessionFactoryProvider; |
29 | 29 |
30 import de.intevation.flys.artifacts.resources.Resources; | |
30 import de.intevation.flys.artifacts.states.DefaultState; | 31 import de.intevation.flys.artifacts.states.DefaultState; |
31 import de.intevation.flys.artifacts.model.WMSDBLayerFacet; | 32 import de.intevation.flys.artifacts.model.WMSDBLayerFacet; |
32 import de.intevation.flys.utils.FLYSUtils; | 33 import de.intevation.flys.utils.FLYSUtils; |
33 | 34 |
34 | 35 |
104 private static final Logger logger = Logger.getLogger(WMSDBState.class); | 105 private static final Logger logger = Logger.getLogger(WMSDBState.class); |
105 | 106 |
106 protected FLYSArtifact artifact; | 107 protected FLYSArtifact artifact; |
107 | 108 |
108 protected String name; | 109 protected String name; |
110 protected int riverId; | |
109 | 111 |
110 | 112 |
111 public WMSDBState() {} | 113 public WMSDBState() {} |
112 | 114 |
113 public WMSDBState(FLYSArtifact artifact) { | 115 public WMSDBState(FLYSArtifact artifact) { |
114 this.artifact = artifact; | 116 this.artifact = artifact; |
115 this.name = null; | 117 this.name = null; |
118 this.riverId = 0; | |
116 } | 119 } |
117 | 120 |
118 @Override | 121 @Override |
119 public Object computeInit( | 122 public Object computeInit( |
120 FLYSArtifact artifact, | 123 FLYSArtifact artifact, |
223 return FLYSUtils.isUsingOracle() ? "oraclespatial" : "postgis"; | 226 return FLYSUtils.isUsingOracle() ? "oraclespatial" : "postgis"; |
224 } | 227 } |
225 | 228 |
226 protected String getLabelItem() { | 229 protected String getLabelItem() { |
227 return null; | 230 return null; |
231 } | |
232 | |
233 public int getRiverId() { | |
234 if (riverId == 0) { | |
235 String ids = artifact.getDataAsString("ids"); | |
236 String[] parts = ids.split(";"); | |
237 | |
238 try { | |
239 riverId = Integer.valueOf(parts[0]); | |
240 } | |
241 catch (NumberFormatException nfe) { | |
242 logger.error("Cannot parse river id from '" + parts[0] + "'"); | |
243 } | |
244 } | |
245 | |
246 return riverId; | |
228 } | 247 } |
229 | 248 |
230 /** | 249 /** |
231 * Returns the name of the WMS layer. This method extracts the name | 250 * Returns the name of the WMS layer. This method extracts the name |
232 * from 'ids' data string. It is expected, that the 'ids' string is | 251 * from 'ids' data string. It is expected, that the 'ids' string is |
236 */ | 255 */ |
237 public String getName() { | 256 public String getName() { |
238 if (name == null) { | 257 if (name == null) { |
239 String ids = artifact.getDataAsString("ids"); | 258 String ids = artifact.getDataAsString("ids"); |
240 | 259 |
241 String parts[] = ids.split(";"); | 260 String parts[] = ids != null ? ids.split(";") : null; |
242 name = parts[1]; | 261 |
262 if (parts != null && parts.length >= 2) { | |
263 name = parts[1]; | |
264 } | |
243 } | 265 } |
244 | 266 |
245 return name; | 267 return name; |
246 } | 268 } |
247 | 269 |
270 | |
271 /** | |
272 * Returns the name of the layer (returned by getName()) or the layer | |
273 * type if the name is empty. The layer type is created by an i18n | |
274 * string of getFacetType(). | |
275 * | |
276 * @param meta A CallMeta used for i18n. | |
277 * | |
278 * @return the name of the layer or its type if name is empty. | |
279 */ | |
280 protected String getTitle(CallMeta meta) { | |
281 String name = getName(); | |
282 | |
283 return name != null && name.length() > 0 | |
284 ? name | |
285 : Resources.getMsg( | |
286 meta, | |
287 getFacetType(), | |
288 getFacetType()); | |
289 } | |
290 | |
291 | |
248 protected abstract String getFacetType(); | 292 protected abstract String getFacetType(); |
249 | |
250 protected abstract String getTitle(CallMeta meta); | |
251 | 293 |
252 protected abstract String getUrl(); | 294 protected abstract String getUrl(); |
253 | 295 |
254 protected abstract String getSrid(); | 296 protected abstract String getSrid(); |
255 | 297 |