comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENCalculation.java @ 1149:64b465699a24

Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished. flys-artifacts/trunk@2680 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Sep 2011 14:42:36 +0000
parents
children da35b8a23ffb
comparison
equal deleted inserted replaced
1148:302461d5d071 1149:64b465699a24
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.Set;
6
7 import org.w3c.dom.Document;
8 import org.w3c.dom.Element;
9
10 import org.apache.log4j.Logger;
11
12 import de.intevation.artifacts.CallMeta;
13
14
15 public class WSPLGENCalculation extends Calculation {
16
17 private static final Logger log = Logger.getLogger(WSPLGENCalculation.class);
18
19 protected Map<Integer, String> errors;
20 protected Map<Integer, String> warnings;
21
22
23 public WSPLGENCalculation() {
24 errors = new HashMap<Integer, String>();
25 warnings = new HashMap<Integer, String>();
26 }
27
28
29 public void addError(Integer key, String msg) {
30 log.debug("New error: (" + key + ") " + msg);
31 errors.put(key, msg);
32 }
33
34
35 public void addWarning(Integer key, String msg) {
36 log.debug("New warning: (" + key + ") " + msg);
37 warnings.put(key, msg);
38 }
39
40
41 public int numErrors() {
42 return errors.size();
43 }
44
45
46 public int numWarnings() {
47 return warnings.size();
48 }
49
50
51 public void toXML(Document document, CallMeta meta) {
52 Element root = document.createElement("problems");
53
54 if (numErrors() > 0) {
55 Set<Map.Entry<Integer, String>> entrySet = errors.entrySet();
56
57 for (Map.Entry<Integer, String> entry: entrySet) {
58 Element problem = document.createElement("problem");
59 problem.setAttribute("error", String.valueOf(entry.getKey()));
60 problem.setTextContent(entry.getValue());
61
62 root.appendChild(problem);
63 }
64 }
65
66 if (numWarnings() > 0) {
67 Set<Map.Entry<Integer, String>> entrySet = warnings.entrySet();
68
69 for (Map.Entry<Integer, String> entry: entrySet) {
70 Element problem = document.createElement("problem");
71 problem.setAttribute("error", String.valueOf(entry.getKey()));
72 problem.setTextContent(entry.getValue());
73
74 root.appendChild(problem);
75 }
76 }
77
78 document.appendChild(root);
79 }
80 }
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org