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));
}
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)));
}
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;
}
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;
}
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);
}
Aggregations