}
}
}
}
InvalidTradeException badOrder = new InvalidTradeException();
if (cntOrderForBuy < 1 || cntOrderForSell < 1) {
badOrder.setWithParams(Framework.Constants.SP_ER_ERROR, "Must select exactly one BUY and one SELL Order");
ErrorMgr.addError(badOrder);
throw badOrder;
}
if (cntOrderForBuy > 1) {
badOrder.setWithParams(Framework.Constants.SP_ER_ERROR, "User has selected more than 1 BUY Order");
ErrorMgr.addError(badOrder);
throw badOrder;
}
if (cntOrderForSell > 1) {
badOrder.setWithParams(Framework.Constants.SP_ER_ERROR, "User has selected more than 1 SELL Order");
ErrorMgr.addError(badOrder);
throw badOrder;
}
if (((Order)pBuyOrder.getObject()).getQuantity() != ((Order)pSellOrder.getObject()).getQuantity() || ((Order)pBuyOrder.getObject()).getPrice() != ((Order)pSellOrder.getObject()).getPrice() || StringUtils.notEquals(((Order)pBuyOrder.getObject()).getStockName(), ((Order)pSellOrder.getObject()).getStockName())) {
badOrder.setWithParams(Framework.Constants.SP_ER_ERROR, "Quantity, Price and StockName of BUY/SELL Order must be exact match");
ErrorMgr.addError(badOrder);
throw badOrder;
}
}