Search in sources :

Example 1 with SormasToSormasShareRequestIndexDto

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ShareRequestGrid method addShowColumn.

protected void addShowColumn(Consumer<SormasToSormasShareRequestIndexDto> handler) {
    Column<SormasToSormasShareRequestIndexDto, String> showColumn = addColumn(entry -> VaadinIcons.EYE.getHtml(), new HtmlRenderer());
    showColumn.setId(SHOW_MESSAGE);
    showColumn.setSortable(false);
    showColumn.setWidth(20);
    addItemClickListener(new ShowDetailsListener<>(SHOW_MESSAGE, handler::accept));
}
Also used : SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer)

Example 2 with SormasToSormasShareRequestIndexDto

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ShareRequestGrid method initGridColumns.

private void initGridColumns() {
    addShowColumn((request) -> {
        ControllerProvider.getSormasToSormasController().showRequestDetails(request);
    });
    addComponentColumn(indexDto -> createActionButtons(indexDto)).setId(COLUMN_ACTIONS);
    setColumns(SHOW_MESSAGE, SormasToSormasShareRequestIndexDto.UUID, SormasToSormasShareRequestIndexDto.CREATION_DATE, SormasToSormasShareRequestIndexDto.DATA_TYPE, SormasToSormasShareRequestIndexDto.ORGANIZATION_NAME, SormasToSormasShareRequestIndexDto.SENDER_NAME, SormasToSormasShareRequestIndexDto.OWNERSHIP_HANDED_OVER, SormasToSormasShareRequestIndexDto.STATUS, SormasToSormasShareRequestIndexDto.COMMENT, COLUMN_ACTIONS);
    getColumn(COLUMN_ACTIONS).setMinimumWidth(260);
    ((Column<SormasToSormasShareRequestIndexDto, String>) getColumn(LabMessageIndexDto.UUID)).setRenderer(new UuidRenderer());
    ((Column<SormasToSormasShareRequestIndexDto, Date>) getColumn(SormasToSormasShareRequestIndexDto.CREATION_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(I18nProperties.getUserLanguage())));
    getColumn(SormasToSormasShareRequestIndexDto.ORGANIZATION_NAME).setSortable(false);
    getColumn(SormasToSormasShareRequestIndexDto.OWNERSHIP_HANDED_OVER).setRenderer(new BooleanRenderer());
    for (Column<?, ?> column : getColumns()) {
        column.setCaption(I18nProperties.getPrefixCaption(SormasToSormasShareRequestIndexDto.I18N_PREFIX, column.getId(), column.getCaption()));
    }
    setSortOrder(Collections.singletonList(new GridSortOrder<>(getColumn(SormasToSormasShareRequestIndexDto.CREATION_DATE), SortDirection.DESCENDING)));
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) ShareRequestCriteria(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestCriteria) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LabMessageIndexDto(de.symeda.sormas.api.labmessage.LabMessageIndexDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GridSortOrder(com.vaadin.data.provider.GridSortOrder) VaadinIcons(com.vaadin.icons.VaadinIcons) DataProvider(com.vaadin.data.provider.DataProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) Captions(de.symeda.sormas.api.i18n.Captions) SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) Consumer(java.util.function.Consumer) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Collections(java.util.Collections) Component(com.vaadin.ui.Component) GridSortOrder(com.vaadin.data.provider.GridSortOrder) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 3 with SormasToSormasShareRequestIndexDto

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ShareRequestGrid method createActionButtons.

private Component createActionButtons(SormasToSormasShareRequestIndexDto indexDto) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setMargin(false);
    layout.setSpacing(true);
    if (indexDto.getStatus() == ShareRequestStatus.PENDING) {
        layout.addComponent(ButtonHelper.createButton(Captions.actionAccept, (e) -> {
            ControllerProvider.getSormasToSormasController().acceptShareRequest(indexDto, this::reload);
        }, ValoTheme.BUTTON_SMALL));
        layout.addComponent(ButtonHelper.createButton(Captions.actionReject, (e) -> {
            ControllerProvider.getSormasToSormasController().rejectShareRequest(indexDto, this::reload);
        }, ValoTheme.BUTTON_SMALL));
    }
    return layout;
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) ShareRequestCriteria(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestCriteria) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LabMessageIndexDto(de.symeda.sormas.api.labmessage.LabMessageIndexDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GridSortOrder(com.vaadin.data.provider.GridSortOrder) VaadinIcons(com.vaadin.icons.VaadinIcons) DataProvider(com.vaadin.data.provider.DataProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) Captions(de.symeda.sormas.api.i18n.Captions) SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) Consumer(java.util.function.Consumer) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Collections(java.util.Collections) Component(com.vaadin.ui.Component) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 4 with SormasToSormasShareRequestIndexDto

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasShareRequestFacadeEJB method getIndexList.

