Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeFactory.java @ 1828:9562ca537143
Added new optional condition for theme-mappings: the output name.
flys-artifacts/trunk@3158 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 04 Nov 2011 08:59:42 +0000 |
parents | 6ed439ff61bf |
children | 6f047a407f84 |
comparison
equal
deleted
inserted
replaced
1827:03f129fa0256 | 1828:9562ca537143 |
---|---|
57 return theme; | 57 return theme; |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 /** | 61 /** |
62 * Returns the theme for a specified output type and facet. | |
63 * | |
64 * @param c The FLYSContext that stores the mappings and themes. | |
65 * @param name The name of the mapping. | |
66 * | |
67 * @return a theme. | |
68 */ | |
69 public static Theme getTheme(FLYSContext c, String name) { | |
70 return getTheme(c, name, null); | |
71 } | |
72 | |
73 | |
74 /** | |
75 * Get first matching theme for facet. | 62 * Get first matching theme for facet. |
76 * | 63 * |
77 * @param name Name to match "from" of theme mapping. | 64 * @param name Name to match "from" of theme mapping. |
78 * @param pattern String to 'compare' to pattern in mapping. | 65 * @param pattern String to 'compare' to pattern in mapping. |
66 * @param output Name of the current output | |
79 * | 67 * |
80 * @return First matching theme. | 68 * @return First matching theme. |
81 */ | 69 */ |
82 public static Theme getTheme(FLYSContext c, String name, String pattern) { | 70 public static Theme getTheme( |
83 | 71 FLYSContext c, |
84 logger.debug("Search theme for: " + name + " - " + pattern); | 72 String name, |
73 String pattern, | |
74 String output) | |
75 { | |
76 logger.debug("Search theme for: " + name + " - pattern: " + pattern); | |
85 | 77 |
86 if (c == null || name == null) { | 78 if (c == null || name == null) { |
87 logger.warn("Cannot search for theme."); | 79 logger.warn("Cannot search for theme."); |
88 return null; | 80 return null; |
89 } | 81 } |
111 | 103 |
112 // Take first mapping of which all conditions are satisfied. | 104 // Take first mapping of which all conditions are satisfied. |
113 for (ThemeMapping tm: mapping) { | 105 for (ThemeMapping tm: mapping) { |
114 if (name.equals(tm.getFrom()) | 106 if (name.equals(tm.getFrom()) |
115 && tm.applyPattern(pattern) | 107 && tm.applyPattern(pattern) |
116 && tm.masterAttrMatches(artifact)) | 108 && tm.masterAttrMatches(artifact) |
109 && tm.outputMatches(output)) | |
117 { | 110 { |
118 return t.get(tm.getTo()); | 111 return t.get(tm.getTo()); |
119 } | 112 } |
120 } | 113 } |
121 | 114 |
122 String msg = | 115 String msg = |
123 "No theme found for '" + name + | 116 "No theme found for '" + name + |
124 "' with pattern '" + pattern + "'."; | 117 "' with pattern '" + pattern + "' and output " + output + "."; |
125 | 118 |
126 logger.warn(msg); | 119 logger.warn(msg); |
127 | 120 |
128 return null; | 121 return null; |
129 } | 122 } |