Interface PriceDataService<P extends PriceData>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
- All Known Implementing Classes:
DefaultPriceDataService
public interface PriceDataService<P extends PriceData>
extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
Base service API for
PriceData
. Backed by a
PriceDataRepository
.- Author:
- Chad Harchar (charchar)
-
Method Summary
Modifier and TypeMethodDescriptioncom.broadleafcommerce.pricing.client.domain.PriceableTargetRef
convertTargetToRef
(com.broadleafcommerce.pricing.client.domain.PriceableTarget target) create
(PriceList priceList, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) int
decrementAvailableQuantity
(String priceDataId, String priceListId, Instant usageDate, int quantityToDecrement, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Decrements thePriceData.getAvailableQuantity()
.void
delete
(PriceList priceList, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) findByPriceableTargetRefAndPriceListId
(com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, String priceListId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds thePriceData
that has the givenPriceData.target
andorg.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.findByTargetInAndPriceListIn
(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets, Collection<String> priceListIds, boolean filterByVendor, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Uses the cache first to find a list of price data by the givenPriceableTargetRefs
and price list ids, if not found from cache, delegates tofindByTargetRefInAndPriceListIn(Collection, Collection, boolean, ContextInfo)
findByTargetInAndPriceListIn
(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets, Collection<String> priceListIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) findByTargetRefInAndPriceListIn
(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, Collection<String> priceListIds, boolean filterByVendor, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Uses the repository to find a list of price data by the givenPriceableTargetRefs
and price list ids.findByTargetRefInAndPriceListIn
(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, Collection<String> priceListIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) int
incrementAvailableQuantity
(String priceDataId, int quantityToIncrement, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Increments thePriceData.getAvailableQuantity()
, typically used as part of the rollback.readAllByPriceListId
(String priceListId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) readByContextId
(PriceList priceList, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) replace
(PriceList priceList, String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) update
(PriceList priceList, String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) 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
-
Method Details
-
findByPriceList
@NonNull @Deprecated(since="1.7.2", forRemoval=true) 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. -
findByPriceList
-
findByPriceListAndTarget
@NonNull @Deprecated(since="1.7.2", forRemoval=true) 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. -
findByPriceListAndTarget
@NonNull 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) -
readAllByPriceListId
-
findByPriceableTargetRefAndPriceListId
@NonNull Optional<P> findByPriceableTargetRefAndPriceListId(@NonNull com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, @NonNull String priceListId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds thePriceData
that has the givenPriceData.target
and- Parameters:
target
-priceListId
-context
-- Returns:
-
findByTargetRefInAndPriceListIn
default List<P> findByTargetRefInAndPriceListIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, @NonNull Collection<String> priceListIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
findByTargetRefInAndPriceListIn
List<P> findByTargetRefInAndPriceListIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, @NonNull Collection<String> priceListIds, boolean filterByVendor, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Uses the repository to find a list of price data by the givenPriceableTargetRefs
and price list ids.- Parameters:
targets
- a list ofPriceableTargetRefs
to matchpriceListIds
- a list of price list ids to look forfilterByVendor
- whether to also filter the price data based on the {@link {@link PriceableTargetRef#getVendorRef()}. When this isfalse
, vendor-discriminated targets will also get non-vendor price data.contextInfo
- the current context- Returns:
- a list of price data by the given
PriceableTargetRefs
and price list ids from the repository
-
findByTargetInAndPriceListIn
@NonNull default 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) -
findByTargetInAndPriceListIn
@NonNull List<P> findByTargetInAndPriceListIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets, @NonNull Collection<String> priceListIds, boolean filterByVendor, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Uses the cache first to find a list of price data by the givenPriceableTargetRefs
and price list ids, if not found from cache, delegates tofindByTargetRefInAndPriceListIn(Collection, Collection, boolean, ContextInfo)
- Parameters:
targets
- a list ofPriceableTargetRefs
to matchpriceListIds
- a list of price list ids to look forfilterByVendor
- whether to also filter the price data based on the {@link {@link PriceableTargetRef#getVendorRef()}. When this isfalse
, vendor-discriminated targets will also get non-vendor price data.contextInfo
- the current context- Returns:
- a list of price data by the given
PriceableTargetRefs
and price list ids from cache if found in cache, otherwise from the repository
-
readByContextId
-
update
-
delete
-
replace
-
create
-
incrementAvailableQuantity
int incrementAvailableQuantity(String priceDataId, int quantityToIncrement, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Increments thePriceData.getAvailableQuantity()
, typically used as part of the rollback.This method updates the quantity based on the current
PriceData.getAvailableQuantity()
to prevent causing stale data (e.g. read entity and then update the entity separately could cause the data to be stale).This method should be used to increment the
PriceData.getAvailableQuantity()
to prevent race condition and cause the quantity to be stale.- Parameters:
priceDataId
- thePriceData.getId()
to incrementquantityToIncrement
- the quantity to incrementcontextInfo
- the context info- Returns:
- the count of records updated
-
decrementAvailableQuantity
int decrementAvailableQuantity(String priceDataId, String priceListId, Instant usageDate, int quantityToDecrement, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Decrements thePriceData.getAvailableQuantity()
.This method only updates the quantity if the
PriceData.getAvailableQuantity()
is enough to cover thequantityToDecrement
.This method should be used to decrement the
PriceData.getAvailableQuantity()
to prevent race condition and decrement more quantity than actually available.- Parameters:
priceDataId
- thePriceData.getId()
to decrementpriceListId
- thePriceList.getId()
that it belongs tousageDate
- theInstant
used to check against the active start and end datesquantityToDecrement
- the quantity to decrementcontextInfo
- the context info- Returns:
- the count of records updated
-
convertTargetToRef
@Nullable com.broadleafcommerce.pricing.client.domain.PriceableTargetRef convertTargetToRef(@Nullable com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
-