Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/wsplgen/JobObserver.java @ 2792:fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk
........
r4539 | teichmann | 2012-05-27 20:02:13 +0200 (So, 27 Mai 2012) | 1 line
FixA: Added forgotten csv/report facets/generators to conf.
........
r4540 | teichmann | 2012-05-27 20:11:31 +0200 (So, 27 Mai 2012) | 1 line
FixA: Fixed class cast bug in report facet.
........
r4543 | teichmann | 2012-05-28 20:35:01 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Added facet to return delta w/t as CSV
........
r4545 | teichmann | 2012-05-28 22:59:27 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Made Delta W/t calculation finally work
........
r4546 | teichmann | 2012-05-28 23:34:24 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: corrected fitting (Q->W instead W->Q).
........
flys-artifacts/tags/2.7@4547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 29 May 2012 04:58:29 +0000 |
parents | a470b7c3b165 |
children | 453d2d0c4258 |
line wrap: on
line source
package de.intevation.flys.wsplgen; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.log4j.Logger; import de.intevation.flys.artifacts.model.CalculationMessage; import de.intevation.flys.artifacts.model.WSPLGENJob; public class JobObserver extends Thread { private static Logger logger = Logger.getLogger(JobObserver.class); public static final String WSPLGEN_ENCODING = "ISO-8859-1"; public static final String WSPLGEN_LOG_OUTPUT = System.getProperty("wsplgen.log.output", "false"); public static final String[] STEPS = { ".*<-Auswertung der Kommandozeilen-Parameter beendet.*", ".*->Laden des DGM in Datei '.*' gestartet.*", ".*->Triangulierung der Knoten gestartet.*", ".*->Anpassung der Elemente an Dämme und Gräben gestartet.*", ".*<-WSPLGEN Version .* beendet.*" }; protected WSPLGENJob job; protected InputStream in; protected Pattern[] patterns; protected int len; protected boolean copy; public JobObserver(WSPLGENJob job) { this.job = job; this.len = 0; this.copy = Boolean.parseBoolean(WSPLGEN_LOG_OUTPUT); patterns = new Pattern[STEPS.length]; } protected void prepareRegexes() { for (int num = STEPS.length, i = 0; i < num; i++) { patterns[i] = Pattern.compile(STEPS[i], Pattern.DOTALL); } } public void setInputStream(InputStream in) { this.in = in; } public void run() { logger.debug("Start observation..."); prepareRegexes(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(in, WSPLGEN_ENCODING)); String line = null; while ((line = reader.readLine()) != null) { if (copy) { logger.debug(line); } update(line); } } catch (IOException ioe) { logger.warn("Observation canceled: " + ioe.getMessage()); } } protected void update(String log) { for (int num = patterns.length, i = 0; i < num; i++) { Matcher m = patterns[i].matcher(log); if (m.matches()) { job.getCallContext().addBackgroundMessage( new CalculationMessage(num, i+1, log)); logger.info("Finished step " + (i+1) + " / " + num); } } } } // vim:set ts=4 sw=4 si et sta sts=5 fenc=utf-8 :