Class DefaultAccountMemberService<M extends AccountMember>

  • All Implemented Interfaces:
    AccountMemberService<M>, com.broadleafcommerce.data.tracking.core.service.CrudEntityService<M>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<M>

    public class DefaultAccountMemberService<M extends AccountMember>
    extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<M>
    implements AccountMemberService<M>
    Default implementation of the AccountMemberService.
    Author:
    Chris Kittrell (ckittrell)
    • Method Detail

      • readAllByAccountId

        public org.springframework.data.domain.Page<M> readAllByAccountId​(@NonNull
                                                                          @NonNull String accountId,
                                                                          @Nullable
                                                                          cz.jirutka.rsql.parser.ast.Node filters,
                                                                          @Nullable
                                                                          org.springframework.data.domain.Pageable page,
                                                                          @Nullable
                                                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountMemberService
        Reads all of the AccountMember relationships in the database associated with the given account context ID.
        Specified by:
        readAllByAccountId in interface AccountMemberService<M extends AccountMember>
        Parameters:
        accountId - the account context ID to find the relationships for
        filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
        page - the requested page of results from the database
        contextInfo - the context to query within
        Returns:
        the AccountMember relationships in the database that match the given account context ID
      • delete

        public void delete​(@NonNull
                           @NonNull String id,
                           @Nullable
                           com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Specified by:
        delete in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<M extends AccountMember>
        Overrides:
        delete in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<M extends AccountMember>
      • readByIdAndAccountId

        public M readByIdAndAccountId​(@NonNull
                                      @NonNull String id,
                                      @NonNull
                                      @NonNull String accountId,
                                      @Nullable
                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: AccountMemberService
        Finds the AccountMember which has the given ID and parent account ID.
        Specified by:
        readByIdAndAccountId in interface AccountMemberService<M extends AccountMember>
        Parameters:
        id - the context ID of the AccountMember
        accountId - the context ID of the owning Account
        contextInfo - context surrounding customer and multitenant state
        Returns:
        the account member that has the given ID and owning account ID
      • getOrCreateCustomer

        protected Customer getOrCreateCustomer​(@NonNull
                                               @NonNull RegisterAccountMemberRequest registerRequest,
                                               @Nullable
                                               com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Either gathers the Customer based on the RegisterAccountMemberRequest.getCustomerRef() or creates a new customer
        Parameters:
        registerRequest - the request used to identify or describe the customer
        context - the context within which the request has been made
        Returns:
        the customer that is to be added to the account
      • createAccountMember

        protected M createAccountMember​(@NonNull
                                        @NonNull RegisterAccountMemberRequest registerRequest,
                                        @Nullable
                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Parameters:
        registerRequest - the request data used to build the AccountMember
        context - the context in which the AccountMember should be created
        Returns:
        The persisted AccountMember
      • assignRoleToCustomer

        protected void assignRoleToCustomer​(@NonNull
                                            @NonNull RegisterAccountMemberRequest registerRequest,
                                            @Nullable
                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Assign the provided RegisterAccountMemberRequest.getRoleRef() to the related Customer
        Parameters:
        registerRequest - the request used specify which role to give the customer for this account
        context - the context within which the request has been made
      • getRepository

        protected AccountMemberRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
        Overrides:
        getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<M extends AccountMember>
      • getTypeFactory

        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()