コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="activitiEvent"></param>
        /// <returns></returns>
        public static string GetPrefix(IActivitiEvent activitiEvent)
        {
            if (IsProcessEvent(activitiEvent))
            {
                return(PROCESS_EVENT_PREFIX);
            }
            else if (IsTaskEvent(activitiEvent))
            {
                return(TASK_EVENT_PREFIX);
            }
            else if (IsIdentityLinkEntityEvent(activitiEvent))
            {
                IIdentityLink identityLinkEntity = (IIdentityLink)((IActivitiEntityEvent)activitiEvent).Entity;
                if (IsCandidateUserEntity(identityLinkEntity))
                {
                    return(TASK_CANDIDATE_USER_EVENT_PREFIX);
                }
                else if (IsCandidateGroupEntity(identityLinkEntity))
                {
                    return(TASK_CANDIDATE_GROUP_EVENT_PREFIX);
                }
            }

            return(EVENT_PREFIX);
        }
コード例 #2
0
        protected internal virtual HistoryEvent CreateHistoricIdentityLinkEvt(IIdentityLink identityLink, HistoryEventTypes eventType)
        {
            // create historic identity link event
            HistoricIdentityLinkLogEventEntity evt = NewIdentityLinkEventEntity();

            // Mapping all the values of identity link to HistoricIdentityLinkEvent
            InitHistoricIdentityLinkEvent(evt, identityLink, eventType);
            return(evt);
        }
コード例 #3
0
        public virtual void testCandidateGroupLink()
        {
            try
            {
                identityService.AuthenticatedUserId = "demo";

                runtimeService.StartProcessInstanceByKey("IdentityLinksProcess");

                string taskId = taskService.CreateTaskQuery().First().Id;

                taskService.AddCandidateGroup(taskId, "muppets");

                IList <IIdentityLink> identityLinks = taskService.GetIdentityLinksForTask(taskId);
                IIdentityLink         identityLink  = identityLinks[0];

                Assert.AreEqual("muppets", identityLink.GroupId);
                Assert.IsNull("kermit", identityLink.UserId);
                Assert.AreEqual(IdentityLinkType.Candidate, identityLink.Type);
                Assert.AreEqual(taskId, identityLink.TaskId);

                Assert.AreEqual(1, identityLinks.Count);

                if (processEngineConfiguration.HistoryLevel.Id >= ProcessEngineConfigurationImpl.HistorylevelFull)
                {
                    IList <IEvent> taskEvents = taskService.GetTaskEvents(taskId);
                    Assert.AreEqual(1, taskEvents.Count);
                    IEvent taskEvent = taskEvents[0];
                    Assert.AreEqual(EventFields.ActionAddGroupLink, taskEvent.Action);
                    IList <string> taskEventMessageParts = taskEvent.MessageParts;
                    Assert.AreEqual("muppets", taskEventMessageParts[0]);
                    Assert.AreEqual(IdentityLinkType.Candidate, taskEventMessageParts[1]);
                    Assert.AreEqual(2, taskEventMessageParts.Count);
                }

                taskService.DeleteCandidateGroup(taskId, "muppets");

                if (processEngineConfiguration.HistoryLevel.Id >= ProcessEngineConfigurationImpl.HistorylevelFull)
                {
                    IList <IEvent> taskEvents = taskService.GetTaskEvents(taskId);
                    IEvent         taskEvent  = findTaskEvent(taskEvents, EventFields.ActionDeleteGroupLink);
                    Assert.AreEqual(EventFields.ActionDeleteGroupLink, taskEvent.Action);
                    IList <string> taskEventMessageParts = taskEvent.MessageParts;
                    Assert.AreEqual("muppets", taskEventMessageParts[0]);
                    Assert.AreEqual(IdentityLinkType.Candidate, taskEventMessageParts[1]);
                    Assert.AreEqual(2, taskEventMessageParts.Count);
                    Assert.AreEqual(2, taskEvents.Count);
                }

                Assert.AreEqual(0, taskService.GetIdentityLinksForTask(taskId).Count);
            }
            finally
            {
                identityService.ClearAuthentication();
            }
        }
コード例 #4
0
        public virtual void testOwnerLink()
        {
            ITask task = taskService.NewTask("task");

            task.Owner = "owner";
            taskService.SaveTask(task);

            IList <IIdentityLink> identityLinks = taskService.GetIdentityLinksForTask(task.Id);

            Assert.NotNull(identityLinks);
            Assert.AreEqual(1, identityLinks.Count);

            IIdentityLink identityLink = identityLinks[0];

            Assert.AreEqual(IdentityLinkType.Owner, identityLink.Type);
            Assert.AreEqual("owner", identityLink.UserId);
            Assert.AreEqual("task", identityLink.TaskId);

            taskService.DeleteTask(task.Id, true);
        }
