Search in sources :

Example 1 with OrderMultishipOptionDTO

use of org.broadleafcommerce.core.order.service.call.OrderMultishipOptionDTO in project BroadleafCommerce by BroadleafCommerce.

the class OrderMultishipOptionServiceImpl method saveOrderMultishipOptions.

@Override
public void saveOrderMultishipOptions(Order order, List<OrderMultishipOptionDTO> optionDTOs) {
    Map<Long, OrderMultishipOption> currentOptions = new HashMap<Long, OrderMultishipOption>();
    for (OrderMultishipOption option : findOrderMultishipOptions(order.getId())) {
        currentOptions.put(option.getId(), option);
    }
    List<OrderMultishipOption> orderMultishipOptions = new ArrayList<OrderMultishipOption>();
    for (OrderMultishipOptionDTO dto : optionDTOs) {
        OrderMultishipOption option = currentOptions.get(dto.getId());
        if (option == null) {
            option = orderMultishipOptionDao.create();
        }
        option.setOrder(order);
        option.setOrderItem(orderItemService.readOrderItemById(dto.getOrderItemId()));
        if (dto.getAddressId() != null) {
            option.setAddress(addressService.readAddressById(dto.getAddressId()));
        } else {
            option.setAddress(null);
        }
        if (dto.getFulfillmentOptionId() != null) {
            option.setFulfillmentOption(fulfillmentOptionService.readFulfillmentOptionById(dto.getFulfillmentOptionId()));
        } else {
            option.setFulfillmentOption(null);
        }
        orderMultishipOptions.add(option);
    }
    for (OrderMultishipOption option : orderMultishipOptions) {
        save(option);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) OrderMultishipOption(org.broadleafcommerce.core.order.domain.OrderMultishipOption) OrderMultishipOptionDTO(org.broadleafcommerce.core.order.service.call.OrderMultishipOptionDTO)

Example 2 with OrderMultishipOptionDTO

use of org.broadleafcommerce.core.order.service.call.OrderMultishipOptionDTO in project BroadleafCommerce by BroadleafCommerce.

the class OrderMultishipOptionServiceImpl method getOrderMultishipOptionsFromDTOs.

@Override
public List<OrderMultishipOption> getOrderMultishipOptionsFromDTOs(Order order, List<OrderMultishipOptionDTO> optionDtos) {
    List<OrderMultishipOption> orderMultishipOptions = new ArrayList<OrderMultishipOption>();
    for (OrderMultishipOptionDTO optionDto : optionDtos) {
        OrderMultishipOption option = new OrderMultishipOptionImpl();
        if (optionDto.getAddressId() != null) {
            option.setAddress(addressService.readAddressById(optionDto.getAddressId()));
        }
        if (optionDto.getFulfillmentOptionId() != null) {
            option.setFulfillmentOption(fulfillmentOptionService.readFulfillmentOptionById(optionDto.getFulfillmentOptionId()));
        }
        option.setId(optionDto.getId());
        option.setOrder(order);
        option.setOrderItem(orderItemService.readOrderItemById(optionDto.getOrderItemId()));
        orderMultishipOptions.add(option);
    }
    return orderMultishipOptions;
}
Also used : OrderMultishipOptionImpl(org.broadleafcommerce.core.order.domain.OrderMultishipOptionImpl) ArrayList(java.util.ArrayList) OrderMultishipOption(org.broadleafcommerce.core.order.domain.OrderMultishipOption) OrderMultishipOptionDTO(org.broadleafcommerce.core.order.service.call.OrderMultishipOptionDTO)

Aggregations

ArrayList (java.util.ArrayList)2 OrderMultishipOption (org.broadleafcommerce.core.order.domain.OrderMultishipOption)2 OrderMultishipOptionDTO (org.broadleafcommerce.core.order.service.call.OrderMultishipOptionDTO)2 HashMap (java.util.HashMap)1 OrderMultishipOptionImpl (org.broadleafcommerce.core.order.domain.OrderMultishipOptionImpl)1