use of org.hisp.dhis.dxf2.events.event.EventSearchParams in project dhis2-core by dhis2.
the class TrackerEventsExportController method getEvents.
@GetMapping(produces = APPLICATION_JSON_VALUE)
public PagingWrapper<org.hisp.dhis.tracker.domain.Event> getEvents(TrackerEventCriteria eventCriteria, @RequestParam Map<String, String> parameters, HttpServletRequest request) throws WebMessageException {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
EventSearchParams eventSearchParams = requestToSearchParamsMapper.map(eventCriteria);
if (areAllEnrollmentsInvalid(eventCriteria, eventSearchParams)) {
return new PagingWrapper<org.hisp.dhis.tracker.domain.Event>().withInstances(Collections.emptyList());
}
Events events = eventService.getEvents(eventSearchParams);
if (hasHref(fields, eventCriteria.getSkipEventId())) {
events.getEvents().forEach(e -> e.setHref(getUri(e.getEvent(), request)));
}
PagingWrapper<org.hisp.dhis.tracker.domain.Event> eventPagingWrapper = new PagingWrapper<>();
if (eventCriteria.isPagingRequest()) {
eventPagingWrapper = eventPagingWrapper.withPager(PagingWrapper.Pager.fromLegacy(eventCriteria, events.getPager()));
}
return eventPagingWrapper.withInstances(EVENTS_MAPPER.fromCollection(events.getEvents()));
}
use of org.hisp.dhis.dxf2.events.event.EventSearchParams in project dhis2-core by dhis2.
the class EventRequestToParamsMapperTest method testEventRequestToSearchParamsMapperSuccess.
@Test
void testEventRequestToSearchParamsMapperSuccess() {
EventSearchParams eventSearchParams = requestToSearchParamsMapper.map("programuid", null, null, null, "orgunituid", OrganisationUnitSelectionMode.ACCESSIBLE, "teiUid", null, null, null, null, null, null, null, null, null, null, null, null, false, false, null, null, false, new HashSet<>(), new HashSet<>(), null, null, new HashSet<>(), Collections.singleton("UXz7xuGCEhU:GT:100"), new HashSet<>(), false, // Then
false);
assertThat(eventSearchParams, is(not(nullValue())));
}
Aggregations