use of com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget in project cuba by cuba-platform.
the class EntityPermissionsFrame method applyPermissionMask.
@SuppressWarnings("unused")
public void applyPermissionMask() {
Set<OperationPermissionTarget> selected = entityPermissionsTable.getSelected();
if (!selected.isEmpty() && (selected.size() > 1)) {
for (OperationPermissionTarget target : selected) {
for (EntityOperationControl control : operationControls) {
if (control.isControlVisible() && control.applicableToEntity(target.getEntityClass())) {
PermissionVariant variant;
if (Boolean.TRUE.equals(control.getAllowChecker().getValue())) {
variant = PermissionVariant.ALLOWED;
} else if (Boolean.TRUE.equals(control.getDenyChecker().getValue())) {
variant = PermissionVariant.DISALLOWED;
} else {
variant = PermissionVariant.NOTSET;
}
markTargetPermission(target, control.getMetaProperty(), control.getOperation(), variant);
}
}
}
// update all after data change
entityPermissionsTable.repaint();
showNotification(getMessage("notification.applied"), NotificationType.HUMANIZED);
}
}
use of com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget in project cuba by cuba-platform.
the class EntityPermissionsFrame method attachAllCheckBoxListener.
protected void attachAllCheckBoxListener(CheckBox checkBox, final PermissionVariant activeVariant) {
checkBox.addValueChangeListener(e -> {
if (itemChanging)
return;
if (entityPermissionsTable.getSelected().isEmpty())
return;
itemChanging = true;
PermissionVariant permissionVariant = PermissionUiHelper.getCheckBoxVariant(e.getValue(), activeVariant);
if (isSingleSelection()) {
for (EntityOperationControl control : operationControls) {
OperationPermissionTarget target = entityPermissionsTable.getSingleSelected();
// noinspection ConstantConditions
if (control.applicableToEntity(target.getEntityClass())) {
markItemPermission(control.getMetaProperty(), control.getOperation(), permissionVariant);
}
}
} else {
for (EntityOperationControl control : operationControls) {
control.getAllowChecker().setValue(permissionVariant == PermissionVariant.ALLOWED);
control.getDenyChecker().setValue(permissionVariant == PermissionVariant.DISALLOWED);
}
allAllowCheck.setValue(permissionVariant == PermissionVariant.ALLOWED);
allDenyCheck.setValue(permissionVariant == PermissionVariant.DISALLOWED);
}
entityPermissionsTable.repaint();
itemChanging = false;
});
}
use of com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget in project cuba by cuba-platform.
the class EntityPermissionTargetsDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
if (permissionDs == null)
return;
if (targets == null) {
targets = new ArrayList<>();
PermissionConfig permissionConfig = AppBeans.get(PermissionConfig.class);
List<OperationPermissionTarget> entities = permissionConfig.getEntities(userSessionSource.getLocale());
for (OperationPermissionTarget target : entities) {
try {
OperationPermissionTarget cloneTarget = target.clone();
loadPermissionVariants(cloneTarget);
attachListener(cloneTarget);
targets.add(cloneTarget);
} catch (CloneNotSupportedException e) {
throw new RuntimeException("Can't clone permission target", e);
}
}
}
data.clear();
targets.stream().filter(permittedEntityFilter).filter(t -> permissionsFilter == null || permissionsFilter.test(t)).forEach(t -> data.put(t.getId(), t));
}
use of com.haulmont.cuba.gui.app.security.entity.OperationPermissionTarget in project cuba by cuba-platform.
the class EntityPermissionsFrame method markItemPermission.
protected void markItemPermission(String property, EntityOp operation, PermissionVariant permissionVariant) {
OperationPermissionTarget target = entityPermissionsTable.getSingleSelected();
markTargetPermission(target, property, operation, permissionVariant);
}
Aggregations