Class JpaAssetCriteriaUtils
java.lang.Object
com.broadleafcommerce.catalog.provider.jpa.repository.asset.support.JpaAssetCriteriaUtils
Support class with convenience methods for criteria-building functionality common to custom JPA
repository implementations.
- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.persistence.criteria.Predicate
buildAltTextLikeFilter
(String formattedSearchString, jakarta.persistence.criteria.Root<?> assetEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Builds a criteria that restricts results to only include entities whose alt-text (after applying an uppercase conversion) is like the givenformattedSearchString
.static jakarta.persistence.criteria.Predicate
buildTitleLikeFilter
(String formattedSearchString, jakarta.persistence.criteria.Root<?> assetEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Builds a criteria that restricts results to only include entities whose title (after applying an uppercase conversion) is like the givenformattedSearchString
.static jakarta.persistence.criteria.Predicate
buildUrlLikeFilter
(String formattedSearchString, jakarta.persistence.criteria.Root<?> assetEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Builds a criteria that restricts results to only include entities whose URL (after applying an uppercase conversion) is like the givenformattedSearchString
.static String
formatForSearch
(String searchString) Accepts a search string and formats it for use in contains-ignore-case criteria.
-
Method Details
-
formatForSearch
Accepts a search string and formats it for use in contains-ignore-case criteria.Surrounds the given string with
%
wildcards and applies an uppercase conversion.TODO: also add logic to escape wildcards (and escape characters themselves)
- Parameters:
searchString
- the string to format for search- Returns:
- the given string after applying an uppercase conversion and surrounding it with wildcard characters
-
buildUrlLikeFilter
public static jakarta.persistence.criteria.Predicate buildUrlLikeFilter(String formattedSearchString, jakarta.persistence.criteria.Root<?> assetEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Builds a criteria that restricts results to only include entities whose URL (after applying an uppercase conversion) is like the givenformattedSearchString
.- Parameters:
formattedSearchString
- the pre-formatted search string as prepared informatForSearch(String)
assetEntity
- the asset entity on which the filter should be createdcriteriaBuilder
- the criteria builder used to generate parameters/predicatesparameterValues
- a map of parameter names to argument values that will be used to run the query. Any parameter values required to perform the query should be added to this map.- Returns:
- a criteria that restricts results to only include entities whose URL (after applying
an uppercase conversion) is like the given
formattedSearchString
-
buildTitleLikeFilter
public static jakarta.persistence.criteria.Predicate buildTitleLikeFilter(String formattedSearchString, jakarta.persistence.criteria.Root<?> assetEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Builds a criteria that restricts results to only include entities whose title (after applying an uppercase conversion) is like the givenformattedSearchString
.- Parameters:
formattedSearchString
- the pre-formatted search string as prepared informatForSearch(String)
assetEntity
- the asset entity on which the filter should be createdcriteriaBuilder
- the criteria builder used to generate parameters/predicatesparameterValues
- a map of parameter names to argument values that will be used to run the query. Any parameter values required to perform the query should be added to this map.- Returns:
- a criteria that restricts results to only include entities whose title (after
applying an uppercase conversion) is like the given
formattedSearchString
-
buildAltTextLikeFilter
public static jakarta.persistence.criteria.Predicate buildAltTextLikeFilter(String formattedSearchString, jakarta.persistence.criteria.Root<?> assetEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Builds a criteria that restricts results to only include entities whose alt-text (after applying an uppercase conversion) is like the givenformattedSearchString
.- Parameters:
formattedSearchString
- the pre-formatted search string as prepared informatForSearch(String)
assetEntity
- the asset entity on which the filter should be createdcriteriaBuilder
- the criteria builder used to generate parameters/predicatesparameterValues
- a map of parameter names to argument values that will be used to run the query. Any parameter values required to perform the query should be added to this map.- Returns:
- a criteria that restricts results to only include entities whose alt-text (after
applying an uppercase conversion) is like the given
formattedSearchString
-