Class DefaultCustomerService<P extends Customer>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.customer.service.DefaultCustomerService<P>
- Type Parameters:
P
- A subtype ofCustomer
- All Implemented Interfaces:
CustomerService<P>
,com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
public class DefaultCustomerService<P extends Customer>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements CustomerService<P>
Default implementation of
CustomerService
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorDescriptionDefaultCustomerService
(CustomerRepository<com.broadleafcommerce.data.tracking.core.Trackable> customerRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, CustomerConfigurationProperties customerProperties, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) -
Method Summary
Modifier and TypeMethodDescriptioncom.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P>
createAllAllowingPartialSuccess
(List<P> customers, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected AccountMemberService<AccountMember>
protected CustomerConfigurationProperties
protected CustomerRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>
protected void
handleAccountMemberUpdate
(P customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reflect thecustomer
updates to their correspondingAccountMember
instances, namely the full name and email updates.protected void
handleEmailAsUsername
(P customer) Assign thecustomer
's username to match their email whenCustomerConfigurationProperties
is configured with email as username.protected void
handleEmailAsUsernameUpdate
(P customer) Adjust thecustomer
update for the username to match their email whenCustomerConfigurationProperties
is configured with email as username.readAllByEmail
(Set<String> emails, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Searches for customers in the data store whoseCustomer.email
contains in the givenemails
.org.springframework.data.domain.Page<P>
readAllByFullName
(String nameQuery, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Searches for customers in the data store whoseCustomer#name
matches the givennameQuery
.readAllUniqueIds
(int page, cz.jirutka.rsql.parser.ast.Node filters) Retrieves a list of unique customer context IDs no larger than page.readByContextIdOpt
(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Read a single instance of an entity in the form of a business domain.readByEmail
(String email, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a customer by email.readCustomersPagingStream
(cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all customers matching the given filters.replace
(String id, P customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) replaceAll
(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P>
replaceAllAllowingPartialSuccess
(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) void
setAccountMemberService
(AccountMemberService<AccountMember> accountMemberService) streamAll
(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Sort sort, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Stream a list of customers matching the provided filtersupdateAll
(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> updates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<P>
updateAllAllowingPartialSuccess
(List<com.broadleafcommerce.data.tracking.core.service.Update<P>> updates, 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, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, setSortPositionStrategy, 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
delete, readAll, readAll, readAll, readAllByContextId, readByContextId, updateSort
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Constructor Details
-
DefaultCustomerService
public DefaultCustomerService(CustomerRepository<com.broadleafcommerce.data.tracking.core.Trackable> customerRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, CustomerConfigurationProperties customerProperties, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
-
-
Method Details
-
readByContextIdOpt
public Optional<P> readByContextIdOpt(@NonNull String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomerService
Read a single instance of an entity in the form of a business domain.- Specified by:
readByContextIdOpt
in interfaceCustomerService<P extends Customer>
- Parameters:
id
- The context id for the entity. This is the id by which the business recognizes the item.context
- Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.- Returns:
- an
Optional
containing the narrowed entity instance in the form of a business instance if found,Optional.empty()
otherwise
-
readAllByFullName
@NonNull public org.springframework.data.domain.Page<P> readAllByFullName(@NonNull String nameQuery, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomerService
Searches for customers in the data store whoseCustomer#name
matches the givennameQuery
. Ignores case.- Specified by:
readAllByFullName
in interfaceCustomerService<P extends Customer>
- Parameters:
nameQuery
- the name to search forfilters
- An RSQL filter used to narrow query results. May beEmptyNode
if no filters should be applied.page
- the requested page of results from the databasecontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- the customers in the data store whose
Customer#name
matches the givennameQuery
. Ignores case.
-
readAllByEmail
@NonNull public List<P> readAllByEmail(@NonNull Set<String> emails, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomerService
Searches for customers in the data store whoseCustomer.email
contains in the givenemails
. Ignores case.- Specified by:
readAllByEmail
in interfaceCustomerService<P extends Customer>
- Parameters:
emails
- the set of emails to search forcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- the customers in the data store whose
Customer.email
contains in the givenemails
. Ignores case.
-
readAllUniqueIds
@NonNull public List<String> readAllUniqueIds(int page, @NonNull cz.jirutka.rsql.parser.ast.Node filters) Description copied from interface:CustomerService
Retrieves a list of unique customer context IDs no larger than page. It is expected that any appropriate offset is achieved through criteria designated infilters
.- Specified by:
readAllUniqueIds
in interfaceCustomerService<P extends Customer>
- Parameters:
page
- the requested page of results from the database. -1 indicates no limit.filters
- An RSQL filter used to narrow query results. May beEmptyNode
if no filters should be applied.- Returns:
- unique customer IDs
-
streamAll
public Stream<P> streamAll(@NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Sort sort, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomerService
Stream a list of customers matching the provided filters- Specified by:
streamAll
in interfaceCustomerService<P extends Customer>
- Parameters:
filters
- An RSQL filter used to narrow query results. May beEmptyNode
if no filters should be applied.sort
- The string containing the structured list of sorts to apply. May beSort.unsorted()
contextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- A stream of customers matching the filters.
-
readCustomersPagingStream
public Stream<P> readCustomersPagingStream(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomerService
Reads all customers matching the given filters. In case filters are empty, all customers are returned.- Specified by:
readCustomersPagingStream
in interfaceCustomerService<P extends Customer>
- Parameters:
filters
- additional filters to apply in the querycontextInfo
- Request context information around sandbox and multitenant state- Returns:
- the customers matching the given filters
-
readByEmail
public Optional<P> readByEmail(@NonNull String email, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomerService
Find a customer by email. Note: While e-mail is guaranteed to be unique per customer context, this is not guaranteed across multiple customer contexts. Therefore, thecontextInfo
argument is required.- Specified by:
readByEmail
in interfaceCustomerService<P extends Customer>
- Parameters:
email
- The email to search forcontextInfo
- The current context- Returns:
- The customer associated with the supplied email address.
-
update
-
updateAll
-
updateAllAllowingPartialSuccess
-
replace
-
replaceAll
-
replaceAllAllowingPartialSuccess
-
create
-
createAll
-
createAllAllowingPartialSuccess
-
handleEmailAsUsername
Assign thecustomer
's username to match their email whenCustomerConfigurationProperties
is configured with email as username.- Parameters:
customer
- the customer for which to handle email as username
-
handleEmailAsUsernameUpdate
Adjust thecustomer
update for the username to match their email whenCustomerConfigurationProperties
is configured with email as username.- Parameters:
customer
- the customer update for which to handle email as username
-
handleAccountMemberUpdate
protected void handleAccountMemberUpdate(@NonNull P customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reflect thecustomer
updates to their correspondingAccountMember
instances, namely the full name and email updates.- Parameters:
customer
- the customer object containing the updatescontext
- context information surrounding sandboxing and multitenant state
-
getCustomerRepository
protected CustomerRepository<com.broadleafcommerce.data.tracking.core.Trackable> getCustomerRepository() -
getCustomerProperties
-
getParser
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> getParser() -
setAccountMemberService
@Autowired @Lazy public void setAccountMemberService(AccountMemberService<AccountMember> accountMemberService) -
getAccountMemberService
-