Interface CustomizedPriceDataRepository<D extends com.broadleafcommerce.data.tracking.core.Trackable>

All Known Subinterfaces:
JpaPriceDataRepository<D>, PriceDataRepository<D>
All Known Implementing Classes:
JpaCustomizedPriceDataRepository

public interface CustomizedPriceDataRepository<D extends com.broadleafcommerce.data.tracking.core.Trackable>
Author:
Nick Crum ncrum
  • Method Details

    • findByPriceListIdAndTarget

      @Deprecated(since="1.7.2", forRemoval=true) @Policy(operationTypes=READ) org.springframework.data.domain.Page<D> findByPriceListIdAndTarget(@Nullable String priceListId, @Nullable String targetType, Collection<String> targetIds, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • findByPriceListIdAndTarget

      @NonNull @Policy(operationTypes=READ) org.springframework.data.domain.Page<D> findByPriceListIdAndTarget(@Nullable String priceListId, @Nullable String targetType, Collection<String> targetIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • findByTargetInAndPriceListIdsIn

      @NonNull @Policy(operationTypes=READ) default List<D> findByTargetInAndPriceListIdsIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, @NonNull Collection<String> listIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • findByTargetInAndPriceListIdsIn

      @NonNull @Policy(operationTypes=READ) List<D> findByTargetInAndPriceListIdsIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, @NonNull Collection<String> listIds, boolean filterByVendor, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds a list of price data by the given PriceableTargetRefs and price list ids.
      Parameters:
      targets - a list of PriceableTargetRefs to match
      listIds - a list of price list ids to look for
      filterByVendor - whether to also filter the price data based on the {@link {@link PriceableTargetRef#getVendorRef()}
      contextInfo - the current context
      Returns:
      a list of price data by the given PriceableTargetRefs and price list ids
    • findByTargetAndPriceListId

      @NonNull @Policy(operationTypes=READ) Optional<D> findByTargetAndPriceListId(@NonNull com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, @NonNull String priceListId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readAllByPriceListId

      @Policy(operationTypes=READ) Stream<D> readAllByPriceListId(String priceListId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reads all JpaPriceData by the given price list id.

      This method explicitly fetches the ids and then fetches the entities by the ids to avoid using the SQL offset for the sake of performance, which is used under the hood in JpaNarrowExecutor when the query is a page query.

    • incrementAvailableQuantity

      @Policy(operationTypes=UPDATE) int incrementAvailableQuantity(String priceDataId, int quantityToIncrement, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Increments the PriceData.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 - the PriceData.getId() to increment
      quantityToIncrement - the quantity to increment
      contextInfo - the context info
      Returns:
      the count of records updated
    • decrementAvailableQuantity

      @Policy(operationTypes=UPDATE) int decrementAvailableQuantity(String priceDataId, String priceListId, Instant usageDate, int quantityToDecrement, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Decrements the PriceData.getAvailableQuantity().

      This method only updates the quantity if the PriceData.getAvailableQuantity() is enough to cover the quantityToDecrement.

      This method should be used to decrement the PriceData.getAvailableQuantity() to prevent race condition and decrement more quantity than actually available.

      Parameters:
      priceDataId - the PriceData.getId() to decrement
      priceListId - the PriceList.getId() that it belongs to
      usageDate - the Instant used to check against the active start and end dates
      quantityToDecrement - the quantity to decrement
      contextInfo - the context info
      Returns:
      the count of records updated