Class DefaultVariantService<P extends Variant>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.catalog.service.product.DefaultVariantService<P>
- All Implemented Interfaces:
VariantService<P>,com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
public class DefaultVariantService<P extends Variant>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements VariantService<P>
- Author:
- Phillip Verheyden (phillipuniverse)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultVariantService(VariantRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) -
Method Summary
Modifier and TypeMethodDescriptionlongcountNonProductionRecordsByProductIdsInTenant(@NonNull Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the givenproductContextIdsand the given tenant context.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.CacheStateManagerprotected VariantRepository<com.broadleafcommerce.data.tracking.core.Trackable>readAllByContextIds(Collection<String> variantIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return all of the variants with IDs in the supplied collection.readAllByExternalIds(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) readAllByIdOrProductId(@NonNull Collection<String> variantIds, @NonNull Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) org.springframework.data.domain.Page<P>readAllByProductId(String productId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) org.springframework.data.domain.Page<P>readAllByProductIdAndSkuQuery(String productId, String query, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, Class<P> returnType) readAllByProductIdIn(Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all of the variants which are associated with any of the givenproductIds.readAllByProductIdInAndSkuIn(Collection<String> productIds, Collection<String> skus, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all variants which are associated with any of the givenproductIdsandskus.readAllBySkus(Collection<String> skus, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) readByContextIdOpt(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Read a single instance of an entity in the form of a business domain.readByProductIdAndSku(String productId, String sku, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads a specific variant for a given product by its sku code.voidsetCacheByVariantKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByVariantKeyGen) 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, readAllMethods inherited from interface com.broadleafcommerce.catalog.service.product.VariantService
readAllByProductId
-
Field Details
-
CACHE_BY_VARIANT
- See Also:
-
-
Constructor Details
-
DefaultVariantService
public DefaultVariantService(VariantRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, @Nullable com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager)
-
-
Method Details
-
readByContextIdOpt
public Optional<P> readByContextIdOpt(@NonNull String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantServiceRead a single instance of an entity in the form of a business domain.- Specified by:
readByContextIdOptin interfaceVariantService<P extends Variant>- Parameters:
id- The context id for the entity. This is the id by which the business recognizes the item.context- Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.- Returns:
- an
Optionalcontaining the narrowed entity instance in the form of a business instance if found,Optional.empty()otherwise
-
readAllByContextIds
public Stream<P> readAllByContextIds(@NonNull Collection<String> variantIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:VariantServiceReturn all of the variants with IDs in the supplied collection.- Specified by:
readAllByContextIdsin interfaceVariantService<P extends Variant>- Parameters:
variantIds- the variant context IDs to search forcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the variants that matched with the IDs in the given collection
-
readAllByProductId
public org.springframework.data.domain.Page<P> readAllByProductId(@Nullable String productId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
readAllByProductIdin interfaceVariantService<P extends Variant>
-
readAllByProductIdIn
public Stream<P> readAllByProductIdIn(Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantServiceReads all of the variants which are associated with any of the givenproductIds.- Specified by:
readAllByProductIdInin interfaceVariantService<P extends Variant>- 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 variants which are associated with any of the given
productIds
-
readAllByProductIdInAndSkuIn
public List<P> readAllByProductIdInAndSkuIn(Collection<String> productIds, Collection<String> skus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantServiceReads all variants which are associated with any of the givenproductIdsandskus.- Specified by:
readAllByProductIdInAndSkuInin interfaceVariantService<P extends Variant>- Parameters:
productIds- a collection of product IDs which the results must be associated withskus- a collection of skus which the results must be associated withcontext- context information surrounding sandboxing and multitenant state- Returns:
- all variants which are associated with any of the given
productIdsandskus
-
readAllByProductIdAndSkuQuery
public org.springframework.data.domain.Page<P> readAllByProductIdAndSkuQuery(@Nullable String productId, @NonNull String query, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @NonNull Class<P> returnType) - Specified by:
readAllByProductIdAndSkuQueryin interfaceVariantService<P extends Variant>
-
readByProductIdAndSku
public Optional<P> readByProductIdAndSku(@Nullable String productId, @NonNull String sku, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantServiceReads a specific variant for a given product by its sku code.- Specified by:
readByProductIdAndSkuin interfaceVariantService<P extends Variant>- Parameters:
productId- the product ID which the result must be associated withsku- the sku code to match againscontext- context information surrounding sandboxing and multitenant state- Returns:
- the variant with the associated product and sku code
-
readAllByIdOrProductId
public List<P> readAllByIdOrProductId(@NonNull @NonNull @NonNull Collection<String> variantIds, @NonNull @NonNull @NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantService- Specified by:
readAllByIdOrProductIdin interfaceVariantService<P extends Variant>- Parameters:
variantIds- Variant IDs to match againstproductIds- IDs of parent Products to match againstcontext- Request context information around sandbox and multitenant state- Returns:
- All
Variantswith the givenvariantIdsor whose parentProductsare inproductIds.
-
readAllByExternalIds
public List<P> readAllByExternalIds(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantService- Specified by:
readAllByExternalIdsin interfaceVariantService<P extends Variant>- Parameters:
externalIds- a list of external IDscontext- context information around sandbox and multitenant state- Returns:
- a List of variants with the corresponding external IDs provided
-
readAllBySkus
public List<P> readAllBySkus(Collection<String> skus, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantService- Specified by:
readAllBySkusin interfaceVariantService<P extends Variant>- Parameters:
skus- a list of SKUscontext- context information around sandbox and multitenant state- Returns:
- a List of variants with the corresponding SKUs provided
-
countNonProductionRecordsByProductIdsInTenant
public long countNonProductionRecordsByProductIdsInTenant(@NonNull @NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantServiceReturns the count of non-production records that match the givenproductContextIdsand the given tenant context.- Specified by:
countNonProductionRecordsByProductIdsInTenantin interfaceVariantService<P extends Variant>- 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
productContextIdsand the given tenant context
-
getRepositoryDomain
- Specified by:
getRepositoryDomainin interfaceVariantService<P extends Variant>
-
getRepository
@NonNull protected VariantRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository() -
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
setCacheByVariantKeyGen
@Autowired @Qualifier("catalogCacheByVariant") public void setCacheByVariantKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByVariantKeyGen) - See Also:
-
getCacheByVariantKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByVariantKeyGen()- See Also:
-