Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java @ 4656:442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
On startup the RiverMapfileGeneratorStarter is called by the server app.
The starter invokes a call to RiverMapfileGenerator.generate() which
reads all available rivers from the database and generates
layers for each river (in theory...uncompleted) in a
river.map file.
The old MapfileGenerator which generates layers that have
artifact dependencies is now in ArtifactMapfileGenerator.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 11 Dec 2012 15:24:24 +0100 |
parents | e29f368c09ba |
children | b26465581abf |
comparison
equal
deleted
inserted
replaced
4655:cd44d28d0fbc | 4656:442fbb290fa8 |
---|---|
1 package de.intevation.flys.artifacts.context; | 1 package de.intevation.flys.artifacts.context; |
2 | |
3 import de.intevation.artifactdatabase.state.State; | |
4 import de.intevation.artifactdatabase.state.StateEngine; | |
5 import de.intevation.artifactdatabase.transition.Transition; | |
6 import de.intevation.artifactdatabase.transition.TransitionEngine; | |
7 import de.intevation.artifacts.ArtifactContextFactory; | |
8 import de.intevation.artifacts.GlobalContext; | |
9 import de.intevation.artifacts.common.utils.Config; | |
10 import de.intevation.artifacts.common.utils.XMLUtils; | |
11 import de.intevation.flys.artifacts.model.Module; | |
12 import de.intevation.flys.artifacts.model.ZoomScale; | |
13 import de.intevation.flys.artifacts.states.StateFactory; | |
14 import de.intevation.flys.artifacts.transitions.TransitionFactory; | |
15 import de.intevation.flys.themes.Theme; | |
16 import de.intevation.flys.themes.ThemeFactory; | |
17 import de.intevation.flys.themes.ThemeGroup; | |
18 import de.intevation.flys.themes.ThemeMapping; | |
2 | 19 |
3 import java.io.File; | 20 import java.io.File; |
4 import java.util.ArrayList; | 21 import java.util.ArrayList; |
5 import java.util.HashMap; | 22 import java.util.HashMap; |
6 import java.util.List; | 23 import java.util.List; |
7 import java.util.Map; | 24 import java.util.Map; |
8 | 25 |
9 import javax.xml.xpath.XPathConstants; | 26 import javax.xml.xpath.XPathConstants; |
10 | 27 |
11 import org.apache.log4j.Logger; | 28 import org.apache.log4j.Logger; |
12 | |
13 import org.w3c.dom.Document; | 29 import org.w3c.dom.Document; |
14 import org.w3c.dom.Element; | 30 import org.w3c.dom.Element; |
15 import org.w3c.dom.Node; | 31 import org.w3c.dom.Node; |
16 import org.w3c.dom.NodeList; | 32 import org.w3c.dom.NodeList; |
17 | |
18 import de.intevation.artifacts.ArtifactContextFactory; | |
19 import de.intevation.artifacts.GlobalContext; | |
20 | |
21 import de.intevation.artifacts.common.utils.XMLUtils; | |
22 import de.intevation.artifacts.common.utils.Config; | |
23 | |
24 import de.intevation.artifactdatabase.state.State; | |
25 import de.intevation.artifactdatabase.state.StateEngine; | |
26 import de.intevation.artifactdatabase.transition.Transition; | |
27 import de.intevation.artifactdatabase.transition.TransitionEngine; | |
28 | |
29 import de.intevation.flys.artifacts.model.Module; | |
30 import de.intevation.flys.artifacts.model.ZoomScale; | |
31 import de.intevation.flys.artifacts.states.StateFactory; | |
32 import de.intevation.flys.artifacts.transitions.TransitionFactory; | |
33 import de.intevation.flys.themes.Theme; | |
34 import de.intevation.flys.themes.ThemeGroup; | |
35 import de.intevation.flys.themes.ThemeFactory; | |
36 import de.intevation.flys.themes.ThemeMapping; | |
37 | 33 |
38 | 34 |
39 /** | 35 /** |
40 * The ArtifactContextFactory is used to initialize basic components and put | 36 * The ArtifactContextFactory is used to initialize basic components and put |
41 * them into the global context of the application. | 37 * them into the global context of the application. |
92 * components required by the application. | 88 * components required by the application. |
93 * | 89 * |
94 * @param config The artifact server configuration. | 90 * @param config The artifact server configuration. |
95 * @return a FLYSArtifactContext. | 91 * @return a FLYSArtifactContext. |
96 */ | 92 */ |
93 @Override | |
97 public GlobalContext createArtifactContext(Document config) { | 94 public GlobalContext createArtifactContext(Document config) { |
98 FLYSContext context = new FLYSContext(config); | 95 FLYSContext context = new FLYSContext(config); |
99 | 96 |
100 configureTransitions(config, context); | 97 configureTransitions(config, context); |
101 configureStates(config, context); | 98 configureStates(config, context); |
102 configureOutGenerators(config, context); | 99 configureOutGenerators(config, context); |
103 configureThemes(config, context); | 100 configureThemes(config, context); |
104 configureThemesMappings(config, context); | 101 configureThemesMappings(config, context); |
105 configureRiverWMS(config, context); | 102 configureFloodmapWMS(config, context); |
106 configureModules(config, context); | 103 configureModules(config, context); |
107 configureZoomScales(config, context); | 104 configureZoomScales(config, context); |
108 | 105 |
109 return context; | 106 return context; |
110 } | 107 } |
111 | 108 |
112 | 109 |
113 private void configureZoomScales(Document config, FLYSContext context) { | 110 protected void configureZoomScales(Document config, FLYSContext context) { |
114 NodeList list = (NodeList)XMLUtils.xpath( | 111 NodeList list = (NodeList)XMLUtils.xpath( |
115 config, | 112 config, |
116 XPATH_ZOOM_SCALES, | 113 XPATH_ZOOM_SCALES, |
117 XPathConstants.NODESET); | 114 XPathConstants.NODESET); |
118 ZoomScale scale = new ZoomScale(); | 115 ZoomScale scale = new ZoomScale(); |
276 * | 273 * |
277 * @param config the config document. | 274 * @param config the config document. |
278 * @param context the FLYSContext. | 275 * @param context the FLYSContext. |
279 */ | 276 */ |
280 protected void configureOutGenerators(Document config, FLYSContext context){ | 277 protected void configureOutGenerators(Document config, FLYSContext context){ |
281 Map<String, Class> generators = new HashMap<String, Class>(); | 278 Map<String, Class<?>> generators = new HashMap<String, Class<?>>(); |
282 | 279 |
283 NodeList outGenerators = (NodeList) XMLUtils.xpath( | 280 NodeList outGenerators = (NodeList) XMLUtils.xpath( |
284 config, | 281 config, |
285 XPATH_OUTPUT_GENERATORS, | 282 XPATH_OUTPUT_GENERATORS, |
286 XPathConstants.NODESET); | 283 XPathConstants.NODESET); |
449 | 446 |
450 context.put(FLYSContext.THEME_MAPPING, mapping); | 447 context.put(FLYSContext.THEME_MAPPING, mapping); |
451 } | 448 } |
452 | 449 |
453 | 450 |
454 protected void configureRiverWMS(Document cfg, FLYSContext context) { | 451 /** |
452 * Reads configured floodmap river WMSs from floodmap.xml and | |
453 * loads them into the given FLYSContext. | |
454 * @param cfg | |
455 * @param context | |
456 */ | |
457 protected void configureFloodmapWMS(Document cfg, FLYSContext context) { | |
455 Map<String, String> riverWMS = new HashMap<String, String>(); | 458 Map<String, String> riverWMS = new HashMap<String, String>(); |
456 | 459 |
457 NodeList rivers = (NodeList) XMLUtils.xpath( | 460 NodeList rivers = (NodeList) XMLUtils.xpath( |
458 cfg, XPATH_RIVER_WMS, XPathConstants.NODESET); | 461 cfg, XPATH_RIVER_WMS, XPathConstants.NODESET); |
459 | 462 |