Class FilterHelper
- Author:
- Jeff Fischer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRelationship information about aLinkannotated field and the target entity and target field a particular selector is pointing to. -
Method Summary
Modifier and TypeMethodDescriptionstatic cz.jirutka.rsql.parser.ast.NodefilterByFieldAndFilters(cz.jirutka.rsql.parser.ast.Node filters, String fieldName, String searchString, FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) Produces aNodethat is the "AND"-ed combination offiltersand a contains-ignoring-case filter onfieldNamewithsearchString.static cz.jirutka.rsql.parser.ast.NodefilterByFieldAndFiltersIn(cz.jirutka.rsql.parser.ast.Node filters, String fieldName, List<String> searchList, FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) Produces aNodethat is the "AND"-ed combination offiltersand a in filter onfieldNamewithsearchString.static cz.jirutka.rsql.parser.ast.NodefilterByNameAndFilters(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 aLinkannotated field is targeted by the selector, return information about the link.static cz.jirutka.rsql.parser.ast.Nodetransform(cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.common.extension.DomainTypeAware domainAware, List<RsqlQueryTransformer> rsqlQueryTransformers) Transformsfiltersfrom properties that target a projection into ones that apply to a backing repository provider domain objectstatic cz.jirutka.rsql.parser.ast.Nodetransform(cz.jirutka.rsql.parser.ast.Node filters, TrackableRepository<Trackable> repository, List<RsqlQueryTransformer> rsqlQueryTransformers) Transformsfiltersfrom 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 aLinkannotated 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 theLinkannotated 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) Transformsfiltersfrom properties that target a projection into ones that apply to a backing repository provider domain object- Parameters:
filters- RSQL filters targeting a projection domainrepository- ATrackableRepositoryform which to glean entity information for the transformationrsqlQueryTransformers- Customizes a RSQL query before it is passed on to the repository layer- Returns:
- null if
filtersis 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) Transformsfiltersfrom properties that target a projection into ones that apply to a backing repository provider domain object- Parameters:
filters- RSQL filters targeting a projection domaindomainAware- ADomainTypeAwareform which to glean entity information for the transformationrsqlQueryTransformers- Customizes a RSQL query before it is passed on to the repository layer- Returns:
- null if
filtersis 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)Nodefiltersname- (optional) the search string that will be used to filter by nameparser- (optional) the parser that can be used to build aNodefor filtering by name. If null,namewill be ignored.- Returns:
- the "AND"-ed combination of
filtersand 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 aNodethat is the "AND"-ed combination offiltersand a contains-ignoring-case filter onfieldNamewithsearchString.If
searchStringandfiltersare both empty (or effectively not present),EmptyNodewill be returned.If
filtersis provided andsearchStringis empty,filterswill be returned as-is.If
searchStringis provided andfiltersis empty (or effectively not present), aNodefor filteringfieldNamebysearchStringwill be built and returned.If
searchStringandfiltersare both provided, both will be combined and returned in anAndNode.- Parameters:
filters- (optional)NodefiltersfieldName- the name of the field against which a contains-ignoring-case filter should be built withsearchStringas an argument. Required ifsearchStringis supplied.searchString- (optional) the search string that will be used to filterfieldNameparser- (optional) the parser that can be used to build aNodeforfieldName/searchString. If null,searchStringwill be ignored.- Returns:
- the "AND"-ed combination of
filtersand a contains-ignoring-case filter onfieldNamewithsearchString
-
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 aNodethat is the "AND"-ed combination offiltersand a in filter onfieldNamewithsearchString.If
searchLListandfiltersare both empty (or effectively not present),EmptyNodewill be returned.If
filtersis provided andsearchListis empty,filterswill be returned as-is.If
searchListis provided andfiltersis empty (or effectively not present), aNodefor filteringfieldNamebysearchListwill be built and returned.If
searchListandfiltersare both provided, both will be combined and returned in anAndNode.- Parameters:
filters- (optional)NodefiltersfieldName- the name of the field against which a contains-ignoring-case filter should be built withsearchListas an argument. Required ifsearchStringis supplied.searchList- (optional) the search string that will be used to filterfieldNameparser- the parser that can be used to build aNodeforfieldName/searchList. If null,searchListwill be ignored.- Returns:
- the "AND"-ed combination of
filtersand a contains-ignoring-case filter onfieldNamewithsearchList
-