Search in sources :

Example 1 with ReferenceDto

use of de.symeda.sormas.api.ReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class BaseCriteria method parseUrlParam.

protected Object parseUrlParam(Class<?> type, List<String> fieldParams) throws InstantiationException, IllegalAccessException {
    Object value = null;
    if (ReferenceDto.class.isAssignableFrom(type)) {
        value = type.newInstance();
        ((ReferenceDto) value).setUuid(fieldParams.get(0));
    } else if (Date.class.isAssignableFrom(type)) {
        try {
            value = new Date(Long.parseLong(fieldParams.get(0)));
        } catch (NumberFormatException e) {
        // ignore
        }
    } else if (Boolean.class.isAssignableFrom(type)) {
        value = Boolean.valueOf(fieldParams.get(0));
    } else if (Enum.class.isAssignableFrom(type)) {
        try {
            // noinspection unchecked
            value = Enum.valueOf((Class<Enum>) type, fieldParams.get(0));
        } catch (IllegalArgumentException e) {
        // ignore
        }
    } else if (String.class.isAssignableFrom(type)) {
        value = fieldParams.get(0);
    } else if (Integer.class.isAssignableFrom(type)) {
        value = Integer.valueOf(fieldParams.get(0));
    } else if (EpiWeek.class.isAssignableFrom(type)) {
        value = EpiWeek.fromUrlString(fieldParams.get(0));
    } else if (CustomizableEnum.class.isAssignableFrom(type)) {
        value = type.newInstance();
        ((CustomizableEnum) value).setValue(fieldParams.get(0));
    } else {
        throw new NotImplementedException(type.toString());
    }
    return value;
}
Also used : CustomizableEnum(de.symeda.sormas.api.customizableenum.CustomizableEnum) ReferenceDto(de.symeda.sormas.api.ReferenceDto) CustomizableEnum(de.symeda.sormas.api.customizableenum.CustomizableEnum) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Date(java.util.Date)

Example 2 with ReferenceDto

