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);
}
Aggregations