// Identity link related history /// <summary> /// /// </summary> /// <param name="identityLink"></param> public virtual void RecordIdentityLinkCreated(IIdentityLinkEntity identityLink) { // It makes no sense storing historic counterpart for an identity-link // that is related // to a process-definition only as this is never kept in history if (IsHistoryLevelAtLeast(HistoryLevel.AUDIT) && (identityLink.ProcessInstanceId is object || identityLink.TaskId is object)) { IHistoricIdentityLinkEntity historicIdentityLinkEntity = HistoricIdentityLinkEntityManager.Create(); historicIdentityLinkEntity.Id = identityLink.Id; historicIdentityLinkEntity.GroupId = identityLink.GroupId; historicIdentityLinkEntity.ProcessInstanceId = identityLink.ProcessInstanceId; historicIdentityLinkEntity.TaskId = identityLink.TaskId; historicIdentityLinkEntity.Type = identityLink.Type; historicIdentityLinkEntity.UserId = identityLink.UserId; HistoricIdentityLinkEntityManager.Insert(historicIdentityLinkEntity, false); } }
public virtual IList <IIdentityLink> Execute(ICommandContext commandContext) { ITaskEntity task = commandContext.TaskEntityManager.FindById <ITaskEntity>(new KeyValuePair <string, object>("id", taskId)); IList <IIdentityLink> identityLinks = (IList <IIdentityLink>)task.IdentityLinks; // 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 cascaded to all associated identityLinks // and of course this leads to exception while trying to delete a // non-existing identityLink if (task.Assignee is object) { IIdentityLinkEntity identityLink = commandContext.IdentityLinkEntityManager.Create(); identityLink.UserId = task.Assignee; identityLink.Type = IdentityLinkType.ASSIGNEE; identityLink.TaskId = task.Id; identityLinks.Add(identityLink); } if (task.Owner is object) { IIdentityLinkEntity identityLink = commandContext.IdentityLinkEntityManager.Create(); identityLink.UserId = task.Owner; identityLink.TaskId = task.Id; identityLink.Type = IdentityLinkType.OWNER; identityLinks.Add(identityLink); } return((IList <IIdentityLink>)task.IdentityLinks); }