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
-
Constructor Summary
ConstructorDescriptionDefaultVariantService
(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 TypeMethodDescriptionlong
countNonProductionRecordsByProductIdsInTenant
(@NonNull 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.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
protected 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, Class<P> returnType, 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 givenproductIds
andskus
.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.void
setCacheByVariantKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByVariantKeyGen) 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_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:VariantService
Read a single instance of an entity in the form of a business domain.- Specified by:
readByContextIdOpt
in 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
Optional
containing 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:VariantService
Return all of the variants with IDs in the supplied collection.- Specified by:
readAllByContextIds
in 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, @NonNull Class<P> returnType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
readAllByProductId
in 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:VariantService
Reads all of the variants which are associated with any of the givenproductIds
.- Specified by:
readAllByProductIdIn
in 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:VariantService
Reads all variants which are associated with any of the givenproductIds
andskus
.- Specified by:
readAllByProductIdInAndSkuIn
in 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
productIds
andskus
-
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:
readAllByProductIdAndSkuQuery
in 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:VariantService
Reads a specific variant for a given product by its sku code.- Specified by:
readByProductIdAndSku
in 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:
readAllByIdOrProductId
in 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
Variants
with the givenvariantIds
or whose parentProducts
are inproductIds
.
-
readAllByExternalIds
public List<P> readAllByExternalIds(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:VariantService
- Specified by:
readAllByExternalIds
in 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:
readAllBySkus
in 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:VariantService
Returns the count of non-production records that match the givenproductContextIds
and the given tenant context.- Specified by:
countNonProductionRecordsByProductIdsInTenant
in 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
productContextIds
and the given tenant context
-
getRepositoryDomain
- Specified by:
getRepositoryDomain
in 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:
-