Class DefaultAccountMemberService<M extends AccountMember>
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
-
- com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<M>
-
- com.broadleafcommerce.customer.service.DefaultAccountMemberService<M>
-
- 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 theAccountMemberService
.- Author:
- Chris Kittrell (ckittrell)
-
-
Constructor Summary
Constructors Constructor Description DefaultAccountMemberService(AccountMemberRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, AccountService<Account> accountService, CustomerService<Customer> customerService, AccountRoleService<AccountRole> accountRoleService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assignRoleToCustomer(@NonNull RegisterAccountMemberRequest registerRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Assign the providedRegisterAccountMemberRequest.getRoleRef()
to the related Customerprotected M
createAccountMember(@NonNull RegisterAccountMemberRequest registerRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Create anAccountMember
based on theRegisterAccountMemberRequest
void
delete(@NonNull String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
protected AccountRoleService<AccountRole>
getAccountRoleService()
protected AccountService<Account>
getAccountService()
protected CustomerService<Customer>
getCustomerService()
protected Customer
getOrCreateCustomer(@NonNull RegisterAccountMemberRequest registerRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Either gathers theCustomer
based on theRegisterAccountMemberRequest.getCustomerRef()
or creates a new customerprotected AccountMemberRepository<com.broadleafcommerce.data.tracking.core.Trackable>
getRepository()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
org.springframework.data.domain.Page<M>
readAllByAccountId(@NonNull String accountId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Reads all of the AccountMember relationships in the database associated with the given account context ID.M
readByIdAndAccountId(@NonNull String id, @NonNull String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Finds theAccountMember
which has the given ID and parent account ID.M
registerAccountMember(@NonNull String accountId, @NonNull RegisterAccountMemberRequest registerRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
M
updateAccountMember(@NonNull String accountId, @NonNull String accountMemberId, @NonNull UpdateAccountMemberRequest updateRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAll
-
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
-
-
-
-
Constructor Detail
-
DefaultAccountMemberService
public DefaultAccountMemberService(AccountMemberRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, AccountService<Account> accountService, CustomerService<Customer> customerService, AccountRoleService<AccountRole> accountRoleService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
-
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 interfaceAccountMemberService<M extends AccountMember>
- Parameters:
accountId
- the account context ID to find the relationships forfilters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontextInfo
- the context to query within- Returns:
- the AccountMember relationships in the database that match the given account context ID
-
registerAccountMember
public M registerAccountMember(@NonNull @NonNull String accountId, @NonNull @NonNull RegisterAccountMemberRequest registerRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:AccountMemberService
Relates aCustomer
with theAccount
identified by theaccountId
. If the customer cannot be found, then one is created.- Specified by:
registerAccountMember
in interfaceAccountMemberService<M extends AccountMember>
- Parameters:
accountId
- Id of theAccount
that theRegisterAccountMemberRequest.customerRef
should be related toregisterRequest
- The payload that describes the requested relationship between the customer & the accountcontext
- The context of the user's request- Returns:
- The registered AccountMember
-
updateAccountMember
public M updateAccountMember(@NonNull @NonNull String accountId, @NonNull @NonNull String accountMemberId, @NonNull @NonNull UpdateAccountMemberRequest updateRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:AccountMemberService
- Specified by:
updateAccountMember
in interfaceAccountMemberService<M extends AccountMember>
- Parameters:
accountId
- Id of theAccount
in the relationshipaccountMemberId
- Id of theAccountMember
that is to be updatedupdateRequest
- The payload that describes the requested changescontext
- The context of the user's request- Returns:
-
delete
public void delete(@NonNull @NonNull String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
delete
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<M extends AccountMember>
- Overrides:
delete
in classcom.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 theAccountMember
which has the given ID and parent account ID.- Specified by:
readByIdAndAccountId
in interfaceAccountMemberService<M extends AccountMember>
- Parameters:
id
- the context ID of theAccountMember
accountId
- the context ID of the owningAccount
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 theCustomer
based on theRegisterAccountMemberRequest.getCustomerRef()
or creates a new customer- Parameters:
registerRequest
- the request used to identify or describe the customercontext
- 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)
Create anAccountMember
based on theRegisterAccountMemberRequest
- Parameters:
registerRequest
- the request data used to build the AccountMembercontext
- 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 providedRegisterAccountMemberRequest.getRoleRef()
to the related Customer- Parameters:
registerRequest
- the request used specify which role to give the customer for this accountcontext
- the context within which the request has been made
-
getRepository
protected AccountMemberRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
- Overrides:
getRepository
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<M extends AccountMember>
-
getAccountService
protected AccountService<Account> getAccountService()
-
getCustomerService
protected CustomerService<Customer> getCustomerService()
-
getAccountRoleService
protected AccountRoleService<AccountRole> getAccountRoleService()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
-