Search in sources :

Example 1 with EventGroupDto

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()));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) EventDto(de.symeda.sormas.api.event.EventDto) EventGroupDto(de.symeda.sormas.api.event.EventGroupDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 2 with EventGroupDto

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

Example 3 with EventGroupDto

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;
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) Button(com.vaadin.ui.Button) SormasUI(de.symeda.sormas.ui.SormasUI) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventGroupDto(de.symeda.sormas.api.event.EventGroupDto)

Example 4 with EventGroupDto

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

Example 5 with EventGroupDto

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

Aggregations

EventGroupDto (de.symeda.sormas.api.event.EventGroupDto)6 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)2 Button (com.vaadin.ui.Button)1 EventDto (de.symeda.sormas.api.event.EventDto)1 EventGroupFacade (de.symeda.sormas.api.event.EventGroupFacade)1 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)1 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)1 SormasUI (de.symeda.sormas.ui.SormasUI)1 UserProvider (de.symeda.sormas.ui.UserProvider)1 TitleLayout (de.symeda.sormas.ui.utils.components.page.title.TitleLayout)1 Test (org.junit.Test)1