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