Search in sources :

Example 21 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class EventController method create.

public EventDto create(ContactDto contact) {
    CommitDiscardWrapperComponent<EventDataForm> eventCreateComponent = getEventCreateComponent(contact);
    EventDto eventDto = eventCreateComponent.getWrappedComponent().getValue();
    VaadinUiUtil.showModalPopupWindow(eventCreateComponent, I18nProperties.getString(Strings.headingCreateNewEvent));
    return eventDto;
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto)

Example 22 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class EventController method createSubordinateEvent.

public EventDto createSubordinateEvent(EventReferenceDto superordinateEvent) {
    CommitDiscardWrapperComponent<EventDataForm> eventCreateComponent = getEventCreateComponent(superordinateEvent, false);
    EventDto eventDto = eventCreateComponent.getWrappedComponent().getValue();
    VaadinUiUtil.showModalPopupWindow(eventCreateComponent, I18nProperties.getString(Strings.headingCreateNewEvent));
    return eventDto;
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto)

Example 23 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class EventController method getEventViewTitleLayout.

public TitleLayout getEventViewTitleLayout(String uuid) {
    EventDto event = findEvent(uuid);
    TitleLayout titleLayout = new TitleLayout();
    titleLayout.addRow(event.getEventStatus().toString());
    if (event.getStartDate() != null) {
        String eventStartDateLabel = event.getEndDate() != null ? DateFormatHelper.buildPeriodString(event.getStartDate(), event.getEndDate()) : DateFormatHelper.formatDate(event.getStartDate());
        titleLayout.addRow(eventStartDateLabel);
    }
    String shortUuid = DataHelper.getShortUuid(event.getUuid());
    String eventTitle = event.getEventTitle();
    String mainRowText = StringUtils.isNotBlank(eventTitle) ? eventTitle + " (" + shortUuid + ")" : shortUuid;
    titleLayout.addMainRow(mainRowText);
    return titleLayout;
}
Also used : TitleLayout(de.symeda.sormas.ui.utils.components.page.title.TitleLayout) EventDto(de.symeda.sormas.api.event.EventDto)

Example 24 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class EventController method getEventCreateComponentForContactList.

