/**
* CustomGroupEntityManager
* @author connor
*
*/
public class CustomGroupEntityManager extends GroupEntityManager {
@Autowired
private UserManageService userManageService;
@Override
public List<Group> findGroupsByUser(String userId) {
// TODO Auto-generated method stub
List<Group> groups = null;
Account account = this.userManageService.findByName(Account.class, userId);
if(account != null ){
groups = new ArrayList<Group>();
List<Role> roles = account.getRoleList();
for(Role role : roles){
GroupEntity ge = new GroupEntity();
ge.setId(role.getRoleCode());
ge.setName(role.getName());
groups.add(ge);
}
}
return groups;
}
}
public class CustomUserEntityManager extends UserEntityManager {
@Autowired
private UserManageService userManageService;
@Override
public UserEntity findUserById(String userId) {
// TODO Auto-generated method stub
Account account = this.userManageService.findByName(Account.class, userId);
UserEntity userEntity = null;
if(account != null){
userEntity = new UserEntity();
userEntity.setId(account.getName());
}
return userEntity;
}
@Override
public List<Group> findGroupsByUser(String userId) {
List<Group> groups = null;
Account account = this.userManageService.findByName(Account.class, userId);
if(account != null ){
groups = new ArrayList<Group>();
List<Role> roles = account.getRoleList();
for(Role role : roles){
GroupEntity ge = new GroupEntity();
ge.setId(role.getRoleCode());
ge.setName(role.getName());
groups.add(ge);
}
}
return groups;
}
}
xml:
<property name="customSessionFactories">
<list>
<bean class="com.connor.activiti.util.CustomGroupEntityManageFactory">
<property name="groupEntityManager">
<bean class="com.connor.activiti.util.CustomGroupEntityManager"/>
</property>
</bean>
<bean class="com.connor.activiti.util.CustomUserEntityManageFactory">
<property name="userEntityManager">
<bean class="com.connor.activiti.util.CustomUserEntityManager"/>
</property>
</bean>
</list>
</property>
Task task = taskService.createTaskQuery().taskCandidateGroup("deptLeader").singleResult();// still query the internal tables