Mercurial > dive4elements > river
changeset 1157:a470b7c3b165
Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
flys-artifacts/trunk@2689 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 09 Sep 2011 15:03:00 +0000 |
parents | 4da9f058fed6 |
children | fbe18ad4caff |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CalculationMessage.java flys-artifacts/src/main/java/de/intevation/flys/wsplgen/JobObserver.java |
diffstat | 4 files changed, 89 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Sep 09 13:26:28 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Sep 09 15:03:00 2011 +0000 @@ -1,3 +1,19 @@ +2011-09-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/CalculationMessage.java: + New. A subclass of Message (in the Artifacts system). It stores a + string message and a progress (in form of step x/y). + + * src/main/java/de/intevation/flys/wsplgen/JobObserver.java: The observer + now writes background messages into the artifact system using the + CallContext.addBackgroundMessage(). We use instances of + CalculationMessage here, that makes the WINFOArtifact able to put + progress information into the Artifact's DESCRIBE as well. + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: Write + status message and progress information into the DESCRIBE if the + Artifact has started a background process. + 2011-09-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> Fix flys/issue280 .
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Sep 09 13:26:28 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Sep 09 15:03:00 2011 +0000 @@ -14,6 +14,7 @@ import de.intevation.artifactdatabase.transition.TransitionEngine; import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.Message; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -53,6 +54,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -63,6 +65,7 @@ import org.w3c.dom.Node; import de.intevation.flys.artifacts.charts.CrossSectionApp; +import de.intevation.flys.artifacts.model.CalculationMessage; /** * The default WINFO artifact. @@ -192,6 +195,7 @@ CallContext context ) { Element inBackground = cr.create("background-processing"); + root.appendChild(inBackground); cr.addAttr( inBackground, @@ -199,7 +203,26 @@ String.valueOf(context.isInBackground()), true); - root.appendChild(inBackground); + LinkedList<Message> messages = context.getBackgroundMessages(); + + if (messages == null) { + return; + } + + CalculationMessage message = (CalculationMessage) messages.getLast(); + cr.addAttr( + inBackground, + "steps", + String.valueOf(message.getSteps()), + true); + + cr.addAttr( + inBackground, + "currentStep", + String.valueOf(message.getCurrentStep()), + true); + + inBackground.setTextContent(message.getMessage()); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CalculationMessage.java Fri Sep 09 15:03:00 2011 +0000 @@ -0,0 +1,45 @@ +package de.intevation.flys.artifacts.model; + +import de.intevation.artifacts.Message; + + +public class CalculationMessage implements Message { + + protected String message; + protected int steps; + protected int currentStep; + + + public CalculationMessage() { + } + + + public CalculationMessage(int steps, int currentStep, String message) { + this.steps = steps; + this.currentStep = currentStep; + this.message = message; + } + + + public int getSteps() { + return steps; + } + + + public int getCurrentStep() { + return currentStep; + } + + + public String getMessage() { + return message; + } + + + @Override + public String getText() { + return + String.valueOf(currentStep) + "/" + String.valueOf(steps) + + " - " + getMessage(); + } +}
--- a/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/JobObserver.java Fri Sep 09 13:26:28 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/JobObserver.java Fri Sep 09 15:03:00 2011 +0000 @@ -9,6 +9,7 @@ import org.apache.log4j.Logger; +import de.intevation.flys.artifacts.model.CalculationMessage; import de.intevation.flys.artifacts.model.WSPLGENJob; @@ -94,6 +95,9 @@ 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); } }