use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class LeftMenuPanel method addCollectionsMenuItems.
private void addCollectionsMenuItems(MainMenuItem mainMenuItem, QName type, Class<? extends PageBase> redirectToPage) {
List<CompiledObjectCollectionView> objectViews = getPageBase().getCompiledGuiProfile().findAllApplicableObjectCollectionViews(type);
objectViews.forEach(objectView -> {
if (!WebComponentUtil.getElementVisibility(objectView.getVisibility())) {
return;
}
OperationTypeType operationTypeType = objectView.getApplicableForOperation();
if (operationTypeType != null && operationTypeType != OperationTypeType.MODIFY) {
return;
}
if (objectView.getCollection() == null) {
return;
}
DisplayType viewDisplayType = objectView.getDisplay();
PageParameters pageParameters = new PageParameters();
pageParameters.add(PageBase.PARAMETER_OBJECT_COLLECTION_NAME, objectView.getViewIdentifier());
String label = "MenuItem.noName";
PolyStringType display = WebComponentUtil.getCollectionLabel(viewDisplayType);
if (display != null) {
label = WebComponentUtil.getTranslatedPolyString(display);
}
String iconClass = WebComponentUtil.getIconCssClass(viewDisplayType);
MenuItem userViewMenu = new MenuItem(label, StringUtils.isEmpty(iconClass) ? BaseMenuItem.DEFAULT_ICON : iconClass, redirectToPage, pageParameters, isObjectCollectionMenuActive(objectView));
userViewMenu.setDisplayOrder(objectView.getDisplayOrder());
mainMenuItem.addCollectionMenuItem(userViewMenu);
});
// We need to sort after we get all the collections. Only then we have correct collection labels.
// We do not want to determine the labels twice.
// TODO: can this be combined in a single sort?
// collectionMenuItems.sort(Comparator.comparing(o -> o.getNameModel().getObject()));
// collectionMenuItems.sort(Comparator.comparingInt(o -> ObjectUtils.defaultIfNull(o.getDisplayOrder(), Integer.MAX_VALUE)));
// return collectionMenuItems;
}
Aggregations