Search in sources :

Example 1 with PromotionMessageDTO

use of org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO in project BroadleafCommerce by BroadleafCommerce.

the class CartMessageOrderItemServiceExtensionHandler method gatherProductCartMessages.

protected List<String> gatherProductCartMessages(OrderItem orderItem) {
    List<String> cartMessages = new ArrayList<>();
    if (DiscreteOrderItem.class.isAssignableFrom(orderItem.getClass())) {
        DiscreteOrderItem discreteOrderItem = (DiscreteOrderItem) orderItem;
        Product product = discreteOrderItem.getProduct();
        for (PromotionMessageGenerator generator : generators) {
            Map<String, List<PromotionMessageDTO>> promotionMessages = generator.generatePromotionMessages(product);
            List<PromotionMessageDTO> messageDTOs = new ArrayList<>();
            addPromotionMessagesForType(messageDTOs, promotionMessages.get(PromotionMessagePlacementType.CART.getType()));
            addPromotionMessagesForType(messageDTOs, promotionMessages.get(PromotionMessagePlacementType.EVERYWHERE.getType()));
            BLCPromotionMessageUtils.sortMessagesByPriority(messageDTOs);
            cartMessages.addAll(BLCPromotionMessageUtils.gatherMessagesFromDTOs(messageDTOs));
        }
    }
    return cartMessages;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) PromotionMessageGenerator(org.broadleafcommerce.core.promotionMessage.service.PromotionMessageGenerator) PromotionMessageDTO(org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with PromotionMessageDTO

use of org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO in project BroadleafCommerce by BroadleafCommerce.

the class PromotionMessageVariableExpression method getProductPromotionMessages.

public List<PromotionMessageDTO> getProductPromotionMessages(Product product, String... placements) {
    List<String> filteredPlacements = filterInvalidPlacements(placements);
    if (!filteredPlacements.contains(PromotionMessagePlacementType.EVERYWHERE.getType())) {
        filteredPlacements.add(PromotionMessagePlacementType.EVERYWHERE.getType());
    }
    Map<String, List<PromotionMessageDTO>> promotionMessages = new MultiValueMap();
    for (PromotionMessageGenerator generator : generators) {
        promotionMessages.putAll(generator.generatePromotionMessages(product));
    }
    List<PromotionMessageDTO> filteredMessages = BLCPromotionMessageUtils.filterPromotionMessageDTOsByTypes(promotionMessages, filteredPlacements);
    BLCPromotionMessageUtils.sortMessagesByPriority(filteredMessages);
    return filteredMessages;
}
Also used : PromotionMessageGenerator(org.broadleafcommerce.core.promotionMessage.service.PromotionMessageGenerator) PromotionMessageDTO(org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO) ArrayList(java.util.ArrayList) List(java.util.List) MultiValueMap(org.apache.commons.collections.map.MultiValueMap)

Example 3 with PromotionMessageDTO

use of org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO in project BroadleafCommerce by BroadleafCommerce.

the class PromotionMessageDTOServiceImpl method convertPromotionMessagesToDTOs.

@Override
public Map<String, List<PromotionMessageDTO>> convertPromotionMessagesToDTOs(Set<PromotionMessage> promotionMessages, Offer offer) {
    MultiValueMap promotionMessageDTOs = new MultiValueMap();
    for (PromotionMessage message : promotionMessages) {
        PromotionMessageDTO dto = new PromotionMessageDTO(message);
        CustomerRuleHolder customerRuleHolder = buildCustomerRuleHolder(offer);
        dto.setCustomerRuleHolder(customerRuleHolder);
        promotionMessageDTOs.put(dto.getMessagePlacement(), dto);
    }
    return promotionMessageDTOs;
}
Also used : PromotionMessage(org.broadleafcommerce.core.promotionMessage.domain.PromotionMessage) CustomerRuleHolder(org.broadleafcommerce.profile.core.dto.CustomerRuleHolder) PromotionMessageDTO(org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO) MultiValueMap(org.apache.commons.collections.map.MultiValueMap)

Aggregations

PromotionMessageDTO (org.broadleafcommerce.core.promotionMessage.dto.PromotionMessageDTO)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MultiValueMap (org.apache.commons.collections.map.MultiValueMap)2 PromotionMessageGenerator (org.broadleafcommerce.core.promotionMessage.service.PromotionMessageGenerator)2 Product (org.broadleafcommerce.core.catalog.domain.Product)1 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)1 PromotionMessage (org.broadleafcommerce.core.promotionMessage.domain.PromotionMessage)1 CustomerRuleHolder (org.broadleafcommerce.profile.core.dto.CustomerRuleHolder)1