Class DefaultPriceDataService<P extends PriceData>
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
-
- com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
-
- com.broadleafcommerce.pricing.service.DefaultPriceDataService<P>
-
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>,PriceDataService<P>
public class DefaultPriceDataService<P extends PriceData> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements PriceDataService<P>
- Author:
- Chad Harchar (charchar)
-
-
Field Summary
Fields Modifier and Type Field Description static StringCACHE_BY_TARGETS_AND_PRICE_LIST
-
Constructor Summary
Constructors Constructor Description DefaultPriceDataService(PriceDataRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable> priceListRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory pricingFactory, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected List<P>convertFromDomain(List<com.broadleafcommerce.data.tracking.core.Trackable> trackables, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected org.springframework.data.domain.Page<P>convertFromDomain(org.springframework.data.domain.Page<com.broadleafcommerce.data.tracking.core.Trackable> trackables, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef>convertTargetsToRefs(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets)com.broadleafcommerce.pricing.client.domain.PriceableTargetRefconvertTargetToRef(com.broadleafcommerce.pricing.client.domain.PriceableTarget target)Pcreate(PriceList priceList, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Pcreate(P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)voiddelete(PriceList priceList, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Optional<P>findByPriceableTargetRefAndPriceListId(com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, String priceListId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Finds thePriceDatathat has the givenPriceData.targetandorg.springframework.data.domain.Page<P>findByPriceList(String priceListId, 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>findByPriceList(String priceListId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Deprecated, for removal: This API element is subject to removal in a future version.org.springframework.data.domain.Page<P>findByPriceListAndTarget(String priceListId, String targetType, Collection<String> targetIds, 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>findByPriceListAndTarget(String priceListId, String targetType, Collection<String> targetIds, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Deprecated, for removal: This API element is subject to removal in a future version.List<P>findByTargetInAndPriceListIn(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets, Collection<String> priceListIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)List<P>findByTargetRefInAndPriceListIn(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, Collection<String> priceListIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected PfixCurrency(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, P priceData)protected PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable>getPriceListRepository()protected com.broadleafcommerce.common.extension.TypeFactorygetPricingFactory()protected PriceDataRepository<com.broadleafcommerce.data.tracking.core.Trackable>getRepository()protected voidinitializeCurrency(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, String priceListId)Stream<P>readAllByPriceListId(String priceListId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)PreadByContextId(PriceList priceList, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)PreadByContextId(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Preplace(PriceList priceList, String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Preplace(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected voidsetupPlaceholderCurrency(com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Useful when reading priceData as we don't yet know the correct currency which is needed by the model mapper when reading by id.protected org.springframework.data.domain.PageabletransformSort(org.springframework.data.domain.Pageable pageable)Pupdate(PriceList priceList, String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Pupdate(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)-
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, createAll, createAllAllowingPartialSuccess, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, updateAll, updateAllAllowingPartialSuccess, updateSort
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
CACHE_BY_TARGETS_AND_PRICE_LIST
public static final String CACHE_BY_TARGETS_AND_PRICE_LIST
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultPriceDataService
public DefaultPriceDataService(PriceDataRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable> priceListRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory pricingFactory, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager)
-
-
Method Detail
-
findByPriceList
@NonNull @Deprecated(since="1.7.2", forRemoval=true) public org.springframework.data.domain.Page<P> findByPriceList(@NonNull String priceListId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
findByPriceListin interfacePriceDataService<P extends PriceData>
-
findByPriceList
@NonNull public org.springframework.data.domain.Page<P> findByPriceList(@NonNull String priceListId, @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:
findByPriceListin interfacePriceDataService<P extends PriceData>
-
transformSort
protected org.springframework.data.domain.Pageable transformSort(org.springframework.data.domain.Pageable pageable)
-
findByPriceListAndTarget
@NonNull @Deprecated(since="1.7.2", forRemoval=true) public org.springframework.data.domain.Page<P> findByPriceListAndTarget(@Nullable String priceListId, @Nullable String targetType, @Nullable Collection<String> targetIds, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
findByPriceListAndTargetin interfacePriceDataService<P extends PriceData>
-
findByPriceListAndTarget
@NonNull public org.springframework.data.domain.Page<P> findByPriceListAndTarget(@Nullable String priceListId, @Nullable String targetType, @Nullable Collection<String> targetIds, @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:
findByPriceListAndTargetin interfacePriceDataService<P extends PriceData>
-
readAllByPriceListId
public Stream<P> readAllByPriceListId(String priceListId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
readAllByPriceListIdin interfacePriceDataService<P extends PriceData>
-
findByPriceableTargetRefAndPriceListId
@NonNull public Optional<P> findByPriceableTargetRefAndPriceListId(com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, String priceListId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:PriceDataServiceFinds thePriceDatathat has the givenPriceData.targetand- Specified by:
findByPriceableTargetRefAndPriceListIdin interfacePriceDataService<P extends PriceData>- Returns:
-
findByTargetRefInAndPriceListIn
@NonNull public List<P> findByTargetRefInAndPriceListIn(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, Collection<String> priceListIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
findByTargetRefInAndPriceListInin interfacePriceDataService<P extends PriceData>
-
findByTargetInAndPriceListIn
@NonNull public List<P> findByTargetInAndPriceListIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets, @NonNull Collection<String> priceListIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
findByTargetInAndPriceListInin interfacePriceDataService<P extends PriceData>
-
convertTargetsToRefs
protected Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> convertTargetsToRefs(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets)
-
readByContextId
@NonNull public P readByContextId(@NonNull PriceList priceList, @NonNull String id, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
readByContextIdin interfacePriceDataService<P extends PriceData>
-
update
@NonNull public P update(@NonNull PriceList priceList, @NonNull String id, @NonNull P businessInstance, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
updatein interfacePriceDataService<P extends PriceData>
-
delete
public void delete(@NonNull PriceList priceList, @NonNull String id, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)- Specified by:
deletein interfacePriceDataService<P extends PriceData>
-
replace
@NonNull public P replace(@NonNull PriceList priceList, @NonNull String id, @NonNull P businessInstance, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
replacein interfacePriceDataService<P extends PriceData>
-
create
@NonNull public P create(@NonNull PriceList priceList, @NonNull P businessInstance, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
createin interfacePriceDataService<P extends PriceData>
-
convertTargetToRef
@Nullable public com.broadleafcommerce.pricing.client.domain.PriceableTargetRef convertTargetToRef(@Nullable com.broadleafcommerce.pricing.client.domain.PriceableTarget target)- Specified by:
convertTargetToRefin interfacePriceDataService<P extends PriceData>
-
convertFromDomain
protected List<P> convertFromDomain(List<com.broadleafcommerce.data.tracking.core.Trackable> trackables, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
convertFromDomain
protected org.springframework.data.domain.Page<P> convertFromDomain(org.springframework.data.domain.Page<com.broadleafcommerce.data.tracking.core.Trackable> trackables, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
readByContextId
public P readByContextId(@NonNull String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
update
public P update(@NonNull String id, @NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
replace
public P replace(@NonNull String id, @NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
create
public P create(@NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
setupPlaceholderCurrency
protected void setupPlaceholderCurrency(com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Useful when reading priceData as we don't yet know the correct currency which is needed by the model mapper when reading by id. The "fixCurrency" method will be called to adjust the PriceData before returning to the caller. Sets the Context to the default currency.
-
fixCurrency
protected P fixCurrency(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, P priceData)
-
initializeCurrency
protected void initializeCurrency(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, String priceListId)
-
getRepository
@NonNull protected PriceDataRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
-
getPriceListRepository
@NonNull protected PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable> getPriceListRepository()
-
getPricingFactory
@NonNull protected com.broadleafcommerce.common.extension.TypeFactory getPricingFactory()
-
-