# HG changeset patch # User Ingo Weinzierl # Date 1315580580 0 # Node ID a470b7c3b16507aac324144c4ee700d40b76d75e # Parent 4da9f058fed6595d939ed53d086a6f7ddb45a719 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document. flys-artifacts/trunk@2689 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4da9f058fed6 -r a470b7c3b165 flys-artifacts/ChangeLog --- 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 + + * 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 Fix flys/issue280 . diff -r 4da9f058fed6 -r a470b7c3b165 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- 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 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()); } diff -r 4da9f058fed6 -r a470b7c3b165 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CalculationMessage.java --- /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(); + } +} diff -r 4da9f058fed6 -r a470b7c3b165 flys-artifacts/src/main/java/de/intevation/flys/wsplgen/JobObserver.java --- 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); } }