return holdingResponse;
}
public CollectionResult findHoldingsByAccountId(Integer accountId, Integer page, Integer pageSize) {
CollectionResult collectionResults = new CollectionResult();
if (log.isDebugEnabled()) {
log.debug("TradingServiceFacade.findHoldingsByAccount: id=" + accountId);
}
List<Holding> holdingResponse = new ArrayList<Holding>();
collectionResults.setTotalRecords(tradingService.findCountOfHoldingsByAccountId(accountId));
List<org.springframework.nanotrader.data.domain.Holding> holdings = tradingService.findHoldingsByAccountId(accountId, getPage(page), getPageSize(pageSize));
if (holdings != null && holdings.size() > 0) {
Set<String> symbols = new HashSet<String>();
for (org.springframework.nanotrader.data.domain.Holding h: holdings) {
//get unique quotes symbols
symbols.add(h.getQuoteSymbol());
}
Map<String, Quote> currentQuotes = getCurrentQuotes(symbols);
for(org.springframework.nanotrader.data.domain.Holding h: holdings) {
Holding holding = new Holding();
mapper.map(h, holding, HOLDING_MAPPING);
holding.setQuote(currentQuotes.get(h.getQuoteSymbol()));
holdingResponse.add(holding);
}
}
if (log.isDebugEnabled()) {
log.debug("TradingServiceFacade.findHoldingsByAccountId completed");
}
collectionResults.setPage(getPage(page));
collectionResults.setPageSize(getPageSize(pageSize));
collectionResults.setResults(holdingResponse);
return collectionResults;
}