comparison flys-artifacts/src/main/java/de/intevation/flys/wsplgen/ProblemObserver.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 e7d5452a7381
children d1d6fd8cfbb2
comparison
equal deleted inserted replaced
1148:302461d5d071 1149:64b465699a24
1 package de.intevation.flys.wsplgen; 1 package de.intevation.flys.wsplgen;
2 2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.regex.Matcher; 3 import java.util.regex.Matcher;
6 import java.util.regex.Pattern; 4 import java.util.regex.Pattern;
7 5
8 import org.apache.log4j.Logger; 6 import org.apache.log4j.Logger;
9 7
8 import de.intevation.flys.artifacts.model.WSPLGENCalculation;
10 import de.intevation.flys.artifacts.model.WSPLGENJob; 9 import de.intevation.flys.artifacts.model.WSPLGENJob;
11 10
12 11
13 public class ProblemObserver extends JobObserver { 12 public class ProblemObserver extends JobObserver {
14 13
33 32
34 33
35 protected int error; 34 protected int error;
36 protected int warning; 35 protected int warning;
37 36
38 protected Map<Integer, String> errorMsg; 37 protected WSPLGENCalculation calculation;
39 protected Map<Integer, String> warningMsg;
40 38
41 39
42 public ProblemObserver(WSPLGENJob job) { 40 public ProblemObserver(WSPLGENJob job) {
43 super(job); 41 super(job);
44 error = -1; 42 error = -1;
45 warning = -1; 43 warning = -1;
46 errorMsg = new HashMap<Integer, String>(); 44 calculation = job.getCalculation();
47 warningMsg = new HashMap<Integer, String>();
48 } 45 }
49 46
50 47
51 public void run() { 48 public void run() {
52 logger.debug("Start observation..."); 49 logger.debug("Start observation...");
73 if (endError.matches()) { 70 if (endError.matches()) {
74 error = -1; 71 error = -1;
75 } 72 }
76 73
77 if (error > 0) { 74 if (error > 0) {
78 errorMsg.put(new Integer(error), log); 75 calculation.addError(new Integer(error), log);
79 } 76 }
80 77
81 Matcher startWarning = WSPLGEN_WARNING_START.matcher(log); 78 Matcher startWarning = WSPLGEN_WARNING_START.matcher(log);
82 if (startWarning.matches()) { 79 if (startWarning.matches()) {
83 warning = Integer.parseInt(startWarning.group(1)); 80 warning = Integer.parseInt(startWarning.group(1));
88 if (endWarning.matches()) { 85 if (endWarning.matches()) {
89 warning = -1; 86 warning = -1;
90 } 87 }
91 88
92 if (warning > 0) { 89 if (warning > 0) {
93 warningMsg.put(new Integer(warning), log); 90 calculation.addWarning(new Integer(warning), log);
94 } 91 }
95 } 92 }
96 93
97 94
98 public int numErrors() { 95 public int numErrors() {
99 return errorMsg.size(); 96 return calculation.numErrors();
100 } 97 }
101 98
102 99
103 public int numWarnings() { 100 public int numWarnings() {
104 return warningMsg.size(); 101 return calculation.numWarnings();
105 } 102 }
106 } 103 }
107 // vim:set ts=4 sw=4 si et sta sts=5 fenc=utf-8 : 104 // vim:set ts=4 sw=4 si et sta sts=5 fenc=utf-8 :

http://dive4elements.wald.intevation.org