@Override
public List<SormasToSormasShareRequestIndexDto> getIndexList(ShareRequestCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<SormasToSormasShareRequestIndexDto> cq = cb.createQuery(SormasToSormasShareRequestIndexDto.class);
    Root<SormasToSormasShareRequest> requestRoot = cq.from(SormasToSormasShareRequest.class);
    Path<SormasToSormasOriginInfo> originInfo = requestRoot.get(SormasToSormasShareRequest.ORIGIN_INFO);
    cq.multiselect(requestRoot.get(SormasToSormasShareRequest.UUID), requestRoot.get(SormasToSormasShareRequest.CREATION_DATE), requestRoot.get(SormasToSormasShareRequest.DATA_TYPE), requestRoot.get(SormasToSormasShareRequest.STATUS), originInfo.get(SormasToSormasOriginInfo.ORGANIZATION_ID), originInfo.get(SormasToSormasOriginInfo.SENDER_NAME), originInfo.get(SormasToSormasOriginInfo.OWNERSHIP_HANDED_OVER), originInfo.get(SormasToSormasOriginInfo.COMMENT));
    Predicate filter = null;
    if (criteria != null) {
        filter = shareRequestService.buildCriteriaFilter(criteria, cb, requestRoot);
    }
    if (filter != null) {
        cq.where(filter);
    }
    List<Order> order = new ArrayList<>();
    if (sortProperties != null && sortProperties.size() > 0) {
        for (SortProperty sortProperty : sortProperties) {
            Expression<?> expression;
            switch(sortProperty.propertyName) {
                case SormasToSormasShareRequest.UUID:
                case SormasToSormasShareRequest.CREATION_DATE:
                case SormasToSormasShareRequest.DATA_TYPE:
                case SormasToSormasShareRequest.STATUS:
                    expression = requestRoot.get(sortProperty.propertyName);
                    break;
                case SormasToSormasOriginInfo.ORGANIZATION_ID:
                case SormasToSormasOriginInfo.SENDER_NAME:
                case SormasToSormasOriginInfo.COMMENT:
                case SormasToSormasOriginInfo.OWNERSHIP_HANDED_OVER:
                    expression = originInfo.get(sortProperty.propertyName);
                    break;
                default:
                    throw new IllegalArgumentException(sortProperty.propertyName);
            }
            order.add(sortProperty.ascending ? cb.asc(expression) : cb.desc(expression));
        }
    }
    cq.orderBy(order);
    List<SormasToSormasShareRequestIndexDto> requests = QueryHelper.getResultList(em, cq, first, max);
    if (!requests.isEmpty()) {
        Map<String, SormasServerDescriptor> serverDescriptorMap = sormasToSormasDiscoveryService.getAllAvailableServers().stream().collect(Collectors.toMap(SormasServerDescriptor::getId, Function.identity()));
        requests.forEach(request -> {
            String organizationId = request.getOrganizationId();
            SormasServerDescriptor serverDescriptor = serverDescriptorMap.get(organizationId);
            request.setOrganizationName(serverDescriptor != null ? serverDescriptor.getName() : organizationId);
        });
    }
    return requests;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Order(javax.persistence.criteria.Order) ArrayList(java.util.ArrayList) Predicate(javax.persistence.criteria.Predicate) SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) SormasToSormasOriginInfo(de.symeda.sormas.backend.sormastosormas.origin.SormasToSormasOriginInfo)

Example 5 with SormasToSormasShareRequestIndexDto

use of de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ShareRequestGrid method setLazyDataProvider.

public void setLazyDataProvider() {
    DataProvider<SormasToSormasShareRequestIndexDto, ShareRequestCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getSormasToSormasShareRequestFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getSormasToSormasShareRequestFacade().count(query.getFilter().orElse(null)));
    setDataProvider(dataProvider);
    setSelectionMode(SelectionMode.NONE);
}
Also used : SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) ShareRequestCriteria(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestCriteria)

Aggregations

SormasToSormasShareRequestIndexDto (de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto)5 SortProperty (de.symeda.sormas.api.utils.SortProperty)4 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)3 ShareRequestCriteria (de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestCriteria)3 DataProvider (com.vaadin.data.provider.DataProvider)2 GridSortOrder (com.vaadin.data.provider.GridSortOrder)2 ListDataProvider (com.vaadin.data.provider.ListDataProvider)2 VaadinIcons (com.vaadin.icons.VaadinIcons)2 SortDirection (com.vaadin.shared.data.sort.SortDirection)2 Component (com.vaadin.ui.Component)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 DateRenderer (com.vaadin.ui.renderers.DateRenderer)2 ValoTheme (com.vaadin.ui.themes.ValoTheme)2 FacadeProvider (de.symeda.sormas.api.FacadeProvider)2 Captions (de.symeda.sormas.api.i18n.Captions)2 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)2 LabMessageIndexDto (de.symeda.sormas.api.labmessage.LabMessageIndexDto)2 ShareRequestStatus (de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus)2 DateHelper (de.symeda.sormas.api.utils.DateHelper)2 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)2