需要有关 Alfresco 工作流程的帮助

发布于 2024-08-30 05:56:44 字数 6054 浏览 9 评论 0原文

你好,SO社区,

我没有在 Alfresco 论坛上获得任何帮助,我希望在这里能得到更多帮助。我们正在构建一个基于 Alfresco 和 jBPM 的应用程序,我已经定义了一个工作流程,但我要么定义错误,要么遗漏了某些内容,或者 Alfresco 与 jBPM 集成中存在错误,我需要帮助找出并修复它。问题是这样的:

我有一个高级工作流程,我正在尝试从 JavaScript 启动它。这是我用来启动工作流程的代码:

var nodeId = args.nodeid;
var document = search.findNode("workspace://SpacesStore/" + nodeId);
var workflowAction = actions.create("start-workflow");
workflowAction.parameters.workflowName = "jbpm$nmwf:MyWorkflow";
workflowAction.parameters["bpm:workflowDescription"] = "Please edit: " + document.name;
workflowAction.parameters["bpm:assignees"] = [people.getPerson("admin"), people.getPerson("andyg")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflowAction.parameters["bpm:workflowDueDate"] = futureDate;
workflowAction.execute(document);

这运行得很好,并且从起始节点的默认转换发送的电子邮件也很好。但是,当我在任务列表中查找工作流程时,它不在那里,但它在我的已完成任务列表中。从起始节点开始的默认转换(唯一的转换)指向具有四个转换的任务节点。

工作流程中有 8 个任务和 22 个转换。当我使用工作流控制台启动工作流并结束启动任务时,它会正确遵循默认启动节点转换到下一个任务。新任务显示在“显示任务”中,但不会显示在“显示我的任务”中(显然是因为该任务由于某种原因被标记为已完成,尽管它不在“结束”节点中)。任务是:

任务 ID:jbpm$111,名称:nmwf:submitInEditing,属性:18

如果我“显示过渡”,它看起来就像我所期望的那样:

path: jbpm$62-@ , node: In Editing , active: true
 task id: jbpm$111 , name: nmwf:submitInEditing, title: submitInEditing title , desc: submitInEditing description , properties: 18
 transition id: Submit for Approval , title: Submit for Approval
 transition id: Request Copyediting Review , title: Request Copyediting Review
 transition id: Request Legal Review , title: Request Legal Review
 transition id: Request Review , title: Request Review

我不想发布整个工作流程,因为它很大,但这里是前两个节点:

首先是泳道:

<swimlane name="initiator"></swimlane>
<swimlane name="Content Providers">
  <assignment actor-id="Content Providers"  class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
     <actor>#{bpm_assignees}</actor>
  </assignment>
</swimlane>

现在节点:

<start-state name="start">
    <task name="nmwf:submitTask" swimlane="initiator"/>
    <transition name="" to="In Editing">
        <action>
            <runas>admin</runas>
            <script>
                /* Code to send e-mail that a new workflow was started.  I get this e-mail. */
            </script>
        </action>
    </transition>
</start-state>
<task-node name="In Editing">
    <task name="nmwf:submitInEditing" swimlane="Content Providers" />
    <!-- I put e-mail sending code in each of these transitions, but none are firing. -->
    <transition to="In Approval" name="Submit for Approval"></transition>
    <transition to="In Copyediting" name="Request Copyediting Review"></transition>
    <transition to="In Legal Review" name="Request Legal Review"></transition>
    <transition to="In Review" name="Request Review"></transition>
</task-node>

这是这两个节点的模型:

 <type name="nmwf:submitTask">
    <parent>bpm:startTask</parent>


    <mandatory-aspects>
       <aspect>bpm:assignees</aspect>
    </mandatory-aspects>
 </type>


 <type name="nmwf:submitInEditing">
    <parent>bpm:workflowTask</parent>


    <mandatory-aspects>
       <aspect>bpm:assignees</aspect>
    </mandatory-aspects>
 </type>

以下是在工作流控制台中运行工作流的伪日志:

:: deploy alfresco/extension/workflow/processdefinition.xml

deployed definition id: jbpm$69 , name: jbpm$nmwf:MyWorkflow , title: nmwf:MyWorkflow , version: 28

:: var bpm:assignees* person admin,andyg

set var {http://www.alfresco.org/model/bpm/1.0}assignees = [workspace://SpacesStore/73cf1b28-21aa-40ca-9dde-1cff492d0268, workspace://SpacesStore/03297e91-0b89-4db6-b764-5ada2d167424]

:: var bpm:package package 1

set var {http://www.alfresco.org/model/bpm/1.0}package = workspace://SpacesStore/6e2bbbbd-b728-4403-be37-dfce55a83641

:: start bpm:assignees bpm:package

started workflow id: jbpm$63 , def: nmwf:MyWorkflow
path: jbpm$63-@ , node: start , active: true
 task id: jbpm$112 , name: nmwf:submitTask, title: submitTask title , desc: submitTask description , properties: 16
 transition id: [default] , title: Task Done

:: show transitions

path: jbpm$63-@ , node: start , active: true
 task id: jbpm$112 , name: nmwf:submitTask, title: submitTask title , desc: submitTask description , properties: 17
 transition id: [default] , title: Task Done

:: end task jbpm$112

signal sent - path id: jbpm$63-@
path: jbpm$63-@ , node: In Editing , active: true
 task id: jbpm$113 , name: nmwf:submitInEditing, title: submitInEditing title , desc: submitInEditing description , properties: 17
 transition id: Submit for Approval , title: Submit for Approval
 transition id: Request Copyediting Review , title: Request Copyediting Review
 transition id: Request Legal Review , title: Request Legal Review
 transition id: Request Review , title: Request Review

:: show tasks

task id: jbpm$113 , name: nmwf:submitInEditing , properties: 18

:: show my tasks

admin:
 [there is no output here]

我一直假设我在最初启动工作流程之前设置的 bpm:assignees 将传递到第一个任务节点“正在编辑”。显然,受让人位于任务对象上,而不是工作流对象上。我将受让人方面添加到开始状态任务中,以便它可以保留他们(在我遇到问题之后;最初他们不在那里),并且可能他们仍然坐在那里,但在我获得控制权之前开始状态已经结束从网络脚本返回(并不是说如果没有结束它会有帮助,我需要它处于“编辑中”状态,因为开始状态仅用于记录工作流程已启动)。

让我一直困惑的是,我需要在输入任务之前请求需要在每个任务上设置的属性(当您选择转换时,您必须提供下一个任务的数据,然后才能实际移动到下一个任务,如下所示)您必须首先验证您是否拥有所有必需的数据,然后发出转换信号)。但是,启动工作流的代码是异步的,因此不会返回启动的工作流或当前任务(在我的例子中为“正在编辑”)。因此,无论哪种方式,您都无法设置 bpm:assignees 和 bpm:dueDate 等变量。

我想知道这是否是用户任务列表的问题。我正在属性列表中设置受让人,但也许这些受让人将进入开始状态任务并且不会传递到“编辑中”任务?

请注意,这是我的第一个 jBPM 工作流程,因此请不要假设我知道自己在做什么。如果你看到一些看起来不对劲的东西,那很可能就是这样,只是我不知道而已。

预先感谢您的任何建议或帮助,

Hello SO community,

I haven't had any luck getting help in the Alfresco forums, and I'm hoping for more here. We are building an application based on Alfresco and jBPM and I have defined a workflow, but I have either defined it wrong or am missing something or there are bugs in Alfresco integration with jBPM and I need help figuring out which and fixing it. Here is the problem:

I have an advanced workflow and I am trying to launch it from JavaScript. Here is the code I'm using to start the workflow:

var nodeId = args.nodeid;
var document = search.findNode("workspace://SpacesStore/" + nodeId);
var workflowAction = actions.create("start-workflow");
workflowAction.parameters.workflowName = "jbpm$nmwf:MyWorkflow";
workflowAction.parameters["bpm:workflowDescription"] = "Please edit: " + document.name;
workflowAction.parameters["bpm:assignees"] = [people.getPerson("admin"), people.getPerson("andyg")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflowAction.parameters["bpm:workflowDueDate"] = futureDate;
workflowAction.execute(document);

This runs fine and e-mail sent from the start node's default transition fires just fine. However, when I go looking for the workflow in my task list it is not there, but it is in my completed task list. The default transition (the only transition) from the start node points at a task node which has four transitions.

There are 8 tasks and 22 transitions in the workflow. When I use the workflow console to start the workflow and end the start task, it properly follows the default start node transition to the next task. The new task shows up in "show tasks" but does not show up in "show my tasks" (apparently because the task was marked completed for some reason, though it is not in the "end" node). The task is:

task id: jbpm$111 , name: nmwf:submitInEditing , properties: 18

If I do "show transitions" it looks just as I would expect:

path: jbpm$62-@ , node: In Editing , active: true
 task id: jbpm$111 , name: nmwf:submitInEditing, title: submitInEditing title , desc: submitInEditing description , properties: 18
 transition id: Submit for Approval , title: Submit for Approval
 transition id: Request Copyediting Review , title: Request Copyediting Review
 transition id: Request Legal Review , title: Request Legal Review
 transition id: Request Review , title: Request Review

I don't want to post the entire workflow as it's large, but here are the first two nodes:

First the swimlanes:

<swimlane name="initiator"></swimlane>
<swimlane name="Content Providers">
  <assignment actor-id="Content Providers"  class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
     <actor>#{bpm_assignees}</actor>
  </assignment>
</swimlane>

Now the nodes:

<start-state name="start">
    <task name="nmwf:submitTask" swimlane="initiator"/>
    <transition name="" to="In Editing">
        <action>
            <runas>admin</runas>
            <script>
                /* Code to send e-mail that a new workflow was started.  I get this e-mail. */
            </script>
        </action>
    </transition>
</start-state>
<task-node name="In Editing">
    <task name="nmwf:submitInEditing" swimlane="Content Providers" />
    <!-- I put e-mail sending code in each of these transitions, but none are firing. -->
    <transition to="In Approval" name="Submit for Approval"></transition>
    <transition to="In Copyediting" name="Request Copyediting Review"></transition>
    <transition to="In Legal Review" name="Request Legal Review"></transition>
    <transition to="In Review" name="Request Review"></transition>
</task-node>

Here is the model for these two nodes:

 <type name="nmwf:submitTask">
    <parent>bpm:startTask</parent>


    <mandatory-aspects>
       <aspect>bpm:assignees</aspect>
    </mandatory-aspects>
 </type>


 <type name="nmwf:submitInEditing">
    <parent>bpm:workflowTask</parent>


    <mandatory-aspects>
       <aspect>bpm:assignees</aspect>
    </mandatory-aspects>
 </type>

Here is a pseudo-log of running the workflow in the workflow console:

:: deploy alfresco/extension/workflow/processdefinition.xml

deployed definition id: jbpm$69 , name: jbpm$nmwf:MyWorkflow , title: nmwf:MyWorkflow , version: 28

:: var bpm:assignees* person admin,andyg

set var {http://www.alfresco.org/model/bpm/1.0}assignees = [workspace://SpacesStore/73cf1b28-21aa-40ca-9dde-1cff492d0268, workspace://SpacesStore/03297e91-0b89-4db6-b764-5ada2d167424]

:: var bpm:package package 1

set var {http://www.alfresco.org/model/bpm/1.0}package = workspace://SpacesStore/6e2bbbbd-b728-4403-be37-dfce55a83641

:: start bpm:assignees bpm:package

started workflow id: jbpm$63 , def: nmwf:MyWorkflow
path: jbpm$63-@ , node: start , active: true
 task id: jbpm$112 , name: nmwf:submitTask, title: submitTask title , desc: submitTask description , properties: 16
 transition id: [default] , title: Task Done

:: show transitions

path: jbpm$63-@ , node: start , active: true
 task id: jbpm$112 , name: nmwf:submitTask, title: submitTask title , desc: submitTask description , properties: 17
 transition id: [default] , title: Task Done

:: end task jbpm$112

signal sent - path id: jbpm$63-@
path: jbpm$63-@ , node: In Editing , active: true
 task id: jbpm$113 , name: nmwf:submitInEditing, title: submitInEditing title , desc: submitInEditing description , properties: 17
 transition id: Submit for Approval , title: Submit for Approval
 transition id: Request Copyediting Review , title: Request Copyediting Review
 transition id: Request Legal Review , title: Request Legal Review
 transition id: Request Review , title: Request Review

:: show tasks

task id: jbpm$113 , name: nmwf:submitInEditing , properties: 18

:: show my tasks

admin:
 [there is no output here]

I have been making the assumption that the bpm:assignees that I am setting before starting the workflow initially are getting passed to the first task node "In Editing". Clearly the assignees are on the task object and not on the workflow object. I added the assignees aspect to the start-state task so that it could hold them (after I had a problem; initially they were not there) and possibly they are still sitting there, but the start-state has ended before I even get control back from the web script (not that it would help if it wasn't ended, I need it to be in "In Editing" as the start-state is only used to log that the workflow was started).

It has always confused me that the properties that I need to set on each task need to be requested before the task is entered (when you choose a transition you must provide the data for the next task before you can actually move to the next task as you have to validate that you have all of the required data first and then signal the transition). However, the code to start the workflow is asynchronous and therefore does not return either the started workflow or the current task (which in my case would be "In Editing"). So, either way you cannot set variables such as bpm:assignees and bpm:dueDate.

I wonder if this is the problem with the user task list. I'm setting the assignees in the property list, but maybe those assignees are going to the start-state task and are not getting passed to the "In Editing" task?

Note that this is my first jBPM workflow, so please don't assume I know what I'm doing. If you see something that looks off, it probably is and I just don't know it.

Thanks in advance for any advice or help,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

追我者格杀勿论 2024-09-06 05:56:45

因此,事实证明,我的问题是误解了如何处理多个受让人,同时允许工作流程与任何一位受让人进行转换。事实证明,jBPM 在简单的模型中不支持这一点,您必须做更多的工作,而不仅仅是分配多个受让人。我遵循了在互联网上找到的一个错误示例,并对如何实现这一点做出了错误的假设作品。

jBPM 确实有并行任务的概念(使用分叉),但正常操作要求所有受让人在工作流程转换之前完成其任务。事实证明,解决这个问题的正确方法是将任务分叉给所有受让人,但是当任何受让人完成其任务时,我们将存储有多少受让人必须完成其任务的变量 (node.nOutOfM) 修补为欺骗 jBPM 在所有受让人完成任务之前完成任务(这也可以允许 y 受让人中只有 x 必须完成任务)。

我没有发布更新的代码,而是使用以下文章来解决此问题:

http://forums.alfresco.com/en/viewtopic.php?f=30&t=8691

http://forums.alfresco.com/en/viewtopic.php?f=34&t=5189

http://dev.alfresco.com/resource/docs/java /repository/org/alfresco/repo/workflow/jbpm/ForEachFork.html

http:// /wiki.alfresco.com/wiki/WorkflowAdministration#For_Each_Fork

So, it turned out that my problem was misunderstanding how to do multiple assignees while allowing the workflow to transition with any one of those assignees. It turns out that jBPM doesn't support this in a simple model, you have to do a lot more work than just assigning multiple assignees.I had followed a bad example that I found on the Internet and had made an incorrect assumption about how this works.

jBPM does have a concept of parallel tasks (using forks), but the normal action requires all assignees to complete their tasks before the workflow will transition. It turns out that the right way to solve this is to fork the task to all of the assignees, but when any of the assignees completes their task we patch up the variable that stores how many assignees must complete their tasks (node.nOutOfM) to fool jBPM into finishing the task before all assignees have completed it (this can also allow only x out of y assignees to have to complete the task).

Rather than posting updated code, here are the articles that I used to solve this problem:

http://forums.alfresco.com/en/viewtopic.php?f=30&t=8691

http://forums.alfresco.com/en/viewtopic.php?f=34&t=5189

http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/repo/workflow/jbpm/ForEachFork.html

http://wiki.alfresco.com/wiki/WorkflowAdministration#For_Each_Fork

我乃一代侩神 2024-09-06 05:56:45

我不确定,但我认为您需要这里 而不是

也许这就是您的 wf 无法按预期工作的原因。

<actor>#{bpm_assignees}</actor>

另外,我认为该任务应该位于您的合并任务中,而不是您的我的任务中,因为它是一个合并任务(因为您正在尝试设置多个受让人)。

I'm not sure, but I think that you want <pooledactors> here instead of <actor>.

Maybe this is why your wf doesn't work as expected.

<actor>#{bpm_assignees}</actor>

Also, I believe that the task should be in your Pooled tasks, not your My Tasks, as it is a pooled task (because you're trying to set multiple assignees).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文