private List<JobInfo> chooseJobs() {
List<JobInfo> jobsToReport = new ArrayList<JobInfo>();
if (jobID != null) {
Job oneJob = jobManagerService.get(jobID);
JobInfo info = null;
if (isSingleJobOK(oneJob)) {
List<String> userList = oneJob.getSubjectUsernames();
ActionReport actionReport = oneJob.getActionReport();
String message = actionReport == null ? "" : actionReport.getMessage();
if (!StringUtils.ok(message)) {
message = ProgressStatusClient.composeMessageForPrint(oneJob.getCommandProgress());
}
String exitCode = actionReport == null ? "" : actionReport.getActionExitCode().name();
info = new JobInfo(oneJob.getId(),oneJob.getName(),oneJob.getCommandExecutionDate(),exitCode,userList.get(0),message,oneJob.getJobsFile(),oneJob.getState().name(),0);
} else {
if (getCompletedJobs() != null) {
info = getCompletedJobForId(jobID);
}
}
if (info != null && !skipJob(info.jobName)) {
jobsToReport.add(info);
}
} else {
for (Iterator<Job> iterator = jobManagerService.getJobs(); iterator.hasNext(); ) {
Job job = iterator.next();
if (isJobEligible(job)) {
List<String> userList = job.getSubjectUsernames();
ActionReport actionReport = job.getActionReport();
String message = actionReport == null ? "" : actionReport.getMessage();
if (!StringUtils.ok(message)) {
message = ProgressStatusClient.composeMessageForPrint(job.getCommandProgress());
}
String exitCode = actionReport == null ? "" : actionReport.getActionExitCode().name();
String user = DEFAULT_USER_STRING;
if(userList.size() > 0){
user = userList.get(0);
}
jobsToReport.add(new JobInfo(job.getId(),job.getName(),job.getCommandExecutionDate(),exitCode,user,message,job.getJobsFile(),job.getState().name(),0));
}
}
JobInfos completedJobs = getCompletedJobs();
if (completedJobs != null ) {