Class FilterHelper
- Author:
- Jeff Fischer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Relationship information about aLink
annotated field and the target entity and target field a particular selector is pointing to. -
Method Summary
Modifier and TypeMethodDescriptionstatic cz.jirutka.rsql.parser.ast.Node
filterByFieldAndFilters
(cz.jirutka.rsql.parser.ast.Node filters, String fieldName, String searchString, FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) Produces aNode
that is the "AND"-ed combination offilters
and a contains-ignoring-case filter onfieldName
withsearchString
.static cz.jirutka.rsql.parser.ast.Node
filterByFieldAndFiltersIn
(cz.jirutka.rsql.parser.ast.Node filters, String fieldName, List<String> searchList, FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) Produces aNode
that is the "AND"-ed combination offilters
and a in filter onfieldName
withsearchString
.static cz.jirutka.rsql.parser.ast.Node
filterByNameAndFilters
(cz.jirutka.rsql.parser.ast.Node filters, String name, FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) A convenience method that acts as a shortcut tofilterByFieldAndFilters(Node, String, String, FilterParser)
with"name"
supplied as the field argument.static Optional<FilterHelper.LinkField>
getLinkedFieldInformation
(Class<?> rootType, String selector) If aLink
annotated field is targeted by the selector, return information about the link.static cz.jirutka.rsql.parser.ast.Node
transform
(cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.common.extension.DomainTypeAware domainAware, List<RsqlQueryTransformer> rsqlQueryTransformers) Transformsfilters
from properties that target a projection into ones that apply to a backing repository provider domain objectstatic cz.jirutka.rsql.parser.ast.Node
transform
(cz.jirutka.rsql.parser.ast.Node filters, TrackableRepository<Trackable> repository, List<RsqlQueryTransformer> rsqlQueryTransformers) Transformsfilters
from properties that target a projection into ones that apply to a backing repository provider domain object
-
Method Details
-
getLinkedFieldInformation
public static Optional<FilterHelper.LinkField> getLinkedFieldInformation(@NonNull Class<?> rootType, @NonNull String selector) If aLink
annotated field is targeted by the selector, return information about the link.- Parameters:
rootType
- The type of the containing repository domainselector
- The selector from RSQL targeting a projection field that is buried in the entity referenced via theLink
annotated field.- Returns:
- Information about the link
-
transform
@NonNull public static cz.jirutka.rsql.parser.ast.Node transform(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull TrackableRepository<Trackable> repository, @NonNull List<RsqlQueryTransformer> rsqlQueryTransformers) Transformsfilters
from properties that target a projection into ones that apply to a backing repository provider domain object- Parameters:
filters
- RSQL filters targeting a projection domainrepository
- ATrackableRepository
form which to glean entity information for the transformationrsqlQueryTransformers
- Customizes a RSQL query before it is passed on to the repository layer- Returns:
- null if
filters
is null, otherwise an RSQL query suitable for targeting a repository domain object. - See Also:
-
transform
@NonNull public static cz.jirutka.rsql.parser.ast.Node transform(@NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull com.broadleafcommerce.common.extension.DomainTypeAware domainAware, @NonNull List<RsqlQueryTransformer> rsqlQueryTransformers) Transformsfilters
from properties that target a projection into ones that apply to a backing repository provider domain object- Parameters:
filters
- RSQL filters targeting a projection domaindomainAware
- ADomainTypeAware
form which to glean entity information for the transformationrsqlQueryTransformers
- Customizes a RSQL query before it is passed on to the repository layer- Returns:
- null if
filters
is null, otherwise an RSQL query suitable for targeting a repository domain object. - See Also:
-
filterByNameAndFilters
@NonNull public static cz.jirutka.rsql.parser.ast.Node filterByNameAndFilters(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable String name, @Nullable FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) A convenience method that acts as a shortcut tofilterByFieldAndFilters(Node, String, String, FilterParser)
with"name"
supplied as the field argument.- Parameters:
filters
- (optional)Node
filtersname
- (optional) the search string that will be used to filter by nameparser
- (optional) the parser that can be used to build aNode
for filtering by name. If null,name
will be ignored.- Returns:
- the "AND"-ed combination of
filters
and a contains-ignoring-case filter on the name field
-
filterByFieldAndFilters
@NonNull public static cz.jirutka.rsql.parser.ast.Node filterByFieldAndFilters(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable String fieldName, @Nullable String searchString, @Nullable FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) Produces aNode
that is the "AND"-ed combination offilters
and a contains-ignoring-case filter onfieldName
withsearchString
.If
searchString
andfilters
are both empty (or effectively not present),EmptyNode
will be returned.If
filters
is provided andsearchString
is empty,filters
will be returned as-is.If
searchString
is provided andfilters
is empty (or effectively not present), aNode
for filteringfieldName
bysearchString
will be built and returned.If
searchString
andfilters
are both provided, both will be combined and returned in anAndNode
.- Parameters:
filters
- (optional)Node
filtersfieldName
- the name of the field against which a contains-ignoring-case filter should be built withsearchString
as an argument. Required ifsearchString
is supplied.searchString
- (optional) the search string that will be used to filterfieldName
parser
- (optional) the parser that can be used to build aNode
forfieldName
/searchString
. If null,searchString
will be ignored.- Returns:
- the "AND"-ed combination of
filters
and a contains-ignoring-case filter onfieldName
withsearchString
-
filterByFieldAndFiltersIn
@NonNull public static cz.jirutka.rsql.parser.ast.Node filterByFieldAndFiltersIn(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull String fieldName, @Nullable List<String> searchList, @NonNull FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) Produces aNode
that is the "AND"-ed combination offilters
and a in filter onfieldName
withsearchString
.If
searchLList
andfilters
are both empty (or effectively not present),EmptyNode
will be returned.If
filters
is provided andsearchList
is empty,filters
will be returned as-is.If
searchList
is provided andfilters
is empty (or effectively not present), aNode
for filteringfieldName
bysearchList
will be built and returned.If
searchList
andfilters
are both provided, both will be combined and returned in anAndNode
.- Parameters:
filters
- (optional)Node
filtersfieldName
- the name of the field against which a contains-ignoring-case filter should be built withsearchList
as an argument. Required ifsearchString
is supplied.searchList
- (optional) the search string that will be used to filterfieldName
parser
- the parser that can be used to build aNode
forfieldName
/searchList
. If null,searchList
will be ignored.- Returns:
- the "AND"-ed combination of
filters
and a contains-ignoring-case filter onfieldName
withsearchList
-