comparison artifacts/src/main/java/org/dive4elements/river/themes/ThemeFactory.java @ 5866:9a6741ccf6d4

FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 15:14:30 +0200
parents 4897a58c8746
children 59ff03ff48f1
comparison
equal deleted inserted replaced
5865:73da40528cf2 5866:9a6741ccf6d4
8 8
9 package org.dive4elements.river.themes; 9 package org.dive4elements.river.themes;
10 10
11 import org.dive4elements.artifacts.common.utils.XMLUtils; 11 import org.dive4elements.artifacts.common.utils.XMLUtils;
12 import org.dive4elements.river.artifacts.FLYSArtifact; 12 import org.dive4elements.river.artifacts.FLYSArtifact;
13 import org.dive4elements.river.artifacts.context.FLYSContext; 13 import org.dive4elements.river.artifacts.context.RiverContext;
14 14
15 import java.util.ArrayList; 15 import java.util.ArrayList;
16 import java.util.HashMap; 16 import java.util.HashMap;
17 import java.util.List; 17 import java.util.List;
18 import java.util.Map; 18 import java.util.Map;
74 * @param output Name of the current output 74 * @param output Name of the current output
75 * 75 *
76 * @return First matching theme. 76 * @return First matching theme.
77 */ 77 */
78 public static Theme getTheme( 78 public static Theme getTheme(
79 FLYSContext c, 79 RiverContext c,
80 String name, 80 String name,
81 String pattern, 81 String pattern,
82 String output, 82 String output,
83 String groupName) 83 String groupName)
84 { 84 {
93 } 93 }
94 94
95 // Fetch mapping and themes. 95 // Fetch mapping and themes.
96 @SuppressWarnings("unchecked") 96 @SuppressWarnings("unchecked")
97 Map<String, List<ThemeMapping>> map = (Map<String, List<ThemeMapping>>) 97 Map<String, List<ThemeMapping>> map = (Map<String, List<ThemeMapping>>)
98 c.get(FLYSContext.THEME_MAPPING); 98 c.get(RiverContext.THEME_MAPPING);
99 99
100 @SuppressWarnings("unchecked") 100 @SuppressWarnings("unchecked")
101 List<ThemeGroup> tgs = (List<ThemeGroup>) 101 List<ThemeGroup> tgs = (List<ThemeGroup>)
102 c.get(FLYSContext.THEMES); 102 c.get(RiverContext.THEMES);
103 103
104 ThemeGroup group = null; 104 ThemeGroup group = null;
105 for (ThemeGroup tg: tgs) { 105 for (ThemeGroup tg: tgs) {
106 if (tg.getName().equals(groupName)) { 106 if (tg.getName().equals(groupName)) {
107 group = tg; 107 group = tg;
114 return null; 114 return null;
115 } 115 }
116 116
117 Map<String, Theme> t = group.getThemes(); 117 Map<String, Theme> t = group.getThemes();
118 118
119 FLYSArtifact artifact = (FLYSArtifact) c.get(FLYSContext.ARTIFACT_KEY); 119 FLYSArtifact artifact = (FLYSArtifact) c.get(RiverContext.ARTIFACT_KEY);
120 120
121 if (map == null || map.isEmpty() || t == null || t.isEmpty()) { 121 if (map == null || map.isEmpty() || t == null || t.isEmpty()) {
122 logger.warn("No mappings or themes found. Cannot retrieve theme!"); 122 logger.warn("No mappings or themes found. Cannot retrieve theme!");
123 return null; 123 return null;
124 } 124 }
153 return null; 153 return null;
154 } 154 }
155 155
156 156
157 @SuppressWarnings("unchecked") 157 @SuppressWarnings("unchecked")
158 public static List<ThemeGroup> getThemeGroups(FLYSContext c) { 158 public static List<ThemeGroup> getThemeGroups(RiverContext c) {
159 List<ThemeGroup> tgs = (List<ThemeGroup>) 159 List<ThemeGroup> tgs = (List<ThemeGroup>)
160 c.get(FLYSContext.THEMES); 160 c.get(RiverContext.THEMES);
161 return tgs; 161 return tgs;
162 } 162 }
163 163
164 164
165 @SuppressWarnings("unchecked") 165 @SuppressWarnings("unchecked")
166 public static List<Theme> getThemes (FLYSContext c, String name) { 166 public static List<Theme> getThemes (RiverContext c, String name) {
167 List<ThemeGroup> tgs = (List<ThemeGroup>) 167 List<ThemeGroup> tgs = (List<ThemeGroup>)
168 c.get(FLYSContext.THEMES); 168 c.get(RiverContext.THEMES);
169 if (tgs == null) { 169 if (tgs == null) {
170 return null; 170 return null;
171 } 171 }
172 172
173 List<Theme> themes = new ArrayList<Theme>(); 173 List<Theme> themes = new ArrayList<Theme>();

http://dive4elements.wald.intevation.org