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);
}
}
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;
}
Aggregations