Interface CategoryProductService<P extends CategoryProduct>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
- All Known Implementing Classes:
DefaultCategoryProductService
public interface CategoryProductService<P extends CategoryProduct>
extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
Service API for
CategoryProducts
. Supported by
CategoryProductRepository
.- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionlong
countNonProductionRecordsByProductIdsInTenant
(Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the givenproductContextIds
and the given tenant context.boolean
existsByJoinedIds
(String productId, String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether there is a category-product relationship for the given product and category in the data store.org.springframework.data.domain.Page<P>
readAllByCategoryIdAndIsSorted
(String categoryId, boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.data.domain.Page<P>
readAllByCategoryIdAndProductIdsAndIsSorted
(String categoryId, List<String> productIds, boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds allCategoryProducts
for the givenCategory.id
,Product.id
, andCategoryProduct.sorted
values.readAllByCategoryIdIn
(Collection<String> categoryIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads a list ofCategoryProducts
by ID.readAllByProductIdIn
(Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all of the category products which are associated with any of the givenproductIds
.org.springframework.data.domain.Page<P>
readByCategoryContextId
(String categoryContextId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the CategoryProduct relationships in the database associated with the given category context ID.org.springframework.data.domain.Page<P>
readByCategoryContextIdAndProductIds
(String categoryContextId, List<String> productIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all CategoryProduct relationships in the database associated with the given category context ID and Product IDs.org.springframework.data.domain.Page<P>
readByCategoryIdIn
(Collection<String> categoryIds, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads a page ofCategoryProducts
by ID.readByIdAndCategoryId
(String id, String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theCategoryProduct
which has the given ID and parent category ID.readByJoinedIds
(String productId, String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query for a CategoryProduct that joins a given product and category.org.springframework.data.domain.Page<P>
readByProductContextId
(String productContextId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the CategoryProduct relationships in the database associated with the given product context ID.org.springframework.data.domain.Page<P>
readPageForCategory
(Category category, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, Boolean isSorted, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a page ofCategoryProducts
for the givenCategory
and additional inputs.readPrimaryByProductIdIn
(Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads allCategoryProducts
whose product ID is in one of the given values and whoseCategoryProduct.primary
is true.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
-
Method Details
-
existsByJoinedIds
boolean existsByJoinedIds(String productId, String categoryId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether there is a category-product relationship for the given product and category in the data store.- Parameters:
productId
- the product context IDcategoryId
- the category context IDcontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- true if a relationship was found between the product and category, false otherwise
-
readByCategoryContextId
@NonNull org.springframework.data.domain.Page<P> readByCategoryContextId(@NonNull String categoryContextId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the CategoryProduct relationships in the database associated with the given category context ID.- Parameters:
categoryContextId
- the category context ID to find the relationships 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 to query within- Returns:
- the CategoryProduct relationships in the database that match the given category context ID
-
readByCategoryContextIdAndProductIds
@NonNull org.springframework.data.domain.Page<P> readByCategoryContextIdAndProductIds(@NonNull String categoryContextId, List<String> productIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all CategoryProduct relationships in the database associated with the given category context ID and Product IDs.- Parameters:
categoryContextId
- the category context ID to find the relationships forproductIds
- the list ofProduct.id
s to retrievefilters
- 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 to query within- Returns:
- the CategoryProduct relationships in the database that match the given category context ID
-
readByProductContextId
@NonNull org.springframework.data.domain.Page<P> readByProductContextId(@NonNull String productContextId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the CategoryProduct relationships in the database associated with the given product context ID.- Parameters:
productContextId
- the product context ID to find the relationships 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 to query within- Returns:
- the CategoryProduct relationships in the database that match the given category context ID
-
readAllByProductIdIn
List<P> readAllByProductIdIn(Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all of the category products which are associated with any of the givenproductIds
.- Parameters:
productIds
- a collection of product IDs which the results must be associated withcontext
- context information surrounding sandboxing and multitenant state- Returns:
- all of the category products which are associated with any of the given
productIds
-
readAllByCategoryIdAndIsSorted
@NonNull org.springframework.data.domain.Page<P> readAllByCategoryIdAndIsSorted(@NonNull String categoryId, boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Parameters:
categoryId
- parentCategory.id
isSorted
- Whether to returnCategoryProducts
whereCategoryProduct.sorted
is true, else false.filters
- 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 to query within- Returns:
- the
CategoryProducts
with the givencategoryId
and sorting values
-
readAllByCategoryIdAndProductIdsAndIsSorted
@NonNull org.springframework.data.domain.Page<P> readAllByCategoryIdAndProductIdsAndIsSorted(@NonNull String categoryId, List<String> productIds, boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds allCategoryProducts
for the givenCategory.id
,Product.id
, andCategoryProduct.sorted
values.- Parameters:
categoryId
- parentCategory.id
productIds
- the list ofProduct.id
s to retrieveisSorted
- Whether to returnCategoryProducts
whereCategoryProduct.sorted
is true, else false.filters
- 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 to query within- Returns:
- the
CategoryProducts
with the givencategoryId
and sorting values
-
readByJoinedIds
@NonNull Optional<P> readByJoinedIds(@NonNull String productId, @NonNull String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query for a CategoryProduct that joins a given product and category.- Parameters:
productId
- the product context IDcategoryId
- the category context IDcontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- an
Optional
that is either empty or contains the CategoryProduct that was found
-
readByIdAndCategoryId
@NonNull P readByIdAndCategoryId(@NonNull String id, @NonNull String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theCategoryProduct
which has the given ID and parent category ID.- Parameters:
id
- the context ID of theCategoryProduct
categoryId
- the context ID of the parentCategory
contextInfo
- context surrounding sandboxing and multitenant state- Returns:
- the category product that has the given ID and parent category ID
- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if no suchCategoryProduct
was found
-
readByCategoryIdIn
@NonNull org.springframework.data.domain.Page<P> readByCategoryIdIn(@NonNull Collection<String> categoryIds, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads a page ofCategoryProducts
by ID.- Parameters:
categoryIds
-Category
IDs to match againstpage
- Pagination infocontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- A page of
CategoryProducts
by ID.
-
readAllByCategoryIdIn
@NonNull List<P> readAllByCategoryIdIn(Collection<String> categoryIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads a list ofCategoryProducts
by ID.- Parameters:
categoryIds
-Category
IDs to match againstcontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- A list of
CategoryProducts
by ID.
-
readPrimaryByProductIdIn
@NonNull Map<String,P> readPrimaryByProductIdIn(@NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads allCategoryProducts
whose product ID is in one of the given values and whoseCategoryProduct.primary
is true.This essentially finds the relationships between the given products and their primary categories.
For any given product ID, there should only be one primary category, but in the event more than one result is found, only the first will be used.
- Parameters:
productIds
- the ids of the products for which to find primary category-product relationshipscontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- a map from product ID to the category-product found for it. If no category-product was found for a product id, it will not have an entry in the resulting map.
-
readPageForCategory
org.springframework.data.domain.Page<P> readPageForCategory(@NonNull Category category, @Nullable org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable Boolean isSorted, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a page ofCategoryProducts
for the givenCategory
and additional inputs.- Parameters:
category
- The parent categorypage
- Pagination infofilters
- RSQL filtersisSorted
- Whether to read onlyCategoryProducts
that have a sort value.contextInfo
- Additional multitenant and sandbox info- Returns:
- Page of
CategoryProducts
for the givenCategory
.
-
countNonProductionRecordsByProductIdsInTenant
long countNonProductionRecordsByProductIdsInTenant(@NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the givenproductContextIds
and the given tenant context.- Parameters:
productIds
- IDs of parent Products to match againstcontext
- Request context information around sandbox and multitenant state- Returns:
- the count of non-production records that match the given
productContextIds
and the given tenant context
-