Skip to content

Commit

Permalink
Added taskExecutionStatus to TaskExecutionThinResource. (#5781)
Browse files Browse the repository at this point in the history
  • Loading branch information
corneil committed Apr 23, 2024
1 parent 6833026 commit ed3b379
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.cloud.dataflow.schema.AggregateTaskExecution;
import org.springframework.hateoas.PagedModel;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.util.StringUtils;

/**
* This resource is a match for AggregateTaskExecution and should satisfy UI paging.
Expand Down Expand Up @@ -66,6 +67,8 @@ public class TaskExecutionThinResource extends RepresentationModel<TaskExecution

private String errorMessage;

private String taskExecutionStatus;

/**
* @since 2.11.0
*/
Expand Down Expand Up @@ -178,6 +181,39 @@ public String getPlatformName() {
public void setPlatformName(String platformName) {
this.platformName = platformName;
}
public void setTaskExecutionStatus(String taskExecutionStatus) {
this.taskExecutionStatus = taskExecutionStatus;
}

/**
* Returns the calculated status of this {@link TaskExecution}.
*
* If {@link #startTime} is
* null, the {@link TaskExecution} is considered to be not running (never executed).
*
* If {@link #endTime} is
* null, the {@link TaskExecution} is considered to be still running:
* {@link TaskExecutionStatus#RUNNING}. If the {@link #endTime} is defined and the
* {@link #exitCode} is non-zero, an status of {@link TaskExecutionStatus#ERROR} is assumed,
* if {@link #exitCode} is zero, {@link TaskExecutionStatus#COMPLETE} is returned.
*
* @return TaskExecutionStatus, never null
*/
public TaskExecutionStatus getTaskExecutionStatus() {
if (StringUtils.hasText(this.taskExecutionStatus)) {
return TaskExecutionStatus.valueOf(this.taskExecutionStatus);
}
if (this.startTime == null) {
return TaskExecutionStatus.UNKNOWN;
}
if (this.endTime == null) {
return TaskExecutionStatus.RUNNING;
}

return (this.exitCode == null) ? TaskExecutionStatus.RUNNING :
((this.exitCode == 0) ? TaskExecutionStatus.COMPLETE : TaskExecutionStatus.ERROR);
}

public static class Page extends PagedModel<TaskExecutionThinResource> {
}
}

0 comments on commit ed3b379

Please sign in to comment.