Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java @ 1926:fde3db5e68e8
Added a new Artifact to enable users to add external WMS layers to floodmaps.
flys-artifacts/trunk@3302 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 22 Nov 2011 20:04:46 +0000 |
parents | 7f5426c69ee0 |
children | 453d2d0c4258 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java Tue Nov 22 14:00:55 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java Tue Nov 22 20:04:46 2011 +0000 @@ -42,6 +42,10 @@ protected String layer; protected String srid; + protected Document cfg; + + protected Map<String, String> variables; + private static final Logger logger = Logger.getLogger(WMSBackgroundState.class); @@ -64,34 +68,14 @@ ) { logger.debug("WMSBackgroundState.computeInit()"); - if (url == null || layer == null) { - Document cfg = Config.getConfig(); - - String river = artifact.getDataAsString("river"); - - Map<String, String> variables = new HashMap<String, String>(); - variables.put("name", river); + initVariables(artifact); - srid = (String) XMLUtils.xpath( - cfg, - XPATH_SRID, - XPathConstants.STRING, - null, - variables); - - url = (String) XMLUtils.xpath( - cfg, - XPATH_WMS_URL, - XPathConstants.STRING, - null, - variables); - - layer = (String) XMLUtils.xpath( - cfg, - XPATH_WMS_LAYER, - XPathConstants.STRING, - null, - variables); + if (url == null || layer == null) { + // XXX I don't remember why 'srid', 'url' and 'layer' are member + // variables. I think the reason was buffering those values. + srid = getSrid(); + url = getUrl(); + layer = getLayer(); } if (url == null || layer == null) { @@ -103,8 +87,8 @@ WMSLayerFacet facet = new WMSLayerFacet( 0, - FLOODMAP_WMSBACKGROUND, - Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION), + getFacetType(), + getTitle(meta), ComputeType.INIT, getID(), hash, url); @@ -116,5 +100,62 @@ return null; } + + + protected Document getConfig() { + if (cfg == null) { + cfg = Config.getConfig(); + } + + return cfg; + } + + + protected void initVariables(FLYSArtifact artifact) { + String river = artifact.getDataAsString("river"); + + variables = new HashMap<String, String>(); + variables.put("name", river); + } + + + protected String getFacetType() { + return FLOODMAP_WMSBACKGROUND; + } + + + protected String getSrid() { + return (String) XMLUtils.xpath( + getConfig(), + XPATH_SRID, + XPathConstants.STRING, + null, + variables); + } + + + protected String getUrl() { + return (String) XMLUtils.xpath( + getConfig(), + XPATH_WMS_URL, + XPathConstants.STRING, + null, + variables); + } + + + protected String getLayer() { + return (String) XMLUtils.xpath( + getConfig(), + XPATH_WMS_LAYER, + XPathConstants.STRING, + null, + variables); + } + + + protected String getTitle(CallMeta meta) { + return Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :