您的位置:首页 > 其它

activiti5.0DOC之用户任务

2010-06-24 15:19 316 查看

User task用户任务

Description

A 'user task' is used to model work that needs to be done by a human actor. When process executes arrives at such a user task, a new task is created in the task list of the user(s) or group(s) assigned to that task.

用户任务是一个需要参与者执行的工作模型。当流程执行到一个用户任务,任务列表中被指派给相应参与者或者参与组的新任务将被创建。

Graphical notation

A user task is visualized as a typical task (rounded rectangle), with a small user icon in the left upper corner.

用户任务图标是个典型任务模样(圆角矩形),左上角有个小的用户图标。

XML representation

A user task is defined in XML as follows. The id attribute is required, the name attribute is optional.

用户任务XML定义如下。id属性是必需的,name属性是可选的。

<userTask id="theTask" name="Important task" />


A user task can have also a description. In fact any BPMN 2.0 element can have a description, but for the moment we've only implemented it for user tasks since it makes most sense there. A description is defined by adding the documentation element. Note that only one documentation element is supported at the moment (can be multiple according to the specification).

用户任务也可以拥有一个描述。实际上任何BPMN2.0的元素都拥有描述,但当前我们只在用户任务里面实现了描述,因为只有用在这儿才特别有意义。在用户任务中,描述通过documentation元素添加。注意当前一个用户任务中只允许存在一个documentation元素(BPMN2.0标准说明中允许存在多个)。

<userTask id="theTask" name="Schedule meeting" >
<documentation>
Schedule an engineering meeting for next week with the new hire.
</documentation>

The description text can be retrieved from the task in the standard Java way:

描述的详细内容在程序中可通过以下方式获得:

task.getDescription()


User assignment用户指派

A user task can be directly assigned to a user. This is done by defining a humanPerformer sub element. Such a humanPerformer definition needs a resourceAssignmentExpression that actually defines the user. Currently, only formalExpressions are supported.
一个用户任务可以被直接指派给一个用户。通过定义一个humanPerformer 子元素来进行。这个humanPerformer 子元素定义需要一个resourceAssignmentExpression 标签来实际定义用户。当前来说,只支持formalExpressions 标签。

<resource id="actorResource" name="theActor" />

<process ...

...

<userTask id='theTask' name='important task' >
<humanPerformer resourceRef="actorResource">
<resourceAssignmentExpression>
<formalExpression>kermit</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>


Note that the BPMN 2.0 specification requires that the resourceRef is defined when using the humanPerformer construct. The value given for this attribute must reference an existing resource that is defined outside the process. Currenly, there is little value in defining this resource (later this resource shall become parameterizable), but there is no way around it, since the specification requires it.
注意BPMN2.0标准中,在使用humanPerformer 标签时必须有一个resourceRef 属性。这个属性的值必须引用一个在流程外定义的已存在的资源。当前,这个资源仅有几个有限的值(今后资源的值将做成参数可配置),但是当前没办法绕过它,因为是BPMN2.0 标准规定。

Only one user can be assigned as human performer to the task. In Activiti terminology, this user is called the assignee. Task that have an assignee are not visible in the task lists of other people, and are found in the so-called personal task list of the assignee.
一个用户任务只能指派一个用户作为执行者。在流程术语中,这个用户被称为受托人。拥有受托人的用户任务不会出现在其他用户的任务列表中,只会出现在受托人的个人任务列表中。

Tasks directly assigned to users can be retrieved through the TaskService as follows:
可以使用TaskService 取出用户被直接指派的所有任务:

List<Task> tasks = taskService.findAssignedTasks("kermit");


Or the TaskQuery API can be used:
或者可以采用TaskQuery API 实现同样功能:

List<Task> tasks = taskService.createTaskQuery().assignee("kermit").list();


Both code snippets will retrieve the tasks where the assignee currently is the given user.
上述两个代码片段都可以取出用户被指派的任务列表。

Tasks can also be put in the so-called candidate task list of people. In that case, the potentialOwner construct must be used. The usage is similar to the humanPerformer construct. Do note that it is required to define for each element in the formal expression to specify if it is a user or a group (the engine cannot guess this).
用户任务同样也可以被放在用户所谓的候选任务列表(candidate task list)中。在这种情况下,潜在用户(potentialOwner )标签将被使用,用法和humanPerformer 标签一样。需要特别注意的是,使用潜在用户标签时必须指明每个formal表达式标签中的元素是用户还是用户组,因为流程引擎无法自己判断。

<resource id="actorResource" name="theActor" />

<process ...

...

<userTask id='theTask' name='important task' >
<potentialOwner resourceRef="actorResource">
<resourceAssignmentExpression>
<formalExpression>user(kermit), group(management)</formalExpression>
</resourceAssignmentExpression>
</potentialOwner>
</userTask>


Tasks defines with the potential owner construct, can be retrieved as follows (or a similar TaskQuery usage as for the tasks with an assignee):
使用潜在用户标签定义的任务也可以通过用户查询的方式获取(或者同样通过TaskQuery 使用用户名进行查询):

List<Task> tasks = taskService.findUnassignedTasks("kermit");


This will retrieve all tasks where kermit is a candidate user, ie. the formal expression contains user(kermit). This will also retrieve all tasks that are assigned to a group where kermit is a member of (eg group(management), if kermit is a member of that group). Note that the groups of the user are resolved at runtime and these can be managed through the IdentityService.
这样可以获取所有kermit作为潜在用户(candidate user)分配到的所有任务,比如:formal 表达式标签包含user(kermit)。同样可以获取到kermit所在用户组被分配到的所有任务。注意用户所在的组是运行时处理,并且可以被IdentityService管理(动态改变)。

If no specifics are given whether the given text string is a user or group, the engine defaults to group. So the following would be the same as when group(accountancy) was declared.
当未作声明时,formalExpression标签中的值会被引擎默认为用户组。所以下面formalExpression标签中的值等同于声明了group(accountancy)。

<formalExpression>accountancy</formalExpression>

Custom extension for simple task assignments简单任务指派的定制扩展

It is clear that user and group assigmnents are quite cumbersome for use cases where the assignment is not complex. To avoid these complexities, custom extensions on the user task are possible.
很明显,在任务指派情况不复杂时,要进行的用户或者组指派动作相当繁琐。为了避免这种复杂性,用户任务上面可以进行定制扩展。

assignee attribute: this custom extension allows to directly assign a user task to a given user.

assignee属性:这个定制扩展可以直接将用户任务指派给用户。

<userTask id="theTask" name="my task" activiti:assignee="kermit" />

This is exactly the same as using a humanPerformer construct as defined above.

这和上面使用humanPerformer 指派用户的效果是一样的。

candidateUsers attribute: this custom extension allows to make a user a candidate for a task.

candidateUsers属性:这个定制扩展允许为任务指派候选用户。

<userTask id="theTask" name="my task" activiti:candidateUsers="kermit, gonzo" />

This is exactly the same as using a potentialOwner construct as defined above. Note that it is not required to use the user(kermit) declaration as is the case with the potential owner construct, since the attribute can only be used for users.

这个同上面指派潜在用户的potentialOwner 标签是一样的作用。注意这个地方并没使用user(kermit)这种类型声明,因为这个
定制扩展属性只能指派用户,不能指派用户组。

candidateGroups attribute: this custom extension allows to make a group a candidate for a task.

candidateGroups属性:这个定制扩展可以为任务指派候选用户组

<userTask id="theTask" name="my task" activiti:candidateGroup="management, accountancy" />

This is exactly the same as using a potentialOwner construct as defined above. Note that it is not required to use the group(management) declaration as is the case with the potential owner construct, since the attribute can only be used for groups.

这个同上面指派潜在用户的potentialOwner 标签是一样的作用。注意这个地方并没使用group(management)这种类型声明,因
为这个定制扩展属性只能指派用户组,不能指派用户。

candidateUsers and candidateGroups can both be defined on the same user task.

candidateUsers and candidateGroups属性可以同时运用于同一个任务中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: