Search in sources :

Example 1 with EntityPermissionTarget

use of com.haulmont.cuba.gui.app.security.entity.EntityPermissionTarget in project cuba by cuba-platform.

the class EntityNameFilter method test.

@Override
public boolean test(@Nullable T target) {
    if (target != null) {
        if (Boolean.TRUE.equals(assignedOnlyCheckBox.getValue()) && !target.isAssigned()) {
            return false;
        }
        if (Boolean.FALSE.equals(systemLevelCheckBox.getValue()) && (target instanceof EntityPermissionTarget) && !target.isAssigned()) {
            Class entityClass = ((EntityPermissionTarget) target).getEntityClass();
            MetaClass metaClass = metadata.getSession().getClassNN(entityClass);
            if (metadata.getTools().isSystemLevel(metaClass)) {
                return false;
            }
        }
        String filterValue = StringUtils.trimToEmpty(entityFilter.<String>getValue());
        return StringUtils.isBlank(filterValue) || StringUtils.containsIgnoreCase(target.getCaption(), filterValue);
    }
    return false;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) MetaClass(com.haulmont.chile.core.model.MetaClass) EntityPermissionTarget(com.haulmont.cuba.gui.app.security.entity.EntityPermissionTarget)

Aggregations

MetaClass (com.haulmont.chile.core.model.MetaClass)1 EntityPermissionTarget (com.haulmont.cuba.gui.app.security.entity.EntityPermissionTarget)1