Class DefaultCustomerAccountService<P extends CustomerAccount,D extends com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware & com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable>
java.lang.Object
com.broadleafcommerce.auth.user.service.DefaultCustomerAccountService<P,D>
- All Implemented Interfaces:
CustomerAccountService<P>
public class DefaultCustomerAccountService<P extends CustomerAccount,D extends com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware & com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable>
extends Object
implements CustomerAccountService<P>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultCustomerAccountService
(CustomerAccountRepository<D> repository, SimplePayloadMapper mapper, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Delete aCustomerAccount
.getAccountAncestors
(String accountId) Get a list of all parent accounts for the account with the given id.getAccountAncestorsInternal
(String accountId) Get a list of all parent accounts for the account with the given id.getAccountDescendantsInternal
(@NonNull Collection<String> accountIds) Recursively traces the accounts' descendants and returns a list them all for the accounts with the given id.getAccountInheritanceLine
(String accountId) Returns the account and all of its ancestors in order with the given account first.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
getAccountInheritanceLineInternal
(String accountId) Get a list of all parent accounts for the account with the given id.getAllAccountsDescendants
(@NonNull Collection<String> accountIds) Gets a list of all child accounts/sub-accounts for the accounts with the given ids.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected SimplePayloadMapper
protected CustomerAccountRepository<D>
readAllByParentAccountIdIn
(Collection<String> parentAccountIds) Find a list ofCustomerAccount
by their parent account ids.readByAccountId
(String accountId) Find aCustomerAccount
by its account id.Save aCustomerAccount
,void
setAccountInheritanceLineCacheByAccountId
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen accountInheritanceLineCacheByAccountId) void
setAncestorAccountCacheByAccountId
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen ancestorAccountCacheByAccountId) void
setDescendantAccountCacheByAccountId
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen descendantAccountCacheByAccountId)
-
Field Details
-
CACHE_ANCESTORS_BY_ACCOUNT_ID
- See Also:
-
CACHE_ACCOUNT_INHERITANCE_LINE_BY_ACCOUNT_ID
- See Also:
-
CACHE_DESCENDANTS_BY_ACCOUNT_ID
- See Also:
-
-
Constructor Details
-
DefaultCustomerAccountService
public DefaultCustomerAccountService(CustomerAccountRepository<D> repository, SimplePayloadMapper mapper, @Nullable com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager)
-
-
Method Details
-
readByAccountId
Description copied from interface:CustomerAccountService
Find aCustomerAccount
by its account id.- Specified by:
readByAccountId
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
accountId
- The account id to look-up theCustomerAccount
.- Returns:
- The
CustomerAccount
for the given account id.
-
readAllByParentAccountIdIn
Description copied from interface:CustomerAccountService
Find a list ofCustomerAccount
by their parent account ids.- Specified by:
readAllByParentAccountIdIn
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
parentAccountIds
- The parent account id to look-up theCustomerAccount
.- Returns:
- The list of
CustomerAccount
for the given parent account id.
-
save
Description copied from interface:CustomerAccountService
Save aCustomerAccount
,- Specified by:
save
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
customerAccount
- TheCustomerAccount
to save.- Returns:
- The persisted
CustomerAccount
.
-
delete
Description copied from interface:CustomerAccountService
Delete aCustomerAccount
.- Specified by:
delete
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
customerAccount
- TheCustomerAccount
to delete.
-
getAccountAncestors
Description copied from interface:CustomerAccountService
Get a list of all parent accounts for the account with the given id. The returned list does not include the given account id.- Specified by:
getAccountAncestors
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
accountId
- The id of the account for which to lookup ancestors- Returns:
- A list of ids of ancestors to the given account id.
-
getAccountInheritanceLine
Description copied from interface:CustomerAccountService
Returns the account and all of its ancestors in order with the given account first.- Specified by:
getAccountInheritanceLine
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
accountId
- The account whose inheritance line to build.- Returns:
- The account and all of its ancestors in order with the given account first.
-
getAllAccountsDescendants
Description copied from interface:CustomerAccountService
Gets a list of all child accounts/sub-accounts for the accounts with the given ids. The returned list does not include the given account ids.- Specified by:
getAllAccountsDescendants
in interfaceCustomerAccountService<P extends CustomerAccount>
- Parameters:
accountIds
- The id of the account for which to lookup descendants- Returns:
- A list of ids of descendants for the given account ids.
-
getAccountAncestorsInternal
Get a list of all parent accounts for the account with the given id. The returned list does not include the given account id.- Parameters:
accountId
- The id of the account for which to lookup ancestors- Returns:
- A list of ids of ancestors to the given account id.
-
getAccountInheritanceLineInternal
Get a list of all parent accounts for the account with the given id. The returned list includes the given account. The given account will be the first item in the list.- Parameters:
accountId
- The id of the account for which to lookup ancestors- Returns:
- A list of
CustomerAccounts
ancestors to the given account.
-
getAccountDescendantsInternal
protected List<String> getAccountDescendantsInternal(@NonNull @NonNull Collection<String> accountIds) Recursively traces the accounts' descendants and returns a list them all for the accounts with the given id. The returned list does not include the originally provided account ids as those are not descendents.- Parameters:
accountIds
- The ids of the accounts for which to lookup descendants- Returns:
- A list of ids of descendants to the given account id.
-
getRepository
-
getMapper
-
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
setAncestorAccountCacheByAccountId
@Autowired @Qualifier("ancestorAccountCacheByAccountId") public void setAncestorAccountCacheByAccountId(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen ancestorAccountCacheByAccountId) - See Also:
-
getAncestorAccountCacheByAccountId
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getAncestorAccountCacheByAccountId()- See Also:
-
setAccountInheritanceLineCacheByAccountId
@Autowired @Qualifier("accountInheritanceLineCacheByAccountId") public void setAccountInheritanceLineCacheByAccountId(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen accountInheritanceLineCacheByAccountId) -
getAccountInheritanceLineCacheByAccountId
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getAccountInheritanceLineCacheByAccountId() -
setDescendantAccountCacheByAccountId
@Autowired @Qualifier("descendantAccountCacheByAccountId") public void setDescendantAccountCacheByAccountId(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen descendantAccountCacheByAccountId) - See Also:
-
getDescendantAccountCacheByAccountId
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getDescendantAccountCacheByAccountId()- See Also:
-