use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateEvent.
public void selectOrCreateEvent(CaseReferenceDto caseRef) {
CaseDataDto caseDataDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());
EventSelectionField eventSelect = new EventSelectionField(caseDataDto.getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForCase), null);
eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.caze(caseRef);
eventCriteria.setUserFilterIncluded(false);
List<EventIndexDto> eventIndexDto = FacadeProvider.getEventFacade().getIndexList(eventCriteria, null, null, null);
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
if (!eventIndexDto.contains(selectedEvent)) {
linkCaseToEvent(eventReferenceDto, caseDataDto, caseRef);
SormasUI.refreshView();
} else {
SormasUI.refreshView();
Notification notification = new Notification(I18nProperties.getString(Strings.messagePersonAlreadyCaseInEvent), "", Type.HUMANIZED_MESSAGE);
notification.setDelayMsec(10000);
notification.show(Page.getCurrent());
}
} else {
create(caseRef);
SormasUI.refreshView();
}
});
eventSelect.setSelectionChangeCallback((commitAllowed) -> {
component.getCommitButton().setEnabled(commitAllowed);
});
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventActionsGrid method setLazyDataProvider.
public void setLazyDataProvider() {
DataProvider<EventActionIndexDto, EventCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getActionFacade().getEventActionList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getActionFacade().countEventActions(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(SelectionMode.NONE);
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class LabMessageController method pickOrCreateEvent.
private void pickOrCreateEvent(LabMessageDto labMessageDto, PersonDto person) {
EventSelectionField eventSelect = new EventSelectionField(labMessageDto.getTestedDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForLabMessage), null);
eventSelect.setWidth(1024, Sizeable.Unit.PIXELS);
Window window = VaadinUiUtil.createPopupWindow();
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.setPerson(person.toReference());
eventCriteria.setUserFilterIncluded(false);
List<EventIndexDto> eventIndexDtos = FacadeProvider.getEventFacade().getIndexList(eventCriteria, null, null, null);
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
if (!eventIndexDtos.contains(selectedEvent)) {
createEventParticipant(FacadeProvider.getEventFacade().getEventByUuid(eventReferenceDto.getUuid(), false), labMessageDto, person);
} else {
CommitDiscardWrapperComponent<VerticalLayout> commitDiscardWrapperComponent = new CommitDiscardWrapperComponent<>(new VerticalLayout(new Label(I18nProperties.getString(Strings.infoEventParticipantAlreadyExisting))));
commitDiscardWrapperComponent.getCommitButton().setCaption(I18nProperties.getCaption(Captions.actionContinue));
commitDiscardWrapperComponent.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionBack));
commitDiscardWrapperComponent.addCommitListener(() -> {
EventParticipantReferenceDto participant = FacadeProvider.getEventParticipantFacade().getReferenceByEventAndPerson(selectedEvent.getUuid(), person.getUuid());
List<SampleDto> samples = FacadeProvider.getSampleFacade().getSimilarSamples(createSampleCriteria(labMessageDto).eventParticipant(participant));
if (samples.isEmpty()) {
createSample(SampleDto.build(UserProvider.getCurrent().getUserReference(), participant), labMessageDto, selectedEvent.getDisease(), false);
} else {
pickOrCreateSample(FacadeProvider.getEventParticipantFacade().getByUuid(participant.getUuid()), labMessageDto, samples);
}
});
commitDiscardWrapperComponent.addDiscardListener(() -> pickOrCreateEvent(labMessageDto, person));
VaadinUiUtil.showModalPopupWindow(commitDiscardWrapperComponent, I18nProperties.getCaption(Captions.info));
}
} else {
createEvent(labMessageDto, person);
}
window.close();
});
component.addDiscardListener(window::close);
eventSelect.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
window.setContent(component);
window.setCaption(I18nProperties.getString(Strings.headingPickOrCreateEvent));
UI.getCurrent().addWindow(window);
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventService method createEventDateFilter.
private Predicate createEventDateFilter(CriteriaQuery<?> cq, CriteriaBuilder cb, From<?, Event> from, EventCriteria eventCriteria) {
Predicate filter = null;
CriteriaDateType eventDateType = eventCriteria.getEventDateType();
Date eventDateFrom = eventCriteria.getEventDateFrom();
Date eventDateTo = eventCriteria.getEventDateTo();
if (eventDateType == null || eventDateType == EventCriteriaDateType.EVENT_DATE) {
Predicate eventDateFilter = null;
if (eventDateFrom != null && eventDateTo != null) {
eventDateFilter = cb.or(cb.and(cb.isNull(from.get(Event.END_DATE)), cb.between(from.get(Event.START_DATE), eventDateFrom, eventDateTo)), cb.and(cb.isNull(from.get(Event.START_DATE)), cb.between(from.get(Event.END_DATE), eventDateFrom, eventDateTo)), cb.and(cb.greaterThanOrEqualTo(from.get(Event.END_DATE), eventDateFrom), cb.lessThanOrEqualTo(from.get(Event.START_DATE), eventDateTo)));
} else if (eventDateFrom != null) {
eventDateFilter = cb.or(cb.and(cb.isNull(from.get(Event.END_DATE)), cb.greaterThanOrEqualTo(from.get(Event.START_DATE), eventDateFrom)), cb.and(cb.isNull(from.get(Event.START_DATE)), cb.greaterThanOrEqualTo(from.get(Event.END_DATE), eventDateFrom)));
} else if (eventDateTo != null) {
eventDateFilter = cb.or(cb.and(cb.isNull(from.get(Event.START_DATE)), cb.lessThanOrEqualTo(from.get(Event.END_DATE), eventDateTo)), cb.and(cb.isNull(from.get(Event.END_DATE)), cb.lessThanOrEqualTo(from.get(Event.START_DATE), eventDateTo)));
}
if (eventDateFrom != null || eventDateTo != null) {
filter = CriteriaBuilderHelper.and(cb, filter, eventDateFilter);
}
} else if (eventDateType == EventCriteriaDateType.REPORT_DATE) {
Predicate eventDateFilter = null;
if (eventDateFrom != null && eventDateTo != null) {
eventDateFilter = cb.between(from.get(Event.REPORT_DATE_TIME), eventDateFrom, eventDateTo);
} else if (eventDateFrom != null) {
eventDateFilter = cb.greaterThanOrEqualTo(from.get(Event.REPORT_DATE_TIME), eventDateFrom);
} else if (eventDateTo != null) {
eventDateFilter = cb.lessThanOrEqualTo(from.get(Event.REPORT_DATE_TIME), eventDateTo);
}
if (eventDateFrom != null || eventDateTo != null) {
filter = CriteriaBuilderHelper.and(cb, filter, eventDateFilter);
}
} else if (eventDateType == ExternalShareDateType.LAST_EXTERNAL_SURVEILLANCE_TOOL_SHARE) {
filter = externalShareInfoService.buildLatestSurvToolShareDateFilter(cq, cb, from, ExternalShareInfo.EVENT, (latestShareDate) -> {
if (eventDateFrom != null && eventDateTo != null) {
return cb.between(latestShareDate, eventDateFrom, eventDateTo);
} else if (eventDateFrom != null) {
return cb.greaterThanOrEqualTo(latestShareDate, eventDateFrom);
} else {
return cb.lessThanOrEqualTo(latestShareDate, eventDateTo);
}
});
}
return filter;
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testGetExportList.
@Test
public void testGetExportList() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR);
creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 1), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.setDisease(Disease.EVD);
List<EventExportDto> results = getEventFacade().getExportList(eventCriteria, Collections.emptySet(), 0, 100);
// List should have one entry
assertThat(results, Matchers.hasSize(1));
}
Aggregations