@CliCommand(value = DISPLAY_JOB_INSTANCE, help = "Display information about a given job instance")
public CharSequence displayJobInstance(
@CliOption(key = { "", "id" }, help = "the id of the job instance to retrieve") long instanceId
) {
JobInstanceInfoResource jobInstance = jobOperations().displayJobInstance(instanceId);
StringBuilder result = new StringBuilder("Information about instance ");
result.append(jobInstance.getInstanceId()).append(" of the job '").append(jobInstance.getJobName()).append(
"':\n");
Table table = new Table();
table.addHeader(1, new TableHeader("Name"))
.addHeader(2, new TableHeader("Execution Id"))
.addHeader(3, new TableHeader("Start Time"))
.addHeader(4, new TableHeader("Step Execution Count"))
.addHeader(5, new TableHeader("Status"))
.addHeader(6, new TableHeader("Job Parameters"));
for (JobExecutionInfoResource jobExecutionInfoResource : jobInstance.getJobExecutions()) {
String startTimeAsString =
jobExecutionInfoResource.getStartDate() + " " +
jobExecutionInfoResource.getStartTime() + " " +
jobExecutionInfoResource.getTimeZone().getID();
table.addRow(//
jobInstance.getJobName(), //
String.valueOf(jobExecutionInfoResource.getExecutionId()), //
startTimeAsString, //
String.valueOf(jobExecutionInfoResource.getStepExecutionCount()), //
jobExecutionInfoResource.getJobExecution().getStatus().name(), //
jobExecutionInfoResource.getJobParametersString()//