s_logger.info("Aggregation complete, about to persist...");
if (aggregatedPortfolio == null) {
s_logger.error("Portfolio " + portfolioName + " was not correctly aggregated by the Portfolio Aggregator");
System.exit(1);
}
SavePortfolio savePortfolio = new SavePortfolio(newFixedThreadPool, portfolioMaster, positionMaster);
if (split) {
for (PortfolioNode portfolioNode : aggregatedPortfolio.getRootNode().getChildNodes()) {
String splitPortfolioName = portfolioName + " (" + aggregationName + " " + portfolioNode.getName() + ")";
SimplePortfolioNode root = new SimplePortfolioNode("root");
root.addChildNode(portfolioNode);
Portfolio splitPortfolio = new SimplePortfolio(splitPortfolioName, root);
splitPortfolio.setAttributes(aggregatedPortfolio.getAttributes());
s_logger.info("Saving split portfolio " + portfolioName + "...");
savePortfolio.savePortfolio(splitPortfolio, true);
}
} else {
savePortfolio.savePortfolio(aggregatedPortfolio, true); // update matching named portfolio.
}
s_logger.info("Saved.");
// Shut down thread pool before returning
newFixedThreadPool.shutdown();