Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java @ 3630:28be160b5870
Add a module service. It's now possible to configure the modules which are
available for a client. With the selected attribute it is possible to give
a hint for the client which module should be pre selected by default
flys-artifacts/trunk@5330 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 31 Aug 2012 13:17:16 +0000 |
parents | 17ca0a43027a |
children | 58bdf95df5e4 |
comparison
equal
deleted
inserted
replaced
3629:f3717e625b0a | 3630:28be160b5870 |
---|---|
24 import de.intevation.artifactdatabase.state.State; | 24 import de.intevation.artifactdatabase.state.State; |
25 import de.intevation.artifactdatabase.state.StateEngine; | 25 import de.intevation.artifactdatabase.state.StateEngine; |
26 import de.intevation.artifactdatabase.transition.Transition; | 26 import de.intevation.artifactdatabase.transition.Transition; |
27 import de.intevation.artifactdatabase.transition.TransitionEngine; | 27 import de.intevation.artifactdatabase.transition.TransitionEngine; |
28 | 28 |
29 import de.intevation.flys.artifacts.model.Module; | |
29 import de.intevation.flys.artifacts.states.StateFactory; | 30 import de.intevation.flys.artifacts.states.StateFactory; |
30 import de.intevation.flys.artifacts.transitions.TransitionFactory; | 31 import de.intevation.flys.artifacts.transitions.TransitionFactory; |
31 import de.intevation.flys.themes.Theme; | 32 import de.intevation.flys.themes.Theme; |
32 import de.intevation.flys.themes.ThemeGroup; | 33 import de.intevation.flys.themes.ThemeGroup; |
33 import de.intevation.flys.themes.ThemeFactory; | 34 import de.intevation.flys.themes.ThemeFactory; |
79 "/themes/mappings/mapping"; | 80 "/themes/mappings/mapping"; |
80 | 81 |
81 public static final String XPATH_RIVER_WMS = | 82 public static final String XPATH_RIVER_WMS = |
82 "/artifact-database/floodmap/river"; | 83 "/artifact-database/floodmap/river"; |
83 | 84 |
85 public static final String XPATH_MODULES = "/artifact-database/modules/module"; | |
86 | |
84 /** | 87 /** |
85 * Creates a new FLYSArtifactContext object and initialize all | 88 * Creates a new FLYSArtifactContext object and initialize all |
86 * components required by the application. | 89 * components required by the application. |
87 * | 90 * |
88 * @param config The artifact server configuration. | 91 * @param config The artifact server configuration. |
95 configureStates(config, context); | 98 configureStates(config, context); |
96 configureOutGenerators(config, context); | 99 configureOutGenerators(config, context); |
97 configureThemes(config, context); | 100 configureThemes(config, context); |
98 configureThemesMappings(config, context); | 101 configureThemesMappings(config, context); |
99 configureRiverWMS(config, context); | 102 configureRiverWMS(config, context); |
103 configureModules(config, context); | |
100 | 104 |
101 return context; | 105 return context; |
102 } | 106 } |
103 | 107 |
104 | 108 |
421 | 425 |
422 logger.debug("Found " + riverWMS.size() + " river WMS."); | 426 logger.debug("Found " + riverWMS.size() + " river WMS."); |
423 | 427 |
424 context.put(FLYSContext.RIVER_WMS, riverWMS); | 428 context.put(FLYSContext.RIVER_WMS, riverWMS); |
425 } | 429 } |
430 | |
431 | |
432 /** | |
433 * This method initializes the modules configuration. | |
434 * | |
435 * @param config the config document. | |
436 * @param context the FLYSContext. | |
437 */ | |
438 protected void configureModules(Document cfg, FLYSContext context) { | |
439 NodeList modulenodes = (NodeList) XMLUtils.xpath( | |
440 cfg, XPATH_MODULES, XPathConstants.NODESET); | |
441 | |
442 int num = modulenodes != null ? modulenodes.getLength() : 0; | |
443 ArrayList<Module> modules = new ArrayList<Module>(num); | |
444 | |
445 for (int i = 0; i < num; i++) { | |
446 Element e = (Element) modulenodes.item(i); | |
447 String modulename = e.getAttribute("name"); | |
448 String attrselected = e.getAttribute("selected"); | |
449 boolean selected = attrselected == null ? false : | |
450 attrselected.equalsIgnoreCase("true"); | |
451 logger.debug("Loaded module " + modulename); | |
452 modules.add(new Module(modulename, selected)); | |
453 } | |
454 context.put(FLYSContext.MODULES, modules); | |
455 } | |
426 } | 456 } |
427 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 457 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |