use of io.datarouter.tasktracker.scheduler.LongRunningTaskStatus in project datarouter by hotpads.
the class LongRunningTasksHandler method longRunningTasks.
@Handler(defaultHandler = true)
Mav longRunningTasks(OptionalString name, OptionalString status) {
Mav mav = new Mav(files.jsp.admin.datarouter.tasktracker.longRunningTasksJsp);
String lowercaseNameSearch = name.map(String::toLowerCase).map(String::trim).orElse("");
boolean showAllStatuses = status.map(ALL_STATUSES_VALUE::equals).orElse(false);
LongRunningTaskStatus filteredStatus;
if (showAllStatuses) {
filteredStatus = null;
} else {
filteredStatus = status.map(LongRunningTaskStatus::fromPersistentStringStatic).orElse(LongRunningTaskStatus.RUNNING);
}
ZoneId zoneId = currentUserSessionInfoService.getZoneId(request);
List<LongRunningTaskJspDto> longRunningTasks = longRunningTaskDao.scan().include(task -> task.getKey().getName().toLowerCase().contains(lowercaseNameSearch)).include(task -> showAllStatuses || task.getJobExecutionStatus() == filteredStatus).map(task -> new LongRunningTaskJspDto(task, zoneId)).list();
Set<Pair<String, String>> statuses = Arrays.stream(LongRunningTaskStatus.values()).map(jobExecutionStatus -> new Pair<>(jobExecutionStatus.name(), jobExecutionStatus.getPersistentString())).collect(Collectors.toSet());
mav.put("longRunningTasks", longRunningTasks);
mav.put("statuses", statuses);
mav.put("allStatusesValue", ALL_STATUSES_VALUE);
mav.put("displayedStatus", showAllStatuses ? ALL_STATUSES_VALUE : filteredStatus.getPersistentString());
if (!showAllStatuses) {
mav.put("filteringStatusName", filteredStatus.name());
}
mav.put("nameSearch", name.orElse(""));
mav.put("legend", legend().renderFormatted());
return mav;
}
Aggregations