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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCategoryService(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 TypeMethodDescriptionbooleancheckRelatedProductMembershipInCategory(String categoryId, String productId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks whether a product is a member of the given category.booleanexistsById(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.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.key.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.key.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.key.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.CacheStateManagerprotected CategoryProductService<CategoryProduct>protected ProductService<Product>protected CategoryRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected RSQLEvaluationServicecz.jirutka.rsql.parser.ast.NodemergeInFilter(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 theCategoriesthat 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.voidsetCacheByActiveCategoryIdKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryIdKeyGen) voidsetCacheByActiveCategoryKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryKeyGen) voidsetCacheByActiveCategoryUrlKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByActiveCategoryUrlKeyGen) voidsetCacheByExternalCategoryId(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, readAllMethods 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, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, updateSortMethods 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:CategoryServiceReturns whether there is a category with the given context ID in the data store.- Specified by:
existsByIdin 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:CategoryServiceReturn all of the categories with IDs in the supplied list.- Specified by:
readAllByContextIdsin 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:CategoryServiceReturn all of the categories with IDs in the supplied collection.- Specified by:
readAllByContextIdsin 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:CategoryServiceRead all categories, filtered by name. IfrootsOnlyis true, then results are also filtered to only include categories that have no specifiedparent category.- Specified by:
readAllByNamein interfaceCategoryService<P extends Category>- Parameters:
rootsOnly- if true, restricts results to only include categories that have not specified aparent categoryname- the category name to filter byfilters- additional filters to apply in the query. Should beEmptyNodeif 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:CategoryServiceRead all categories, filtered by name. IfrootsOnlyis true, then results are also filtered to only include categories that have no specifiedparent category.- Specified by:
readAllByNamesInin 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:CategoryServiceRead all categories in the database that have the given category context ID set as their parent category.- Specified by:
readAllByParentCategoryIdin interfaceCategoryService<P extends Category>- Parameters:
parentCategoryId- the category context ID whose children should be foundfilters- additional filters to apply in the query. Should beEmptyNodeif 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:
readAllByParentCategoryIdInin interfaceCategoryService<P extends Category>
-
streamByParentCategoryId
public Stream<P> streamByParentCategoryId(String parentCategoryId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryServiceRead all categories in the database that have the given category context ID set as their parent category.- Specified by:
streamByParentCategoryIdin 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:CategoryServiceChecks whether a product is a member of the given category. If the category isCategoryProductMembershipType.EXPLICIT, will check if there is aCategoryProductbetween the supplied category and product. If the category isCategoryProductMembershipType.RULE_BASED, will evaluate thecategory's rule stringagainst the product to see if the product satisfies the rule string.- Specified by:
checkRelatedProductMembershipInCategoryin 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:CategoryServiceFinds a category by the given url.- Specified by:
readByUrlin 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:CategoryServiceFinds a categories by the given urls.- Specified by:
readAllByUrlsin 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:CategoryServiceRetrieves of all theCategoriesthat match thecontextIds.- Specified by:
readAllByIdin interfaceCategoryService<P extends Category>- Parameters:
ids- IDs to match againstcontext- the current context to look in- Returns:
- All the
Categoriesthat match thecontextIds.
-
readByExternalIdIn
public List<P> readByExternalIdIn(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryServiceFind a list of categories by the supplied external IDs- Specified by:
readByExternalIdInin 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:CategoryServiceFind categories by their external IDs- Specified by:
readByExternalIdInin interfaceCategoryService<P extends Category>- Parameters:
externalIds- The external IDs to query forfilters- additional filters to apply in the query. Should beEmptyNodeif 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:CategoryServiceFind a category by its external ID- Specified by:
readByExternalIdin interfaceCategoryService<P extends Category>- Parameters:
externalId- The external IDcontextInfo- the context around sandboxing and multitenant state
-
getRepositoryDomain
- Specified by:
getRepositoryDomainin 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:
-