use of pl.com.bottega.erp.sales.domain.errors.OrderOperationException in project ddd-cqrs-sample by BottegaIT.
the class SubmitOrderCommandHandler method handle.
@Override
public Void handle(SubmitOrderCommand command) {
Order order = orderRepository.load(command.getOrderId());
Specification<Order> orderSpecification = generateSpecification(systemUser);
if (!orderSpecification.isSatisfiedBy(order))
throw new OrderOperationException("Order does not meet specification", order.getEntityId());
//Domain logic
order.submit();
//Domain service
Invoice invoice = invoicingService.issuance(order, generateTaxPolicy(systemUser));
orderRepository.save(order);
invoiceRepository.save(invoice);
return null;
}
use of pl.com.bottega.erp.sales.domain.errors.OrderOperationException in project ddd-cqrs-sample by BottegaIT.
the class PurchaseApplicationService method approveOrder.
/**
* Sample of the separation of domain logic in aggregate and domain logic in
* domain service
*
* @param orderId
*/
public void approveOrder(Long orderId) {
Order order = orderRepository.load(orderId);
Specification<Order> orderSpecification = generateSpecification(systemUser);
if (!orderSpecification.isSatisfiedBy(order))
throw new OrderOperationException("Order does not meet specification", order.getEntityId());
// Domain logic
order.submit();
// Domain service
Invoice invoice = invoicingService.issuance(order, generateTaxPolicy(systemUser));
invoiceRepository.save(invoice);
orderRepository.save(order);
}
Aggregations