use of com.salesmanager.shop.populator.order.ReadableOrderProductPopulator in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method setOrderProductList.
private void setOrderProductList(final Order order, final Locale locale, final MerchantStore store, final Language language, final com.salesmanager.shop.model.order.v0.ReadableOrder readableOrder) throws ConversionException {
List<ReadableOrderProduct> orderProducts = new ArrayList<ReadableOrderProduct>();
for (OrderProduct p : order.getOrderProducts()) {
ReadableOrderProductPopulator orderProductPopulator = new ReadableOrderProductPopulator();
orderProductPopulator.setLocale(locale);
orderProductPopulator.setProductService(productService);
orderProductPopulator.setPricingService(pricingService);
orderProductPopulator.setimageUtils(imageUtils);
ReadableOrderProduct orderProduct = new ReadableOrderProduct();
orderProductPopulator.populate(p, orderProduct, store, language);
// image
// attributes
orderProducts.add(orderProduct);
}
readableOrder.setProducts(orderProducts);
}
use of com.salesmanager.shop.populator.order.ReadableOrderProductPopulator in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method getReadableOrder.
@Override
public com.salesmanager.shop.model.order.v0.ReadableOrder getReadableOrder(Long orderId, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Order modelOrder = orderService.getOrder(orderId, store);
if (modelOrder == null) {
throw new ResourceNotFoundException("Order not found with id " + orderId);
}
com.salesmanager.shop.model.order.v0.ReadableOrder readableOrder = new com.salesmanager.shop.model.order.v0.ReadableOrder();
Long customerId = modelOrder.getCustomerId();
if (customerId != null) {
ReadableCustomer readableCustomer = customerFacade.getCustomerById(customerId, store, language);
if (readableCustomer == null) {
LOGGER.warn("Customer id " + customerId + " not found in order " + orderId);
} else {
readableOrder.setCustomer(readableCustomer);
}
}
try {
readableOrderPopulator.populate(modelOrder, readableOrder, store, language);
// order products
List<ReadableOrderProduct> orderProducts = new ArrayList<ReadableOrderProduct>();
for (OrderProduct p : modelOrder.getOrderProducts()) {
ReadableOrderProductPopulator orderProductPopulator = new ReadableOrderProductPopulator();
orderProductPopulator.setProductService(productService);
orderProductPopulator.setPricingService(pricingService);
orderProductPopulator.setimageUtils(imageUtils);
ReadableOrderProduct orderProduct = new ReadableOrderProduct();
orderProductPopulator.populate(p, orderProduct, store, language);
orderProducts.add(orderProduct);
}
readableOrder.setProducts(orderProducts);
} catch (Exception e) {
throw new ServiceRuntimeException("Error while getting order [" + orderId + "]");
}
return readableOrder;
}
Aggregations