Class DefaultProductAssetService<P extends ProductAsset>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.catalog.service.asset.DefaultProductAssetService<P>
- All Implemented Interfaces:
ProductAssetService<P>,com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
public class DefaultProductAssetService<P extends ProductAsset>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements ProductAssetService<P>
- Author:
- Samarth Dhruva (samarthd)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static final com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.EmptyNode -
Constructor Summary
ConstructorsConstructorDescriptionDefaultProductAssetService(ProductAssetRepository<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.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.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.CacheStateManagerprotected AbstractPrimaryAssetCollisionService<P>protected ProductAssetRepository<com.broadleafcommerce.data.tracking.core.Trackable>readAllByProductIdIn(Collection<String> productIds, @NonNull cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all of the product assets which are associated with any of the givenproductIds.readAllByProductIdIn(Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all of the product assets which are associated with any of the givenproductIds.readAllLowestSortValueByProductIds(List<String> productContextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theProductAssetwith the lowestSortable.getSorting()value for each of the products provided inproductContextIds, and returns its sort value.readAllPrimaryAssetsByProductIds(Iterable<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the primaryProductAssetsfor the given product IDs.readAllPrimaryAssetsByProductIdsExcludeAssetIds(Iterable<String> productIds, Iterable<String> assetIdsToExclude, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all the primaryProductAssetsfor the given product IDs excluding given asset IDs.readByProductIdAndPrimaryTrue(String productId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the primaryProductAssetfor the givenProductAsset.productId.replace(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>searchAllWithProductId(String productId, Boolean isSorted, String searchString, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds allProductAssetsfor the given product ID, optionally filtering by additional search/filter arguments.voidsetCacheByProductAssetKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByProductAssetKeyGen) voidsetPrimaryAssetCollisionResolverService(AbstractPrimaryAssetCollisionService<P> primaryAssetCollisionResolverService) 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, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, setSortPositionStrategy, 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
delete, readAll, readAll, readAll, readAllByContextId, readByContextId, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Field Details
-
EMPTY_NODE
protected static final com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.EmptyNode EMPTY_NODE -
CACHE_BY_PRODUCT_ASSET
- See Also:
-
-
Constructor Details
-
DefaultProductAssetService
public DefaultProductAssetService(ProductAssetRepository<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:
createin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
createin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
businessInstance- The business domain instance. In general, theDomainMapperManageris 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:
updatein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
updatein classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- 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, theDomainMapperManageris 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(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:
replacein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
replacein classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- 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:
createAllin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
createAllin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
businessInstances- The list of business domain instances. In general, theDomainMapperManageris 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:
updateAllin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
updateAllin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
updates- The list of updates of the business domain instances. In general, theDomainMapperManageris 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:
replaceAllin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
replaceAllin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
replacements- The list of updates of the business domain instances. In general, theDomainMapperManageris 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:
createAllAllowingPartialSuccessin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
createAllAllowingPartialSuccessin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
businessInstances- The list of the business domain instances. In general, theDomainMapperManageris 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:
updateAllAllowingPartialSuccessin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
updateAllAllowingPartialSuccessin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
updates- The list of updates of the business domain instances. In general, theDomainMapperManageris 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:
replaceAllAllowingPartialSuccessin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ProductAsset>- Overrides:
replaceAllAllowingPartialSuccessin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>- Parameters:
replacements- The list of updates of the business domain instances. In general, theDomainMapperManageris 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
-
searchAllWithProductId
public org.springframework.data.domain.Page<P> searchAllWithProductId(String productId, @Nullable Boolean isSorted, @Nullable String searchString, @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:ProductAssetServiceFinds allProductAssetsfor the given product ID, optionally filtering by additional search/filter arguments.If
searchStringis provided, then this method will search for assets whoseEntityAsset.url,EntityAsset.title,EntityAsset.altText, orEntityAsset.tagscontain it.If no
searchStringis provided, then this method will simply return all assets for the given product.This method also supports RSQL filtration via
filters.- Specified by:
searchAllWithProductIdin interfaceProductAssetService<P extends ProductAsset>- Parameters:
productId- the value which the product ID should match againstisSorted- (optional) if not-null, will restrict results to only includeProductAssetswhereProductAsset.sortedhas the given valuesearchString- (optional) a string which should be found inEntityAsset.url,EntityAsset.title,EntityAsset.altText, orEntityAsset.tagsfilters- additional filters to apply in the query. Should beEmptyNodeif no additional filters should be applied.page- the requested page of results from the databasecontextInfo- the context to query within- Returns:
- the assets in the database with the given product ID, optionally filtered by the given search/filter arguments (if provided)
-
readAllByProductIdIn
public List<P> readAllByProductIdIn(Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductAssetServiceReads all of the product assets which are associated with any of the givenproductIds.- Specified by:
readAllByProductIdInin interfaceProductAssetService<P extends ProductAsset>- 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 product assets which are associated with any of the given
productIds
-
readAllByProductIdIn
public List<P> readAllByProductIdIn(Collection<String> productIds, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductAssetServiceReads all of the product assets which are associated with any of the givenproductIds.- Specified by:
readAllByProductIdInin interfaceProductAssetService<P extends ProductAsset>- Parameters:
productIds- a collection of product IDs which the results must be associated withfilters- additional filters to apply in the query. Should beEmptyNodeif no additional filters should be applied.context- context information surrounding sandboxing and multitenant state- Returns:
- all of the product assets which are associated with any of the given
productIds
-
readByProductIdAndPrimaryTrue
public Optional<P> readByProductIdAndPrimaryTrue(String productId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductAssetServiceFinds the primaryProductAssetfor the givenProductAsset.productId.- Specified by:
readByProductIdAndPrimaryTruein interfaceProductAssetService<P extends ProductAsset>- Parameters:
productId- the value to match againstProductAsset.productIdcontextInfo- context information around sandboxing and multitenant state- Returns:
- an optional containing the primary asset for a product, empty otherwise
-
readAllPrimaryAssetsByProductIds
public List<P> readAllPrimaryAssetsByProductIds(Iterable<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductAssetServiceReads all of the primaryProductAssetsfor the given product IDs.- Specified by:
readAllPrimaryAssetsByProductIdsin interfaceProductAssetService<P extends ProductAsset>- Parameters:
productIds- IDs of the products for which to read primary assetscontextInfo- context information around sandboxing and multitenant state- Returns:
- all of the primary
ProductAssetsfor the given product IDs.
-
readAllPrimaryAssetsByProductIdsExcludeAssetIds
public List<P> readAllPrimaryAssetsByProductIdsExcludeAssetIds(Iterable<String> productIds, Iterable<String> assetIdsToExclude, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductAssetServiceReads all the primaryProductAssetsfor the given product IDs excluding given asset IDs.- Specified by:
readAllPrimaryAssetsByProductIdsExcludeAssetIdsin interfaceProductAssetService<P extends ProductAsset>- Parameters:
productIds- IDs of the products for which to find primary assetsassetIdsToExclude- IDs of the assets to excludecontextInfo- context information around sandboxing and multitenant state- Returns:
- the primary
ProductAssetsfor the given product IDs excluding given asset IDs.
-
countNonProductionRecordsByProductIdsInTenant
public long countNonProductionRecordsByProductIdsInTenant(@NonNull @NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductAssetServiceReturns the count of non-production records that match the givenproductContextIdsand the given tenant context.- Specified by:
countNonProductionRecordsByProductIdsInTenantin interfaceProductAssetService<P extends ProductAsset>- 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
-
readAllLowestSortValueByProductIds
public Map<String,String> readAllLowestSortValueByProductIds(List<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductAssetServiceFinds theProductAssetwith the lowestSortable.getSorting()value for each of the products provided inproductContextIds, and returns its sort value.- Specified by:
readAllLowestSortValueByProductIdsin interfaceProductAssetService<P extends ProductAsset>- Parameters:
productContextIds- IDs of parent Products to match againstcontextInfo- Request context information around sandbox and multitenant state- Returns:
- pairings of product IDs to the lowest sort value found for the specified ID
-
getRepositoryDomain
- Specified by:
getRepositoryDomainin interfaceProductAssetService<P extends ProductAsset>
-
getRepository
protected ProductAssetRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()- Overrides:
getRepositoryin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ProductAsset>
-
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
getPrimaryAssetCollisionResolverService
-
setCacheByProductAssetKeyGen
@Autowired @Qualifier("catalogCacheByProductAsset") public void setCacheByProductAssetKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByProductAssetKeyGen) - See Also:
-
getCacheByProductAssetKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByProductAssetKeyGen()- See Also:
-