comparison artifacts/src/main/java/org/dive4elements/river/collections/CollectionAttribute.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents 162ef5e93715
children 0a5239a1e46e
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
35 * 35 *
36 * Has outputs, settings, facets and list of loaded recommendations. 36 * Has outputs, settings, facets and list of loaded recommendations.
37 */ 37 */
38 public class CollectionAttribute { 38 public class CollectionAttribute {
39 39
40 /** Privately owned logger. */ 40 /** Privately owned log. */
41 private static final Logger logger = 41 private static final Logger log =
42 Logger.getLogger(CollectionAttribute.class); 42 Logger.getLogger(CollectionAttribute.class);
43 43
44 protected ElementCreator ec; 44 protected ElementCreator ec;
45 45
46 protected Map<String, Output> outputMap; 46 protected Map<String, Output> outputMap;
93 } 93 }
94 94
95 95
96 public void setSettings(String outputKey, Settings settings) { 96 public void setSettings(String outputKey, Settings settings) {
97 if (settings == null) { 97 if (settings == null) {
98 logger.warn("Tried to set empty Settings for '" + outputKey + "'"); 98 log.warn("Tried to set empty Settings for '" + outputKey + "'");
99 return; 99 return;
100 } 100 }
101 101
102 if (outputMap == null) { 102 if (outputMap == null) {
103 logger.warn("Tried to add settings but no Outputs are existing yet."); 103 log.warn("Tried to add settings but no Outputs are existing yet.");
104 return; 104 return;
105 } 105 }
106 106
107 Output output = outputMap.get(outputKey); 107 Output output = outputMap.get(outputKey);
108 108
109 if (output == null) { 109 if (output == null) {
110 logger.warn("Tried to add settings for unknown Output: " + outputKey); 110 log.warn("Tried to add settings for unknown Output: " + outputKey);
111 return; 111 return;
112 } 112 }
113 113
114 output.setSettings(settings); 114 output.setSettings(settings);
115 } 115 }
116 116
117 117
118 public void addFacet(String outputKey, Facet facet) { 118 public void addFacet(String outputKey, Facet facet) {
119 if (facet == null) { 119 if (facet == null) {
120 logger.warn("Tried to add null facet."); 120 log.warn("Tried to add null facet.");
121 return; 121 return;
122 } 122 }
123 123
124 if (outputMap == null) { 124 if (outputMap == null) {
125 logger.warn("Tried to add facet but no Outputs are existing yet."); 125 log.warn("Tried to add facet but no Outputs are existing yet.");
126 return; 126 return;
127 } 127 }
128 128
129 Output output = outputMap.get(outputKey); 129 Output output = outputMap.get(outputKey);
130 130
131 if (output == null) { 131 if (output == null) {
132 logger.warn("Tried to add facet for unknown Output: " + outputKey); 132 log.warn("Tried to add facet for unknown Output: " + outputKey);
133 return; 133 return;
134 } 134 }
135 135
136 logger.debug("Add facet for '" + outputKey + "': " + facet.getName()); 136 log.debug("Add facet for '" + outputKey + "': " + facet.getName());
137 output.addFacet(facet); 137 output.addFacet(facet);
138 } 138 }
139 139
140 140
141 public void setLoadedRecommendations(Node loadedRecommendations) { 141 public void setLoadedRecommendations(Node loadedRecommendations) {
145 145
146 146
147 /** Empty facets list for outputKey output. */ 147 /** Empty facets list for outputKey output. */
148 public void clearFacets(String outputKey) { 148 public void clearFacets(String outputKey) {
149 if (outputKey == null || outputKey.length() == 0) { 149 if (outputKey == null || outputKey.length() == 0) {
150 logger.warn("Tried to clear Facets, but no Output key specified!"); 150 log.warn("Tried to clear Facets, but no Output key specified!");
151 return; 151 return;
152 } 152 }
153 153
154 if (outputMap == null) { 154 if (outputMap == null) {
155 logger.warn("Tried to clear Facets, but no Outputs existing!"); 155 log.warn("Tried to clear Facets, but no Outputs existing!");
156 return; 156 return;
157 } 157 }
158 158
159 Output output = outputMap.get(outputKey); 159 Output output = outputMap.get(outputKey);
160 if (output == null) { 160 if (output == null) {
161 logger.warn("Tried to clear Facets for unknown Out: " + outputKey); 161 log.warn("Tried to clear Facets for unknown Out: " + outputKey);
162 return; 162 return;
163 } 163 }
164 164
165 output.setFacets(new ArrayList<Facet>()); 165 output.setFacets(new ArrayList<Facet>());
166 } 166 }
194 } 194 }
195 195
196 196
197 public Output getOutput(String name) { 197 public Output getOutput(String name) {
198 if (name == null || name.length() == 0) { 198 if (name == null || name.length() == 0) {
199 logger.warn("No Output name specified."); 199 log.warn("No Output name specified.");
200 return null; 200 return null;
201 } 201 }
202 202
203 if (outputMap == null || outputMap.isEmpty()) { 203 if (outputMap == null || outputMap.isEmpty()) {
204 logger.warn("Tried to retrieve Output, but no Outputs existing."); 204 log.warn("Tried to retrieve Output, but no Outputs existing.");
205 return null; 205 return null;
206 } 206 }
207 207
208 return outputMap.get(name); 208 return outputMap.get(name);
209 } 209 }
210 210
211 211
212 public List<Facet> getFacets(String output) { 212 public List<Facet> getFacets(String output) {
213 if (output == null || output.length() == 0) { 213 if (output == null || output.length() == 0) {
214 logger.warn("No Output name specified."); 214 log.warn("No Output name specified.");
215 return new ArrayList<Facet>(); 215 return new ArrayList<Facet>();
216 } 216 }
217 217
218 if (outputMap == null) { 218 if (outputMap == null) {
219 logger.warn("Tried to retrieve facets, but no Outputs existing."); 219 log.warn("Tried to retrieve facets, but no Outputs existing.");
220 return new ArrayList<Facet>(); 220 return new ArrayList<Facet>();
221 } 221 }
222 222
223 Output o = outputMap.get(output); 223 Output o = outputMap.get(output);
224 224
225 if (o == null) { 225 if (o == null) {
226 logger.warn("No Output '" + output + "' existing."); 226 log.warn("No Output '" + output + "' existing.");
227 return new ArrayList<Facet>(); 227 return new ArrayList<Facet>();
228 } 228 }
229 229
230 return o.getFacets(); 230 return o.getFacets();
231 } 231 }
233 233
234 public List<Facet> getFacets() { 234 public List<Facet> getFacets() {
235 List<Facet> allFacets = new ArrayList<Facet>(); 235 List<Facet> allFacets = new ArrayList<Facet>();
236 236
237 if (outputMap == null || outputMap.isEmpty()) { 237 if (outputMap == null || outputMap.isEmpty()) {
238 logger.warn("No Outputs existing."); 238 log.warn("No Outputs existing.");
239 return allFacets; 239 return allFacets;
240 } 240 }
241 241
242 for (String outputName: outputMap.keySet()) { 242 for (String outputName: outputMap.keySet()) {
243 allFacets.addAll(getFacets(outputName)); 243 allFacets.addAll(getFacets(outputName));
247 } 247 }
248 248
249 249
250 protected void appendOutputs(Element root) { 250 protected void appendOutputs(Element root) {
251 if (outputMap == null || outputMap.isEmpty()) { 251 if (outputMap == null || outputMap.isEmpty()) {
252 logger.warn("No outputs to append."); 252 log.warn("No outputs to append.");
253 return; 253 return;
254 } 254 }
255 255
256 logger.debug("Append " + outputMap.size() + " Output Elements."); 256 log.debug("Append " + outputMap.size() + " Output Elements.");
257 257
258 Element outputsEl = ec.create("outputs"); 258 Element outputsEl = ec.create("outputs");
259 259
260 for (Map.Entry<String, Output> entry: outputMap.entrySet()) { 260 for (Map.Entry<String, Output> entry: outputMap.entrySet()) {
261 appendOutput(outputsEl, entry.getKey(), entry.getValue()); 261 appendOutput(outputsEl, entry.getKey(), entry.getValue());
265 } 265 }
266 266
267 267
268 protected void appendOutput(Element root, String name, Output output) { 268 protected void appendOutput(Element root, String name, Output output) {
269 if (name == null || name.length() == 0 || output == null) { 269 if (name == null || name.length() == 0 || output == null) {
270 logger.warn("Tried to appendOutput, but Output is invalid."); 270 log.warn("Tried to appendOutput, but Output is invalid.");
271 return; 271 return;
272 } 272 }
273 273
274 logger.debug("Append Output Element for '" + name + "'"); 274 log.debug("Append Output Element for '" + name + "'");
275 275
276 Element outputEl = ec.create("output"); 276 Element outputEl = ec.create("output");
277 ec.addAttr(outputEl, "name", name); 277 ec.addAttr(outputEl, "name", name);
278 278
279 appendSettings(outputEl, output.getSettings()); 279 appendSettings(outputEl, output.getSettings());
283 } 283 }
284 284
285 285
286 protected void appendSettings(Element root, Settings settings) { 286 protected void appendSettings(Element root, Settings settings) {
287 if (settings == null) { 287 if (settings == null) {
288 logger.warn("Tried to append Settings, but Settings is empty!"); 288 log.warn("Tried to append Settings, but Settings is empty!");
289 return; 289 return;
290 } 290 }
291 291
292 settings.toXML(root); 292 settings.toXML(root);
293 } 293 }
294 294
295 295
296 protected void appendFacets(Element root, List<Facet> facets) { 296 protected void appendFacets(Element root, List<Facet> facets) {
297 if (facets == null || facets.isEmpty()) { 297 if (facets == null || facets.isEmpty()) {
298 logger.warn("Tried to append 0 Facets."); 298 log.warn("Tried to append 0 Facets.");
299 return; 299 return;
300 } 300 }
301 301
302 Document owner = root.getOwnerDocument(); 302 Document owner = root.getOwnerDocument();
303 303
304 logger.debug("Append " + facets.size() + " facets."); 304 log.debug("Append " + facets.size() + " facets.");
305 305
306 for (Facet facet: facets) { 306 for (Facet facet: facets) {
307 Node facetNode = facet.toXML(owner); 307 Node facetNode = facet.toXML(owner);
308 308
309 if (facetNode != null) { 309 if (facetNode != null) {
313 } 313 }
314 314
315 315
316 protected void appendLoadedRecommendations(Element root) { 316 protected void appendLoadedRecommendations(Element root) {
317 if (loadedRecommendations == null) { 317 if (loadedRecommendations == null) {
318 logger.debug("No loaded recommendations existing yet."); 318 log.debug("No loaded recommendations existing yet.");
319 return; 319 return;
320 } 320 }
321 321
322 Document owner = root.getOwnerDocument(); 322 Document owner = root.getOwnerDocument();
323 323

http://dive4elements.wald.intevation.org