Search in sources :

Example 1 with TaskCategory

use of org.hisp.dhis.scheduling.TaskCategory in project dhis2-core by dhis2.

the class SystemController method getTaskSummaryJson.

@RequestMapping(value = "/taskSummaries/{category}", method = RequestMethod.GET, produces = { "*/*", "application/json" })
public void getTaskSummaryJson(HttpServletResponse response, @PathVariable("category") String category) throws IOException {
    if (category != null) {
        TaskCategory taskCategory = TaskCategory.valueOf(category.toUpperCase());
        TaskId taskId = new TaskId(taskCategory, currentUserService.getCurrentUser());
        Object summary = notifier.getTaskSummary(taskId);
        if (//TODO improve this
        summary != null && summary.getClass().isAssignableFrom(ImportSummary.class)) {
            ImportSummary importSummary = (ImportSummary) summary;
            renderService.toJson(response.getOutputStream(), importSummary);
            return;
        } else {
            renderService.toJson(response.getOutputStream(), summary);
            return;
        }
    }
    renderService.toJson(response.getOutputStream(), new ImportSummary());
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) TaskCategory(org.hisp.dhis.scheduling.TaskCategory) ImportSummary(org.hisp.dhis.dxf2.common.ImportSummary) StyleObject(org.hisp.dhis.setting.StyleObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with TaskCategory

use of org.hisp.dhis.scheduling.TaskCategory in project dhis2-core by dhis2.

the class SystemController method getTaskJson.

@RequestMapping(value = "/tasks/{category}", method = RequestMethod.GET, produces = { "*/*", "application/json" })
public void getTaskJson(@PathVariable("category") String category, @RequestParam(required = false) String lastId, HttpServletResponse response) throws IOException {
    List<Notification> notifications = new ArrayList<>();
    if (category != null) {
        TaskCategory taskCategory = TaskCategory.valueOf(category.toUpperCase());
        TaskId taskId = new TaskId(taskCategory, currentUserService.getCurrentUser());
        notifications = notifier.getNotifications(taskId, lastId);
    }
    renderService.toJson(response.getOutputStream(), notifications);
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) TaskCategory(org.hisp.dhis.scheduling.TaskCategory) ArrayList(java.util.ArrayList) Notification(org.hisp.dhis.system.notification.Notification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TaskCategory (org.hisp.dhis.scheduling.TaskCategory)2 TaskId (org.hisp.dhis.scheduling.TaskId)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ArrayList (java.util.ArrayList)1 ImportSummary (org.hisp.dhis.dxf2.common.ImportSummary)1 StyleObject (org.hisp.dhis.setting.StyleObject)1 Notification (org.hisp.dhis.system.notification.Notification)1