Class DefaultCategoryAssetService<P extends CategoryAsset>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.catalog.service.asset.DefaultCategoryAssetService<P>
All Implemented Interfaces:
CategoryAssetService<P>, com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>

public class DefaultCategoryAssetService<P extends CategoryAsset> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements CategoryAssetService<P>
Author:
Samarth Dhruva (samarthd)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultCategoryAssetService(CategoryAssetRepository<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
    create(P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    createAll(List<P> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P>
    createAllAllowingPartialSuccess(List<P> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
     
    protected com.broadleafcommerce.common.extension.cache.CacheStateManager
     
     
    protected CategoryAssetRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
     
    readAllPrimaryAssetsByCategoryIdsExcludeAssetIds(Iterable<String> categoryIds, Iterable<String> assetIdsToExclude, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Reads all the primary CategoryAsset for the given category IDs excluding given asset IDs.
    readByCategoryId(@NonNull String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds all of the CategoryAssets for a Category by ID.
    readByCategoryIdAndPrimaryTrue(@NonNull String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds the primary CategoryAsset for the given CategoryAsset.categoryId.
    replace(@NonNull String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    replaceAll(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P>
    replaceAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    org.springframework.data.domain.Page<P>
    searchAllWithCategoryId(@NonNull String categoryId, Boolean isSorted, String searchString, @NonNull cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds all CategoryAssets for the given category ID, optionally filtering by additional search/filter arguments.
    void
    setCacheByCategoryAssetKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByCategoryAssetKeyGen)
     
    void
     
    update(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    updateAll(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> updates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.
    com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P>
    updateAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> updates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to enable automatic un-setting of the existing primary.

    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, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, setSortPositionStrategy, 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

    delete, readAll, readAll, readAll, readAllByContextId, readByContextId, updateSort

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll, readAll
  • Field Details

  • Constructor Details

    • DefaultCategoryAssetService

      public DefaultCategoryAssetService(CategoryAssetRepository<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

    • setPrimaryAssetCollisionResolverService

      @Autowired public void setPrimaryAssetCollisionResolverService(AbstractPrimaryAssetCollisionService<P> primaryAssetCollisionResolverService)
    • create

      public P create(P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      create in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      create in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      businessInstance - The business domain instance. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      the created entity
    • update

      public P update(String id, P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      update in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      update in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      id - The context id for the entity. This is the id by which the business recognizes the item.
      businessInstance - The business domain instance. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      the updated entity
    • replace

      public P replace(@NonNull @NonNull String id, @NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      replace in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      replace in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      id - The context id for the entity. This is the id by which the business recognizes the item.
      businessInstance - The payload type that domain class should be converted to. In general, the payload is what the rest API responds with.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      the entity after replacement
    • createAll

      public List<P> createAll(List<P> businessInstances, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      createAll in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      createAll in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      businessInstances - The list of business domain instances. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      the list of created entities
    • updateAll

      public List<P> updateAll(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> updates, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      updateAll in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      updateAll in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      updates - The list of updates of the business domain instances. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      the list of updated entities
    • replaceAll

      public List<P> replaceAll(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> replacements, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      replaceAll in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      replaceAll in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      replacements - The list of updates of the business domain instances. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      the list of replaced entities
    • createAllAllowingPartialSuccess

      public com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P> createAllAllowingPartialSuccess(List<P> businessInstances, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      createAllAllowingPartialSuccess in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      createAllAllowingPartialSuccess in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      businessInstances - The list of the business domain instances. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      a response containing a list of any entities which failed, and a list of the successfully created, narrowed entity instances in the form of a payload instance
    • updateAllAllowingPartialSuccess

      public com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P> updateAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> updates, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      updateAllAllowingPartialSuccess in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      updateAllAllowingPartialSuccess in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      updates - The list of updates of the business domain instances. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      a response containing a list of any entities which failed, and a list of the successfully updated, narrowed entity instances in the form of a payload instance
    • replaceAllAllowingPartialSuccess

      public com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P> replaceAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> replacements, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to enable automatic un-setting of the existing primary.
      Specified by:
      replaceAllAllowingPartialSuccess in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends CategoryAsset>
      Overrides:
      replaceAllAllowingPartialSuccess in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
      Parameters:
      replacements - The list of updates of the business domain instances. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      a response containing a list of any entities which failed, and a list of the successfully replaced, narrowed entity instances in the form of a payload instance
    • searchAllWithCategoryId

      public org.springframework.data.domain.Page<P> searchAllWithCategoryId(@NonNull @NonNull String categoryId, @Nullable Boolean isSorted, @Nullable String searchString, @NonNull @NonNull 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: CategoryAssetService
      Finds all CategoryAssets for the given category ID, optionally filtering by additional search/filter arguments.

      If searchString is provided, then this method will search for assets whose EntityAsset.url, EntityAsset.title, EntityAsset.altText, or EntityAsset.tags contain it.

      If no searchString is provided, then this method will simply return all assets for the given category.

      This method also supports RSQL filtration via filters.

      Specified by:
      searchAllWithCategoryId in interface CategoryAssetService<P extends CategoryAsset>
      Parameters:
      categoryId - the value which the category ID should match against
      isSorted - (optional) if not-null, will restrict results to only include CategoryAssets where CategoryAsset.sorted has the given value
      searchString - (optional) a string which should be found in EntityAsset.url, EntityAsset.title, EntityAsset.altText, or EntityAsset.tags
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      page - the requested page of results from the database
      contextInfo - the context to query within
      Returns:
      the assets in the database with the given category ID, optionally filtered by the given search/filter arguments (if provided)
    • readByCategoryIdAndPrimaryTrue

      public Optional<P> readByCategoryIdAndPrimaryTrue(@NonNull @NonNull String categoryId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CategoryAssetService
      Finds the primary CategoryAsset for the given CategoryAsset.categoryId.
      Specified by:
      readByCategoryIdAndPrimaryTrue in interface CategoryAssetService<P extends CategoryAsset>
      Parameters:
      categoryId - the value to match against CategoryAsset.categoryId
      contextInfo - context information around sandboxing and multitenant state
      Returns:
      an optional containing the primary asset for a category, empty otherwise
    • readAllPrimaryAssetsByCategoryIdsExcludeAssetIds

      public List<P> readAllPrimaryAssetsByCategoryIdsExcludeAssetIds(Iterable<String> categoryIds, Iterable<String> assetIdsToExclude, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CategoryAssetService
      Reads all the primary CategoryAsset for the given category IDs excluding given asset IDs.
      Specified by:
      readAllPrimaryAssetsByCategoryIdsExcludeAssetIds in interface CategoryAssetService<P extends CategoryAsset>
      Parameters:
      categoryIds - IDs of the categories for which to find primary assets
      assetIdsToExclude - IDs of the assets to exclude
      contextInfo - context information around sandboxing and multitenant state
      Returns:
      the primary CategoryAsset for the given category IDs excluding given asset IDs.
    • readByCategoryId

      public List<P> readByCategoryId(@NonNull @NonNull String categoryId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CategoryAssetService
      Finds all of the CategoryAssets for a Category by ID.
      Specified by:
      readByCategoryId in interface CategoryAssetService<P extends CategoryAsset>
      Parameters:
      categoryId - Id of the category which's assets to read
      contextInfo - context information around sandboxing and multitenant state
      Returns:
      all of the CategoryAssets for a Category by ID.
    • getRepositoryDomain

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

      protected CategoryAssetRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends CategoryAsset>
    • getCacheStateManager

      @Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager()
    • getPrimaryAssetCollisionResolverService

      protected AbstractPrimaryAssetCollisionService<P> getPrimaryAssetCollisionResolverService()
    • setCacheByCategoryAssetKeyGen

      @Autowired @Qualifier("catalogCacheByCategoryAsset") public void setCacheByCategoryAssetKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByCategoryAssetKeyGen)
      See Also:
    • getCacheByCategoryAssetKeyGen

      @Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByCategoryAssetKeyGen()
      See Also: