Search in sources :

Example 1 with EventSelectionField

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));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria) Notification(com.vaadin.ui.Notification) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField)

Example 2 with EventSelectionField

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));
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) HashSet(java.util.HashSet) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField)

Example 3 with EventSelectionField

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));
}
Also used : ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) EventGroupReferenceDto(de.symeda.sormas.api.event.EventGroupReferenceDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField)

Example 4 with EventSelectionField

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));
}
Also used : ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) EventGroupReferenceDto(de.symeda.sormas.api.event.EventGroupReferenceDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField)

Example 5 with EventSelectionField

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);
}
Also used : Window(com.vaadin.ui.Window) Label(com.vaadin.ui.Label) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) VerticalLayout(com.vaadin.ui.VerticalLayout) SampleDto(de.symeda.sormas.api.sample.SampleDto)

Aggregations

EventIndexDto (de.symeda.sormas.api.event.EventIndexDto)8 EventSelectionField (de.symeda.sormas.ui.events.eventLink.EventSelectionField)8 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)8 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)6 EventCriteria (de.symeda.sormas.api.event.EventCriteria)3 EventParticipantReferenceDto (de.symeda.sormas.api.event.EventParticipantReferenceDto)3 ReferenceDto (de.symeda.sormas.api.ReferenceDto)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)2 ContactReferenceDto (de.symeda.sormas.api.contact.ContactReferenceDto)2 EventDto (de.symeda.sormas.api.event.EventDto)2 EventGroupReferenceDto (de.symeda.sormas.api.event.EventGroupReferenceDto)2 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)2 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)2 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)2 HashSet (java.util.HashSet)2 Label (com.vaadin.ui.Label)1 Notification (com.vaadin.ui.Notification)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1