ResultsCache cache,
Class<?> columnType,
Object inlineKey) {
PortfolioGridRow row = _rows.get(rowIndex);
ComputationTargetReference target = row.getTarget();
ComputationTargetType targetType = target.getType();
// TODO do I need to use the target type to figure out the row type? can I just have different row types?
if (targetType.isTargetType(ComputationTargetType.POSITION)) {
RowTarget rowTarget;
UniqueId securityId = row.getSecurityId();
ResultsCache.Result securityResult = cache.getEntity(securityId.getObjectId());
Security security = (Security) securityResult.getValue();
if (isOtc(security)) {
// TODO different type for OTC positions with no trades? they are effecively the same but the client
// needs to know when a position has no trades because it will be a different endpoint to trigger editing
// OTC trades and positions are shown as a single row as there's always one trade per position
rowTarget = new OtcTradeTarget(row.getName(), row.getNodeId(), row.getPositionId(), row.getTradeId());
} else {
// Positions in fungible trades can contain multiple trades so the position has its own row and child rows
// for each of its trades
rowTarget = new PositionTarget(row.getName(), row.getNodeId(), row.getPositionId());
}
// TODO check the cache items for the position, security, underlying to find out whether they've been updated
return ResultsCell.forStaticValue(rowTarget, columnType, format);
} else if (targetType.isTargetType(ComputationTargetType.PORTFOLIO_NODE)) {
return ResultsCell.forStaticValue(new NodeTarget(row.getName(), row.getNodeId()), columnType, format);
} else if (targetType.isTargetType(ComputationTargetType.TRADE)) {
// only fungible trades have their own row, OTC trades are shown on the same row as their parent position
FungibleTradeTarget tradeTarget =
new FungibleTradeTarget(row.getName(), row.getNodeId(), row.getPositionId(), row.getTradeId());
// TODO check cache item for trade to see if it's been updated
return ResultsCell.forStaticValue(tradeTarget, columnType, format);