本文介绍了触发Activiti工作流程以使任务处于ReceiveTask循环中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Activiti工作流程,其中包含一个ReceiveTask,用于对任务进行分组。我有一个侦听器,该侦听器在ReceiveTask的事件开始时触发,在该事件中,我检查新添加的任务的属性,以查看ReceiveTask中是否有其他具有相同属性的任务。如果是,那么我想触发它​​们全部移至下一步。

I have an Activiti workflow that contains a ReceiveTask where I'm grouping tasks. I have a Listener that triggers on the event start of the ReceiveTask where I check the property of the newly added task to see if others with the same properties are in the ReceiveTask. If yes, then I want to trigger them all to move to the next step.

<receiveTask id="IssuePost" name="Issue Post">
  <extensionElements>
    <activiti:executionListener event="start" delegateExpression="${IssuePost}"></activiti:executionListener>
  </extensionElements>
</receiveTask>

当任务移到ReceiveTask时,我的Java侦听器类IssuePost被调用。我可以获取该ReceiveTask中其他任务的列表。我在触发任务转到工作流程的下一步时遇到问题。在任务上调用信号时,我陷入了一个循环。在Alfresco / Activiti放弃并引发异常之前,IssuePost侦听器会不断被无限循环触发。

My Java Listener class IssuePost gets called when the task moves to the ReceiveTask just fine. I can get the list of other tasks sitting in that ReceiveTask. I'm having a problem triggering the tasks to move to the next step in the workflow. I get caught in a loop when calling "signal" on the tasks. The IssuePost listener keeps on getting triggered in an infinite loop until Alfresco/Activiti gives up and throws an exception.

List<NodeRef> siblingNodes = searchService.selectNodes( parent, xpath, null, namespacePrefixResolver, false );
if( siblingNodes.size() == batchCount )
{
    for( int i=0; i < siblingNodes.size(); i++ )
    {
        List<WorkflowInstance> workflows = workflowService.getWorkflowsForContent( siblingNodes.get( i ), true );
        // this line causes the loop.
        workflowService.signal( workflows.get(0).getId(), null );

我如何在ReceiveTask中发信号通知任务,使其移至工作流程的下一步而不触发我听众?从ReceiveTask到下一步骤只有一个流程。

How can I signal the tasks in the ReceiveTask to move to the next step in the workflow without triggering my listener? There's only one flow out of the ReceiveTask to the next step in the workflow.

推荐答案

查看 InvitationServiceImpl 我看到以下有用的代码段:

Looking at the InvitationServiceImpl I see the following useful snippet:

    List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(startTask.getPath().getId());
    if(tasks.size()==1)
    {
        WorkflowTask task = tasks.get(0);
        if(taskTypeMatches(task, taskTypes))
        {
            if(properties != null)
            {
                workflowService.updateTask(task.getId(), properties, null, null);
            }
            workflowService.endTask(task.getId(), transition);
            return;
        }
    }

因此,您需要让任务本身进行更新或结束甚至开始。

So you need to have the task itself to update or end or even start.

或者在您的情况下,查找在开始之后的下一个转换,并用信号代替空值。

Or maybe in your case, lookup the next transition which is after start and signal that one instead of null.

这篇关于触发Activiti工作流程以使任务处于ReceiveTask循环中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 01:16