码迷,mamicode.com
首页 > 其他好文 > 详细

How to integrate Identity System in Activity

时间:2016-06-22 10:33:36      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

Reference:
http://activiti.org/userguide/index.html?_ga=1.41496610.1079305175.1466499422#bpmnUserTask
----------------------------------------------------------------------------------------------------------------------
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.

1 2 3 4 5 6 7 8 9 10 11
<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. Tasks that have an assignee are not visible in the task lists of other people and can be found in the so-called personal task list of the assignee instead.

Tasks directly assigned to users can be retrieved through the TaskService as follows:

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

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

1 2 3 4 5 6 7 8 9 10 11
<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):

1
List<Task> tasks = taskService.createTaskQuery().taskCandidateUser("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 and the Activiti identity component is used). The groups of a user are resolved at runtime and these can be managed through theIdentityService.

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.

1
<formalExpression>accountancy</formalExpression>
Activiti extensions for task assignment

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.

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

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

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

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

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

1
<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 thegroup(management) declaration as is the case with the potential owner construct, since the attribute can only be used for groups.

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

Note: Although Activiti provides an identity management component, which is exposed through the IdentityService, no check is done whether a provided user is known by the identity component. This allows Activiti to integrate with existing identity management solutions when it is embedded into an application.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

For example:

taskService.claim("62556", "user1");

user1 is a userID, it should be saved in pt_wf_id_user, but if it does‘t exist, the claim function can also be executed successful.

 

How to integrate Identity System in Activity

标签:

原文地址:http://www.cnblogs.com/ceinx1984/p/5605846.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!