use of de.symeda.sormas.api.event.EventGroupCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventsView 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<>();
if (isDefaultViewType()) {
Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
eventCriteria.setEventStatus(null);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
statusAll.setCaptionAsHtml(true);
statusFilterLayout.addComponent(statusAll);
statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
activeStatusButton = statusAll;
for (EventStatus status : EventStatus.values()) {
Button statusButton = ButtonHelper.createButton("status-" + status, status.toString(), e -> {
eventCriteria.setEventStatus(status);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
statusButton.setCaptionAsHtml(true);
statusButton.setData(status);
statusFilterLayout.addComponent(statusButton);
statusButtons.put(statusButton, status.toString());
}
} else if (isActionViewType()) {
Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
eventCriteria.setActionStatus(null);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
statusAll.setCaptionAsHtml(true);
statusFilterLayout.addComponent(statusAll);
statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
activeStatusButton = statusAll;
for (ActionStatus status : ActionStatus.values()) {
Button statusButton = ButtonHelper.createButton("status-" + status, status.toString(), e -> {
eventCriteria.actionStatus(status);
navigateTo(eventCriteria);
}, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
statusButton.setCaptionAsHtml(true);
statusButton.setData(status);
statusFilterLayout.addComponent(statusButton);
statusButtons.put(statusButton, status.toString());
}
}
HorizontalLayout actionButtonsLayout = new HorizontalLayout();
actionButtonsLayout.setSpacing(true);
{
// Show active/archived/all dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW)) {
if (isGroupViewType()) {
groupRelevanceStatusFilter = buildRelevanceStatus(Captions.eventActiveGroups, Captions.eventArchivedGroups, Captions.eventAllGroups);
groupRelevanceStatusFilter.addValueChangeListener(e -> {
eventGroupCriteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(eventGroupCriteria);
});
actionButtonsLayout.addComponent(groupRelevanceStatusFilter);
} else {
int daysAfterEventGetsArchived = FacadeProvider.getConfigFacade().getDaysAfterEventGetsArchived();
if (daysAfterEventGetsArchived > 0) {
relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedEvents), daysAfterEventGetsArchived), ContentMode.HTML);
relevanceStatusInfoLabel.setVisible(false);
relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
}
eventRelevanceStatusFilter = buildRelevanceStatus(Captions.eventActiveEvents, Captions.eventArchivedEvents, Captions.eventAllEvents);
eventRelevanceStatusFilter.addValueChangeListener(e -> {
relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
eventCriteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
navigateTo(eventCriteria);
});
actionButtonsLayout.addComponent(eventRelevanceStatusFilter);
}
}
// Bulk operation dropdown
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_EVENT) && isDefaultViewType()) {
EventGrid eventGrid = (EventGrid) grid;
List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>();
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().showBulkEventDataEditComponent(items))));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_DELETE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().deleteAllSelectedItems(items, () -> navigateTo(eventCriteria)), true)));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().archiveAllSelectedItems(items, () -> navigateTo(eventCriteria, true)), true), EntityRelevanceStatus.ACTIVE.equals(eventCriteria.getRelevanceStatus())));
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionDearchive), VaadinIcons.ARCHIVE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().dearchiveAllSelectedItems(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria, true)), true), EntityRelevanceStatus.ARCHIVED.equals(eventCriteria.getRelevanceStatus())));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_CREATE) && UserProvider.getCurrent().hasUserRight(UserRight.EVENTGROUP_LINK)) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.actionGroupEvent), VaadinIcons.FILE_TREE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventGroupController().linkAllToGroup(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria)))));
}
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.ExternalSurveillanceToolGateway_send), VaadinIcons.SHARE, mi -> grid.bulkActionHandler(items -> ControllerProvider.getEventController().sendAllSelectedToExternalSurveillanceTool(eventGrid.asMultiSelect().getSelectedItems(), () -> navigateTo(eventCriteria))), FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()));
if (isDocGenerationAllowed()) {
bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
grid.bulkActionHandler(items -> {
EventGrid eventGrid1 = (EventGrid) this.grid;
List<EventReferenceDto> references = eventGrid1.asMultiSelect().getSelectedItems().stream().map(EventIndexDto::toReference).collect(Collectors.toList());
if (references.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoEventsSelected), I18nProperties.getString(Strings.headingNoEventsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
ControllerProvider.getDocGenerationController().showEventDocumentDialog(references);
});
}));
}
bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
bulkOperationsDropdown.setVisible(viewConfiguration.isInEagerMode());
bulkOperationsDropdown.setCaption("");
actionButtonsLayout.addComponent(bulkOperationsDropdown);
}
if (isDefaultViewType()) {
// Contact Count Method Dropdown
contactCountMethod = ComboBoxHelper.createComboBoxV7();
contactCountMethod.setCaption(I18nProperties.getCaption(Captions.Event_contactCountMethod));
contactCountMethod.addItem(EventContactCountMethod.ALL);
contactCountMethod.addItem(EventContactCountMethod.SOURCE_CASE_IN_EVENT);
contactCountMethod.addItem(EventContactCountMethod.BOTH_METHODS);
contactCountMethod.setItemCaption(EventContactCountMethod.ALL, I18nProperties.getEnumCaption(EventContactCountMethod.ALL));
contactCountMethod.setItemCaption(EventContactCountMethod.SOURCE_CASE_IN_EVENT, I18nProperties.getEnumCaption(EventContactCountMethod.SOURCE_CASE_IN_EVENT));
contactCountMethod.setItemCaption(EventContactCountMethod.BOTH_METHODS, I18nProperties.getEnumCaption(EventContactCountMethod.BOTH_METHODS));
contactCountMethod.setValue(EventContactCountMethod.ALL);
contactCountMethod.setTextInputAllowed(false);
contactCountMethod.setNullSelectionAllowed(false);
contactCountMethod.addValueChangeListener(event -> {
((EventGrid) grid).setContactCountMethod((EventContactCountMethod) event.getProperty().getValue());
((EventGrid) grid).reload();
});
actionButtonsLayout.addComponent(contactCountMethod);
}
}
statusFilterLayout.addComponent(actionButtonsLayout);
statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
return statusFilterLayout;
}
use of de.symeda.sormas.api.event.EventGroupCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventDataView method initView.
@Override
protected void initView(String params) {
EventDto event = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
setHeightUndefined();
String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EVENT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TASKS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ACTIONS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 12, 0, DOCUMENTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EventDocumentsComponent.DOCGENERATION_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SUPERORDINATE_EVENT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SUBORDINATE_EVENTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENT_GROUPS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SORMAS_TO_SORMAS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ExternalSurveillanceServiceGateway.EXTERANEL_SURVEILLANCE_TOOL_GATEWAY_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SHORTCUT_LINKS_LOC));
DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
container.setWidth(100, Unit.PERCENTAGE);
container.setMargin(true);
setSubComponent(container);
CustomLayout layout = new CustomLayout();
layout.addStyleName(CssStyles.ROOT_COMPONENT);
layout.setTemplateContents(htmlLayout);
layout.setWidth(100, Unit.PERCENTAGE);
layout.setHeightUndefined();
container.addComponent(layout);
editComponent = ControllerProvider.getEventController().getEventDataEditComponent(getEventRef().getUuid(), this::setExternalSurvToolLayoutVisibility);
editComponent.setMargin(false);
editComponent.setWidth(100, Unit.PERCENTAGE);
editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
layout.addComponent(editComponent, EVENT_LOC);
externalSurvToolLayout = ExternalSurveillanceServiceGateway.addComponentToLayout(layout, editComponent, event);
setExternalSurvToolLayoutVisibility(event.getEventStatus());
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT)) {
TaskListComponent taskList = new TaskListComponent(TaskContext.EVENT, getEventRef(), event.getDisease());
taskList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(taskList, TASKS_LOC);
}
ActionStatsComponent actionList = new ActionStatsComponent(ActionContext.EVENT, getEventRef());
actionList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(actionList, ACTIONS_LOC);
DocumentListComponent documentList = null;
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.DOCUMENTS)) {
// TODO: user rights?
documentList = new DocumentListComponent(DocumentRelatedEntityType.EVENT, getEventRef(), UserRight.EVENT_EDIT, event.isPseudonymized());
layout.addComponent(new SideComponentLayout(documentList), DOCUMENTS_LOC);
}
EventDocumentsComponent eventDocuments = new EventDocumentsComponent(getEventRef(), documentList);
eventDocuments.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(eventDocuments, EventDocumentsComponent.DOCGENERATION_LOC);
boolean eventHierarchiesFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_HIERARCHIES);
if (eventHierarchiesFeatureEnabled) {
SuperordinateEventComponent superordinateEventComponent = new SuperordinateEventComponent(event, () -> editComponent.discard());
superordinateEventComponent.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(superordinateEventComponent, SUPERORDINATE_EVENT_LOC);
EventListComponent subordinateEventList = new EventListComponent(event.toReference());
subordinateEventList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(subordinateEventList, SUBORDINATE_EVENTS_LOC);
}
boolean eventGroupsFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_GROUPS);
if (eventGroupsFeatureEnabled) {
EventReferenceDto eventReference = event.toReference();
EventGroupListComponent eventGroupsList = new EventGroupListComponent(eventReference);
eventGroupsList.addSideComponentCreateEventListener(e -> showNavigationConfirmPopupIfDirty(() -> {
EventDto eventByUuid = FacadeProvider.getEventFacade().getEventByUuid(eventReference.getUuid(), false);
UserProvider user = UserProvider.getCurrent();
if (!user.hasNationalJurisdictionLevel() && !user.hasRegion(eventByUuid.getEventLocation().getRegion())) {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
return;
}
EventGroupCriteria eventGroupCriteria = new EventGroupCriteria();
Set<String> eventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(Collections.singletonList(eventByUuid.toReference())).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
eventGroupCriteria.setExcludedUuids(eventGroupUuids);
if (user.hasUserRight(UserRight.EVENTGROUP_CREATE) && user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
long events = FacadeProvider.getEventGroupFacade().count(eventGroupCriteria);
if (events > 0) {
ControllerProvider.getEventGroupController().selectOrCreate(eventReference);
} else {
ControllerProvider.getEventGroupController().create(eventReference);
}
} else if (user.hasUserRight(UserRight.EVENTGROUP_CREATE)) {
ControllerProvider.getEventGroupController().create(eventReference);
} else {
long events = FacadeProvider.getEventGroupFacade().count(eventGroupCriteria);
if (events > 0) {
ControllerProvider.getEventGroupController().select(eventReference);
} else {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorNotRequiredRights), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
}
}
}));
layout.addComponent(new SideComponentLayout(eventGroupsList), EVENT_GROUPS_LOC);
}
boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingEventsEnabledForUser();
if (sormasToSormasEnabled || event.getSormasToSormasOriginInfo() != null) {
VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
sormasToSormasLocLayout.setMargin(false);
sormasToSormasLocLayout.setSpacing(false);
SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(event, sormasToSormasEnabled);
sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
layout.addComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
}
VerticalLayout shortcutLinksLayout = new VerticalLayout();
shortcutLinksLayout.setMargin(false);
shortcutLinksLayout.setSpacing(true);
if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
Button seeEventCasesBtn = ButtonHelper.createButton("eventLinkToCases", I18nProperties.getCaption(Captions.eventLinkToCases), thisEvent -> ControllerProvider.getCaseController().navigateTo(new CaseCriteria().eventLike(getEventRef().getUuid())), ValoTheme.BUTTON_PRIMARY);
shortcutLinksLayout.addComponent(seeEventCasesBtn);
}
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
Button seeEventContactsBtn = ButtonHelper.createButton("eventLinkToContacts", I18nProperties.getCaption(Captions.eventLinkToContacts), thisEvent -> ControllerProvider.getContactController().navigateTo(new ContactCriteria().eventUuid(getEventRef().getUuid())), ValoTheme.BUTTON_PRIMARY);
shortcutLinksLayout.addComponent(seeEventContactsBtn);
}
LocationDto eventLocationDto = ((EventDataForm) editComponent.getWrappedComponent()).getValue().getEventLocation();
if (eventLocationDto.getFacility() != null) {
Button seeEventsWithinTheSameFacility = ButtonHelper.createButton("eventLinkToEventsWithinTheSameFacility", I18nProperties.getCaption(Captions.eventLinkToEventsWithinTheSameFacility), thisEvent -> ControllerProvider.getEventController().navigateTo(new EventCriteria().region(eventLocationDto.getRegion()).district(eventLocationDto.getDistrict()).eventCommunity(eventLocationDto.getCommunity()).typeOfPlace(TypeOfPlace.FACILITY).facilityType(eventLocationDto.getFacilityType()).facility(eventLocationDto.getFacility())), ValoTheme.BUTTON_PRIMARY);
shortcutLinksLayout.addComponent(seeEventsWithinTheSameFacility);
}
layout.addComponent(shortcutLinksLayout, SHORTCUT_LINKS_LOC);
setEventEditPermission(container);
}
use of de.symeda.sormas.api.event.EventGroupCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventGroupController method linkAllToGroup.
public void linkAllToGroup(Set<EventIndexDto> selectedItems, Runnable callback) {
if (selectedItems.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoEventsSelected), I18nProperties.getString(Strings.messageNoEventsSelected), Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
UserProvider user = UserProvider.getCurrent();
if (!user.hasUserRight(UserRight.EVENTGROUP_CREATE) && !user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorNotRequiredRights), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
}
List<EventReferenceDto> eventReferences = selectedItems.stream().map(EventIndexDto::toReference).collect(Collectors.toList());
List<String> eventUuids = eventReferences.stream().map(EventReferenceDto::getUuid).collect(Collectors.toList());
if (!user.hasNationalJurisdictionLevel()) {
Set<RegionReferenceDto> regions = FacadeProvider.getEventFacade().getAllRegionsRelatedToEventUuids(eventUuids);
for (RegionReferenceDto region : regions) {
if (!user.hasRegion(region)) {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
return;
}
}
}
EventGroupCriteria eventGroupCriteria = new EventGroupCriteria();
Set<String> eventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(eventReferences).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
eventGroupCriteria.setExcludedUuids(eventGroupUuids);
if (user.hasUserRight(UserRight.EVENTGROUP_CREATE) && user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
long eventCount = FacadeProvider.getEventGroupFacade().count(eventGroupCriteria);
if (eventCount > 0) {
selectOrCreate(eventReferences, null);
} else {
create(eventReferences, null);
}
} else if (user.hasUserRight(UserRight.EVENTGROUP_CREATE)) {
create(eventReferences, null);
} else {
long eventCount = FacadeProvider.getEventGroupFacade().count(eventGroupCriteria);
if (eventCount > 0) {
select(eventReferences, null);
} else {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorNotRequiredRights), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
}
}
}
use of de.symeda.sormas.api.event.EventGroupCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventGroupsGrid method setLazyDataProvider.
public void setLazyDataProvider() {
DataProvider<EventGroupIndexDto, EventGroupCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventGroupFacade().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.getEventGroupFacade().count(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(SelectionMode.NONE);
}
use of de.symeda.sormas.api.event.EventGroupCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventGroupSelectionGrid method setLazyDataProvider.
public void setLazyDataProvider() {
DataProvider<EventGroupIndexDto, EventGroupCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventGroupFacade().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.getEventGroupFacade().count(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(SelectionMode.NONE);
EventGroupSelectionGrid tempGrid = this;
dataProvider.addDataProviderListener((DataProviderListener<EventGroupIndexDto>) dataChangeEvent -> {
if (tempGrid.getItemCount() > 0) {
tempGrid.setHeightByRows(Math.min(tempGrid.getItemCount(), 5));
} else {
tempGrid.setHeightByRows(1);
}
});
}
Aggregations