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
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultVariantService(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 Type
    Method
    Description
    long
    countNonProductionRecordsByProductIdsInTenant(@NonNull Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Returns the count of non-production records that match the given productContextIds 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)
    Returns a List of Variant objects, filtered by a collection of external IDs.
    readAllByIdOrProductId(@NonNull Collection<String> variantIds, @NonNull Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Retrieves all Variants with the given variantIds or whose parent Products are in productIds.
    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 given productIds.
    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 given productIds and skus.
    readAllBySkus(Collection<String> skus, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Returns a List of Variant objects, filtered by a collection of external IDs.
    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

  • 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 interface VariantService<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 interface VariantService<P extends Variant>
      Parameters:
      variantIds - the variant context IDs to search for
      contextInfo - 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 interface VariantService<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 given productIds.
      Specified by:
      readAllByProductIdIn in interface VariantService<P extends Variant>
      Parameters:
      productIds - a collection of product IDs which the results must be associated with
      context - 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 given productIds and skus.
      Specified by:
      readAllByProductIdInAndSkuIn in interface VariantService<P extends Variant>
      Parameters:
      productIds - a collection of product IDs which the results must be associated with
      skus - a collection of skus which the results must be associated with
      context - context information surrounding sandboxing and multitenant state
      Returns:
      all variants which are associated with any of the given productIds and skus
    • 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 interface VariantService<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 interface VariantService<P extends Variant>
      Parameters:
      productId - the product ID which the result must be associated with
      sku - the sku code to match agains
      context - 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
      Retrieves all Variants with the given variantIds or whose parent Products are in productIds.
      Specified by:
      readAllByIdOrProductId in interface VariantService<P extends Variant>
      Parameters:
      variantIds - Variant IDs to match against
      productIds - IDs of parent Products to match against
      context - Request context information around sandbox and multitenant state
      Returns:
      All Variants with the given variantIds or whose parent Products are in productIds.
    • readAllByExternalIds

      public List<P> readAllByExternalIds(Collection<String> externalIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: VariantService
      Returns a List of Variant objects, filtered by a collection of external IDs.
      Specified by:
      readAllByExternalIds in interface VariantService<P extends Variant>
      Parameters:
      externalIds - a list of external IDs
      context - 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
      Returns a List of Variant objects, filtered by a collection of external IDs.
      Specified by:
      readAllBySkus in interface VariantService<P extends Variant>
      Parameters:
      skus - a list of SKUs
      context - 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 given productContextIds and the given tenant context.
      Specified by:
      countNonProductionRecordsByProductIdsInTenant in interface VariantService<P extends Variant>
      Parameters:
      productIds - IDs of parent Products to match against
      context - 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

      public String getRepositoryDomain()
      Specified by:
      getRepositoryDomain in interface VariantService<P extends Variant>
    • getRepository

      @NonNull protected VariantRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Variant>
    • 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: