annotate flys-artifacts/src/main/java/de/intevation/flys/wsplgen/ProblemObserver.java @ 1642:6c0b79efd2c9

Bugfix: #320 Substitue '../' in shapefile directories. flys-artifacts/trunk@2829 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 27 Sep 2011 07:41:21 +0000
parents 64b465699a24
children d1d6fd8cfbb2
rev   line source
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.wsplgen;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.regex.Matcher;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.regex.Pattern;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
8 import de.intevation.flys.artifacts.model.WSPLGENCalculation;
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.flys.artifacts.model.WSPLGENJob;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 public class ProblemObserver extends JobObserver {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 private static Logger logger = Logger.getLogger(ProblemObserver.class);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 public static final Pattern WSPLGEN_ERROR_START = Pattern.compile(
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 ".*->Fehler\\s*\\((\\d+)\\).*",
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 Pattern.DOTALL);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 public static final Pattern WSPLGEN_ERROR_END = Pattern.compile(
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 ".*<-Fehler .*",
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 Pattern.DOTALL);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 public static final Pattern WSPLGEN_WARNING_START = Pattern.compile(
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 ".*->Warnung\\s*\\((\\d+)\\).*",
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 Pattern.DOTALL);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public static final Pattern WSPLGEN_WARNING_END = Pattern.compile(
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 ".*<-Warnung .*",
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 Pattern.DOTALL);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 protected int error;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 protected int warning;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
37 protected WSPLGENCalculation calculation;
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public ProblemObserver(WSPLGENJob job) {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 super(job);
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
42 error = -1;
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
43 warning = -1;
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
44 calculation = job.getCalculation();
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 public void run() {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 logger.debug("Start observation...");
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 super.run();
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 @Override
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 protected void prepareRegexes() {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 // do nothing
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 @Override
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 protected void update(String log) {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 Matcher startError = WSPLGEN_ERROR_START.matcher(log);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 if (startError.matches()) {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 error = Integer.parseInt(startError.group(1));
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 return;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 Matcher endError = WSPLGEN_ERROR_END.matcher(log);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 if (endError.matches()) {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 error = -1;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 if (error > 0) {
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
75 calculation.addError(new Integer(error), log);
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 Matcher startWarning = WSPLGEN_WARNING_START.matcher(log);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 if (startWarning.matches()) {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 warning = Integer.parseInt(startWarning.group(1));
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 return;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 Matcher endWarning = WSPLGEN_WARNING_END.matcher(log);
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 if (endWarning.matches()) {
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 warning = -1;
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 if (warning > 0) {
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
90 calculation.addWarning(new Integer(warning), log);
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 public int numErrors() {
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
96 return calculation.numErrors();
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 public int numWarnings() {
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1147
diff changeset
101 return calculation.numWarnings();
1147
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 }
e7d5452a7381 Added a 'ProblemObserver' that analyses WSPLGEN's error stream for errors and warnings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 // vim:set ts=4 sw=4 si et sta sts=5 fenc=utf-8 :

http://dive4elements.wald.intevation.org