use of io.jmix.ui.accesscontext.UiEntityContext in project jmix by jmix-framework.
the class ChangePasswordAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isEditPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.accesscontext.UiEntityContext in project jmix by jmix-framework.
the class ResetRememberMeTokenAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isEditPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.accesscontext.UiEntityContext in project jmix by jmix-framework.
the class ShowUserSubstitutionsAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isViewPermitted()) {
return false;
}
UiEntityContext userSubstitutionContext = new UiEntityContext(metadata.getClass(UserSubstitutionEntity.class));
accessManager.applyRegisteredConstraints(userSubstitutionContext);
if (!userSubstitutionContext.isViewPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.accesscontext.UiEntityContext in project jmix by jmix-framework.
the class RelatedEntitiesImpl method isSuitableProperty.
protected boolean isSuitableProperty(MetaClass metaClass, MetaProperty metaProperty, @Nullable Pattern excludePattern) {
if (!metaProperty.getRange().isClass()) {
return false;
}
// check that entities are placed in the same data store
MetaClass propertyMetaClass = metaProperty.getRange().asClass();
String propertyStore = propertyMetaClass.getStore().getName();
String effectiveStore = metaClass.getStore().getName();
if (!Objects.equals(effectiveStore, propertyStore)) {
return false;
}
// apply security
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(metaClass, metaProperty.getName());
accessManager.applyRegisteredConstraints(attributeContext);
return entityContext.isViewPermitted() && attributeContext.canView() && (excludePattern == null || !excludePattern.matcher(metaProperty.getName()).matches());
}
use of io.jmix.ui.accesscontext.UiEntityContext in project jmix by jmix-framework.
the class EntityInspectorEditor method addTable.
/**
* Creates a table for the entities in ONE_TO_MANY or MANY_TO_MANY relation with the current one
*/
protected void addTable(InstanceContainer parent, MetaProperty childMeta) {
MetaClass meta = childMeta.getRange().asClass();
UiEntityContext entityContext = new UiEntityContext(meta);
accessManager.applyRegisteredConstraints(entityContext);
UiEntityAttributeContext attributeContext = new UiEntityAttributeContext(parent.getEntityMetaClass(), childMeta.getName());
accessManager.applyRegisteredConstraints(attributeContext);
// don't show empty table if the user don't have permissions on the attribute or the entity
if (!attributeContext.canView() || !entityContext.isViewPermitted()) {
return;
}
// vertical box for the table and its label
BoxLayout vbox = uiComponents.create(VBoxLayout.class);
vbox.setSizeFull();
Table entitiesTable = InspectorTableBuilder.from(getApplicationContext(), createTableContainer(parent, childMeta, meta)).withMaxTextLength(MAX_TEXT_LENGTH).withSystem(true).withButtons(table -> createButtonsPanel(table, childMeta)).build();
vbox.add(entitiesTable);
vbox.expand(entitiesTable);
vbox.setMargin(true);
TabSheet.Tab tab = tablesTabSheet.addTab(childMeta.toString(), vbox);
tab.setCaption(getPropertyCaption(parent.getEntityMetaClass(), childMeta));
}
Aggregations