use of org.hisp.dhis.program.notification.ProgramNotificationInstanceParam in project dhis2-core by dhis2.
the class ProgramNotificationInstanceServiceTest method testGetProgramNotificationInstance.
@Test
void testGetProgramNotificationInstance() {
programRuleEngineService.evaluateEnrollmentAndRunEffects(programInstance.getId());
List<ProgramNotificationInstance> programNotificationInstances = programNotificationInstanceService.getProgramNotificationInstances(ProgramNotificationInstanceParam.builder().programInstance(programInstance).build());
assertFalse(programNotificationInstances.isEmpty());
assertSame(programInstance, programNotificationInstances.get(0).getProgramInstance());
ProgramNotificationInstanceParam param = ProgramNotificationInstanceParam.builder().programInstance(programInstance).build();
List<ProgramNotificationInstance> instances = programNotificationInstanceService.getProgramNotificationInstances(param);
assertFalse(instances.isEmpty());
}
use of org.hisp.dhis.program.notification.ProgramNotificationInstanceParam in project dhis2-core by dhis2.
the class ProgarmNotificationInstanceController method getScheduledMessage.
// -------------------------------------------------------------------------
// GET
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL')")
@GetMapping(produces = { "application/json" })
@ResponseBody
public PagingWrapper<ProgramNotificationInstance> getScheduledMessage(@RequestParam(required = false) String programInstance, @RequestParam(required = false) String programStageInstance, @RequestParam(required = false) Date scheduledAt, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false, defaultValue = "0") int page, @RequestParam(required = false, defaultValue = "50") int pageSize) {
ProgramNotificationInstanceParam params = ProgramNotificationInstanceParam.builder().programInstance(programInstanceService.getProgramInstance(programInstance)).programStageInstance(programStageInstanceService.getProgramStageInstance(programStageInstance)).skipPaging(skipPaging).page(page).pageSize(pageSize).scheduledAt(scheduledAt).build();
PagingWrapper<ProgramNotificationInstance> instancePagingWrapper = new PagingWrapper<>();
if (!skipPaging) {
long total = programNotificationInstanceService.countProgramNotificationInstances(params);
instancePagingWrapper = instancePagingWrapper.withPager(PagingWrapper.Pager.builder().page(page).pageSize(pageSize).total(total).build());
}
programNotificationInstanceService.validateQueryParameters(params);
List<ProgramNotificationInstance> instances = programNotificationInstanceService.getProgramNotificationInstances(params);
return instancePagingWrapper.withInstances(instances);
}
Aggregations