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