Search in sources :

Example 6 with CrudEntityContext

use of io.jmix.core.accesscontext.CrudEntityContext in project jmix by jmix-framework.

the class CategoryBrowse method setupFieldsLock.

protected void setupFieldsLock() {
    CrudEntityContext crudEntityContext = new CrudEntityContext(categoryDc.getEntityMetaClass());
    accessManager.applyRegisteredConstraints(crudEntityContext);
    if (!crudEntityContext.isUpdatePermitted()) {
        applyChangesBtn.setEnabled(false);
    }
}
Also used : CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext)

Example 7 with CrudEntityContext

use of io.jmix.core.accesscontext.CrudEntityContext in project jmix by jmix-framework.

the class CategoryEdit method initLocalizationTab.

protected void initLocalizationTab() {
    if (coreProperties.getAvailableLocales().size() > 1) {
        TabSheet.Tab localizationTab = tabSheet.getTab("localizationTab");
        localizationTab.setVisible(true);
        CrudEntityContext crudEntityContext = new CrudEntityContext(categoryDc.getEntityMetaClass());
        accessManager.applyRegisteredConstraints(crudEntityContext);
        VBoxLayout localizationTabComponent = (VBoxLayout) tabSheet.getTabComponent("localizationTab");
        localizationFragment = fragments.create(this, AttributeLocalizationFragment.class);
        localizationFragment.setNameMsgBundle(getEditedEntity().getLocaleNames());
        localizationFragment.setEnabled(crudEntityContext.isUpdatePermitted());
        Fragment fragment = localizationFragment.getFragment();
        fragment.setWidth(Component.FULL_SIZE);
        localizationTabComponent.add(fragment);
        localizationTabComponent.expand(fragment);
    }
}
Also used : AttributeLocalizationFragment(io.jmix.dynattrui.screen.localization.AttributeLocalizationFragment) CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext) AttributeLocalizationFragment(io.jmix.dynattrui.screen.localization.AttributeLocalizationFragment) CategoryAttrsFragment(io.jmix.dynattrui.screen.categoryattr.CategoryAttrsFragment) AttributeLocationFragment(io.jmix.dynattrui.screen.location.AttributeLocationFragment)

Example 8 with CrudEntityContext

use of io.jmix.core.accesscontext.CrudEntityContext in project jmix by jmix-framework.

the class EntitiesControllerManager method applyEntityConstraints.

protected CrudEntityContext applyEntityConstraints(MetaClass metaClass) {
    CrudEntityContext entityContext = new CrudEntityContext(metaClass);
    accessManager.applyRegisteredConstraints(entityContext);
    return entityContext;
}
Also used : CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext)

Example 9 with CrudEntityContext

use of io.jmix.core.accesscontext.CrudEntityContext in project jmix by jmix-framework.

the class EntityQueryDataFetcher method applyEntityConstraints.

protected CrudEntityContext applyEntityConstraints(MetaClass metaClass) {
    CrudEntityContext entityContext = new CrudEntityContext(metaClass);
    accessManager.applyRegisteredConstraints(entityContext);
    return entityContext;
}
Also used : CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext)

Example 10 with CrudEntityContext

use of io.jmix.core.accesscontext.CrudEntityContext in project jmix by jmix-framework.

the class MessagesDataFetcher method getEntityMessages.

protected List<MessageDetail> getEntityMessages(MetaClass metaClass, Locale locale) {
    List<MessageDetail> messages = new ArrayList<>();
    CrudEntityContext entityContext = new CrudEntityContext(metaClass);
    accessManager.applyRegisteredConstraints(entityContext);
    String metaClassName = metaClass.getName();
    if (entityContext.isReadPermitted()) {
        String entityCaption = messageTools.getEntityCaption(metaClass, locale);
        messages.add(new MessageDetail(metaClassName, entityCaption));
    }
    for (MetaProperty metaProperty : metaClass.getProperties()) {
        EntityAttributeContext attributeContext = new EntityAttributeContext(metaClass, metaProperty.getName());
        accessManager.applyRegisteredConstraints(attributeContext);
        if (attributeContext.canView()) {
            String propertyCaption = messageTools.getPropertyCaption(metaProperty, locale);
            messages.add(new MessageDetail(metaClassName + "." + metaProperty.getName(), propertyCaption));
        }
    }
    return messages;
}
Also used : CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext) EntityAttributeContext(io.jmix.core.accesscontext.EntityAttributeContext) ArrayList(java.util.ArrayList) MessageDetail(io.jmix.graphql.schema.messages.MessageDetail) MetaProperty(io.jmix.core.metamodel.model.MetaProperty)

Aggregations

CrudEntityContext (io.jmix.core.accesscontext.CrudEntityContext)26 MetaClass (io.jmix.core.metamodel.model.MetaClass)9 EntityAttributeContext (io.jmix.core.accesscontext.EntityAttributeContext)4 AttributeLocalizationFragment (io.jmix.dynattrui.screen.localization.AttributeLocalizationFragment)4 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)3 AccessDeniedException (io.jmix.core.security.AccessDeniedException)3 ArrayList (java.util.ArrayList)3 CategoryAttrsFragment (io.jmix.dynattrui.screen.categoryattr.CategoryAttrsFragment)2 AttributeLocationFragment (io.jmix.dynattrui.screen.location.AttributeLocationFragment)2 UiSetting (io.jmix.uidata.entity.UiSetting)2 UiTablePresentation (io.jmix.uidata.entity.UiTablePresentation)2 UUID (java.util.UUID)2 Query (javax.persistence.Query)2 TypedQuery (javax.persistence.TypedQuery)2 Attribute (org.dom4j.Attribute)2 Document (org.dom4j.Document)2 Element (org.dom4j.Element)2 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)1 AccessManager (io.jmix.core.AccessManager)1 Metadata (io.jmix.core.Metadata)1