Skip to content

SNAP-1597_snap-sta #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 9.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,35 +180,46 @@ public List<String> getErrors() {
}

/**
* Initialise and run the defined tool.
* <p>
* This method will block until the tool finishes its execution.
* </p>
* Initialise the defined tool.
*
* @throws OperatorException
* @throws OperatorException when validation error occurs
*/
@Override
public void initialize() throws OperatorException {
if (descriptor == null) {
descriptor = ((ToolAdapterOperatorDescriptor) getSpi().getOperatorDescriptor());
}
if (errorMessages != null) {
errorMessages.clear();
}
validateDescriptor();
if (!isStopped) {
beforeExecute();
}
setTargetProduct(new Product("STA empty product", "unknown", 0, 0));
isInitialised = true;
}

/**
* Executes the operator.
*
* @param pm A progress monitor to be notified for long-running tasks.
* @throws OperatorException If an error occurs during computation of the target raster.
*/
public void doExecute(ProgressMonitor pm) throws OperatorException {
if (this.progressMonitor == null) {
this.progressMonitor = SubProgressMonitor.create(pm, 1);
}
if (this.consumer == null) {
this.consumer = new DefaultOutputConsumer(descriptor.getProgressPattern(), descriptor.getErrorPattern(), descriptor.getStepPattern(), this.progressMonitor);
this.consumer.setLogger(getLogger());
}
Date currentTime = new Date();
int ret = -1;
try {
if (descriptor == null) {
descriptor = ((ToolAdapterOperatorDescriptor) getSpi().getOperatorDescriptor());
}
if (this.progressMonitor != null) {
this.progressMonitor.beginTask("Executing " + this.descriptor.getName(), 100);
}
if (this.consumer == null) {
this.consumer = new DefaultOutputConsumer(descriptor.getProgressPattern(), descriptor.getErrorPattern(), descriptor.getStepPattern(), this.progressMonitor);
this.consumer.setLogger(getLogger());
}
if (errorMessages != null) {
errorMessages.clear();
}
validateDescriptor();
if (!isStopped) {
beforeExecute();
}
if (!isStopped) {
if ((ret = execute()) != 0) {
this.consumer.consumeOutput(String.format("Process exited with value %d", ret));
Expand All @@ -221,9 +232,8 @@ public void initialize() throws OperatorException {
} finally {
try {
if (!wasCancelled) {
isInitialised = (postExecute() == 0);
} else {
isInitialised = true;
ret = postExecute();
this.consumer.consumeOutput(String.format("Load the result of the tool's execution exited with value %d", ret));
}
} finally {
if (this.progressMonitor != null) {
Expand All @@ -239,7 +249,6 @@ public void initialize() throws OperatorException {
}
}
}

public List<String> getExecutionOutput() {
return this.consumer.getProcessOutput();
}
Expand Down