Search in sources :

Example 1 with ProgramNotificationTemplateParam

use of org.hisp.dhis.program.notification.ProgramNotificationTemplateParam in project dhis2-core by dhis2.

the class ProgramNotificationTemplateController method getProgramNotificationTemplates.

// -------------------------------------------------------------------------
// GET
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL')")
@GetMapping(produces = { "application/json" }, value = "/filter")
@ResponseBody
public PagingWrapper<ProgramNotificationTemplate> getProgramNotificationTemplates(@RequestParam(required = false) String program, @RequestParam(required = false) String programStage, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false, defaultValue = "0") int page, @RequestParam(required = false, defaultValue = "50") int pageSize) {
    ProgramNotificationTemplateParam params = ProgramNotificationTemplateParam.builder().program(programService.getProgram(program)).programStage(programStageService.getProgramStage(programStage)).skipPaging(skipPaging).page(page).pageSize(pageSize).build();
    PagingWrapper<ProgramNotificationTemplate> templatePagingWrapper = new PagingWrapper<>();
    if (!skipPaging) {
        long total = programNotificationTemplateService.countProgramNotificationTemplates(params);
        templatePagingWrapper = templatePagingWrapper.withPager(PagingWrapper.Pager.builder().page(page).pageSize(pageSize).total(total).build());
    }
    List<ProgramNotificationTemplate> instances = programNotificationTemplateService.getProgramNotificationTemplates(params);
    return templatePagingWrapper.withInstances(instances);
}
Also used : PagingWrapper(org.hisp.dhis.webapi.controller.event.webrequest.PagingWrapper) ProgramNotificationTemplate(org.hisp.dhis.program.notification.ProgramNotificationTemplate) ProgramNotificationTemplateParam(org.hisp.dhis.program.notification.ProgramNotificationTemplateParam) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ProgramNotificationTemplate (org.hisp.dhis.program.notification.ProgramNotificationTemplate)1 ProgramNotificationTemplateParam (org.hisp.dhis.program.notification.ProgramNotificationTemplateParam)1 PagingWrapper (org.hisp.dhis.webapi.controller.event.webrequest.PagingWrapper)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1