Class DefaultCustomerSegmentService<P extends CustomerSegment>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.customer.service.DefaultCustomerSegmentService<P>
- Type Parameters:
P- A type or subtype ofCustomerSegment
- All Implemented Interfaces:
CustomerSegmentService<P>,com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
public class DefaultCustomerSegmentService<P extends CustomerSegment>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements CustomerSegmentService<P>
Default implementation of
CustomerSegmentService-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCustomerSegmentService(CustomerSegmentRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected ResolveCustomerSegmentsRequestaugmentSegmentResolutionRequest(@NonNull ResolveCustomerSegmentsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Hookpoint to use to augment the data on aResolveCustomerSegmentsRequestin case additional data needs to be included from related entities likeCustomerAddressesthat the external caller may not know about or provide.protected CustomerSegmentRefbuildRefFromSegment(@NonNull CustomerSegment customerSegment) booleancanManuallyAddCustomerToSegment(String segmentId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Evaluates whether the customer segment with the given ID allows manually adding customers.protected CustomerSegmentRepository<com.broadleafcommerce.data.tracking.core.Trackable>getRepo()protected SegmentMemberService<SegmentMember,CustomerSegment> protected com.broadleafcommerce.rulesengine.expression.service.SpelRuleEvaluationServiceprotected com.broadleafcommerce.common.extension.TypeFactoryreadAllRuleBasedCustomerSegmentsByRuleEvaluationType(String evaluationType, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all the matchingCustomerSegmentsbyCustomerSegment.getCustomerSegmentType()andCustomerSegment.getRuleEvaluationType().resolveCustomerSegmentsForRequest(@NonNull ResolveCustomerSegmentsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) ResolvesCustomerSegmentsthat apply to a given request.protected List<CustomerSegmentRef>resolveDirectSegmentsForRequest(@NonNull ResolveCustomerSegmentsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected List<CustomerSegmentRef>resolvePrefetchedSegmentsForRequest(@NonNull ResolveCustomerSegmentsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Filters theprefetched segmentsto find those that match the request.protected List<CustomerSegmentRef>resolveRuleBasedSegmentsForRequest(@NonNull ResolveCustomerSegmentsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds all of therule-basedCustomerSegmentsthat have aCustomerSegment.getRuleEvaluationType()that matches the givenrequest.voidsetSegmentMemberService(SegmentMemberService<SegmentMember, CustomerSegment> segmentMemberService) voidsetSpelRuleEvaluationService(com.broadleafcommerce.rulesengine.expression.service.SpelRuleEvaluationService spelRuleEvaluationService) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Constructor Details
-
DefaultCustomerSegmentService
public DefaultCustomerSegmentService(CustomerSegmentRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
-
Method Details
-
resolveCustomerSegmentsForRequest
public ResolveCustomerSegmentResponse resolveCustomerSegmentsForRequest(@NonNull @NonNull ResolveCustomerSegmentsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomerSegmentServiceResolvesCustomerSegmentsthat apply to a given request.- Specified by:
resolveCustomerSegmentsForRequestin interfaceCustomerSegmentService<P extends CustomerSegment>- Parameters:
request- Request with user details for customer segments to target and be evaluated against.context- Additional multitenant and sandbox info.- Returns:
- The list of matching segments if any.
-
readAllRuleBasedCustomerSegmentsByRuleEvaluationType
public List<P> readAllRuleBasedCustomerSegmentsByRuleEvaluationType(String evaluationType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomerSegmentServiceReads all the matchingCustomerSegmentsbyCustomerSegment.getCustomerSegmentType()andCustomerSegment.getRuleEvaluationType().- Specified by:
readAllRuleBasedCustomerSegmentsByRuleEvaluationTypein interfaceCustomerSegmentService<P extends CustomerSegment>- Parameters:
evaluationType- The type of rule evaluation. SeeDefaultCustomerSegmentRuleEvaluationType.context- Additional sandbox and multitenant info.- Returns:
- The matching
CustomerSegments.
-
canManuallyAddCustomerToSegment
public boolean canManuallyAddCustomerToSegment(String segmentId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomerSegmentServiceEvaluates whether the customer segment with the given ID allows manually adding customers.As an example, using the default customer segment types,
CUSTOMER_SETandRULE_BASED, only sets support manually adding customers, as rule based segments are derived.- Specified by:
canManuallyAddCustomerToSegmentin interfaceCustomerSegmentService<P extends CustomerSegment>- Parameters:
segmentId- The ID of the segment to evaluatecontext- Context information regarding sandboxing and multitenant state- Returns:
trueif customers may be manually added to this segment, elsefalse
-
augmentSegmentResolutionRequest
protected ResolveCustomerSegmentsRequest augmentSegmentResolutionRequest(@NonNull @NonNull ResolveCustomerSegmentsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Hookpoint to use to augment the data on aResolveCustomerSegmentsRequestin case additional data needs to be included from related entities likeCustomerAddressesthat the external caller may not know about or provide. Typically, callers only use the information available on the auth token claims or request attributes like geo- location. Therefore, if there is a desire to have a rule-based segment with a rule targeting information such ashome address postal code, then this is the place to hydrate that information onto the request.By default, this method does nothing.
- Parameters:
request- The incoming request to augment.context- Additional tenant and sandbox info.- Returns:
- The augmented request.
-
resolveDirectSegmentsForRequest
protected List<CustomerSegmentRef> resolveDirectSegmentsForRequest(@NonNull @NonNull ResolveCustomerSegmentsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Parameters:
request- The request to resolve customer segments for a given contextcontext- Additional sandbox and multitenant info- Returns:
- The directly related segments matching the context
-
resolveRuleBasedSegmentsForRequest
protected List<CustomerSegmentRef> resolveRuleBasedSegmentsForRequest(@NonNull @NonNull ResolveCustomerSegmentsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds all of therule-basedCustomerSegmentsthat have aCustomerSegment.getRuleEvaluationType()that matches the givenrequest.- Parameters:
request- The request to resolve customer segments for a given contextcontext- Additional sandbox and multitenant info- Returns:
- The rule-based segments matching the context
-
resolvePrefetchedSegmentsForRequest
protected List<CustomerSegmentRef> resolvePrefetchedSegmentsForRequest(@NonNull @NonNull ResolveCustomerSegmentsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Filters theprefetched segmentsto find those that match the request. This will filter out anyDefaultCustomerSegmentRuleEvaluationType.OFFLINErule-basedCustomerSegmentsas those can't be evaluated in this context and should already be present on the auth token. Additionally, onlycustomer-setsegments that the user is a member of will be included.- Parameters:
request- The resolution request.context- Additional tenant and sandbox info.- Returns:
- The list of prefetched segments matching the request.
-
buildRefFromSegment
-
getRepo
-
setSegmentMemberService
@Autowired @Lazy public void setSegmentMemberService(SegmentMemberService<SegmentMember, CustomerSegment> segmentMemberService) -
getSegmentMemberService
-
setSpelRuleEvaluationService
@Autowired public void setSpelRuleEvaluationService(com.broadleafcommerce.rulesengine.expression.service.SpelRuleEvaluationService spelRuleEvaluationService) -
getSpelRuleEvaluationService
protected com.broadleafcommerce.rulesengine.expression.service.SpelRuleEvaluationService getSpelRuleEvaluationService() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-