Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeFactory.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 | f72c63713099 |
children | d2a17e990c70 |
comparison
equal
deleted
inserted
replaced
344:79401797f4e1 | 345:88a669785863 |
---|---|
1 package de.intevation.flys.themes; | 1 package de.intevation.flys.themes; |
2 | |
3 import java.util.Map; | |
2 | 4 |
3 import javax.xml.xpath.XPathConstants; | 5 import javax.xml.xpath.XPathConstants; |
4 | 6 |
5 import org.apache.log4j.Logger; | 7 import org.apache.log4j.Logger; |
6 | 8 |
8 import org.w3c.dom.NamedNodeMap; | 10 import org.w3c.dom.NamedNodeMap; |
9 import org.w3c.dom.Node; | 11 import org.w3c.dom.Node; |
10 import org.w3c.dom.NodeList; | 12 import org.w3c.dom.NodeList; |
11 | 13 |
12 import de.intevation.artifacts.common.utils.XMLUtils; | 14 import de.intevation.artifacts.common.utils.XMLUtils; |
15 | |
16 import de.intevation.flys.artifacts.context.FLYSContext; | |
13 | 17 |
14 | 18 |
15 /** | 19 /** |
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
17 */ | 21 */ |
46 | 50 |
47 return theme; | 51 return theme; |
48 } | 52 } |
49 | 53 |
50 | 54 |
55 /** | |
56 * Returns the theme for a specified output type and facet. | |
57 * | |
58 * @param c The FLYSContext that stores the mappings and themes. | |
59 * @param name The name of the mapping. | |
60 * | |
61 * @return a theme. | |
62 */ | |
63 public static Theme getTheme(FLYSContext c, String name) { | |
64 if (c == null || name == null) { | |
65 logger.warn("Cannot search for theme."); | |
66 return null; | |
67 } | |
68 | |
69 Map<String, String> map = (Map<String, String>) | |
70 c.get(FLYSContext.THEME_MAPPING); | |
71 | |
72 Map<String, Theme> t = (Map<String, Theme>) | |
73 c.get(FLYSContext.THEMES); | |
74 | |
75 if (map == null || map.size() == 0 || t == null || t.size() == 0) { | |
76 logger.warn("No mappings or themes found. Cannot retrieve theme!"); | |
77 return null; | |
78 } | |
79 | |
80 String themeName = map.get(name); | |
81 | |
82 if (themeName == null) { | |
83 logger.warn("No theme found for mapping: " + name); | |
84 } | |
85 | |
86 return t.get(themeName); | |
87 } | |
88 | |
89 | |
51 protected static String getName(Node config) { | 90 protected static String getName(Node config) { |
52 return (String) XMLUtils.xpath(config, "@name", XPathConstants.STRING); | 91 return (String) XMLUtils.xpath(config, "@name", XPathConstants.STRING); |
53 } | 92 } |
54 | 93 |
55 | 94 |