Class DefaultMarketingMessageResolver<P extends MarketingMessage,O extends Offer>
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.service.DefaultMarketingMessageResolver<P,O>
-
- All Implemented Interfaces:
MarketingMessageResolver<P,O>
public class DefaultMarketingMessageResolver<P extends MarketingMessage,O extends Offer> extends Object implements MarketingMessageResolver<P,O>
- Author:
- Jon Fleschler (jfleschler)
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTRIBUTES_ORDER_LINE_ITEMprotected MarketingMessageOfferCandidateService<O>marketingMessageOfferCandidateServiceprotected MarketingMessageService<P>marketingMessageServiceprotected OfferCandidateService<O>offerCandidateServiceprotected com.broadleafcommerce.common.extension.TypeFactorytypeFactory
-
Constructor Summary
Constructors Constructor Description DefaultMarketingMessageResolver(MarketingMessageService<P> marketingMessageService, OfferCandidateService<O> offerCandidateService, MarketingMessageOfferCandidateService<O> marketingMessageOfferCandidateService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected @NotNull MarketingMessageResponse<P>buildMarketingMessageResponse(org.springframework.util.MultiValueMap<String,String> associatedOfferIds, List<P> messages, Integer maxResults)Deprecated.deprecated as of 1.7, usebuildMarketingMessageResponse(MultiValueMap, MultiValueMap, List, Integer)insteadprotected @NotNull MarketingMessageResponse<P>buildMarketingMessageResponse(org.springframework.util.MultiValueMap<String,String> associatedTargetProductOfferIds, org.springframework.util.MultiValueMap<String,String> associatedQualifierProductOfferIds, List<P> messages, Integer maxResults)MarketingMessageResponse<P>findAllMarketingMessagesForRequest(MarketingMessageRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Finds all of theMarketingMessagesfor the providedMarketingMessageRequest.protected List<P>findAllMessagesForItemAsQualifierOrTarget(MarketingMessageRequest request, Set<O> candidateOffers, org.springframework.util.MultiValueMap<String,String> associatedOfferIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Deprecated.protected List<P>findAllMessagesForItemAsQualifierOrTarget(MarketingMessageRequest request, Set<O> candidateOffers, org.springframework.util.MultiValueMap<String,String> associatedTargetProductOfferIds, org.springframework.util.MultiValueMap<String,String> associatedQualifierProductOfferIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Find all marketing messages from offers where the line item is used either as the target of the offer, or used to qualify for the offer.protected booleanisItemOffer(Offer offer)Checks if theOffertargets an order or fulfillment group item.protected booleanisItemQualifier(Offer offer, EnhancedLineItem item)Checks if any of the rules inOffer.getItemQualifierCriteria()matches the line item on this request in order to determine if the line item can be used to qualify for the offer.protected booleanisItemTarget(Offer offer, EnhancedLineItem item)If this is an item offer, checks if any of the rules inOffer.getTargetItemCriteria()matches the line item on this request in order to determine if the line item can be used as the target for the offer.protected voidmergeProductMessageMaps(Map<String,List<P>> map, Map<String,P> productToMessageMap, Integer maxResults)protected ItemCriteriamodifyItemCriteria(Offer offer, ItemCriteria itemCriteria)In certain cases (i.e.
-
-
-
Field Detail
-
ATTRIBUTES_ORDER_LINE_ITEM
public static final String ATTRIBUTES_ORDER_LINE_ITEM
- See Also:
- Constant Field Values
-
marketingMessageService
protected final MarketingMessageService<P extends MarketingMessage> marketingMessageService
-
offerCandidateService
protected final OfferCandidateService<O extends Offer> offerCandidateService
-
marketingMessageOfferCandidateService
protected final MarketingMessageOfferCandidateService<O extends Offer> marketingMessageOfferCandidateService
-
typeFactory
protected final com.broadleafcommerce.common.extension.TypeFactory typeFactory
-
-
Constructor Detail
-
DefaultMarketingMessageResolver
public DefaultMarketingMessageResolver(MarketingMessageService<P> marketingMessageService, OfferCandidateService<O> offerCandidateService, MarketingMessageOfferCandidateService<O> marketingMessageOfferCandidateService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Detail
-
findAllMarketingMessagesForRequest
public MarketingMessageResponse<P> findAllMarketingMessagesForRequest(MarketingMessageRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:MarketingMessageResolverFinds all of theMarketingMessagesfor the providedMarketingMessageRequest. This will find all the activeOffersfirst, then split them into two, filtered groups: Those that treat theMarketingMessageRequest.getLineItems()as a target and those that treat it as a qualifier. Then, it will fetch all messages for those offers, grouping byMarketingMessageLocationType, filter by active date range and sort them by priority.- Specified by:
findAllMarketingMessagesForRequestin interfaceMarketingMessageResolver<P extends MarketingMessage,O extends Offer>- Parameters:
request- anMarketingMessageRequestcontaining the parameters by which the results will be filteredcontextInfo- the context information around sandboxing and multitenant state- Returns:
- the marketing messages for the given item in priority order
-
buildMarketingMessageResponse
@NotNull @Deprecated protected @NotNull MarketingMessageResponse<P> buildMarketingMessageResponse(org.springframework.util.MultiValueMap<String,String> associatedOfferIds, List<P> messages, Integer maxResults)
Deprecated.deprecated as of 1.7, usebuildMarketingMessageResponse(MultiValueMap, MultiValueMap, List, Integer)instead
-
buildMarketingMessageResponse
@NotNull protected @NotNull MarketingMessageResponse<P> buildMarketingMessageResponse(org.springframework.util.MultiValueMap<String,String> associatedTargetProductOfferIds, org.springframework.util.MultiValueMap<String,String> associatedQualifierProductOfferIds, List<P> messages, Integer maxResults)
-
mergeProductMessageMaps
protected void mergeProductMessageMaps(Map<String,List<P>> map, Map<String,P> productToMessageMap, Integer maxResults)
-
findAllMessagesForItemAsQualifierOrTarget
@Deprecated protected List<P> findAllMessagesForItemAsQualifierOrTarget(MarketingMessageRequest request, Set<O> candidateOffers, org.springframework.util.MultiValueMap<String,String> associatedOfferIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
findAllMessagesForItemAsQualifierOrTarget
protected List<P> findAllMessagesForItemAsQualifierOrTarget(MarketingMessageRequest request, Set<O> candidateOffers, org.springframework.util.MultiValueMap<String,String> associatedTargetProductOfferIds, org.springframework.util.MultiValueMap<String,String> associatedQualifierProductOfferIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Find all marketing messages from offers where the line item is used either as the target of the offer, or used to qualify for the offer.- Parameters:
request- anMarketingMessageRequestcontaining the parameters by which the results will be filteredcandidateOffers- the candidate offers to filter onassociatedTargetProductOfferIds- map of associated offers to target product idassociatedQualifierProductOfferIds- map of associated offers to qualifier product idcontextInfo- Context information around sandbox and multitenant state.- Returns:
- the list of marketing messages that qualify based on the associated offers and message type.
-
isItemOffer
protected boolean isItemOffer(Offer offer)
Checks if theOffertargets an order or fulfillment group item.- Parameters:
offer- theOfferto check- Returns:
- true if the offer targets an order or fulfillment group item
-
isItemQualifier
protected boolean isItemQualifier(Offer offer, EnhancedLineItem item)
Checks if any of the rules inOffer.getItemQualifierCriteria()matches the line item on this request in order to determine if the line item can be used to qualify for the offer.- Parameters:
offer- theOfferto checkitem- theEnhancedLineItemto check- Returns:
- true if a match is found in the qualifier criteria
-
isItemTarget
protected boolean isItemTarget(Offer offer, EnhancedLineItem item)
If this is an item offer, checks if any of the rules inOffer.getTargetItemCriteria()matches the line item on this request in order to determine if the line item can be used as the target for the offer. If the offer discount cannot apply to the sales price and the line item is on sale, then the item will not qualify as the offer target.- Parameters:
offer- theOfferto checkitem- theEnhancedLineItemto check- Returns:
- true if the line item can qualify as the target of the offer
-
modifyItemCriteria
protected ItemCriteria modifyItemCriteria(Offer offer, @Nullable ItemCriteria itemCriteria)
In certain cases (i.e. Fulfillment Group Item Offers) we need modify the rules so that they can be evaluated.- Parameters:
offer- theOfferto checkitemCriteria- theItemCriteriato modify- Returns:
- the potentially modified item criteria
-
-