this.taskId = taskId;
}
@SuppressWarnings({"unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
TaskEntity task = Context
.getCommandContext()
.getTaskManager()
.findTaskById(taskId);
List<IdentityLink> identityLinks = (List) task.getIdentityLinks();
// assignee is not part of identity links in the db.
// so if there is one, we add it here.
// @Tom: we discussed this long on skype and you agreed ;-)
// an assignee *is* an identityLink, and so must it be reflected in the API
//
// Note: we cant move this code to the TaskEntity (which would be cleaner),
// since the task.delete cascased to all associated identityLinks
// and of course this leads to exception while trying to delete a non-existing identityLink
if (task.getAssignee() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setUserId(task.getAssignee());
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setUserId(task.getOwner());
identityLink.setType(IdentityLinkType.OWNER);
identityLinks.add(identityLink);
}
return (List) task.getIdentityLinks();
}