Activiti源码浅析:Activiti的活动授权机制
2016-04-18 17:32
453 查看
1. IdentityLink与TaskEntity
An identity link is used to associate a task with a certain identity. For example: - a user can be an assignee (= identity link type) for a task - a group can be a candidate-group (= identity link type) for a taskTaskEntity包含了一系列的IdentityLink操作方法:
[html] view
plain copy
print?
public IdentityLinkEntity addIdentityLink(String userId, String groupId, String type) {
IdentityLinkEntity identityLinkEntity = new IdentityLinkEntity();
getIdentityLinks().add(identityLinkEntity);
identityLinkEntity.setTask(this);
identityLinkEntity.setUserId(userId);
identityLinkEntity.setGroupId(groupId);
identityLinkEntity.setType(type);
identityLinkEntity.insert();
if (userId != null && processInstanceId != null) {
getProcessInstance().involveUser(userId, IdentityLinkType.PARTICIPANT);
}
return identityLinkEntity;
}
注意,IdentityLink有一个Type,有一些默认的Type:
[java] view
plain copy
print?
public void addCandidateUser(String userId) {
addIdentityLink(userId, null, IdentityLinkType.CANDIDATE);
}
[html] view
plain copy
print?
public void addCandidateGroup(String groupId) {
addIdentityLink(null, groupId, IdentityLinkType.CANDIDATE);
}
2. IdentityLink与权限过滤
如下查询语句对应于“用户kermit待签收任务列表”的调用过程:[html] view
plain copy
print?
Preparing: select distinct RES.* from AC
T_RU_TASK RES inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_ WHERE RES.ASSIGNEE_ is null and I.TYPE_ = 'candidate' and ( I.USER_ID_ = ? or I.GROUP_ID_ IN ( ? , ? ) )
Parameters: kermit(String), admin(String), management(String)
其中admin和management来自于用户群组关系查询接口:
UserEntityManager.findGroupsByUser("kermit")
相关文章推荐
- 宇宙APP简单的性能测试
- LeetCode 59 Spiral Matrix II
- android AsyncTask介绍
- Lambda表达式:代替std::bind的绝佳方法
- [疯狂Java]JDBC:数据库元数据分析
- windbg 查看符号文件有没有加载进windbg
- Learning Scrapy笔记(三)- Scrapy基础
- Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)
- python操作 redis-list
- sql中sum()和count()的区别
- 常用的数据挖掘&机器学习知识(点)
- 用C++ 实现复杂链表的复制
- 自定义控件三实现方法
- Javascript学习笔记(8)
- 如何让Oracle客户端显示中文
- 学习中遇到的几种上下文 (后期慢慢积累)
- Android 枚举(Enum)类最佳实践
- Impala与Hive的比较
- GifView
- DataGridView很详细的用法