in gui/servlet/embedded/src/main/java/org/apache/batchee/servlet/JBatchController.java [236:285]
private void listExecutions(final HttpServletRequest req, final String name, final int pageSize, final int inStart) {
if (!readOnly) { // can be an auto refresh asking for a stop
final String stopId = req.getParameter("stop");
if (stopId != null) {
try {
operator.stop(Long.parseLong(stopId));
} catch (final NoSuchJobExecutionException nsje) {
// no-op
} catch (final JobExecutionNotRunningException nsje) {
// no-op
}
}
} else {
reportReadOnly(req);
return;
}
final int jobInstanceCount = operator.getJobInstanceCount(name);
int start = inStart;
if (start == -1) { // first page is last page
start = Math.max(0, jobInstanceCount - pageSize);
}
final List<JobInstance> instances = new ArrayList<JobInstance>(operator.getJobInstances(name, start, pageSize));
Collections.sort(instances, JobInstanceIdComparator.INSTANCE);
final Map<JobInstance, List<JobExecution>> executions = new LinkedHashMap<JobInstance, List<JobExecution>>();
for (final JobInstance instance : instances) {
executions.put(instance, operator.getJobExecutions(instance));
}
req.setAttribute("view", "job-instances");
req.setAttribute("name", name);
req.setAttribute("executions", executions);
int nextStart = start + pageSize;
if (nextStart > jobInstanceCount) {
nextStart = -1;
}
req.setAttribute("nextStart", nextStart);
req.setAttribute("previousStart", start - pageSize);
if (jobInstanceCount > pageSize) {
req.setAttribute("lastStart", Math.max(0, jobInstanceCount - pageSize));
} else {
req.setAttribute("lastStart", -1);
}
}