use of de.symeda.sormas.api.event.EventGroupFacade in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method getEventGroupCreateComponent.
public CommitDiscardWrapperComponent<EventGroupDataForm> getEventGroupCreateComponent(List<EventReferenceDto> eventReferences, Runnable callback) {
EventGroupDataForm createForm = new EventGroupDataForm(true);
createForm.setValue(createNewEventGroup());
final CommitDiscardWrapperComponent<EventGroupDataForm> editView = new CommitDiscardWrapperComponent<>(createForm, UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_CREATE), createForm.getFieldGroup());
editView.addCommitListener(() -> {
if (!createForm.getFieldGroup().isModified()) {
EventGroupDto dto = createForm.getValue();
EventGroupFacade eventGroupFacade = FacadeProvider.getEventGroupFacade();
dto = eventGroupFacade.saveEventGroup(dto);
eventGroupFacade.linkEventsToGroup(eventReferences, dto.toReference());
eventGroupFacade.notifyEventEventGroupCreated(dto.toReference());
Notification.show(I18nProperties.getString(Strings.messageEventGroupCreated), Type.WARNING_MESSAGE);
if (callback != null) {
callback.run();
} else {
SormasUI.refreshView();
}
}
});
return editView;
}
Aggregations