Class JpaCustomizedCartRepository<D extends JpaCart>
java.lang.Object
com.broadleafcommerce.cart.provider.jpa.repository.JpaCustomizedCartRepository<D>
- All Implemented Interfaces:
CustomizedCartRepository<D>,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedCartRepository<D extends JpaCart>
extends Object
implements CustomizedCartRepository<D>, org.springframework.beans.factory.InitializingBean
-
Constructor Summary
ConstructorsConstructorDescriptionJpaCustomizedCartRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager typeManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected jakarta.persistence.criteria.PredicatebuildTenantIdFilter(jakarta.persistence.criteria.Root<D> entity, jakarta.persistence.criteria.CriteriaBuilder builder, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) intdeleteAbandonedAnonymousCarts(Instant deletePoint, Collection<String> statuses, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Delete anonymous carts that have not been updated since the given date.org.springframework.data.domain.Page<D>findAllByStatusesAndCustomerId(Set<String> statuses, String customerId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds all carts with the given status within the requested pageorg.springframework.data.domain.Page<D>findAllByStatusesAndCustomerIdAndAccountId(Set<String> statuses, String customerId, String accountId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds all carts with the given status within the requested page.org.springframework.data.domain.Page<D>findAllByStatusesAndCustomerRefCustomerId(Set<String> statuses, String customerId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.findAllMatchingTenantByIds(List<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a list of the carts with the givenidsand matching the tenant from the givenContextInfo.org.springframework.data.domain.Page<D>findAllQuotesByExpirationDateBeforeAndStatusNotIn(@NonNull Instant expirationDate, @NonNull Collection<String> statusesToExclude, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a list of carts of typeDefaultCartTypes.QUOTEwith expiration date before the provided date-time value, and a status not in the provided 'statuses' collection.findByStatusAndCustomerId(String status, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a cart with the given status for the customer ID provided.findByStatusAndCustomerIdAndAccountId(String status, String customerId, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a cart with the given status for the customer ID and account ID provided.findByStatusAndCustomerRefCustomerId(String status, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.org.springframework.data.domain.Page<D>findHistoricalByCustomerIdAndDates(String customerId, Date startDate, Date endDate, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find all carts that areDefaultCartStatuses.CANCELLEDorDefaultCartStatuses.SUBMITTEDfor the provided customer and dates.org.springframework.data.domain.Page<D>findHistoricalByCustomerRefCustomerIdAndDates(String customerId, Date startDate, Date endDate, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.org.springframework.data.domain.Page<D>findPageMatchingTenantByStatus(String status, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a page of the carts with the givenstatusand matching the tenant from the givenContextInfo.protected jakarta.persistence.criteria.PredicategetAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity) Deprecated.protected jakarta.persistence.criteria.PredicategetAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Build the Predicate to determine which carts are abandoned.protected JpaCustomizedRepositoryHelper<D>protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelperprotected CartRepository<D>protected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected JpaCartTenantQueryHelperprotected voidsetPageableProperties(jakarta.persistence.TypedQuery<D> query, org.springframework.data.domain.Pageable pageable) voidsetRepository(CartRepository<D> repository) voidsetTenantQueryHelper(JpaCartTenantQueryHelper tenantQueryHelper)
-
Constructor Details
-
JpaCustomizedCartRepository
public JpaCustomizedCartRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager typeManager)
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
findByStatusAndCustomerId
public Optional<D> findByStatusAndCustomerId(String status, String customerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds a cart with the given status for the customer ID provided. By default, if multiple are found, this selects the cart with the latestcreateDate.- Specified by:
findByStatusAndCustomerIdin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
status- the status to find carts ofcustomerId- the customer ID to find carts withcontextInfo- the context to use for filtering the results- Returns:
- the cart with requested details, or empty if none was found.
-
findByStatusAndCustomerIdAndAccountId
public Optional<D> findByStatusAndCustomerIdAndAccountId(String status, String customerId, @Nullable String accountId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds a cart with the given status for the customer ID and account ID provided. By default, if multiple are found, this selects the cart with the latestcreateDate.- Specified by:
findByStatusAndCustomerIdAndAccountIdin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
status- the status to find carts ofcustomerId- the customer ID to find carts withaccountId- the account ID to find carts withcontextInfo- the context to use for filtering the results- Returns:
- the cart with requested details, or empty if none was found.
-
findByStatusAndCustomerRefCustomerId
@Deprecated public Optional<D> findByStatusAndCustomerRefCustomerId(String status, String customerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Description copied from interface:CustomizedCartRepositoryFinds a cart with the given status for the customer ID provided. By default, if multiple are found, this selects the cart with the latestcreateDate.- Specified by:
findByStatusAndCustomerRefCustomerIdin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
status- the status to find carts ofcustomerId- the customer ID to find carts withcontextInfo- the context to use for filtering the results- Returns:
- the cart with requested details, or empty if none was found.
-
findAllByStatusesAndCustomerId
public org.springframework.data.domain.Page<D> findAllByStatusesAndCustomerId(Set<String> statuses, String customerId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds all carts with the given status within the requested page- Specified by:
findAllByStatusesAndCustomerIdin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
statuses- the status of the carts to considercustomerId- the ID of the customer to find carts forpage- the requested page of results from the databasecontextInfo- context information related to multitenancy- Returns:
- a page of carts with the requested details
-
findAllByStatusesAndCustomerIdAndAccountId
public org.springframework.data.domain.Page<D> findAllByStatusesAndCustomerIdAndAccountId(Set<String> statuses, String customerId, @Nullable String accountId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds all carts with the given status within the requested page. Account id can be null to find customer's personal non-account carts.- Specified by:
findAllByStatusesAndCustomerIdAndAccountIdin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
statuses- the status of the carts to considercustomerId- the ID of the customer to find carts forpage- the requested page of results from the databasecontextInfo- context information related to multitenancy- Returns:
- a page of carts with the requested details
-
findAllByStatusesAndCustomerRefCustomerId
@Deprecated public org.springframework.data.domain.Page<D> findAllByStatusesAndCustomerRefCustomerId(Set<String> statuses, String customerId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Description copied from interface:CustomizedCartRepositoryFinds all carts with the given status within the requested page- Specified by:
findAllByStatusesAndCustomerRefCustomerIdin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
statuses- the status of the carts to considercustomerId- the ID of the customer to find carts forpage- the requested page of results from the databasecontextInfo- context information related to multitenancy- Returns:
- a page of carts with the requested details
-
findHistoricalByCustomerIdAndDates
public org.springframework.data.domain.Page<D> findHistoricalByCustomerIdAndDates(String customerId, Date startDate, Date endDate, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFind all carts that areDefaultCartStatuses.CANCELLEDorDefaultCartStatuses.SUBMITTEDfor the provided customer and dates.- Specified by:
findHistoricalByCustomerIdAndDatesin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
customerId- the id of the customer who owns the cartsstartDate- the starting date to filter carts byendDate- the ending date to filter carts bypage- the requested page of results from the databasecontextInfo- context information related to multitenancy- Returns:
- all carts that are
DefaultCartStatuses.CANCELLEDorDefaultCartStatuses.SUBMITTEDfor the provided customer and dates.
-
findHistoricalByCustomerRefCustomerIdAndDates
@Deprecated public org.springframework.data.domain.Page<D> findHistoricalByCustomerRefCustomerIdAndDates(String customerId, Date startDate, Date endDate, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Description copied from interface:CustomizedCartRepositoryFind all carts that areDefaultCartStatuses.SUBMITTEDorDefaultCartStatuses.CANCELLEDfor the provided customer and dates.- Specified by:
findHistoricalByCustomerRefCustomerIdAndDatesin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
customerId- the id of the customer who owns the cartsstartDate- the starting date to filter carts byendDate- the ending date to filter carts bypage- the requested page of results from the databasecontextInfo- context information related to multitenancy- Returns:
- all carts that are
DefaultCartStatuses.SUBMITTEDorDefaultCartStatuses.CANCELLEDfor the provided customer and dates.
-
deleteAbandonedAnonymousCarts
@Transactional("cartTransactionManager") public int deleteAbandonedAnonymousCarts(Instant deletePoint, Collection<String> statuses, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryDelete anonymous carts that have not been updated since the given date.- Specified by:
deleteAbandonedAnonymousCartsin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
deletePoint- Find carts that have not been updated since this Instant.statuses- Find carts that have one of these statuses.contextInfo- context information related to multitenancy.- Returns:
- The number of carts deleted.
-
findPageMatchingTenantByStatus
public org.springframework.data.domain.Page<D> findPageMatchingTenantByStatus(String status, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds a page of the carts with the givenstatusand matching the tenant from the givenContextInfo.- Specified by:
findPageMatchingTenantByStatusin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
status- the status of the cartpageable- the requested page of results from the databasecontextInfo- context information related to multitenancy- Returns:
- A page of the carts with the given
statusand matching the tenant from the givenContextInfo.
-
findAllMatchingTenantByIds
public List<D> findAllMatchingTenantByIds(List<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds a list of the carts with the givenidsand matching the tenant from the givenContextInfo.- Specified by:
findAllMatchingTenantByIdsin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
ids- the ids of the cartcontextInfo- context information related to multitenancy- Returns:
- Finds a list of the carts with the given
idsand matching the tenant from the givenContextInfo.
-
findAllQuotesByExpirationDateBeforeAndStatusNotIn
public org.springframework.data.domain.Page<D> findAllQuotesByExpirationDateBeforeAndStatusNotIn(@NonNull @NonNull Instant expirationDate, @NonNull @NonNull Collection<String> statusesToExclude, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCartRepositoryFinds a list of carts of typeDefaultCartTypes.QUOTEwith expiration date before the provided date-time value, and a status not in the provided 'statuses' collection.- Specified by:
findAllQuotesByExpirationDateBeforeAndStatusNotInin interfaceCustomizedCartRepository<D extends JpaCart>- Parameters:
expirationDate- the date-time before or on which carts are considered expired.statusesToExclude- a collection of statuses that are not returned.page- the requested page of results from the database.contextInfo- context information related to multitenancy.- Returns:
- a page of expired carts of type
DefaultCartTypes.QUOTEwith a status not in the provided collection.
-
getAbandonedCartPredicate
@Deprecated protected jakarta.persistence.criteria.Predicate getAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity) Deprecated.Build the Predicate to determine which carts are abandoned.- Parameters:
abandonedPoint- Consider carts that have not been updated since this Instant.statuses- Consider carts that have one of these statuses.builder- The CriteriaBuilder for this query.entity- The Root entity of this delete query.- Returns:
- A Predicate to find carts that are abandoned.
-
getAbandonedCartPredicate
protected jakarta.persistence.criteria.Predicate getAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Build the Predicate to determine which carts are abandoned.- Parameters:
abandonedPoint- Consider carts that have not been updated since this Instant.statuses- Consider carts that have one of these statuses.builder- The CriteriaBuilder for this query.entity- The Root entity of this delete query.- Returns:
- A Predicate to find carts that are abandoned.
-
buildTenantIdFilter
protected jakarta.persistence.criteria.Predicate buildTenantIdFilter(jakarta.persistence.criteria.Root<D> entity, jakarta.persistence.criteria.CriteriaBuilder builder, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTenantIdFromContext
@Nullable protected String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
setPageableProperties
protected void setPageableProperties(jakarta.persistence.TypedQuery<D> query, @Nullable org.springframework.data.domain.Pageable pageable) -
getRepository
-
setRepository
-
getNarrowingHelper
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper() -
getHelper
-
getTenantQueryHelper
-
setTenantQueryHelper
-
getAbandonedCartPredicate(Instant, Collection, CriteriaBuilder, Root, ContextInfo)