コード例 #5
0
        public virtual void testCustomLinkGroupLink()
        {
            runtimeService.StartProcessInstanceByKey("IdentityLinksProcess");

            string taskId = taskService.CreateTaskQuery().First().Id;

            taskService.AddGroupIdentityLink(taskId, "muppets", "playing");

            IList <IIdentityLink> identityLinks = taskService.GetIdentityLinksForTask(taskId);
            IIdentityLink         identityLink  = identityLinks[0];

            Assert.AreEqual("muppets", identityLink.GroupId);
            Assert.IsNull("kermit", identityLink.UserId);
            Assert.AreEqual("playing", identityLink.Type);
            Assert.AreEqual(taskId, identityLink.TaskId);

            Assert.AreEqual(1, identityLinks.Count);

            taskService.DeleteGroupIdentityLink(taskId, "muppets", "playing");

            Assert.AreEqual(0, taskService.GetIdentityLinksForTask(taskId).Count);
        }
コード例 #6
0
        public virtual void testCandidateUserLink()
        {
            runtimeService.StartProcessInstanceByKey("IdentityLinksProcess");

            string taskId = taskService.CreateTaskQuery().First().Id;

            taskService.AddCandidateUser(taskId, "kermit");

            IList <IIdentityLink> identityLinks = taskService.GetIdentityLinksForTask(taskId);
            IIdentityLink         identityLink  = identityLinks[0];

            Assert.IsNull(identityLink.GroupId);
            Assert.AreEqual("kermit", identityLink.UserId);
            Assert.AreEqual(IdentityLinkType.Candidate, identityLink.Type);
            Assert.AreEqual(taskId, identityLink.TaskId);

            Assert.AreEqual(1, identityLinks.Count);

            taskService.DeleteCandidateUser(taskId, "kermit");

            Assert.AreEqual(0, taskService.GetIdentityLinksForTask(taskId).Count);
        }
コード例 #7
0
        protected internal virtual void InitHistoricIdentityLinkEvent(HistoricIdentityLinkLogEventEntity evt, IIdentityLink identityLink, HistoryEventTypes eventType)
        {
            if (!string.ReferenceEquals(identityLink.TaskId, null))
            {
                TaskEntity task = Context.CommandContext.TaskManager.FindTaskById(identityLink.TaskId);

                evt.ProcessDefinitionId = task.ProcessDefinitionId;

                if (task.ProcessDefinition != null)
                {
                    evt.ProcessDefinitionKey = task.ProcessDefinition.Key;
                }
            }

            if (!string.ReferenceEquals(identityLink.ProcessDefId, null))
            {
                evt.ProcessDefinitionId = identityLink.ProcessDefId;

                ProcessDefinitionEntity definition = Context.ProcessEngineConfiguration.DeploymentCache.FindProcessDefinitionFromCache(identityLink.ProcessDefId);
                evt.ProcessDefinitionKey = definition.Key;
            }

            evt.Time     = ClockUtil.CurrentTime;
            evt.Type     = identityLink.Type;
            evt.UserId   = identityLink.UserId;
            evt.GroupId  = identityLink.GroupId;
            evt.TaskId   = identityLink.TaskId;
            evt.TenantId = identityLink.TenantId;
            // There is a conflict in HistoryEventTypes for 'delete' keyword,
            // So HistoryEventTypes.IDENTITY_LINK_ADD /
            // HistoryEventTypes.IDENTITY_LINK_DELETE is provided with the event name
            // 'add-identity-link' /'delete-identity-link'
            // and changed to 'add'/'delete' (While inserting it into the database) on
            // Historic identity link add / delete event
            string operationType = "add";

            if (eventType.EventName.Equals(HistoryEventTypes.IdentityLinkDelete.EventName))
            {
                operationType = "delete";
            }

            evt.OperationType = operationType;
            evt.EventType     = eventType.EventName;
            evt.AssignerId    = Context.CommandContext.AuthenticatedUserId;
        }
コード例 #8
0
 public virtual HistoryEvent CreateHistoricIdentityLinkDeleteEvent(IIdentityLink identityLink)
 {
     return(CreateHistoricIdentityLinkEvt(identityLink, HistoryEventTypes.IdentityLinkDelete));
 }
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="identityLinkEntity"></param>
 /// <returns></returns>
 private static bool IsCandidateGroupEntity(IIdentityLink identityLinkEntity)
 {
     return(string.Compare(IdentityLinkType.CANDIDATE, identityLinkEntity.Type, true) == 0 && identityLinkEntity.GroupId != null);
 }