List<Order> orders = new ArrayList<Order>();
for (int j = 0; j < request.getOrders(); j++) {
Order order = new Order();
order.setOn(timestampGenerator.getNow());
String oId = request.getId() + "-" + request.getIndex() + "-" + j;
order.setId(oId);
for (int i = 0; i < request.getItems(); i++) {
OrderItem item = new OrderItem();
item.setName(ITEM_NAME_PREFIX + i);
item.setPrice(new BigDecimal(i));
item.setId(oId + "-" + i);
order.getItems().add(item);
}
logger.debug("Saving Order: " + order);
dao.saveOder(request, order);
orders.add(order);
}
logger.debug("Delete Orders and Order Items for: " + request);
for (Order order : orders) {
logger.debug("Delete Order Items: " + order.getId());
dao.removeOderItems(order.getId());
logger.debug("Delete Order: " + request.getId());
dao.removeOders(request.getId());
}