use of pl.com.bottega.erp.sales.domain.Order in project ddd-cqrs-sample by BottegaIT.
the class OrderShipmentStatusTrackerSaga method completeIfPossible.
private void completeIfPossible() {
if (data.getOrderId() != null && data.getShipmentId() != null && data.getShipmentReceived()) {
Order shippedOrder = orderRepository.load(data.getOrderId());
shippedOrder.archive();
orderRepository.save(shippedOrder);
markAsCompleted();
}
}
use of pl.com.bottega.erp.sales.domain.Order in project ddd-cqrs-sample by BottegaIT.
the class AddProductToOrderCommandHandler method handle.
@Override
public Void handle(AddProductToOrderCommand command) {
Product product = productRepository.load(command.getProductId());
Order order = orderRepository.load(command.getOrderId());
order.addProduct(product, command.getQuantity());
orderRepository.save(order);
return null;
}
use of pl.com.bottega.erp.sales.domain.Order 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.Order 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);
}
use of pl.com.bottega.erp.sales.domain.Order in project ddd-cqrs-sample by BottegaIT.
the class PurchaseApplicationService method createNewOrder.
/**
* Sample usage of factory and repository
*
* @throws OrderCreationException
*/
public void createNewOrder() throws OrderCreationException {
Client client = loadClient(systemUser.getUserId());
Order order = orderFactory.crateOrder(client);
orderRepository.persist(order);
}
Aggregations