private JobExecutionInfoResource getJobExecutionInfoResource(JobExecution jobExecution,
Set<String> restartableJobs,
Set<String> deployedJobs,
Set<String> jobDefinitionNames) {
final JobExecutionInfoResource jobExecutionInfoResource = jobExecutionInfoResourceAssembler.toResource(new JobExecutionInfo(
jobExecution,
timeZone));
final String jobName = jobExecution.getJobInstance().getJobName();
jobExecutionInfoResource.setDeleted(!jobDefinitionNames.contains(jobName));
jobExecutionInfoResource.setDeployed(deployedJobs.contains(jobName));
if (restartableJobs.contains(jobName)) {
// Set restartable flag for the JobExecutionResource based on the actual JobInstance
// If any one of the jobExecutions for the jobInstance is complete, set the restartable flag for
// all the jobExecutions to false.
if (jobExecution.getStatus() != BatchStatus.COMPLETED) {
jobExecutionInfoResource.setRestartable(isJobExecutionRestartable(jobExecution));
}
}
else {
// Set false for this job execution irrespective its status.
jobExecutionInfoResource.setRestartable(false);
}
return jobExecutionInfoResource;
}