Search in sources :

Example 1 with LongRunningTaskStatus

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;
}
Also used : LongRunningTaskStatus(io.datarouter.tasktracker.scheduler.LongRunningTaskStatus) Arrays(java.util.Arrays) CurrentUserSessionInfoService(io.datarouter.web.user.session.CurrentUserSessionInfoService) DateTool(io.datarouter.util.DateTool) Date(java.util.Date) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) Inject(javax.inject.Inject) NumberFormatter(io.datarouter.util.number.NumberFormatter) Duration(java.time.Duration) DatarouterTaskTrackerFiles(io.datarouter.tasktracker.config.DatarouterTaskTrackerFiles) Mav(io.datarouter.web.handler.mav.Mav) Set(java.util.Set) StringTool(io.datarouter.util.string.StringTool) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) ContainerTag(j2html.tags.ContainerTag) ZonedDateFormatterTool(io.datarouter.util.time.ZonedDateFormatterTool) List(java.util.List) LongRunningTaskDao(io.datarouter.tasktracker.storage.LongRunningTaskDao) J2HtmlLegendTable(io.datarouter.web.html.j2html.J2HtmlLegendTable) BaseHandler(io.datarouter.web.handler.BaseHandler) Optional(java.util.Optional) Pair(io.datarouter.util.tuple.Pair) TagCreator.div(j2html.TagCreator.div) LongRunningTask(io.datarouter.tasktracker.storage.LongRunningTask) Mav(io.datarouter.web.handler.mav.Mav) ZoneId(java.time.ZoneId) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) LongRunningTaskStatus(io.datarouter.tasktracker.scheduler.LongRunningTaskStatus) Pair(io.datarouter.util.tuple.Pair) BaseHandler(io.datarouter.web.handler.BaseHandler)

Aggregations

DatarouterTaskTrackerFiles (io.datarouter.tasktracker.config.DatarouterTaskTrackerFiles)1 LongRunningTaskStatus (io.datarouter.tasktracker.scheduler.LongRunningTaskStatus)1 LongRunningTask (io.datarouter.tasktracker.storage.LongRunningTask)1 LongRunningTaskDao (io.datarouter.tasktracker.storage.LongRunningTaskDao)1 DateTool (io.datarouter.util.DateTool)1 NumberFormatter (io.datarouter.util.number.NumberFormatter)1 StringTool (io.datarouter.util.string.StringTool)1 ZonedDateFormatterTool (io.datarouter.util.time.ZonedDateFormatterTool)1 Pair (io.datarouter.util.tuple.Pair)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 Mav (io.datarouter.web.handler.mav.Mav)1 OptionalString (io.datarouter.web.handler.types.optional.OptionalString)1 J2HtmlLegendTable (io.datarouter.web.html.j2html.J2HtmlLegendTable)1 CurrentUserSessionInfoService (io.datarouter.web.user.session.CurrentUserSessionInfoService)1 TagCreator.div (j2html.TagCreator.div)1 ContainerTag (j2html.tags.ContainerTag)1 Duration (java.time.Duration)1 ZoneId (java.time.ZoneId)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1