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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations