Search in sources :

Example 1 with EmbeddedDatasourceImpl

use of com.haulmont.cuba.gui.data.impl.EmbeddedDatasourceImpl in project cuba by cuba-platform.

the class BulkEditorWindow method createNestedEmbeddedDatasources.

protected void createNestedEmbeddedDatasources(Datasource masterDs, MetaClass metaClass, String fqnPrefix) {
    for (MetaProperty metaProperty : metaClass.getProperties()) {
        if (MetaProperty.Type.ASSOCIATION == metaProperty.getType() || MetaProperty.Type.COMPOSITION == metaProperty.getType()) {
            String fqn = metaProperty.getName();
            if (StringUtils.isNotEmpty(fqnPrefix)) {
                fqn = fqnPrefix + "." + fqn;
            }
            if (managedEmbeddedProperties.contains(fqn) && metadataTools.isEmbedded(metaProperty)) {
                MetaClass propertyMetaClass = metaProperty.getRange().asClass();
                @SuppressWarnings("unchecked") NestedDatasource<Entity> propertyDs = new EmbeddedDatasourceImpl();
                propertyDs.setup(fqn + "Ds", masterDs, metaProperty.getName());
                propertyDs.setAllowCommit(false);
                createNestedEmbeddedDatasources(propertyDs, propertyMetaClass, fqn);
                datasources.put(fqn, propertyDs);
                dsContext.register(propertyDs);
            }
        }
    }
}
Also used : BaseGenericIdEntity(com.haulmont.cuba.core.entity.BaseGenericIdEntity) Entity(com.haulmont.cuba.core.entity.Entity) MetaClass(com.haulmont.chile.core.model.MetaClass) MetaProperty(com.haulmont.chile.core.model.MetaProperty) EmbeddedDatasourceImpl(com.haulmont.cuba.gui.data.impl.EmbeddedDatasourceImpl)

Aggregations

MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)1 Entity (com.haulmont.cuba.core.entity.Entity)1 EmbeddedDatasourceImpl (com.haulmont.cuba.gui.data.impl.EmbeddedDatasourceImpl)1