annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java @ 1063:e7c1ebfc2701

Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed. flys-artifacts/trunk@2541 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 24 Aug 2011 07:51:12 +0000
parents ae198bef4ba0
children 7f5426c69ee0
rev   line source
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
3 import java.util.HashMap;
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
5 import java.util.Map;
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
6
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
7 import javax.xml.xpath.XPathConstants;
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import org.apache.log4j.Logger;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
11 import org.w3c.dom.Document;
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
12 import org.w3c.dom.Node;
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
13
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.CallMeta;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
16 import de.intevation.artifacts.common.utils.Config;
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
17 import de.intevation.artifacts.common.utils.XMLUtils;
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
18
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.artifactdatabase.state.Facet;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.artifacts.FLYSArtifact;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.artifacts.model.WMSLayerFacet;
954
a5ea28339e5b Set the extent of created WMSLayerFacets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 942
diff changeset
23 import de.intevation.flys.artifacts.resources.Resources;
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 public class WMSBackgroundState extends OutputState {
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
954
a5ea28339e5b Set the extent of created WMSLayerFacets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 942
diff changeset
29 public static final String I18N_DESCRIPTION = "floodmap.wmsbackground";
a5ea28339e5b Set the extent of created WMSLayerFacets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 942
diff changeset
30
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
31 public static final String XPATH_WMS_URL =
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
32 "/artifact-database/floodmap/river[@name=$name]/background-wms/@url";
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
33
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
34 public static final String XPATH_WMS_LAYER =
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
35 "/artifact-database/floodmap/river[@name=$name]/background-wms/@layers";
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
36
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
37
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
38 protected String url;
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
39 protected String layer;
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
40
954
a5ea28339e5b Set the extent of created WMSLayerFacets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 942
diff changeset
41
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 private static final Logger logger = Logger.getLogger(WMSBackgroundState.class);
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
44
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
45 @Override
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
46 public void setup(Node config) {
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
47 super.setup(config);
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
48
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
49 logger.debug("WMSBackgroundState.setup()");
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
50 }
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
51
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
52
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 @Override
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 public Object computeInit(
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 FLYSArtifact artifact,
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 String hash,
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 956
diff changeset
57 Object context,
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 CallMeta meta,
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 List<Facet> facets
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 ) {
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 logger.debug("WMSBackgroundState.computeInit()");
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
63 if (url == null || layer == null) {
1063
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
64 Document cfg = Config.getConfig();
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
65
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
66 String river = artifact.getDataAsString("river");
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
67
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
68 Map<String, String> variables = new HashMap<String, String>();
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
69 variables.put("name", river);
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
70
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
71 url = (String) XMLUtils.xpath(
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
72 cfg,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
73 XPATH_WMS_URL,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
74 XPathConstants.STRING,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
75 null,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
76 variables);
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
77
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
78 layer = (String) XMLUtils.xpath(
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
79 cfg,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
80 XPATH_WMS_LAYER,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
81 XPathConstants.STRING,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
82 null,
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
83 variables);
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
84 }
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
85
e7c1ebfc2701 Repaired xpath expressions for wms srid and background layers that broke after the floodmap config structure changed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
86 if (url == null || layer == null) {
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
87 logger.warn("No background layers currently configured:");
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
88 logger.warn("... add config for WMS url: " + XPATH_WMS_URL);
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
89 logger.warn("... add config for WMS layer: " + XPATH_WMS_LAYER);
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
90 return null;
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
91 }
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
92
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 WMSLayerFacet facet = new WMSLayerFacet(
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 0,
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 FLOODMAP_WMSBACKGROUND,
954
a5ea28339e5b Set the extent of created WMSLayerFacets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 942
diff changeset
96 Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION),
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 ComputeType.INIT,
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 getID(), hash,
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
99 url);
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
956
1cf7b4ee7b6d Made the background layer in floodmaps configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 955
diff changeset
101 facet.addLayer(layer);
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 facets.add(facet);
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 return null;
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 }
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 }
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org