Activiti User Guide -- Activit 用户指南 Part11

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

XML 表示

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元素(标准中则可以添加多个)。

<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:

通过标准的java方式在任务中就可以获取描述信息:

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 humanPerformerdefinition needs a resourceAssignmentExpression that actually defines the user. Currently, only formalExpressions are supported.

通过定义humanPerformer 一个子元素,可以将用户任务直接分配给一个用户。humanPerformer 定义需要一个resourceAssignmentExpression 来确定定义用户。当前,仅支持formalExpressions 表达式。

<process ...
  
  ...
  
  <userTask id='theTask' name='important task' >
    <humanPerformer>
      <resourceAssignmentExpression>
        <formalExpression>kermit</formalExpression>
      </resourceAssignmentExpression>
    </humanPerformer>
  </userTask>

 

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.

只能有一个用户用来执行任务。在Activiti中,用户也称之为处理者。那些有处理者的任务只能在该人员的个人任务列表中被看见,而其他人员的任务列表中则无法看到该任务。

 

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).

任务也可以被放进一个称之为候选任务的任务列表中。此时,就需要potentialOwner 构件了。用法和humanPerformer 相近。不过在定义中需要为每一个表达式明确的指出是用户还是小组(因为引擎是不会知道的)。

<process ...
  
  ...
  
  <userTask id='theTask' name='important task' >
    <potentialOwner>
      <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):

使用 potential owner 进行定义的任务可以下面的代码(与直接进行分配的任务查询语法类似)进行获取:

List<Task> tasks = taskService.findUnassignedTasks("kermit");
This will retrieve all tasks where kermit is a  candidate user , i.e. the formal expression contains  user(kermit) . This will also retrieve all tasks that are  assigned to a group where kermit is a member of  (e.g.  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作为候选处理者的任务,因为我们在表达式中包含了user(kermit)。同时也会获取到分配给kermit所属小组的任务(例如group(management),同时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.

如果没有指定给的表达式是岗位还是人员,那么引擎将默认任务是一个岗位。因此,下面的代码就和声明为group(accountancy)是一样的。

<formalExpression>accountancy</formalExpression>

 

Custom extension for simple task assignments

为简化任务分配进行的自定义扩展

It is clear that user and group assignments 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 attribute: 该自定义扩展直接为用户任务分配一个人员

<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 attribute: 该自定义扩展将备选人员赋值给一个任务

<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 attribute: 该自定义扩展允许将一个岗位赋值为一个任务。

<userTask id="theTask" name="my task" activiti:candidateGroups="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 candidateGroups 可以同时使用在一个用户定义中

你可能感兴趣的:(xml)