Search in sources :

Example 1 with ValueLoadContext

use of com.haulmont.cuba.core.global.ValueLoadContext in project cuba by cuba-platform.

the class ValueDatasourceDelegate method beforeLoadValues.

protected ValueLoadContext beforeLoadValues(Map<String, Object> params) {
    ValueLoadContext context = new ValueLoadContext();
    ValueLoadContext.Query q = (ValueLoadContext.Query) ds.createDataQuery(context, params);
    if (q == null) {
        ds.detachListener(ds.data.values());
        ds.data.clear();
        return null;
    }
    if (ds.firstResult > 0)
        q.setFirstResult(ds.firstResult);
    if (ds.maxResults > 0) {
        q.setMaxResults(ds.maxResults);
    }
    if (storeName != null)
        context.setStoreName(storeName);
    context.setSoftDeletion(ds.isSoftDeletion());
    context.setIdName(idName);
    for (MetaProperty property : ds.metaClass.getProperties()) {
        context.addProperty(property.getName());
    }
    ds.dataLoadError = null;
    return context;
}
Also used : ValueLoadContext(com.haulmont.cuba.core.global.ValueLoadContext) MetaProperty(com.haulmont.chile.core.model.MetaProperty) KeyValueMetaProperty(com.haulmont.cuba.core.app.keyvalue.KeyValueMetaProperty)

Example 2 with ValueLoadContext

use of com.haulmont.cuba.core.global.ValueLoadContext in project cuba by cuba-platform.

the class ValueDatasourceDelegate method loadData.

protected void loadData(Map<String, Object> params) {
    if (ds.needLoading()) {
        ValueLoadContext context = beforeLoadValues(params);
        if (context == null) {
            return;
        }
        try {
            List<KeyValueEntity> entities = ds.dataSupplier.loadValues(context);
            afterLoadValues(params, context, entities);
        } catch (Throwable e) {
            ds.dataLoadError = e;
        }
    }
}
Also used : ValueLoadContext(com.haulmont.cuba.core.global.ValueLoadContext) KeyValueEntity(com.haulmont.cuba.core.entity.KeyValueEntity)

Aggregations

ValueLoadContext (com.haulmont.cuba.core.global.ValueLoadContext)2 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 KeyValueMetaProperty (com.haulmont.cuba.core.app.keyvalue.KeyValueMetaProperty)1 KeyValueEntity (com.haulmont.cuba.core.entity.KeyValueEntity)1