public JobExecutionInfo(JobExecution jobExecution, TimeZone timeZone) { // this.jobExecution = jobExecution; this.exitStatus = jobExecution.getExitStatus(); this.timeZone = timeZone; this.id = jobExecution.getId(); this.jobId = jobExecution.getJobId(); this.stepExecutionCount = jobExecution.getStepExecutions().size(); this.jobParameters = converter.getProperties(jobExecution.getJobParameters()); this.jobParametersString = new JobParametersExtractor().fromJobParameters(jobExecution.getJobParameters()); JobInstance jobInstance = jobExecution.getJobInstance(); if (jobInstance != null) { this.jobName = jobInstance.getJobName(); BatchStatus status = jobExecution.getStatus(); this.restartable = status.isGreaterThan(BatchStatus.STOPPING) && status.isLessThan(BatchStatus.ABANDONED); this.abandonable = status.isGreaterThan(BatchStatus.STARTED) && status != BatchStatus.ABANDONED; this.stoppable = status.isLessThan(BatchStatus.STOPPING); } else { this.jobName = "?"; } // Duration is always in GMT durationFormat.setTimeZone(TimeZone.getTimeZone("GMT")); // The others can be localized timeFormat.setTimeZone(timeZone); dateFormat.setTimeZone(timeZone); if (jobExecution.getStartTime() != null) { this.startDate = dateFormat.format(jobExecution.getStartTime()); this.startTime = timeFormat.format(jobExecution.getStartTime()); Date endTime = jobExecution.getEndTime() != null ? jobExecution.getEndTime() : new Date(); this.duration = durationFormat.format( new Date(endTime.getTime() - jobExecution.getStartTime().getTime())); } }
private boolean isComplete(BatchStatus status) { return status.equals(BatchStatus.COMPLETED) || status.isGreaterThan(BatchStatus.STARTED); }