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