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
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidafterPropertiesSet()protected javax.persistence.criteria.PredicatebuildTenantIdFilter(javax.persistence.criteria.Root<D> entity, javax.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.List<D>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.Optional<D>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.Optional<D>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.Optional<D>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 javax.persistence.criteria.PredicategetAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<D> entity)Deprecated.protected javax.persistence.criteria.PredicategetAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, javax.persistence.criteria.CriteriaBuilder builder, javax.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>getHelper()protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelpergetNarrowingHelper()protected CartRepository<D>getRepository()protected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected JpaCartTenantQueryHelpergetTenantQueryHelper()protected voidsetPageableProperties(javax.persistence.TypedQuery<D> query, org.springframework.data.domain.Pageable pageable)Sets thePageableproperties for the givenTypedQuery.voidsetRepository(CartRepository<D> repository)voidsetTenantQueryHelper(JpaCartTenantQueryHelper tenantQueryHelper)
-
-
-
Constructor Detail
-
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 Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
setRepository
@Autowired @Lazy public void setRepository(CartRepository<D> repository)
-
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.
-
getAbandonedCartPredicate
@Deprecated protected javax.persistence.criteria.Predicate getAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, javax.persistence.criteria.CriteriaBuilder builder, javax.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 javax.persistence.criteria.Predicate getAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, javax.persistence.criteria.CriteriaBuilder builder, javax.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 javax.persistence.criteria.Predicate buildTenantIdFilter(javax.persistence.criteria.Root<D> entity, javax.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(javax.persistence.TypedQuery<D> query, @Nullable org.springframework.data.domain.Pageable pageable)
Sets thePageableproperties for the givenTypedQuery.- Parameters:
query- theTypedQueryto sets thePageableproperties forpageable- thePageableto get the properties from
-
getRepository
protected CartRepository<D> getRepository()
-
getNarrowingHelper
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper()
-
getHelper
protected JpaCustomizedRepositoryHelper<D> getHelper()
-
getTenantQueryHelper
protected JpaCartTenantQueryHelper getTenantQueryHelper()
-
setTenantQueryHelper
@Autowired public void setTenantQueryHelper(JpaCartTenantQueryHelper tenantQueryHelper)
-
-