Class DefaultCartApprovalService
java.lang.Object
com.broadleafcommerce.cartoperation.service.approval.DefaultCartApprovalService
- All Implemented Interfaces:
CartApprovalService
The default implementation of
CartApprovalService.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCartApprovalService(CartApprovalValidationService cartApprovalValidationService, CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.retry.support.RetryTemplate messageRetryTemplate) -
Method Summary
Modifier and TypeMethodDescriptionprotected cz.jirutka.rsql.parser.ast.NodebuildAccountCartFilters(String requestedAccountId, @NonNull String status, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull cz.jirutka.rsql.parser.ast.Node existingFilters) BuildsNodefilters based on the requested account id, status, and the account details of the currently authenticatedCustomerRefused to retrieve carts.protected org.springframework.data.domain.PageablebuildAccountCartPageable(org.springframework.data.domain.Pageable pageable) Builds a newPageablewith default sort ofCart.getApprovalRequestedDate()applied.protected com.broadleafcommerce.cart.client.domain.CartActionAuditbuildCartActionAudit(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull com.broadleafcommerce.cart.client.domain.enums.DefaultCartActionTypes actionType, @NonNull String oldCartStatus, @NonNull CartActionAuditUserType userType, String comment, Map<String, Object> data) Builds aCartActionAuditbased on the given fields.protected CartApprovalProcessResponsebuildCartApprovalProcessResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Given the cart andCartApprovalValidationExceptionfailures, creates and returns a response.protected UpdateCartRequestbuildUpdateCartRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit cartActionAudit) Builds anUpdateCartRequestbased on the given cart and cart action audit.protected CartApprovalValidationServiceprotected CartProviderprotected org.springframework.retry.support.RetryTemplateprotected com.broadleafcommerce.common.extension.TypeFactoryrejectCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Action performed by an account approver to reject aCart.org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart>retrieveCartsRequiringApproval(String requestedAccountId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve a page ofCartsthat require approval in the current authenticated user's account context and requested account id if applicable.protected voidsendCartRejectionMessage(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit audit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.This event is now sent from Cart Services in response to the update to the cart's status.submitForApproval(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Action performed by an account member to submit for approval of aCart.protected com.broadleafcommerce.cart.client.domain.CartupdateCartForRejection(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest) Updates the name and status ofCartto reflect that it has been rejected.protected com.broadleafcommerce.cart.client.domain.CartupdateCartForSubmitForApproval(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest) Updates the name and status ofCartto reflect that it has been submitted for approval.
-
Field Details
-
STATUS
- See Also:
-
ACCOUNT_ID
- See Also:
-
ROOT_ACCOUNT_ID
- See Also:
-
ACCOUNT_HIERARCHY
- See Also:
-
RANDOM
-
-
Constructor Details
-
DefaultCartApprovalService
public DefaultCartApprovalService(CartApprovalValidationService cartApprovalValidationService, CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.retry.support.RetryTemplate messageRetryTemplate)
-
-
Method Details
-
retrieveCartsRequiringApproval
public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartsRequiringApproval(@Nullable String requestedAccountId, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartApprovalServiceRetrieve a page ofCartsthat require approval in the current authenticated user's account context and requested account id if applicable.- Specified by:
retrieveCartsRequiringApprovalin interfaceCartApprovalService- Parameters:
requestedAccountId- optional parameter to retrieve carts from a specific account, if not specified, carts in the current account and its sub-accounts context will be retrievedcustomerRef- the currently authenticatedCustomerRefcontaining user's account detailsfilters- exising filters to build on top ofpageable- the requested page of resultscontextInfo- context information related to multitenancy- Returns:
- a page of
Cartsthat require approval in the current authenticated user's account context and requested account id if applicable.
-
submitForApproval
public CartApprovalProcessResponse submitForApproval(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartApprovalServiceAction performed by an account member to submit for approval of aCart. Produces aCartActionAudit.- Specified by:
submitForApprovalin interfaceCartApprovalService- Parameters:
cart- The cart that was submitted for approvalcustomer- The customer who submitted the cart for approvalcartApprovalProcessRequest- the request with whichCartApprovalEndpointis hitcontextInfo- Context information around sandbox and multitenant state.- Returns:
- a
CartApprovalProcessResponsethat contains the updated cart, any validation errors encountered, status of the request, and additionalAttributes
-
rejectCart
public CartApprovalProcessResponse rejectCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartApprovalServiceAction performed by an account approver to reject aCart. Produces aCartActionAudit. Produces aCartRejectionEvent- Specified by:
rejectCartin interfaceCartApprovalService- Parameters:
cart- The cart that was rejectedcustomer- The customer who rejected the cartcartApprovalProcessRequest- the request with whichCartApprovalEndpointis hitcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The rejected cart
-
updateCartForSubmitForApproval
protected com.broadleafcommerce.cart.client.domain.Cart updateCartForSubmitForApproval(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull CartApprovalProcessRequest cartApprovalProcessRequest) Updates the name and status ofCartto reflect that it has been submitted for approval. -
buildCartActionAudit
protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAudit(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.enums.DefaultCartActionTypes actionType, @NonNull @NonNull String oldCartStatus, @NonNull @NonNull CartActionAuditUserType userType, @Nullable String comment, @Nullable Map<String, Object> data) Builds aCartActionAuditbased on the given fields. -
buildUpdateCartRequest
protected UpdateCartRequest buildUpdateCartRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit cartActionAudit) Builds anUpdateCartRequestbased on the given cart and cart action audit.- Parameters:
cart- theCartto updatecartActionAudit- the originalCartActionAuditto create- Returns:
- an
UpdateCartRequestbased on the given cart and cart action audit
-
buildCartApprovalProcessResponse
protected CartApprovalProcessResponse buildCartApprovalProcessResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Given the cart andCartApprovalValidationExceptionfailures, creates and returns a response. -
updateCartForRejection
protected com.broadleafcommerce.cart.client.domain.Cart updateCartForRejection(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull CartApprovalProcessRequest cartApprovalProcessRequest) Updates the name and status ofCartto reflect that it has been rejected. -
sendCartRejectionMessage
@Deprecated(forRemoval=true, since="1.8.3") protected void sendCartRejectionMessage(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit audit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.This event is now sent from Cart Services in response to the update to the cart's status. There is no need to have an additional HTTP request for this event.Sends aCartRejectionEventto notify the cart owner.- Throws:
CartRejectionMessageException- if the message cannot be sent.
-
buildAccountCartFilters
protected cz.jirutka.rsql.parser.ast.Node buildAccountCartFilters(@Nullable String requestedAccountId, @NonNull @NonNull String status, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node existingFilters) BuildsNodefilters based on the requested account id, status, and the account details of the currently authenticatedCustomerRefused to retrieve carts.By default, if the requested account id is present, the filters will look for only requested account's carts, not those of sub-accounts. Otherwise, filters to retrieve sub-account carts will automatically be applied.
Note that the usage of root account id is to avoid a table scan when querying against cart's account hierarchy.
- Parameters:
requestedAccountId- optional parameter to build filters to retrieve carts of a specific accountstatus- the status to filter bycustomerRef- the currently authenticatedCustomerRefcontaining user's account detailsexistingFilters- exising filters to build on top of- Returns:
- the
Nodefilters based on the requested account id, status, and the account details of the currently authenticatedCustomerRefused to retrieve carts
-
buildAccountCartPageable
protected org.springframework.data.domain.Pageable buildAccountCartPageable(@Nullable org.springframework.data.domain.Pageable pageable) Builds a newPageablewith default sort ofCart.getApprovalRequestedDate()applied.- Parameters:
pageable- requestedPageableto build on top of- Returns:
- a new
Pageablewith default sort ofCart.getApprovalRequestedDate()applied
-
getCartApprovalValidationService
-
getCartProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getMessageRetryTemplate
protected org.springframework.retry.support.RetryTemplate getMessageRetryTemplate()
-