use of de.symeda.sormas.api.event.EventIndexDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupMemberList method drawDisplayedEntries.
@Override
protected void drawDisplayedEntries() {
List<EventIndexDto> displayedEntries = getDisplayedEntries();
for (int i = 0, displayedEntriesSize = displayedEntries.size(); i < displayedEntriesSize; i++) {
EventIndexDto event = displayedEntries.get(i);
EventGroupMemberListEntry listEntry = new EventGroupMemberListEntry(event);
UserProvider user = UserProvider.getCurrent();
if (user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
listEntry.addUnlinkEventListener(i, (ClickListener) clickEvent -> {
if (!user.hasNationalJurisdictionLevel() && !user.hasRegion(new RegionReferenceDto(event.getRegionUuid()))) {
new Notification(I18nProperties.getString(Strings.headingEventGroupUnlinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
return;
}
ControllerProvider.getEventGroupController().unlinkEventGroup(event.toReference(), eventGroupReference);
reload();
});
}
if (user.hasUserRight(UserRight.EVENTGROUP_EDIT)) {
listEntry.addEditListener(i, (ClickListener) clickEvent -> ControllerProvider.getEventController().navigateToData(listEntry.getEvent().getUuid()));
}
listLayout.addComponent(listEntry);
}
}
use of de.symeda.sormas.api.event.EventIndexDto in project SORMAS-Project by hzi-braunschweig.
the class EventGrid method setLazyDataProvider.
public void setLazyDataProvider() {
DataProvider<EventIndexDto, EventCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventFacade().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.getEventFacade().count(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(SelectionMode.NONE);
}
use of de.symeda.sormas.api.event.EventIndexDto 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.EventIndexDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateEvent.
public void selectOrCreateEvent(CaseReferenceDto caseRef) {
CaseDataDto caseDataDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseRef.getUuid());
EventSelectionField eventSelect = new EventSelectionField(caseDataDto.getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForCase), null);
eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.caze(caseRef);
eventCriteria.setUserFilterIncluded(false);
List<EventIndexDto> eventIndexDto = FacadeProvider.getEventFacade().getIndexList(eventCriteria, null, null, null);
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
if (!eventIndexDto.contains(selectedEvent)) {
linkCaseToEvent(eventReferenceDto, caseDataDto, caseRef);
SormasUI.refreshView();
} else {
SormasUI.refreshView();
Notification notification = new Notification(I18nProperties.getString(Strings.messagePersonAlreadyCaseInEvent), "", Type.HUMANIZED_MESSAGE);
notification.setDelayMsec(10000);
notification.show(Page.getCurrent());
}
} else {
create(caseRef);
SormasUI.refreshView();
}
});
eventSelect.setSelectionChangeCallback((commitAllowed) -> {
component.getCommitButton().setEnabled(commitAllowed);
});
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
use of de.symeda.sormas.api.event.EventIndexDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateSuperordinateEvent.
public void selectOrCreateSuperordinateEvent(EventReferenceDto subordinateEventRef) {
Set<String> excludedUuids = new HashSet<>();
excludedUuids.add(subordinateEventRef.getUuid());
excludedUuids.addAll(FacadeProvider.getEventFacade().getAllSubordinateEventUuids(subordinateEventRef.getUuid()));
EventDto subordinateEvent = FacadeProvider.getEventFacade().getEventByUuid(subordinateEventRef.getUuid(), false);
EventSelectionField selectionField = EventSelectionField.forSuperordinateEvent(subordinateEvent, excludedUuids);
selectionField.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = selectionField.getValue();
if (selectedEvent != null) {
subordinateEvent.setSuperordinateEvent(selectedEvent.toReference());
FacadeProvider.getEventFacade().save(subordinateEvent);
navigateToData(subordinateEventRef.getUuid());
Notification.show(I18nProperties.getString(Strings.messageEventLinkedAsSuperordinate), Type.TRAY_NOTIFICATION);
} else {
createSuperordinateEvent(subordinateEventRef);
}
});
selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
Aggregations