mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
PL-9570 Enable usage of session parameters in query filter
This commit is contained in:
parent
ce9017a63c
commit
c14e8b93db
@ -211,4 +211,11 @@ public interface GlobalConfig extends Config {
|
||||
@DefaultBoolean(false)
|
||||
boolean getUserSessionLogEnabled();
|
||||
void setUserSessionLogEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* @return whether the new (since 6.7) behavior regarding session parameters in query filter is enabled
|
||||
*/
|
||||
@Property("cuba.enableSessionParamsInQueryFilter")
|
||||
@DefaultBoolean(true)
|
||||
boolean getEnableSessionParamsInQueryFilter();
|
||||
}
|
@ -16,9 +16,7 @@
|
||||
*/
|
||||
package com.haulmont.cuba.core.global.filter;
|
||||
|
||||
import com.haulmont.cuba.core.global.QueryTransformer;
|
||||
import com.haulmont.cuba.core.global.QueryTransformerFactory;
|
||||
import com.haulmont.cuba.core.global.TemplateHelper;
|
||||
import com.haulmont.cuba.core.global.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.text.StrBuilder;
|
||||
import org.dom4j.Element;
|
||||
@ -27,6 +25,9 @@ import java.util.*;
|
||||
|
||||
public class QueryFilter extends FilterParser {
|
||||
|
||||
protected boolean enableSessionParams = AppBeans.get(Configuration.class)
|
||||
.getConfig(GlobalConfig.class).getEnableSessionParamsInQueryFilter();
|
||||
|
||||
public QueryFilter(Condition condition) {
|
||||
super(condition);
|
||||
}
|
||||
@ -101,7 +102,10 @@ public class QueryFilter extends FilterParser {
|
||||
|
||||
if (declaredParams.isEmpty())
|
||||
return true;
|
||||
|
||||
if (enableSessionParams) {
|
||||
return declaredParams.stream()
|
||||
.allMatch(paramInfo -> params.contains(paramInfo.getName()));
|
||||
} else {
|
||||
// Return true only if declared params have values and there is at least one non-session parameter among them.
|
||||
// This is necessary to exclude generic filter conditions that contain only session parameters. Otherwise
|
||||
// there is no way to handle exclusion. Unfortunately this imposes the restriction on custom filters design:
|
||||
@ -115,4 +119,5 @@ public class QueryFilter extends FilterParser {
|
||||
}
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user