Search in sources :

Example 1 with EventGroupFacade

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;
}
Also used : EventGroupFacade(de.symeda.sormas.api.event.EventGroupFacade) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventGroupDto(de.symeda.sormas.api.event.EventGroupDto)

Aggregations

EventGroupDto (de.symeda.sormas.api.event.EventGroupDto)1 EventGroupFacade (de.symeda.sormas.api.event.EventGroupFacade)1 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)1