Search in sources :

Example 11 with UiEntityAttributeContext

use of io.jmix.ui.accesscontext.UiEntityAttributeContext in project jmix by jmix-framework.

the class PivotScreenBuilder method isPermitted.

protected boolean isPermitted(MetaClass metaClass, MetaProperty metaProperty) {
    UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(metaClass, metaProperty.getName());
    accessManager.applyRegisteredConstraints(attributeContext);
    return attributeContext.canView();
}
Also used : UiEntityAttributeContext(io.jmix.ui.accesscontext.UiEntityAttributeContext)

Example 12 with UiEntityAttributeContext

use of io.jmix.ui.accesscontext.UiEntityAttributeContext in project jmix by jmix-framework.

the class AddAction method isPermitted.

@Override
protected boolean isPermitted() {
    if (target == null || !(target.getItems() instanceof ContainerDataUnit)) {
        return false;
    }
    ContainerDataUnit containerDataUnit = (ContainerDataUnit) target.getItems();
    MetaClass metaClass = containerDataUnit.getEntityMetaClass();
    if (metaClass == null) {
        return false;
    }
    if (containerDataUnit.getContainer() instanceof Nested) {
        Nested nestedContainer = (Nested) containerDataUnit.getContainer();
        MetaClass masterMetaClass = nestedContainer.getMaster().getEntityMetaClass();
        MetaProperty metaProperty = masterMetaClass.getProperty(nestedContainer.getProperty());
        UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(masterMetaClass, metaProperty.getName());
        accessManager.applyRegisteredConstraints(attributeContext);
        if (!attributeContext.canModify()) {
            return false;
        }
    }
    return super.isPermitted();
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) UiEntityAttributeContext(io.jmix.ui.accesscontext.UiEntityAttributeContext) Nested(io.jmix.ui.model.Nested) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) MetaProperty(io.jmix.core.metamodel.model.MetaProperty)

Example 13 with UiEntityAttributeContext

use of io.jmix.ui.accesscontext.UiEntityAttributeContext in project jmix by jmix-framework.

the class FilterMetadataTools method isMetaPropertyPathAllowed.

protected boolean isMetaPropertyPathAllowed(MetaPropertyPath propertyPath, String query) {
    UiEntityAttributeContext context = new UiEntityAttributeContext(propertyPath);
    accessManager.applyRegisteredConstraints(context);
    return context.canView() && !metadataTools.isSystemLevel(propertyPath.getMetaProperty()) && ((metadataTools.isJpa(propertyPath) || (propertyPath.getMetaClass() instanceof KeyValueMetaClass && !isAggregateFunction(propertyPath, query) && isKeyValueCrossDataStoreReferenceAllowed(propertyPath, query))) || (isCrossDataStoreReference(propertyPath.getMetaProperty()) && !(propertyPath.getMetaClass() instanceof KeyValueMetaClass))) && !propertyPath.getMetaProperty().getRange().getCardinality().isMany() && !(byte[].class.equals(propertyPath.getMetaProperty().getJavaType()));
}
Also used : KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) UiEntityAttributeContext(io.jmix.ui.accesscontext.UiEntityAttributeContext)

Example 14 with UiEntityAttributeContext

use of io.jmix.ui.accesscontext.UiEntityAttributeContext in project jmix by jmix-framework.

the class AbstractTable method getInitialVisibleColumnIds.

protected List<Object> getInitialVisibleColumnIds(EntityTableItems<E> entityTableSource) {
    List<Object> result = new ArrayList<>();
    MetaClass metaClass = entityTableSource.getEntityMetaClass();
    for (Column column : columnsOrder) {
        if (column.getId() instanceof MetaPropertyPath) {
            MetaPropertyPath propertyPath = (MetaPropertyPath) column.getId();
            UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(metaClass, propertyPath.toString());
            accessManager.applyRegisteredConstraints(attributeContext);
            if (attributeContext.canView()) {
                result.add(column.getId());
            }
        } else {
            result.add(column.getId());
        }
    }
    return result;
}
Also used : KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) MetaClass(io.jmix.core.metamodel.model.MetaClass) UiEntityAttributeContext(io.jmix.ui.accesscontext.UiEntityAttributeContext) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath)

Example 15 with UiEntityAttributeContext

use of io.jmix.ui.accesscontext.UiEntityAttributeContext in project jmix by jmix-framework.

the class AbstractTable method getPropertyColumns.

protected List<Object> getPropertyColumns(EntityTableItems<E> entityTableSource, List<Column<E>> columnsOrder) {
    MetaClass entityMetaClass = entityTableSource.getEntityMetaClass();
    return columnsOrder.stream().filter(c -> {
        MetaPropertyPath propertyPath = c.getMetaPropertyPath();
        if (propertyPath != null) {
            UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(entityMetaClass, propertyPath.toString());
            accessManager.applyRegisteredConstraints(attributeContext);
            return attributeContext.canView();
        }
        return false;
    }).map(Column::getMetaPropertyPath).collect(Collectors.toList());
}
Also used : KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) MetaClass(io.jmix.core.metamodel.model.MetaClass) UiEntityAttributeContext(io.jmix.ui.accesscontext.UiEntityAttributeContext) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath)

Aggregations

UiEntityAttributeContext (io.jmix.ui.accesscontext.UiEntityAttributeContext)20 MetaClass (io.jmix.core.metamodel.model.MetaClass)13 UiEntityContext (io.jmix.ui.accesscontext.UiEntityContext)9 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)7 KeyValueMetaClass (io.jmix.core.impl.keyvalue.KeyValueMetaClass)5 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)5 Nested (io.jmix.ui.model.Nested)4 ValueSource (io.jmix.ui.component.data.ValueSource)3 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)3 EntityValueSource (io.jmix.ui.component.data.meta.EntityValueSource)3 Range (io.jmix.core.metamodel.model.Range)2 io.jmix.ui.component (io.jmix.ui.component)2 HasValueSource (io.jmix.ui.component.data.HasValueSource)2 ContainerValueSource (io.jmix.ui.component.data.value.ContainerValueSource)2 Component (com.vaadin.ui.Component)1 AccessManager (io.jmix.core.AccessManager)1 EntityStates (io.jmix.core.EntityStates)1 MessageTools (io.jmix.core.MessageTools)1 Metadata (io.jmix.core.Metadata)1 ParamsMap (io.jmix.core.common.util.ParamsMap)1