Class DefaultCategoryService<P extends Category>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.catalog.service.DefaultCategoryService<P>
- All Implemented Interfaces:
CategoryService<P>
,com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
public class DefaultCategoryService<P extends Category>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements CategoryService<P>
- Author:
- Jeff Fischer, Samarth Dhruva (samarthd)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultCategoryService
(CategoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, ProductService<Product> productService, CategoryProductService<CategoryProduct> categoryProductService, RSQLEvaluationService rsqlEvaluationService, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkRelatedProductMembershipInCategory
(String categoryId, String productId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks whether a product is a member of the given category.boolean
existsById
(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether there is a category with the given context ID in the data store.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
protected CategoryProductService<CategoryProduct>
protected ProductService<Product>
protected CategoryRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected RSQLEvaluationService
cz.jirutka.rsql.parser.ast.Node
mergeInFilter
(cz.jirutka.rsql.parser.ast.Node filters, String fieldName, List<String> searchList) readAllByContextIds
(Collection<String> categoryIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return all of the categories with IDs in the supplied collection.org.springframework.data.domain.Page<P>
readAllByContextIds
(Collection<String> categoryIds, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return all of the categories with IDs in the supplied list.readAllById
(@NonNull Iterable<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Retrieves of all theCategories
that match thecontextIds
.org.springframework.data.domain.Page<P>
readAllByName
(boolean rootsOnly, String name, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Read all categories, filtered by name.readAllByNamesIn
(Collection<String> names, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Read all categories, filtered by name.org.springframework.data.domain.Page<P>
readAllByParentCategoryId
(String parentCategoryId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read all categories in the database that have the given category context ID set as their parent category.org.springframework.data.domain.Page<P>
readAllByParentCategoryIdIn
(List<String> parentCategoryIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) readAllByUrls
(@NonNull Iterable<String> urls, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds a categories by the given urls.readByExternalId
(String externalId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a category by its external IDreadByExternalIdIn
(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a list of categories by the supplied external IDsorg.springframework.data.domain.Page<P>
readByExternalIdIn
(Collection<String> externalIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find categories by their external IDsFinds a category by the given url.void
setCacheByActiveCategoryIdKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryIdKeyGen) void
setCacheByActiveCategoryKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryKeyGen) void
setCacheByActiveCategoryUrlKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryUrlKeyGen) void
setCacheByExternalCategoryId
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByExternalCategoryId) streamByParentCategoryId
(String parentCategoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read all categories in the database that have the given category context ID set as their parent category.Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAll
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Field Details
-
CACHE_BY_ACTIVE_CATEGORY
- See Also:
-
CACHE_BY_ACTIVE_CATEGORY_ID
- See Also:
-
CACHE_BY_ACTIVE_CATEGORY_URL
- See Also:
-
CACHE_BY_EXTERNAL_CATEGORY_ID
- See Also:
-
-
Constructor Details
-
DefaultCategoryService
public DefaultCategoryService(CategoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, ProductService<Product> productService, CategoryProductService<CategoryProduct> categoryProductService, RSQLEvaluationService rsqlEvaluationService, @Nullable com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
-
-
Method Details
-
existsById
public boolean existsById(@NonNull String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Returns whether there is a category with the given context ID in the data store.- Specified by:
existsById
in interfaceCategoryService<P extends Category>
- Parameters:
id
- the ID to search forcontextInfo
- context information around sandboxing and multitenant state- Returns:
- true if a category exists matching the given ID, false otherwise
-
readAllByContextIds
public org.springframework.data.domain.Page<P> readAllByContextIds(@NonNull Collection<String> categoryIds, @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CategoryService
Return all of the categories with IDs in the supplied list.- Specified by:
readAllByContextIds
in interfaceCategoryService<P extends Category>
- Parameters:
categoryIds
- the category context IDs to search forpage
- the requested page of results from the databasecontext
- the context to perform the operation in- Returns:
- the categories that matched with the IDs in the given list
-
readAllByContextIds
public Stream<P> readAllByContextIds(@NonNull Collection<String> categoryIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Return all of the categories with IDs in the supplied collection.- Specified by:
readAllByContextIds
in interfaceCategoryService<P extends Category>
- Parameters:
categoryIds
- the category context IDs to search forcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- the categories that matched with the IDs in the given collection
-
readAllByName
public org.springframework.data.domain.Page<P> readAllByName(boolean rootsOnly, @Nullable String name, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CategoryService
Read all categories, filtered by name. IfrootsOnly
is true, then results are also filtered to only include categories that have no specifiedparent category
.- Specified by:
readAllByName
in interfaceCategoryService<P extends Category>
- Parameters:
rootsOnly
- if true, restricts results to only include categories that have not specified aparent category
name
- the category name to filter byfilters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- all categories, filtered by name and whether they have specified a
parent category
-
readAllByNamesIn
public List<P> readAllByNamesIn(@NonNull Collection<String> names, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CategoryService
Read all categories, filtered by name. IfrootsOnly
is true, then results are also filtered to only include categories that have no specifiedparent category
.- Specified by:
readAllByNamesIn
in interfaceCategoryService<P extends Category>
- Parameters:
names
- the category names to filter bycontext
- context context information surrounding sandboxing and multitenant state- Returns:
- all categories, filtered by name and whether they have specified a
parent category
-
mergeInFilter
-
readAllByParentCategoryId
public org.springframework.data.domain.Page<P> readAllByParentCategoryId(@NonNull String parentCategoryId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Read all categories in the database that have the given category context ID set as their parent category.- Specified by:
readAllByParentCategoryId
in interfaceCategoryService<P extends Category>
- Parameters:
parentCategoryId
- the category context ID whose children should be foundfilters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- the children categories of the category identified by the given context ID
-
readAllByParentCategoryIdIn
public org.springframework.data.domain.Page<P> readAllByParentCategoryIdIn(@NonNull List<String> parentCategoryIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
readAllByParentCategoryIdIn
in interfaceCategoryService<P extends Category>
-
streamByParentCategoryId
public Stream<P> streamByParentCategoryId(String parentCategoryId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Read all categories in the database that have the given category context ID set as their parent category.- Specified by:
streamByParentCategoryId
in interfaceCategoryService<P extends Category>
- Parameters:
parentCategoryId
- the category context ID whose children should be foundcontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- the stream of children categories of the category identified by the given context ID
-
checkRelatedProductMembershipInCategory
public boolean checkRelatedProductMembershipInCategory(@NonNull String categoryId, @NonNull String productId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Checks whether a product is a member of the given category. If the category isCategoryProductMembershipType.EXPLICIT
, will check if there is aCategoryProduct
between the supplied category and product. If the category isCategoryProductMembershipType.RULE_BASED
, will evaluate thecategory's rule string
against the product to see if the product satisfies the rule string.- Specified by:
checkRelatedProductMembershipInCategory
in interfaceCategoryService<P extends Category>
- Parameters:
categoryId
- the context ID of the category to check membership withproductId
- the context ID of the product to checkcontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- true if the product is a member of the category, false otherwise
-
readByUrl
@NonNull public Optional<P> readByUrl(@NonNull String url, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CategoryService
Finds a category by the given url.- Specified by:
readByUrl
in interfaceCategoryService<P extends Category>
- Parameters:
url
- The url to search by- Returns:
- The Category matching the
url
, orOptional.empty()
if none found
-
readAllByUrls
@NonNull public List<P> readAllByUrls(@NonNull @NonNull @NonNull Iterable<String> urls, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CategoryService
Finds a categories by the given urls.- Specified by:
readAllByUrls
in interfaceCategoryService<P extends Category>
- Parameters:
urls
- The urls to search by- Returns:
- The Category matching the
urls
-
readAllById
public List<P> readAllById(@NonNull @NonNull @NonNull Iterable<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CategoryService
Retrieves of all theCategories
that match thecontextIds
.- Specified by:
readAllById
in interfaceCategoryService<P extends Category>
- Parameters:
ids
- IDs to match againstcontext
- the current context to look in- Returns:
- All the
Categories
that match thecontextIds
.
-
readByExternalIdIn
public List<P> readByExternalIdIn(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Find a list of categories by the supplied external IDs- Specified by:
readByExternalIdIn
in interfaceCategoryService<P extends Category>
- Parameters:
externalIds
- The external IDs to query forcontextInfo
- the context around sandboxing and multitenant state- Returns:
- A list of categories
-
readByExternalIdIn
public org.springframework.data.domain.Page<P> readByExternalIdIn(Collection<String> externalIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Find categories by their external IDs- Specified by:
readByExternalIdIn
in interfaceCategoryService<P extends Category>
- Parameters:
externalIds
- The external IDs to query forfilters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontextInfo
- the context around sandboxing and multitenant state- Returns:
- A page of categories
-
readByExternalId
public P readByExternalId(String externalId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryService
Find a category by its external ID- Specified by:
readByExternalId
in interfaceCategoryService<P extends Category>
- Parameters:
externalId
- The external IDcontextInfo
- the context around sandboxing and multitenant state
-
getRepositoryDomain
- Specified by:
getRepositoryDomain
in interfaceCategoryService<P extends Category>
-
getRepository
@NonNull protected CategoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository() -
getProductService
-
getCategoryProductService
-
getRsqlEvaluationService
-
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
setCacheByActiveCategoryKeyGen
@Autowired @Qualifier("catalogCacheByActiveCategory") public void setCacheByActiveCategoryKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryKeyGen) - See Also:
-
getCacheByActiveCategoryKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByActiveCategoryKeyGen()- See Also:
-
setCacheByActiveCategoryIdKeyGen
@Autowired @Qualifier("catalogCacheByActiveCategoryId") public void setCacheByActiveCategoryIdKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryIdKeyGen) - See Also:
-
getCacheByActiveCategoryIdKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByActiveCategoryIdKeyGen()- See Also:
-
setCacheByActiveCategoryUrlKeyGen
@Autowired @Qualifier("catalogCacheByActiveCategoryUrl") public void setCacheByActiveCategoryUrlKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryUrlKeyGen) - See Also:
-
getCacheByActiveCategoryUrlKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByActiveCategoryUrlKeyGen()- See Also:
-
setCacheByExternalCategoryId
@Autowired @Qualifier("catalogCacheByCategoryExternalId") public void setCacheByExternalCategoryId(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByExternalCategoryId) - See Also:
-
getCacheByExternalCategoryId
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByExternalCategoryId()- See Also:
-