use of de.symeda.sormas.api.ReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class CasesView method createStatusFilterBar.

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
    statusButtons = new HashMap<>();
    Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
        criteria.investigationStatus(null);
        navigateTo(criteria);
    }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;
    for (InvestigationStatus status : InvestigationStatus.values()) {
        Button statusButton = ButtonHelper.createButton(status.toString(), e -> {
            criteria.investigationStatus(status);
            navigateTo(criteria);
        }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setData(status);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show active/archived/all dropdown
        if (Objects.nonNull(UserProvider.getCurrent()) && UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
            int daysAfterCaseGetsArchived = FacadeProvider.getConfigFacade().getDaysAfterCaseGetsArchived();
            if (daysAfterCaseGetsArchived > 0) {
                relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedCases), daysAfterCaseGetsArchived), ContentMode.HTML);
                relevanceStatusInfoLabel.setVisible(false);
                relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
                actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
                actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
            }
            relevanceStatusFilter = ComboBoxHelper.createComboBoxV7();
            relevanceStatusFilter.setId("relevanceStatus");
            relevanceStatusFilter.setWidth(140, Unit.PIXELS);
            relevanceStatusFilter.setNullSelectionAllowed(false);
            relevanceStatusFilter.addItems((Object[]) EntityRelevanceStatus.values());
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ACTIVE, I18nProperties.getCaption(Captions.caseActiveCases));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ARCHIVED, I18nProperties.getCaption(Captions.caseArchivedCases));
            relevanceStatusFilter.setItemCaption(EntityRelevanceStatus.ALL, I18nProperties.getCaption(Captions.caseAllCases));
            relevanceStatusFilter.addValueChangeListener(e -> {
                relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
                criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(relevanceStatusFilter);
        }
        if (viewConfiguration.getViewType().isCaseOverview()) {
            AbstractCaseGrid<?> caseGrid = (AbstractCaseGrid<?>) this.grid;
            // Bulk operation dropdown
            if (isBulkEditAllowed()) {
                boolean hasBulkOperationsRight = UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_CASE_SAMPLES);
                final List<MenuBarHelper.MenuBarItem> menuBarItems = new ArrayList<>();
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().showBulkCaseDataEditComponent(items));
                }, hasBulkOperationsRight));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().deleteAllSelectedItems(items, () -> navigateTo(criteria)), true);
                }, hasBulkOperationsRight));
                final boolean externalMessagesEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.MANUAL_EXTERNAL_MESSAGES);
                final boolean isSmsServiceSetUp = FacadeProvider.getConfigFacade().isSmsServiceSetUp();
                if (isSmsServiceSetUp && externalMessagesEnabled && UserProvider.getCurrent().hasUserRight(UserRight.SEND_MANUAL_EXTERNAL_MESSAGES)) {
                    menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.messagesSendSMS), VaadinIcons.MOBILE_RETRO, mi -> {
                        grid.bulkActionHandler(items -> ControllerProvider.getCaseController().sendSmsToAllSelectedItems(items, () -> navigateTo(criteria)));
                    }, hasBulkOperationsRight));
                }
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().archiveAllSelectedItems(items, () -> navigateTo(criteria, true)), true);
                }, hasBulkOperationsRight && EntityRelevanceStatus.ACTIVE.equals(criteria.getRelevanceStatus())));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchive), VaadinIcons.ARCHIVE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().dearchiveAllSelectedItems(items, () -> navigateTo(criteria, true)), true);
                }, hasBulkOperationsRight && EntityRelevanceStatus.ARCHIVED.equals(criteria.getRelevanceStatus())));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.sormasToSormasShare), VaadinIcons.SHARE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getSormasToSormasController().shareSelectedCases(items, () -> navigateTo(criteria)));
                }, FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser()));
                menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.ExternalSurveillanceToolGateway_send), VaadinIcons.SHARE, mi -> {
                    grid.bulkActionHandler(items -> ControllerProvider.getCaseController().sendCasesToExternalSurveillanceTool(items, () -> navigateTo(criteria)));
                }, FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()));
                if (isDocGenerationAllowed()) {
                    menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
                        grid.bulkActionHandler(items -> {
                            List<ReferenceDto> references = caseGrid.asMultiSelect().getSelectedItems().stream().map(CaseIndexDto::toReference).collect(Collectors.toList());
                            if (references.size() == 0) {
                                new Notification(I18nProperties.getString(Strings.headingNoCasesSelected), I18nProperties.getString(Strings.messageNoCasesSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                                return;
                            }
                            ControllerProvider.getDocGenerationController().showBulkQuarantineOrderDocumentDialog(references, DocumentWorkflow.QUARANTINE_ORDER_CASE);
                        });
                    }));
                }
                if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE)) {
                    menuBarItems.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkLinkToEvent), VaadinIcons.PHONE, mi -> grid.bulkActionHandler(items -> {
                        List<CaseIndexDto> selectedCases = caseGrid.asMultiSelect().getSelectedItems().stream().collect(Collectors.toList());
                        if (selectedCases.isEmpty()) {
                            new Notification(I18nProperties.getString(Strings.headingNoCasesSelected), I18nProperties.getString(Strings.messageNoCasesSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                            return;
                        }
                        if (!selectedCases.stream().allMatch(caze -> caze.getDisease().equals(selectedCases.stream().findAny().get().getDisease()))) {
                            new Notification(I18nProperties.getString(Strings.messageBulkCasesWithDifferentDiseasesSelected), Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                            return;
                        }
                        ControllerProvider.getEventController().selectOrCreateEventForCaseList(selectedCases.stream().map(CaseIndexDto::toReference).collect(Collectors.toList()));
                    })));
                }
                bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, menuBarItems);
                bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
                actionButtonsLayout.addComponent(bulkOperationsDropdown);
            }
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    return statusFilterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) CaseImportLayout(de.symeda.sormas.ui.caze.importer.CaseImportLayout) TextField(com.vaadin.ui.TextField) Date(java.util.Date) DocumentWorkflow(de.symeda.sormas.api.docgeneneration.DocumentWorkflow) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) ReferenceDto(de.symeda.sormas.api.ReferenceDto) Window(com.vaadin.ui.Window) PersonDto(de.symeda.sormas.api.person.PersonDto) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Page(com.vaadin.server.Page) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) DownloadUtil(de.symeda.sormas.ui.utils.DownloadUtil) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) DateField(com.vaadin.ui.DateField) MenuBar(com.vaadin.ui.MenuBar) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) ComboBox(com.vaadin.v7.ui.ComboBox) ExportType(de.symeda.sormas.api.importexport.ExportType) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) ExportConfigurationDto(de.symeda.sormas.api.importexport.ExportConfigurationDto) List(java.util.List) LocalDate(java.time.LocalDate) DateHelper8(de.symeda.sormas.ui.utils.DateHelper8) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) FollowUpUtils.createFollowUpLegend(de.symeda.sormas.ui.utils.FollowUpUtils.createFollowUpLegend) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) SearchSpecificLayout(de.symeda.sormas.ui.SearchSpecificLayout) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) VerticalLayout(com.vaadin.ui.VerticalLayout) DateHelper(de.symeda.sormas.api.utils.DateHelper) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) PopupMenu(de.symeda.sormas.ui.utils.components.popupmenu.PopupMenu) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) CaseExportType(de.symeda.sormas.api.caze.CaseExportType) OptionGroup(com.vaadin.v7.ui.OptionGroup) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) AbstractView(de.symeda.sormas.ui.utils.AbstractView) CaseDownloadUtil(de.symeda.sormas.ui.utils.CaseDownloadUtil) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Validations(de.symeda.sormas.api.i18n.Validations) LineListingImportLayout(de.symeda.sormas.ui.caze.importer.LineListingImportLayout) BAGExportCaseDto(de.symeda.sormas.api.bagexport.BAGExportCaseDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) SampleExportDto(de.symeda.sormas.api.sample.SampleExportDto) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) SampleDto(de.symeda.sormas.api.sample.SampleDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) ExportPropertyMetaInfo(de.symeda.sormas.api.importexport.ExportPropertyMetaInfo) DocGenerationHelper.isDocGenerationAllowed(de.symeda.sormas.ui.docgeneration.DocGenerationHelper.isDocGenerationAllowed) Collections(java.util.Collections) Component(com.vaadin.ui.Component) ReferenceDto(de.symeda.sormas.api.ReferenceDto) Label(com.vaadin.ui.Label) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) ExpandableButton(de.symeda.sormas.ui.utils.components.expandablebutton.ExpandableButton) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) List(java.util.List) ArrayList(java.util.ArrayList) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus)

