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 TypeMethodDescriptionvoid
protected jakarta.persistence.criteria.Predicate
buildTenantIdFilter
(jakarta.persistence.criteria.Root<D> entity, jakarta.persistence.criteria.CriteriaBuilder builder, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) int
deleteAbandonedAnonymousCarts
(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 givenids
and 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.QUOTE
with 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.CANCELLED
orDefaultCartStatuses.SUBMITTED
for 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 givenstatus
and matching the tenant from the givenContextInfo
.protected jakarta.persistence.criteria.Predicate
getAbandonedCartPredicate
(Instant abandonedPoint, Collection<String> statuses, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity) Deprecated.protected jakarta.persistence.criteria.Predicate
getAbandonedCartPredicate
(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.JpaNarrowingHelper
protected CartRepository<D>
protected String
getTenantIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected JpaCartTenantQueryHelper
protected void
setPageableProperties
(jakarta.persistence.TypedQuery<D> query, org.springframework.data.domain.Pageable pageable) void
setRepository
(CartRepository<D> repository) void
setTenantQueryHelper
(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:
afterPropertiesSet
in 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:CustomizedCartRepository
Finds 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:
findByStatusAndCustomerId
in 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:CustomizedCartRepository
Finds 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:
findByStatusAndCustomerIdAndAccountId
in 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:CustomizedCartRepository
Finds 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:
findByStatusAndCustomerRefCustomerId
in 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:CustomizedCartRepository
Finds all carts with the given status within the requested page- Specified by:
findAllByStatusesAndCustomerId
in 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:CustomizedCartRepository
Finds 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:
findAllByStatusesAndCustomerIdAndAccountId
in 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:CustomizedCartRepository
Finds all carts with the given status within the requested page- Specified by:
findAllByStatusesAndCustomerRefCustomerId
in 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:CustomizedCartRepository
Find all carts that areDefaultCartStatuses.CANCELLED
orDefaultCartStatuses.SUBMITTED
for the provided customer and dates.- Specified by:
findHistoricalByCustomerIdAndDates
in 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.CANCELLED
orDefaultCartStatuses.SUBMITTED
for 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:CustomizedCartRepository
Find all carts that areDefaultCartStatuses.SUBMITTED
orDefaultCartStatuses.CANCELLED
for the provided customer and dates.- Specified by:
findHistoricalByCustomerRefCustomerIdAndDates
in 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.SUBMITTED
orDefaultCartStatuses.CANCELLED
for 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:CustomizedCartRepository
Delete anonymous carts that have not been updated since the given date.- Specified by:
deleteAbandonedAnonymousCarts
in 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:CustomizedCartRepository
Finds a page of the carts with the givenstatus
and matching the tenant from the givenContextInfo
.- Specified by:
findPageMatchingTenantByStatus
in 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
status
and 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:CustomizedCartRepository
Finds a list of the carts with the givenids
and matching the tenant from the givenContextInfo
.- Specified by:
findAllMatchingTenantByIds
in 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
ids
and 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:CustomizedCartRepository
Finds a list of carts of typeDefaultCartTypes.QUOTE
with expiration date before the provided date-time value, and a status not in the provided 'statuses' collection.- Specified by:
findAllQuotesByExpirationDateBeforeAndStatusNotIn
in 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.QUOTE
with 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)