use of de.symeda.sormas.api.event.EventGroupDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupFacadeEjbTest method testDeleteEventGroup.
@Test
public void testDeleteEventGroup() {
EventGroupFacadeEjb cut = getBean(EventGroupFacadeEjbLocal.class);
RDCF rdcf = creator.createRDCF();
UserReferenceDto user = creator.createUser(rdcf).toReference();
EventDto event = creator.createEvent(user);
EventGroupDto group = new EventGroupDto();
group.setName("GroupA");
group = cut.saveEventGroup(group);
cut.linkEventsToGroup(Collections.singletonList(event.toReference()), group.toReference());
assertThat(cut.getEventGroupByUuid(group.getUuid()), equalTo(group));
cut.deleteEventGroup(group.getUuid());
assertNull(cut.getEventGroupByUuid(group.getUuid()));
}
use of de.symeda.sormas.api.event.EventGroupDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupFacadeEjb method toDto.
public static EventGroupDto toDto(EventGroup source) {
if (source == null) {
return null;
}
EventGroupDto target = new EventGroupDto();
DtoHelper.fillDto(target, source);
target.setName(source.getName());
return target;
}
use of de.symeda.sormas.api.event.EventGroupDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method getEventGroupEditComponent.
public CommitDiscardWrapperComponent<?> getEventGroupEditComponent(String uuid) {
EventGroupDto eventGroup = FacadeProvider.getEventGroupFacade().getEventGroupByUuid(uuid);
EventGroupDataForm eventGroupEditForm = new EventGroupDataForm(false);
eventGroupEditForm.setValue(eventGroup);
UserProvider user = UserProvider.getCurrent();
final CommitDiscardWrapperComponent<EventGroupDataForm> editView = new CommitDiscardWrapperComponent<>(eventGroupEditForm, user.hasUserRight(UserRight.EVENTGROUP_EDIT), eventGroupEditForm.getFieldGroup());
List<RegionReferenceDto> regions = FacadeProvider.getEventGroupFacade().getEventGroupRelatedRegions(uuid);
boolean hasRegion = user.hasNationJurisdictionLevel() || regions.stream().allMatch(user::hasRegion);
editView.setReadOnly(hasRegion);
if (user.hasUserRight(UserRight.EVENTGROUP_EDIT) && hasRegion) {
editView.addCommitListener(() -> {
if (!eventGroupEditForm.getFieldGroup().isModified()) {
EventGroupDto updatedEventGroup = eventGroupEditForm.getValue();
FacadeProvider.getEventGroupFacade().saveEventGroup(updatedEventGroup);
Notification.show(I18nProperties.getString(Strings.messageEventGroupSaved), Notification.Type.WARNING_MESSAGE);
SormasUI.refreshView();
}
});
}
if (user.hasUserRight(UserRight.EVENTGROUP_DELETE) && hasRegion) {
editView.addDeleteListener(() -> {
deleteEventGroup(eventGroup);
UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityEventGroup));
}
// Initialize 'Archive' button
if (user.hasUserRight(UserRight.EVENTGROUP_ARCHIVE) && hasRegion) {
boolean archived = FacadeProvider.getEventGroupFacade().isArchived(uuid);
Button archiveEventButton = ButtonHelper.createButton(archived ? Captions.actionDearchiveInfrastructure : Captions.actionArchiveInfrastructure, e -> {
archiveOrDearchiveEventGroup(uuid, !archived);
}, ValoTheme.BUTTON_LINK);
editView.getButtonsPanel().addComponentAsFirst(archiveEventButton);
editView.getButtonsPanel().setComponentAlignment(archiveEventButton, Alignment.BOTTOM_LEFT);
}
editView.addDiscardListener(SormasUI::refreshView);
return editView;
}
use of de.symeda.sormas.api.event.EventGroupDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method getEventGroupViewTitleLayout.
public TitleLayout getEventGroupViewTitleLayout(String uuid) {
EventGroupDto eventGroup = FacadeProvider.getEventGroupFacade().getEventGroupByUuid(uuid);
TitleLayout titleLayout = new TitleLayout();
String shortUuid = DataHelper.getShortUuid(eventGroup.getUuid());
String mainRowText = eventGroup.getName() + " (" + shortUuid + ")";
titleLayout.addMainRow(mainRowText);
return titleLayout;
}
use of de.symeda.sormas.api.event.EventGroupDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method create.
public EventGroupDto create(List<EventReferenceDto> events, Runnable callback) {
CommitDiscardWrapperComponent<EventGroupDataForm> eventCreateComponent = getEventGroupCreateComponent(events, callback);
EventGroupDto eventGroupDto = eventCreateComponent.getWrappedComponent().getValue();
VaadinUiUtil.showModalPopupWindow(eventCreateComponent, I18nProperties.getString(Strings.headingCreateNewEventGroup));
return eventGroupDto;
}
Aggregations