Search in sources :

Example 1 with QueryFilter

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

the class FilterDelegateImpl method setDatasource.

@Override
public void setDatasource(CollectionDatasource datasource) {
    this.datasource = datasource;
    this.dsQueryFilter = datasource.getQueryFilter();
    if (getResultingManualApplyRequired()) {
        // set initial denying condition to get empty datasource before explicit filter applying
        QueryFilter queryFilter = new QueryFilter(new DenyingClause());
        if (dsQueryFilter != null) {
            queryFilter = QueryFilter.merge(dsQueryFilter, queryFilter);
        }
        datasource.setQueryFilter(queryFilter);
    }
    if (datasource instanceof CollectionDatasource.Lazy || datasource instanceof HierarchicalDatasource) {
        setUseMaxResults(false);
    } else if (useMaxResults) {
        initMaxResults();
    }
    if (ftsSwitch != null && !isEntityAvailableForFts()) {
        controlsLayout.remove(ftsSwitch);
    }
}
Also used : QueryFilter(com.haulmont.cuba.core.global.filter.QueryFilter) HierarchicalDatasource(com.haulmont.cuba.gui.data.HierarchicalDatasource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) DenyingClause(com.haulmont.cuba.core.global.filter.DenyingClause)

Example 2 with QueryFilter

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

the class FilterDelegateImpl method applyDatasourceFilter.

protected void applyDatasourceFilter() {
    if (datasource != null) {
        String currentFilterXml = filterParser.getXml(conditions, Param.ValueProperty.VALUE);
        if (!Strings.isNullOrEmpty(currentFilterXml)) {
            Element element = Dom4j.readDocument(currentFilterXml).getRootElement();
            QueryFilter queryFilter = new QueryFilter(element);
            if (dsQueryFilter != null) {
                queryFilter = QueryFilter.merge(dsQueryFilter, queryFilter);
            }
            datasource.setQueryFilter(queryFilter);
        } else {
            datasource.setQueryFilter(dsQueryFilter);
        }
    } else {
        log.warn("Unable to apply datasource filter with null datasource");
    }
}
Also used : QueryFilter(com.haulmont.cuba.core.global.filter.QueryFilter) Element(org.dom4j.Element)

Example 3 with QueryFilter

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

the class DsContextLoader method loadQuery.

private void loadQuery(Element element, CollectionDatasource datasource) {
    Element queryElem = element.element("query");
    if (queryElem != null) {
        Element filterElem = queryElem.element("filter");
        String query = queryElem.getText();
        if (!StringUtils.isBlank(query)) {
            if (filterElem != null)
                datasource.setQuery(query, new QueryFilter(filterElem));
            else
                datasource.setQuery(query);
        }
    }
}
Also used : QueryFilter(com.haulmont.cuba.core.global.filter.QueryFilter) Element(org.dom4j.Element)

Aggregations

QueryFilter (com.haulmont.cuba.core.global.filter.QueryFilter)3 Element (org.dom4j.Element)2 DenyingClause (com.haulmont.cuba.core.global.filter.DenyingClause)1 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)1 HierarchicalDatasource (com.haulmont.cuba.gui.data.HierarchicalDatasource)1