public CommitDiscardWrapperComponent<EventDataForm> getEventCreateComponentForContactList(List<ContactReferenceDto> contactRefs) {
    List<ContactDto> contactDtos = FacadeProvider.getContactFacade().getByUuids(contactRefs.stream().map(c -> c.getUuid()).collect(Collectors.toList()));
    EventDataForm eventCreateForm = new EventDataForm(true, false);
    eventCreateForm.setValue(createNewEvent(contactDtos.stream().findFirst().get().getDisease()));
    eventCreateForm.getField(EventDto.DISEASE).setReadOnly(true);
    final CommitDiscardWrapperComponent<EventDataForm> editView = new CommitDiscardWrapperComponent<EventDataForm>(eventCreateForm, UserProvider.getCurrent().hasUserRight(UserRight.EVENT_CREATE), eventCreateForm.getFieldGroup());
    List<ContactDto> finalContactDtos = contactDtos;
    editView.addCommitListener(() -> {
        if (!eventCreateForm.getFieldGroup().isModified()) {
            EventDto dto = eventCreateForm.getValue();
            FacadeProvider.getEventFacade().save(dto);
            Notification.show(I18nProperties.getString(Strings.messageEventCreated), Type.WARNING_MESSAGE);
            linkContactsToEvent(new EventReferenceDto(dto.getUuid()), finalContactDtos);
        }
    });
    return editView;
}
Also used : EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) EventDto(de.symeda.sormas.api.event.EventDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Example 25 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class EventController method getEventDataEditComponent.

public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(final String eventUuid, Consumer<EventStatus> saveCallback) {
    EventDto event = findEvent(eventUuid);
    AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getEventFacade().getAutomaticDeletionInfo(eventUuid);
    EventDataForm eventEditForm = new EventDataForm(false, event.isPseudonymized());
    eventEditForm.setValue(event);
    final CommitDiscardWrapperComponent<EventDataForm> editView = new CommitDiscardWrapperComponent<EventDataForm>(eventEditForm, UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT), eventEditForm.getFieldGroup());
    if (automaticDeletionInfoDto != null) {
        editView.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
    }
    editView.addCommitListener(() -> {
        if (!eventEditForm.getFieldGroup().isModified()) {
            EventDto eventDto = eventEditForm.getValue();
            final UserDto user = UserProvider.getCurrent().getUser();
            final RegionReferenceDto userRegion = user.getRegion();
            final DistrictReferenceDto userDistrict = user.getDistrict();
            final RegionReferenceDto epEventRegion = eventDto.getEventLocation().getRegion();
            final DistrictReferenceDto epEventDistrict = eventDto.getEventLocation().getDistrict();
            final Boolean eventOutsideJurisdiction = (userRegion != null && !userRegion.equals(epEventRegion) || userDistrict != null && !userDistrict.equals(epEventDistrict));
            if (eventOutsideJurisdiction) {
                VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingEventJurisdictionUpdated), new Label(I18nProperties.getString(Strings.messageEventJurisdictionUpdated)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 500, confirmed -> {
                    if (confirmed) {
                        saveEvent(saveCallback, eventDto);
                    }
                });
            } else {
                saveEvent(saveCallback, eventDto);
            }
        }
    });
    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_DELETE)) {
        editView.addDeleteListener(() -> {
            if (!existEventParticipantsLinkedToEvent(event)) {
                try {
                    FacadeProvider.getEventFacade().deleteEvent(event.getUuid());
                } catch (ExternalSurveillanceToolException e) {
                    Notification.show(String.format(I18nProperties.getString(Strings.ExternalSurveillanceToolGateway_notificationEntryNotDeleted), DataHelper.getShortUuid(event.getUuid())), "", Type.ERROR_MESSAGE);
                }
            } else {
                VaadinUiUtil.showSimplePopupWindow(I18nProperties.getString(Strings.headingEventNotDeleted), I18nProperties.getString(Strings.messageEventsNotDeletedReason));
            }
            UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
        }, I18nProperties.getString(Strings.entityEvent));
    }
    // Initialize 'Archive' button
    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
        boolean archived = FacadeProvider.getEventFacade().isArchived(eventUuid);
        Button archiveEventButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
            if (editView.isModified()) {
                editView.commit();
            }
            if (archived) {
                ControllerProvider.getArchiveController().dearchiveEntity(event, FacadeProvider.getEventFacade(), Strings.headingDearchiveEvent, Strings.confirmationDearchiveEvent, Strings.entityEvent, Strings.messageEventDearchived, () -> navigateToData(event.getUuid()));
            } else {
                ControllerProvider.getArchiveController().archiveEntity(event, FacadeProvider.getEventFacade(), Strings.headingArchiveEvent, Strings.confirmationArchiveEvent, Strings.entityEvent, Strings.messageEventArchived, () -> navigateToData(event.getUuid()));
            }
        }, ValoTheme.BUTTON_LINK);
        editView.getButtonsPanel().addComponentAsFirst(archiveEventButton);
        editView.getButtonsPanel().setComponentAlignment(archiveEventButton, Alignment.BOTTOM_LEFT);
    }
    return editView;
}
Also used : UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel) Label(com.vaadin.ui.Label) ExternalSurveillanceToolException(de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Button(com.vaadin.ui.Button) AutomaticDeletionInfoDto(de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel)

Aggregations

EventDto (de.symeda.sormas.api.event.EventDto)125 Test (org.junit.Test)71 UserDto (de.symeda.sormas.api.user.UserDto)49 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)46 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)39 PersonDto (de.symeda.sormas.api.person.PersonDto)38 Date (java.util.Date)38 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)23 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)22 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)22 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)17 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)16 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)16 SampleDto (de.symeda.sormas.api.sample.SampleDto)14 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)14 List (java.util.List)13 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)11 LocalDate (java.time.LocalDate)11 EventParticipantCriteria (de.symeda.sormas.api.event.EventParticipantCriteria)10