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 void
afterPropertiesSet()
protected javax.persistence.criteria.Predicate
buildTenantIdFilter(javax.persistence.criteria.Root<D> entity, javax.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.List<D>
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
.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.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 javax.persistence.criteria.Predicate
getAbandonedCartPredicate(Instant abandonedPoint, Collection<String> statuses, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<D> entity)
Deprecated.protected javax.persistence.criteria.Predicate
getAbandonedCartPredicate(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.JpaNarrowingHelper
getNarrowingHelper()
protected CartRepository<D>
getRepository()
protected String
getTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected JpaCartTenantQueryHelper
getTenantQueryHelper()
protected void
setPageableProperties(javax.persistence.TypedQuery<D> query, org.springframework.data.domain.Pageable pageable)
Sets thePageable
properties for the givenTypedQuery
.void
setRepository(CartRepository<D> repository)
void
setTenantQueryHelper(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:
afterPropertiesSet
in 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: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
.
-
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 thePageable
properties for the givenTypedQuery
.- Parameters:
query
- theTypedQuery
to sets thePageable
properties forpageable
- thePageable
to 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)
-
-