Example 3 with ReferenceDto

use of de.symeda.sormas.api.ReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class CommunityFacadeEjb method getDistrictUuidsForCommunities.

@Override
public Map<String, String> getDistrictUuidsForCommunities(List<CommunityReferenceDto> communities) {
    if (communities.isEmpty()) {
        return new HashMap<>();
    }
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
    Root<Community> root = cq.from(Community.class);
    Join<Community, District> districtJoin = root.join(Community.DISTRICT, JoinType.LEFT);
    Predicate filter = root.get(AbstractDomainObject.UUID).in(communities.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
    cq.where(filter);
    cq.multiselect(root.get(AbstractDomainObject.UUID), districtJoin.get(AbstractDomainObject.UUID));
    return em.createQuery(cq).getResultList().stream().collect(Collectors.toMap(e -> (String) e[0], e -> (String) e[1]));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) DtoHelper(de.symeda.sormas.backend.util.DtoHelper) Join(javax.persistence.criteria.Join) QueryHelper(de.symeda.sormas.backend.util.QueryHelper) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) ReferenceDto(de.symeda.sormas.api.ReferenceDto) InfrastructureAdo(de.symeda.sormas.backend.common.InfrastructureAdo) HashMap(java.util.HashMap) AbstractInfrastructureFacadeEjb(de.symeda.sormas.backend.infrastructure.AbstractInfrastructureFacadeEjb) DistrictService(de.symeda.sormas.backend.infrastructure.district.DistrictService) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) CommunityDto(de.symeda.sormas.api.infrastructure.community.CommunityDto) Page(de.symeda.sormas.api.common.Page) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) Predicate(javax.persistence.criteria.Predicate) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) JoinType(javax.persistence.criteria.JoinType) LocalBean(javax.ejb.LocalBean) Expression(javax.persistence.criteria.Expression) EJB(javax.ejb.EJB) Root(javax.persistence.criteria.Root) CommunityFacade(de.symeda.sormas.api.infrastructure.community.CommunityFacade) Stateless(javax.ejb.Stateless) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Collection(java.util.Collection) Region(de.symeda.sormas.backend.infrastructure.region.Region) District(de.symeda.sormas.backend.infrastructure.district.District) CommunityCriteria(de.symeda.sormas.api.infrastructure.community.CommunityCriteria) NotNull(javax.validation.constraints.NotNull) SortProperty(de.symeda.sormas.api.utils.SortProperty) RegionFacadeEjb(de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb) Collectors(java.util.stream.Collectors) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) List(java.util.List) UserService(de.symeda.sormas.backend.user.UserService) DistrictFacadeEjb(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb) Order(javax.persistence.criteria.Order) FeatureConfigurationFacadeEjbLocal(de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal) ReferenceDto(de.symeda.sormas.api.ReferenceDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) HashMap(java.util.HashMap) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) District(de.symeda.sormas.backend.infrastructure.district.District) Predicate(javax.persistence.criteria.Predicate)

