/**
  * Adds a quantity of items to the given order for the given item id.
  *
  * @param order order to add item to
  * @param itemId id of item to add
  * @param quantity quantity to add
  * @param persist save changes immediately if true
  */
 public static void addItem(OrderDTO order, Integer itemId, BigDecimal quantity, boolean persist) {
   UserBL user = new UserBL(order.getUserId());
   addItem(
       itemId,
       quantity,
       user.getLanguage(),
       order.getUserId(),
       order.getCurrencyId(),
       order,
       null,
       persist);
 }
 /**
  * Adds a quantity of items to the given order for the given item id. Use the given price for the
  * addition.
  *
  * @param order order to add item to
  * @param itemId id of item to add
  * @param quantity quantity to add
  */
 public static void addItem(OrderDTO order, Integer itemId, Integer quantity, BigDecimal price) {
   UserBL user = new UserBL(order.getUserId());
   OrderLineDTO line = new OrderLineDTO();
   line.setItemId(itemId);
   line.setQuantity(quantity);
   line.setPrice(price);
   addItem(
       itemId,
       new BigDecimal(quantity),
       user.getLanguage(),
       order.getUserId(),
       order.getCurrencyId(),
       order,
       line,
       false);
 }
  public static void addLine(OrderDTO order, OrderLineDTO line, boolean persist) {
    if (persist)
      throw new IllegalArgumentException("persist is oboleted"); // TODO remove the argument
    UserBL user = new UserBL(order.getUserId());
    OrderLineDTO oldLine = order.getLine(line.getItemId());
    if (oldLine != null) {
      // get a copy of the old line
      oldLine = new OrderLineDTO(oldLine);
    }

    addItem(
        line.getItemId(),
        line.getQuantity(),
        user.getLanguage(),
        order.getUserId(),
        order.getCurrencyId(),
        order,
        line,
        persist);

    if (persist) {
      // generate NewQuantityEvent
      OrderLineDTO newLine = order.getLine(line.getItemId());
      OrderBL orderBl = new OrderBL();
      List<OrderLineDTO> oldLines = new ArrayList<OrderLineDTO>(1);
      List<OrderLineDTO> newLines = new ArrayList<OrderLineDTO>(1);
      if (oldLine != null) {
        oldLines.add(oldLine);
      }
      newLines.add(newLine);
      LOG.debug("Old line: %s", oldLine);
      LOG.debug("New line: %s", newLine);
      orderBl.checkOrderLineQuantities(
          oldLines, newLines, user.getEntity().getEntity().getId(), order.getId(), true);
    }
  }