Search in sources :

Example 1 with PersistableOrderStatusHistory

use of com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory in project shopizer by shopizer-ecommerce.

the class OrderFacadeImpl method createOrderStatus.

@Override
public void createOrderStatus(PersistableOrderStatusHistory status, Long id, MerchantStore store) {
    Validate.notNull(status, "OrderStatusHistory must not be null");
    Validate.notNull(id, "Order id must not be null");
    Validate.notNull(store, "MerchantStore must not be null");
    // retrieve original order
    Order order = orderService.getOrder(id, store);
    if (order == null) {
        throw new ResourceNotFoundException("Order with id [" + id + "] does not exist for merchant [" + store.getCode() + "]");
    }
    try {
        OrderStatusHistory history = new OrderStatusHistory();
        history.setComments(status.getComments());
        history.setDateAdded(DateUtil.getDate(status.getDate()));
        history.setOrder(order);
        history.setStatus(status.getStatus());
        orderService.addOrderStatusHistory(order, history);
    } catch (Exception e) {
        throw new ServiceRuntimeException("An error occured while converting orderstatushistory", e);
    }
}
Also used : ShopOrder(com.salesmanager.shop.model.order.ShopOrder) Order(com.salesmanager.core.model.order.Order) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ReadableOrderStatusHistory(com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory) PersistableOrderStatusHistory(com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory) OrderStatusHistory(com.salesmanager.core.model.order.orderstatus.OrderStatusHistory) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ServiceException(com.salesmanager.core.business.exception.ServiceException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ConversionException(com.salesmanager.core.business.exception.ConversionException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Aggregations

ConversionException (com.salesmanager.core.business.exception.ConversionException)1 ServiceException (com.salesmanager.core.business.exception.ServiceException)1 Order (com.salesmanager.core.model.order.Order)1 OrderStatusHistory (com.salesmanager.core.model.order.orderstatus.OrderStatusHistory)1 ShopOrder (com.salesmanager.shop.model.order.ShopOrder)1 PersistableOrderStatusHistory (com.salesmanager.shop.model.order.history.PersistableOrderStatusHistory)1 ReadableOrderStatusHistory (com.salesmanager.shop.model.order.history.ReadableOrderStatusHistory)1 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)1 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)1