Example 4 with ReferenceDto

use of de.symeda.sormas.api.ReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class DataHelperTest method testShortUuid.

@Test
public void testShortUuid() {
    EntityDto entityDto = new EntityDto() {
    };
    entityDto.setUuid("ABCDEF-GHIJKL");
    assertEquals("ABCDEF", DataHelper.getShortUuid(entityDto));
    ReferenceDto referenceDto = new ReferenceDto() {
    };
    referenceDto.setUuid("MNOPQR-STUVWX");
    assertEquals("MNOPQR", DataHelper.getShortUuid(referenceDto));
    assertEquals("UZOUEH", DataHelper.getShortUuid("UZOUEH-HP7DRG-YOJ74F-PXWL2JZ4"));
    assertNull(DataHelper.getShortUuid((String) null));
    boolean exceptionThrown = false;
    try {
        assertEquals("A", DataHelper.getShortUuid("A"));
        fail("getShortUuid should not be graceful on Uuids that are too short.");
    } catch (StringIndexOutOfBoundsException e) {
        exceptionThrown = true;
    }
    assertTrue("getShortUuid should throw StringIndexOutOfBoundsException on Uuids that are too short.", exceptionThrown);
}
Also used : EntityDto(de.symeda.sormas.api.EntityDto) ReferenceDto(de.symeda.sormas.api.ReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Test(org.junit.Test)

Example 5 with ReferenceDto

use of de.symeda.sormas.api.ReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class EventController method selectOrCreateEventForCaseList.

public void selectOrCreateEventForCaseList(List<CaseReferenceDto> caseRefs) {
    if (caseRefs == null || caseRefs.isEmpty()) {
        return;
    }
    List<CaseDataDto> caseDataDtos = FacadeProvider.getCaseFacade().getByUuids(caseRefs.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
    EventSelectionField eventSelect = new EventSelectionField(caseDataDtos.stream().findFirst().get().getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForCases), null);
    eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
    final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
    component.addCommitListener(() -> {
        EventIndexDto selectedEvent = eventSelect.getValue();
        if (selectedEvent != null) {
            EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
            linkCasesToEvent(eventReferenceDto, caseDataDtos);
        } else {
            createFromCaseList(caseRefs);
            SormasUI.refreshView();
        }
    });
    eventSelect.setSelectionChangeCallback(commitAllowed -> component.getCommitButton().setEnabled(commitAllowed));
    VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
Also used : ReferenceDto(de.symeda.sormas.api.ReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) EventGroupReferenceDto(de.symeda.sormas.api.event.EventGroupReferenceDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) EventSelectionField(de.symeda.sormas.ui.events.eventLink.EventSelectionField)

Aggregations

ReferenceDto (de.symeda.sormas.api.ReferenceDto)29 ContactReferenceDto (de.symeda.sormas.api.contact.ContactReferenceDto)11 EventParticipantReferenceDto (de.symeda.sormas.api.event.EventParticipantReferenceDto)11 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)11 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)10 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)9 SampleReferenceDto (de.symeda.sormas.api.sample.SampleReferenceDto)9 ArrayList (java.util.ArrayList)9 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)8 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)8 Validations (de.symeda.sormas.api.i18n.Validations)7 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)7 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)7 List (java.util.List)7 Test (org.junit.Test)7 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)6 TravelEntryReferenceDto (de.symeda.sormas.api.travelentry.TravelEntryReferenceDto)6 Collection (java.util.Collection)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6