comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java @ 1747:d2a17e990c70

Improved the Themes: we now support special themes for facets which need to match a given pattern string. flys-artifacts/trunk@3047 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 20 Oct 2011 13:45:45 +0000
parents ee105e5d5ead
children 6ed439ff61bf
comparison
equal deleted inserted replaced
1746:94faf08d143c 1747:d2a17e990c70
28 28
29 import de.intevation.flys.artifacts.states.StateFactory; 29 import de.intevation.flys.artifacts.states.StateFactory;
30 import de.intevation.flys.artifacts.transitions.TransitionFactory; 30 import de.intevation.flys.artifacts.transitions.TransitionFactory;
31 import de.intevation.flys.themes.Theme; 31 import de.intevation.flys.themes.Theme;
32 import de.intevation.flys.themes.ThemeFactory; 32 import de.intevation.flys.themes.ThemeFactory;
33 import de.intevation.flys.themes.ThemeMapping;
33 34
34 35
35 /** 36 /**
36 * The ArtifactContextFactory is used to initialize basic components and put 37 * The ArtifactContextFactory is used to initialize basic components and put
37 * them into the global context of the application. 38 * them into the global context of the application.
342 if (num == 0) { 343 if (num == 0) {
343 logger.warn("No theme <--> facet mappins found!"); 344 logger.warn("No theme <--> facet mappins found!");
344 return; 345 return;
345 } 346 }
346 347
347 Map<String, String> mapping = new HashMap<String, String>(); 348 Map<String, List<ThemeMapping>> mapping =
349 new HashMap<String, List<ThemeMapping>>();
348 350
349 for (int i = 0; i < num; i++) { 351 for (int i = 0; i < num; i++) {
350 Node node = mappings.item(i); 352 Node node = mappings.item(i);
351 353
352 String from = (String) XMLUtils.xpath( 354 String from = (String) XMLUtils.xpath(
353 node, "@from", XPathConstants.STRING); 355 node, "@from", XPathConstants.STRING);
354 356
355 String to = (String) XMLUtils.xpath( 357 String to = (String) XMLUtils.xpath(
356 node, "@to", XPathConstants.STRING); 358 node, "@to", XPathConstants.STRING);
357 359
360 String pattern = (String) XMLUtils.xpath(
361 node, "@pattern", XPathConstants.STRING);
362
358 if (from != null && to != null) { 363 if (from != null && to != null) {
359 mapping.put(from, to); 364 List<ThemeMapping> tm = mapping.get(from);
360 } 365
361 } 366 if (tm == null) {
362 367 tm = new ArrayList<ThemeMapping>();
363 logger.debug("Found " + mapping.size() + " theme/facet mappings."); 368 mapping.put(from, tm);
369 }
370
371 tm.add(new ThemeMapping(from, to, pattern));
372 }
373 }
374
375 logger.debug("Found " + mapping.size() + " theme mappings.");
364 376
365 context.put(FLYSContext.THEME_MAPPING, mapping); 377 context.put(FLYSContext.THEME_MAPPING, mapping);
366 } 378 }
367 379
368 380

http://dive4elements.wald.intevation.org