use of de.symeda.sormas.ui.events.eventLink.EventSelectionField 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.ui.events.eventLink.EventSelectionField in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateSuperordinateEvent.
public void selectOrCreateSuperordinateEvent(EventReferenceDto subordinateEventRef) {
Set<String> excludedUuids = new HashSet<>();
excludedUuids.add(subordinateEventRef.getUuid());
excludedUuids.addAll(FacadeProvider.getEventFacade().getAllSubordinateEventUuids(subordinateEventRef.getUuid()));
EventDto subordinateEvent = FacadeProvider.getEventFacade().getEventByUuid(subordinateEventRef.getUuid(), false);
EventSelectionField selectionField = EventSelectionField.forSuperordinateEvent(subordinateEvent, excludedUuids);
selectionField.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = selectionField.getValue();
if (selectedEvent != null) {
subordinateEvent.setSuperordinateEvent(selectedEvent.toReference());
FacadeProvider.getEventFacade().save(subordinateEvent);
navigateToData(subordinateEventRef.getUuid());
Notification.show(I18nProperties.getString(Strings.messageEventLinkedAsSuperordinate), Type.TRAY_NOTIFICATION);
} else {
createSuperordinateEvent(subordinateEventRef);
}
});
selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
use of de.symeda.sormas.ui.events.eventLink.EventSelectionField in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateEventForCaseList.
public void selectOrCreateEventForCaseList(List<CaseReferenceDto> caseRefs) {
if (caseRefs == null || caseRefs.isEmpty()) {
return;
}
List<CaseDataDto> caseDataDtos = FacadeProvider.getCaseFacade().getByUuids(caseRefs.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
EventSelectionField eventSelect = new EventSelectionField(caseDataDtos.stream().findFirst().get().getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForCases), null);
eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
linkCasesToEvent(eventReferenceDto, caseDataDtos);
} else {
createFromCaseList(caseRefs);
SormasUI.refreshView();
}
});
eventSelect.setSelectionChangeCallback(commitAllowed -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
use of de.symeda.sormas.ui.events.eventLink.EventSelectionField in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateEventForContactList.
public void selectOrCreateEventForContactList(List<ContactReferenceDto> contactRefs) {
if (contactRefs == null || contactRefs.isEmpty()) {
return;
}
List<ContactDto> contactDtos = FacadeProvider.getContactFacade().getByUuids(contactRefs.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
EventSelectionField eventSelect = new EventSelectionField(contactDtos.stream().findFirst().get().getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForContact), null);
eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
linkContactsToEvent(eventReferenceDto, contactDtos);
} else {
createFromContactList(contactRefs);
SormasUI.refreshView();
}
});
eventSelect.setSelectionChangeCallback(commitAllowed -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
use of de.symeda.sormas.ui.events.eventLink.EventSelectionField 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);
}
Aggregations