Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java @ 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.
flys-artifacts/trunk@1747 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 26 Apr 2011 13:17:08 +0000 |
parents | eca7892bf8ff |
children | 32d0a543e3e8 |
comparison
equal
deleted
inserted
replaced
344:79401797f4e1 | 345:88a669785863 |
---|---|
67 "/artifact-database/flys/themes/configuration/text()"; | 67 "/artifact-database/flys/themes/configuration/text()"; |
68 | 68 |
69 public static final String XPATH_THEMES = | 69 public static final String XPATH_THEMES = |
70 "/themes/theme"; | 70 "/themes/theme"; |
71 | 71 |
72 public static final String XPATH_THEME_MAPPINGS = | |
73 "/themes/mappings/mapping"; | |
74 | |
72 /** | 75 /** |
73 * Creates a new FLYSArtifactContext object and initialize all | 76 * Creates a new FLYSArtifactContext object and initialize all |
74 * components required by the application. | 77 * components required by the application. |
75 * | 78 * |
76 * @param config The artifact server configuration. | 79 * @param config The artifact server configuration. |
81 | 84 |
82 configureTransitions(config, context); | 85 configureTransitions(config, context); |
83 configureStates(config, context); | 86 configureStates(config, context); |
84 configureOutGenerators(config, context); | 87 configureOutGenerators(config, context); |
85 configureThemes(config, context); | 88 configureThemes(config, context); |
89 configureThemesMappings(config, context); | |
86 | 90 |
87 return context; | 91 return context; |
88 } | 92 } |
89 | 93 |
90 | 94 |
316 | 320 |
317 logger.debug("Parse theme cfg: " + themeConfig); | 321 logger.debug("Parse theme cfg: " + themeConfig); |
318 | 322 |
319 return XMLUtils.parseDocument(new File(themeConfig)); | 323 return XMLUtils.parseDocument(new File(themeConfig)); |
320 } | 324 } |
325 | |
326 | |
327 protected void configureThemesMappings(Document cfg, FLYSContext context) { | |
328 logger.debug("FLYSContextFactory.configureThemesMappings"); | |
329 | |
330 Document config = getThemeConfig(cfg); | |
331 | |
332 NodeList mappings = (NodeList) XMLUtils.xpath( | |
333 config, XPATH_THEME_MAPPINGS, XPathConstants.NODESET); | |
334 | |
335 int num = mappings != null ? mappings.getLength() : 0; | |
336 | |
337 if (num == 0) { | |
338 logger.warn("No theme <--> facet mappins found!"); | |
339 return; | |
340 } | |
341 | |
342 Map<String, String> mapping = new HashMap<String, String>(); | |
343 | |
344 for (int i = 0; i < num; i++) { | |
345 Node node = mappings.item(i); | |
346 | |
347 String from = (String) XMLUtils.xpath( | |
348 node, "@from", XPathConstants.STRING); | |
349 | |
350 String to = (String) XMLUtils.xpath( | |
351 node, "@to", XPathConstants.STRING); | |
352 | |
353 if (from != null && to != null) { | |
354 mapping.put(from, to); | |
355 } | |
356 } | |
357 | |
358 logger.debug("Found " + mapping.size() + " theme/facet mappings."); | |
359 | |
360 context.put(FLYSContext.THEME_MAPPING, mapping); | |
361 } | |
321 } | 362 } |
322 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 363 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |