/**
* Creates the output root data.
* @return the output root data, not null
*/
protected FlexiBean createRootData() {
FlexiBean out = super.createRootData();
PositionDocument doc = data().getPosition();
// REVIEW jonathan 2012-01-12 -- we are throwing away any adjuster that may be required, e.g. to apply
// normalisation to the time-series. This reproduces the previous behaviour but probably indicates that the
// time-series information is in the wrong place.
ObjectId tsObjectId = null;
Security security = doc.getPosition().getSecurityLink().resolveQuiet(data().getSecuritySource());
if (security != null && !security.getExternalIdBundle().isEmpty()) {
// Get the last price HTS for the security
HistoricalTimeSeriesSource htsSource = data().getHistoricalTimeSeriesSource();
HistoricalTimeSeries series = htsSource.getHistoricalTimeSeries(
MarketDataRequirementNames.MARKET_VALUE, doc.getPosition().getSecurity().getExternalIdBundle(), null, null, false, null, false, 0);
if (series != null) {
tsObjectId = series.getUniqueId().getObjectId();
}
}
out.put("positionDoc", doc);
out.put("position", doc.getPosition());
out.put("security", doc.getPosition().getSecurity());
out.put("timeSeriesId", tsObjectId);
out.put("deleted", !doc.isLatest());
out.put("attributes", doc.getPosition().getAttributes());
TradeAttributesModel tradeAttributesModel = getTradeAttributesModel();
out.put("tradeAttrModel", tradeAttributesModel);
return out;
}