annotate artifacts/src/main/java/org/dive4elements/river/artifacts/context/FLYSContextFactory.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
9 package org.dive4elements.river.artifacts.context;
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
11 import org.dive4elements.artifactdatabase.state.State;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
12 import org.dive4elements.artifactdatabase.state.StateEngine;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
13 import org.dive4elements.artifactdatabase.transition.Transition;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
14 import org.dive4elements.artifactdatabase.transition.TransitionEngine;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
15 import org.dive4elements.artifacts.ArtifactContextFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
16 import org.dive4elements.artifacts.GlobalContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
17 import org.dive4elements.artifacts.common.utils.Config;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
18 import org.dive4elements.artifacts.common.utils.XMLUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
19 import org.dive4elements.river.artifacts.model.Module;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
20 import org.dive4elements.river.artifacts.model.ZoomScale;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
21 import org.dive4elements.river.artifacts.states.StateFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
22 import org.dive4elements.river.artifacts.transitions.TransitionFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
23 import org.dive4elements.river.themes.Theme;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
24 import org.dive4elements.river.themes.ThemeFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
25 import org.dive4elements.river.themes.ThemeGroup;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5152
diff changeset
26 import org.dive4elements.river.themes.ThemeMapping;
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
27
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import java.io.File;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 import java.util.ArrayList;
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
30 import java.util.HashMap;
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import java.util.List;
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
32 import java.util.Map;
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 import javax.xml.xpath.XPathConstants;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 import org.apache.log4j.Logger;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 import org.w3c.dom.Document;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 import org.w3c.dom.Element;
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
39 import org.w3c.dom.Node;
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 import org.w3c.dom.NodeList;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 /**
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 * The ArtifactContextFactory is used to initialize basic components and put
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 * them into the global context of the application.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 *
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 */
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public class FLYSContextFactory implements ArtifactContextFactory {
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
1826
8d9b573d1b9a Minor comsetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1822
diff changeset
51 /** The logger that is used in this class. */
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 private static Logger logger = Logger.getLogger(FLYSContextFactory.class);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 /** The XPath to the artifacts configured in the configuration. */
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 public static final String XPATH_ARTIFACTS =
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 "/artifact-database/artifacts/artifact";
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 /** The XPath to the name of the artifact. */
107
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
59 public static final String XPATH_ARTIFACT_NAME = "/artifact/@name";
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 /** The XPath to the xlink ref in an artifact configuration. */
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 public static final String XPATH_XLINK = "xlink:href";
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 /** The XPath to the transitions configured in the artifact config. */
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 public static final String XPATH_TRANSITIONS =
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 "/artifact/states/transition";
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
107
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
68 /** The XPath to the states configured in the artifact config. */
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
69 public static final String XPATH_STATES =
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
70 "/artifact/states/state";
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
71
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
72 public static final String XPATH_OUTPUT_GENERATORS =
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
73 "/artifact-database/output-generators/output-generator";
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
74
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
75 public static final String XPATH_THEME_CONFIG =
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
76 "/artifact-database/flys/themes/configuration/text()";
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
77
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
78 public static final String XPATH_THEMES =
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
79 "theme";
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
80
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
81 public static final String XPATH_THEME_GROUPS =
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
82 "/themes/themegroup";
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
83
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
84 public static final String XPATH_THEME_MAPPINGS =
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
85 "/themes/mappings/mapping";
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
86
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
87 public static final String XPATH_RIVER_WMS =
1062
ee105e5d5ead Repaired broken river wms initialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
88 "/artifact-database/floodmap/river";
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
89
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
90 public static final String XPATH_MODULES = "/artifact-database/modules/module";
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
91
4619
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
92 private static final String XPATH_ZOOM_SCALES = "/artifact-database/options/zoom-scales/zoom-scale";
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
93
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
94 private static final String XPATH_DGM_PATH = "/artifact-database/options/dgm-path/text()";
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
95
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
96
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 /**
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 * Creates a new FLYSArtifactContext object and initialize all
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 * components required by the application.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 *
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 * @param config The artifact server configuration.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 * @return a FLYSArtifactContext.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 */
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
104 @Override
939
32d0a543e3e8 Adapted a method signature of FLYSContextFactory to apply the changes in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 345
diff changeset
105 public GlobalContext createArtifactContext(Document config) {
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 FLYSContext context = new FLYSContext(config);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 configureTransitions(config, context);
107
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
109 configureStates(config, context);
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
110 configureOutGenerators(config, context);
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
111 configureThemes(config, context);
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
112 configureThemesMappings(config, context);
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
113 configureFloodmapWMS(config, context);
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
114 configureModules(config, context);
4619
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
115 configureZoomScales(config, context);
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
116 configureDGMPath(config, context);
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 return context;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
122 private void configureDGMPath(Document config, FLYSContext context) {
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
123 String dgmPath = (String) XMLUtils.xpath(
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
124 config,
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
125 XPATH_DGM_PATH,
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
126 XPathConstants.STRING);
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
127
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
128 context.put("dgm-path", dgmPath);
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
129 }
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
130
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 4656
diff changeset
131
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
132 protected void configureZoomScales(Document config, FLYSContext context) {
4619
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
133 NodeList list = (NodeList)XMLUtils.xpath(
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
134 config,
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
135 XPATH_ZOOM_SCALES,
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
136 XPathConstants.NODESET);
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
137 ZoomScale scale = new ZoomScale();
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
138 for (int i = 0; i < list.getLength(); i++) {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
139 Element element = (Element)list.item(i);
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
140 String river = "default";
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
141 double range = 0d;
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
142 double radius = 10d;
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
143 if (element.hasAttribute("river")) {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
144 river = element.getAttribute("river");
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
145 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
146 if (!element.hasAttribute("range")) {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
147 continue;
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
148 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
149 else {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
150 String r = element.getAttribute("range");
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
151 try {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
152 range = Double.parseDouble(r);
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
153 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
154 catch (NumberFormatException nfe) {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
155 continue;
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
156 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
157 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
158 if (!element.hasAttribute("radius")) {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
159 continue;
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
160 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
161 else {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
162 String r = element.getAttribute("radius");
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
163 try {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
164 radius = Double.parseDouble(r);
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
165 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
166 catch (NumberFormatException nfe) {
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
167 continue;
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
168 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
169 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
170 scale.addRange(river, range, radius);
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
171 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
172 context.put("zoomscale", scale);
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
173 }
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
174
05c9902c761d Added example config for river 'Elbe' and read the config in context factory.
Raimund Renkert <rrenkert@intevation.de>
parents: 4051
diff changeset
175
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 /**
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 * This method initializes the transition configuration.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 *
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 * @param config the config document.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 * @param context the FLYSContext.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 */
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 protected void configureTransitions(Document config, FLYSContext context) {
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 TransitionEngine engine = new TransitionEngine();
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 Document[] artifacts = getArtifactConfigurations(config);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 logger.info("Found " + artifacts.length + " artifacts in the config.");
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 for (Document doc: artifacts) {
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 String artName = (String) XMLUtils.xpath(
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 doc, XPATH_ARTIFACT_NAME, XPathConstants.STRING);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192
111
7222d8fb53ea Changed the way of storing transitions in the TransitionEngine.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 107
diff changeset
193 NodeList list = (NodeList) XMLUtils.xpath(
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 doc, XPATH_TRANSITIONS, XPathConstants.NODESET);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195
111
7222d8fb53ea Changed the way of storing transitions in the TransitionEngine.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 107
diff changeset
196 if (list == null) {
2141
79a94c4171cb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1828
diff changeset
197 logger.warn("The artifact " + artName +
79a94c4171cb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1828
diff changeset
198 " has no transitions configured.");
107
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
199 continue;
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201
111
7222d8fb53ea Changed the way of storing transitions in the TransitionEngine.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 107
diff changeset
202 int trans = list.getLength();
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 logger.info(
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 "Artifact '" + artName + "' has " + trans + " transitions.");
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 for (int i = 0; i < trans; i++) {
111
7222d8fb53ea Changed the way of storing transitions in the TransitionEngine.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 107
diff changeset
208 Transition t = TransitionFactory.createTransition(list.item(i));
7222d8fb53ea Changed the way of storing transitions in the TransitionEngine.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 107
diff changeset
209 String s = t.getFrom();
7222d8fb53ea Changed the way of storing transitions in the TransitionEngine.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 107
diff changeset
210 engine.addTransition(s, t);
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 context.put(FLYSContext.TRANSITION_ENGINE_KEY, engine);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 /**
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 * This method returns all artifact documents defined in
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 * <code>config</code>. <br>NOTE: The artifact configurations need to be
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 * stored in own files referenced by an xlink.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 *
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 * @param config The global configuration.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 *
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 * @return an array of Artifact configurations.
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 */
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 protected Document[] getArtifactConfigurations(Document config) {
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 NodeList artifacts = (NodeList) XMLUtils.xpath(
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229 config, XPATH_ARTIFACTS, XPathConstants.NODESET);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 int count = artifacts.getLength();
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233 Document[] artifactDocs = new Document[count];
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 for (int i = 0; i < count; i++) {
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 Element tmp = (Element) artifacts.item(i);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 String xlink = tmp.getAttribute(XPATH_XLINK);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 xlink = Config.replaceConfigDir(xlink);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 File artifactFile = new File(xlink);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 artifactDocs[i] = XMLUtils.parseDocument(artifactFile);
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 return artifactDocs;
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 }
107
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
247
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
248
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
249 /**
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
250 * This method initializes the transition configuration.
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
251 *
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
252 * @param config the config document.
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
253 * @param context the FLYSContext.
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
254 */
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
255 protected void configureStates(Document config, FLYSContext context) {
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
256 StateEngine engine = new StateEngine();
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
257
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
258 Document[] artifacts = getArtifactConfigurations(config);
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
259 logger.info("Found " + artifacts.length + " artifacts in the config.");
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
260
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
261 for (Document doc: artifacts) {
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
262 List<State> states = new ArrayList<State>();
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
263
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
264 String artName = (String) XMLUtils.xpath(
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
265 doc, XPATH_ARTIFACT_NAME, XPathConstants.STRING);
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
266
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
267 NodeList stateList = (NodeList) XMLUtils.xpath(
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
268 doc, XPATH_STATES, XPathConstants.NODESET);
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
269
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
270 if (stateList == null) {
2141
79a94c4171cb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1828
diff changeset
271 logger.warn("The artifact " + artName +
79a94c4171cb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1828
diff changeset
272 " has no states configured.");
107
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
273 continue;
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
274 }
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
275
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
276 int count = stateList.getLength();
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
277
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
278 logger.info(
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
279 "Artifact '" + artName + "' has " + count + " states.");
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
280
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
281 for (int i = 0; i < count; i++) {
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
282 states.add(StateFactory.createState(
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
283 stateList.item(i)));
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
284 }
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
285
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
286 engine.addStates(artName, states);
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
287 }
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
288
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
289 context.put(FLYSContext.STATE_ENGINE_KEY, engine);
a228b39494a9 Improved the bootstrap process - the states are initialized.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 106
diff changeset
290 }
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
291
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
292
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
293 /**
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
294 * This method intializes the provided output generators.
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
295 *
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
296 * @param config the config document.
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
297 * @param context the FLYSContext.
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
298 */
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
299 protected void configureOutGenerators(Document config, FLYSContext context){
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
300 Map<String, Class<?>> generators = new HashMap<String, Class<?>>();
295
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
301
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
302 NodeList outGenerators = (NodeList) XMLUtils.xpath(
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
303 config,
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
304 XPATH_OUTPUT_GENERATORS,
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
305 XPathConstants.NODESET);
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
306
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
307 int num = outGenerators == null ? 0 : outGenerators.getLength();
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
308
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
309 if (num == 0) {
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
310 logger.warn("No output generators configured in this application.");
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
311 return;
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
312 }
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
313
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
314 logger.info("Found " + num + " configured output generators.");
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
315
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
316 int idx = 0;
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
317
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
318 for (int i = 0; i < num; i++) {
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
319 Node item = outGenerators.item(i);
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
320
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
321 String name = (String) XMLUtils.xpath(
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
322 item, "@name", XPathConstants.STRING);
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
323
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
324 String clazz = (String) XMLUtils.xpath(
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
325 item, "text()", XPathConstants.STRING);
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
326
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
327 if (name == null || clazz == null) {
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
328 continue;
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
329 }
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
330
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
331 try {
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
332 generators.put(name, Class.forName(clazz));
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
333
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
334 idx++;
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
335 }
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
336 catch (ClassNotFoundException cnfe) {
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
337 logger.warn(cnfe, cnfe);
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
338 }
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
339 }
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
340
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
341 logger.info("Successfully loaded " + idx + " output generators.");
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
342 context.put(FLYSContext.OUTGENERATORS_KEY, generators);
53c155bfde07 Added code to parse the configured OutGenerators in the global configuration and to save a map of such in the FLYSContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 130
diff changeset
343 }
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
344
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
345
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
346 /**
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
347 * This methods reads the configured themes and puts them into the
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
348 * FLYSContext.
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
349 *
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
350 * @param config The global configuration.
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
351 * @param context The FLYSContext.
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
352 */
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
353 protected void configureThemes(Document config, FLYSContext context) {
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
354 logger.debug("FLYSContextFactory.configureThemes");
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
355
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
356 Document cfg = getThemeConfig(config);
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
357
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
358 NodeList themeGroups = (NodeList) XMLUtils.xpath(
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
359 cfg, XPATH_THEME_GROUPS, XPathConstants.NODESET);
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
360
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
361 int groupNum = themeGroups != null ? themeGroups.getLength() : 0;
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
362
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
363 if (groupNum == 0) {
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
364 logger.warn("There are no theme groups configured!");
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
365 }
3256
17ca0a43027a Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3239
diff changeset
366
3239
fb11bd37ddb8 Improved the structure of themes.xml; moved theme groups to own XML files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2742
diff changeset
367 logger.info("Found " + groupNum + " theme groups in configuration");
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
368
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
369 List<ThemeGroup> groups = new ArrayList<ThemeGroup>();
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
370
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
371 for (int g = 0; g < groupNum; g++) {
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
372 Element themeGroup = (Element) themeGroups.item(g);
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
373 NodeList themes = (NodeList) XMLUtils.xpath(
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
374 themeGroup, XPATH_THEMES, XPathConstants.NODESET);
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
375
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
376 int num = themes != null ? themes.getLength() : 0;
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
377
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
378 if (num == 0) {
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
379 logger.warn("There are no themes configured!");
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
380 return;
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
381 }
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
382
3239
fb11bd37ddb8 Improved the structure of themes.xml; moved theme groups to own XML files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2742
diff changeset
383 logger.info("Theme group has " + num + " themes.");
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
384
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
385 Map<String, Theme> theThemes = new HashMap<String, Theme>();
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
386
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
387 for (int i = 0; i < num; i++) {
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
388 Node theme = themes.item(i);
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
389
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
390 Theme theTheme = ThemeFactory.createTheme(cfg, theme);
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
391
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
392 if (theme != null) {
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
393 theThemes.put(theTheme.getName(), theTheme);
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
394 }
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
395 }
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
396 String gName = themeGroup.getAttribute("name");
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
397 groups.add(new ThemeGroup(gName, theThemes));
3256
17ca0a43027a Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3239
diff changeset
398
3239
fb11bd37ddb8 Improved the structure of themes.xml; moved theme groups to own XML files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2742
diff changeset
399 logger.info(
fb11bd37ddb8 Improved the structure of themes.xml; moved theme groups to own XML files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2742
diff changeset
400 "Initialized " + theThemes.size() + "/" + num + " themes " +
fb11bd37ddb8 Improved the structure of themes.xml; moved theme groups to own XML files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2742
diff changeset
401 "of theme-group '" + gName + "'");
2737
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
402 }
83b22ccf48da Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2141
diff changeset
403 context.put(FLYSContext.THEMES, groups);
341
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
404 }
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
405
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
406 /**
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
407 * This method is used to retrieve the theme configuration document.
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
408 *
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
409 * @param config The global configuration.
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
410 *
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
411 * @return the theme configuration.
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
412 */
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
413 protected Document getThemeConfig(Document config) {
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
414 String themeConfig = (String) XMLUtils.xpath(
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
415 config,
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
416 XPATH_THEME_CONFIG,
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
417 XPathConstants.STRING);
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
418
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
419 themeConfig = Config.replaceConfigDir(themeConfig);
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
420
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
421 logger.debug("Parse theme cfg: " + themeConfig);
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
422
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
423 return XMLUtils.parseDocument(new File(themeConfig));
eca7892bf8ff Added a first small theme configuration and code to read it.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 295
diff changeset
424 }
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
425
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
426
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
427 protected void configureThemesMappings(Document cfg, FLYSContext context) {
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
428 logger.debug("FLYSContextFactory.configureThemesMappings");
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
429
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
430 Document config = getThemeConfig(cfg);
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
431
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
432 NodeList mappings = (NodeList) XMLUtils.xpath(
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
433 config, XPATH_THEME_MAPPINGS, XPathConstants.NODESET);
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
434
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
435 int num = mappings != null ? mappings.getLength() : 0;
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
436
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
437 if (num == 0) {
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
438 logger.warn("No theme <--> facet mappins found!");
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
439 return;
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
440 }
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
441
1747
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
442 Map<String, List<ThemeMapping>> mapping =
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
443 new HashMap<String, List<ThemeMapping>>();
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
444
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
445 for (int i = 0; i < num; i++) {
2742
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
446 Element node = (Element)mappings.item(i);
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
447
2742
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
448 String from = node.getAttribute("from");
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
449 String to = node.getAttribute("to");
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
450 String pattern = node.getAttribute("pattern");
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
451 String masterAttrPattern = node.getAttribute("masterAttr");
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
452 String outputPattern = node.getAttribute("output");
1747
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
453
2742
faf73245ec73 Improved startup performance.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2737
diff changeset
454 if (from.length() > 0 && to.length() > 0) {
1747
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
455 List<ThemeMapping> tm = mapping.get(from);
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
456
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
457 if (tm == null) {
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
458 tm = new ArrayList<ThemeMapping>();
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
459 mapping.put(from, tm);
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
460 }
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
461
1822
6ed439ff61bf Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1747
diff changeset
462 tm.add(new ThemeMapping(
1828
9562ca537143 Added new optional condition for theme-mappings: the output name.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1826
diff changeset
463 from, to, pattern, masterAttrPattern, outputPattern));
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
464 }
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
465 }
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
466
1747
d2a17e990c70 Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1062
diff changeset
467 logger.debug("Found " + mapping.size() + " theme mappings.");
345
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
468
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
469 context.put(FLYSContext.THEME_MAPPING, mapping);
88a669785863 Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 341
diff changeset
470 }
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
471
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
472
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
473 /**
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
474 * Reads configured floodmap river WMSs from floodmap.xml and
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
475 * loads them into the given FLYSContext.
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
476 * @param cfg
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
477 * @param context
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
478 */
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4629
diff changeset
479 protected void configureFloodmapWMS(Document cfg, FLYSContext context) {
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
480 Map<String, String> riverWMS = new HashMap<String, String>();
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
481
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
482 NodeList rivers = (NodeList) XMLUtils.xpath(
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
483 cfg, XPATH_RIVER_WMS, XPathConstants.NODESET);
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
484
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
485 int num = rivers != null ? rivers.getLength() : 0;
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
486
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
487 for (int i = 0; i < num; i++) {
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
488 Element e = (Element) rivers.item(i);
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
489
1062
ee105e5d5ead Repaired broken river wms initialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
490 String river = e.getAttribute("name");
ee105e5d5ead Repaired broken river wms initialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 958
diff changeset
491 String url = XMLUtils.xpathString(e, "river-wms/@url", null);
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
492
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
493 if (river != null && url != null) {
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
494 riverWMS.put(river, url);
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
495 }
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
496 }
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
497
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
498 logger.debug("Found " + riverWMS.size() + " river WMS.");
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
499
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
500 context.put(FLYSContext.RIVER_WMS, riverWMS);
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 939
diff changeset
501 }
3630
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
502
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
503
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
504 /**
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
505 * This method initializes the modules configuration.
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
506 *
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
507 * @param config the config document.
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
508 * @param context the FLYSContext.
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
509 */
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
510 protected void configureModules(Document cfg, FLYSContext context) {
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
511 NodeList modulenodes = (NodeList) XMLUtils.xpath(
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
512 cfg, XPATH_MODULES, XPathConstants.NODESET);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
513
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
514 int num = modulenodes != null ? modulenodes.getLength() : 0;
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
515 ArrayList<Module> modules = new ArrayList<Module>(num);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
516
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
517 for (int i = 0; i < num; i++) {
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
518 Element e = (Element) modulenodes.item(i);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
519 String modulename = e.getAttribute("name");
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
520 String attrselected = e.getAttribute("selected");
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
521 boolean selected = attrselected == null ? false :
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
522 attrselected.equalsIgnoreCase("true");
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
523 logger.debug("Loaded module " + modulename);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
524 modules.add(new Module(modulename, selected));
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
525 }
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
526 context.put(FLYSContext.MODULES, modules);
28be160b5870 Add a module service. It's now possible to configure the modules which are
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3256
diff changeset
527 }
106
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
528 }
5864c41219db Initializes a TransitionEngine storing all transitions for each artifact at the application start.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
529 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org