Search in sources :

Example 6 with KeyValueMetaClass

use of io.jmix.core.impl.keyvalue.KeyValueMetaClass in project jmix by jmix-framework.

the class ValueCollectionDatasourceImpl method setup.

@Override
public void setup(DsContext dsContext, DataSupplier dataSupplier, String id, MetaClass metaClass, @Nullable FetchPlan view) {
    this.id = id;
    this.dsContext = dsContext;
    this.dataSupplier = dataSupplier;
    this.metaClass = new KeyValueMetaClass();
}
Also used : KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass)

Example 7 with KeyValueMetaClass

use of io.jmix.core.impl.keyvalue.KeyValueMetaClass in project jmix by jmix-framework.

the class ValueHierarchicalDatasourceImpl method setHierarchyPropertyName.

@Override
public void setHierarchyPropertyName(String hierarchyPropertyName) {
    super.setHierarchyPropertyName(hierarchyPropertyName);
    KeyValueMetaClass metaClass = (KeyValueMetaClass) this.metaClass;
    if (metaClass.findProperty(hierarchyPropertyName) == null) {
        throw new IllegalStateException("Hierarchy property must be added to the datasource as property first");
    }
}
Also used : KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass)

Example 8 with KeyValueMetaClass

use of io.jmix.core.impl.keyvalue.KeyValueMetaClass in project jmix by jmix-framework.

the class AbstractDataGrid method createInstanceContainer.

protected InstanceContainer<E> createInstanceContainer(E item) {
    if (itemDatasources == null) {
        itemDatasources = new WeakHashMap<>();
    }
    Object container = itemDatasources.get(item);
    if (container instanceof InstanceContainer) {
        // noinspection unchecked
        return (InstanceContainer<E>) container;
    }
    EntityDataGridItems<E> items = getEntityDataGridItemsNN();
    DataComponents factory = this.applicationContext.getBean(DataComponents.class);
    FetchPlanRepository viewRepository = this.applicationContext.getBean(FetchPlanRepository.class);
    MetaClass metaClass = items.getEntityMetaClass();
    InstanceContainer<E> instanceContainer;
    if (metaClass instanceof KeyValueMetaClass) {
        // noinspection unchecked
        instanceContainer = (InstanceContainer<E>) factory.createKeyValueContainer(metaClass);
    } else {
        instanceContainer = factory.createInstanceContainer(metaClass.getJavaClass());
    }
    instanceContainer.setFetchPlan(viewRepository.getFetchPlan(metaClass, FetchPlan.LOCAL));
    instanceContainer.setItem(item);
    itemDatasources.put(item, instanceContainer);
    return instanceContainer;
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) InstanceContainer(io.jmix.ui.model.InstanceContainer) DataComponents(io.jmix.ui.model.DataComponents)

Example 9 with KeyValueMetaClass

use of io.jmix.core.impl.keyvalue.KeyValueMetaClass 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 10 with KeyValueMetaClass

use of io.jmix.core.impl.keyvalue.KeyValueMetaClass in project jmix by jmix-framework.

the class AbstractTable method getInstanceContainer.

@SuppressWarnings("unchecked")
@Override
public InstanceContainer<E> getInstanceContainer(E item) {
    if (fieldDatasources == null) {
        fieldDatasources = new WeakHashMap<>();
    }
    Object fieldDatasource = fieldDatasources.get(item);
    if (fieldDatasource instanceof InstanceContainer) {
        return (InstanceContainer<E>) fieldDatasource;
    }
    EntityTableItems containerTableItems = (EntityTableItems) getItems();
    if (containerTableItems == null) {
        throw new IllegalStateException("Table is not bound to items");
    }
    InstanceContainer<E> instanceContainer;
    MetaClass metaClass = containerTableItems.getEntityMetaClass();
    if (metaClass instanceof KeyValueMetaClass) {
        instanceContainer = (InstanceContainer<E>) dataComponents.createKeyValueContainer(metaClass);
    } else {
        instanceContainer = dataComponents.createInstanceContainer(metaClass.getJavaClass());
    }
    FetchPlan view = viewRepository.getFetchPlan(metaClass, FetchPlan.LOCAL);
    instanceContainer.setFetchPlan(view);
    instanceContainer.setItem(item);
    fieldDatasources.put(item, instanceContainer);
    return instanceContainer;
}
Also used : KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) MetaClass(io.jmix.core.metamodel.model.MetaClass) KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) EntityTableItems(io.jmix.ui.component.data.meta.EntityTableItems) InstanceContainer(io.jmix.ui.model.InstanceContainer) FetchPlan(io.jmix.core.FetchPlan)

Aggregations

KeyValueMetaClass (io.jmix.core.impl.keyvalue.KeyValueMetaClass)10 MetaClass (io.jmix.core.metamodel.model.MetaClass)3 InstanceContainer (io.jmix.ui.model.InstanceContainer)2 CubaProperties (com.haulmont.cuba.CubaProperties)1 PersistenceManagerClient (com.haulmont.cuba.client.sys.PersistenceManagerClient)1 Metadata (com.haulmont.cuba.core.global.Metadata)1 FetchPlan (io.jmix.core.FetchPlan)1 MetadataTools (io.jmix.core.MetadataTools)1 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 UiEntityAttributeContext (io.jmix.ui.accesscontext.UiEntityAttributeContext)1 EntityTableItems (io.jmix.ui.component.data.meta.EntityTableItems)1 DataComponents (io.jmix.ui.model.DataComponents)1 Element (org.dom4j.Element)1