activiti5.14 扩展用户自定义表

阅读更多

因项目需要需求,在网上找了很多关于activiti扩展用户自定义表的文章,发现在5.15.1中不起作用,查看源码之后发现在用会话工厂中的返回类型改成了接口而不是原来的抽象类。

1.CustomGroupManagerFactory 用户组会话工厂这边的返回类型要改成 GroupIdentityManager接口,之前的版本貌似是GroupEntityManager,因为在配置加载的时候是以这个为KEY值获得对应的工厂.

package tk.hecks.workflow;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
import org.activiti.engine.impl.persistence.entity.GroupIdentityManager;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 自定义的Activiti用户组会话工厂
 */
public class CustomGroupManagerFactory implements SessionFactory {
	 private GroupEntityManager groupEntityManager;  
	  
	    @Autowired  
	    public void setGroupEntityManager(GroupEntityManager groupEntityManager) {  
	        this.groupEntityManager = groupEntityManager;  
	    }  
	  
	    public Class getSessionType() {  
	        // 返回原始的GroupIdentityManager类型  
	        return GroupIdentityManager.class;  
	    }  
	  
	    public Session openSession() {  
	        // 返回自定义的GroupEntityManager实例  
	        return groupEntityManager;  
	    }  
}

 

2. CustomUserManagerFactory 自定义的Activiti用户会话工厂

package tk.hecks.workflow;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.activiti.engine.impl.persistence.entity.UserIdentityManager;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 自定义的Activiti用户会话工厂
 */
public class CustomUserManagerFactory implements SessionFactory {
	private UserEntityManager userEntityManager;  
	  
    @Autowired  
    public void setUserEntityManager(UserEntityManager userEntityManager) {  
        this.userEntityManager = userEntityManager;  
    }  
  
    public Class getSessionType() {  
        // 返回原始的UserManager类型  
        return UserIdentityManager.class;  
    }  
  
    public Session openSession() {  
        // 返回自定义的UserManager实例  
        return userEntityManager;  
    }  
}

 3.下面是用户组合用户管理器只要在里面实现自己的增删改查就行了

package tk.hecks.workflow;
import java.util.List;
import java.util.Map;

import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.impl.GroupQueryImpl;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.persistence.entity.GroupEntity;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
/**
 * 自定义的Activiti用户组管理器
 *
 */
public class CustomGroupManager extends GroupEntityManager {
    @Override
	public Group createNewGroup(String groupId) {
		// TODO Auto-generated method stub
		return super.createNewGroup(groupId);
	}

	@Override
	public void insertGroup(Group group) {
		// TODO Auto-generated method stub
		super.insertGroup(group);
	}

	@Override
	public void updateGroup(GroupEntity updatedGroup) {
		// TODO Auto-generated method stub
		super.updateGroup(updatedGroup);
	}

	@Override
	public void deleteGroup(String groupId) {
		// TODO Auto-generated method stub
		super.deleteGroup(groupId);
	}

	@Override
	public GroupQuery createNewGroupQuery() {
		// TODO Auto-generated method stub
		return super.createNewGroupQuery();
	}

	@Override
	public List findGroupByQueryCriteria(GroupQueryImpl query, Page page) {
		// TODO Auto-generated method stub
		return super.findGroupByQueryCriteria(query, page);
	}

	@Override
	public long findGroupCountByQueryCriteria(GroupQueryImpl query) {
		// TODO Auto-generated method stub
		return super.findGroupCountByQueryCriteria(query);
	}

	@Override
	public List findGroupsByUser(String userId) {
		// TODO Auto-generated method stub
		return super.findGroupsByUser(userId);
	}

	@Override
	public List findGroupsByNativeQuery(Map parameterMap, int firstResult, int maxResults) {
		// TODO Auto-generated method stub
		return super.findGroupsByNativeQuery(parameterMap, firstResult, maxResults);
	}

	@Override
	public long findGroupCountByNativeQuery(Map parameterMap) {
		// TODO Auto-generated method stub
		return super.findGroupCountByNativeQuery(parameterMap);
	}
}

 

package tk.hecks.workflow;
import java.util.List;
import java.util.Map;

import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.activiti.engine.identity.UserQuery;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.UserQueryImpl;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity;
import org.activiti.engine.impl.persistence.entity.UserEntity;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;

public class CustomUserManager extends UserEntityManager {

	@Override
	public User createNewUser(String userId) {
		// TODO Auto-generated method stub
		return super.createNewUser(userId);
	}

	@Override
	public void insertUser(User user) {
		// TODO Auto-generated method stub
		super.insertUser(user);
	}

	@Override
	public void updateUser(UserEntity updatedUser) {
		// TODO Auto-generated method stub
		super.updateUser(updatedUser);
	}

	@Override
	public UserEntity findUserById(String userId) {
		// TODO Auto-generated method stub
		return super.findUserById(userId);
	}

	@Override
	public void deleteUser(String userId) {
		// TODO Auto-generated method stub
		super.deleteUser(userId);
	}

	@Override
	public List findUserByQueryCriteria(UserQueryImpl query, Page page) {
		// TODO Auto-generated method stub
		return super.findUserByQueryCriteria(query, page);
	}

	@Override
	public long findUserCountByQueryCriteria(UserQueryImpl query) {
		// TODO Auto-generated method stub
		return super.findUserCountByQueryCriteria(query);
	}

	@Override
	public List findGroupsByUser(String userId) {
		return super.findGroupsByUser(userId);
	}

	@Override
	public UserQuery createNewUserQuery() {
		// TODO Auto-generated method stub
		return super.createNewUserQuery();
	}

	@Override
	public IdentityInfoEntity findUserInfoByUserIdAndKey(String userId, String key) {
		// TODO Auto-generated method stub
		return super.findUserInfoByUserIdAndKey(userId, key);
	}

	@Override
	public List findUserInfoKeysByUserIdAndType(String userId, String type) {
		// TODO Auto-generated method stub
		return super.findUserInfoKeysByUserIdAndType(userId, type);
	}

	@Override
	public Boolean checkPassword(String userId, String password) {
		// TODO Auto-generated method stub
		return super.checkPassword(userId, password);
	}

	@Override
	public List findPotentialStarterUsers(String proceDefId) {
		// TODO Auto-generated method stub
		return super.findPotentialStarterUsers(proceDefId);
	}

	@Override
	public List findUsersByNativeQuery(Map parameterMap, int firstResult, int maxResults) {
		// TODO Auto-generated method stub
		return super.findUsersByNativeQuery(parameterMap, firstResult, maxResults);
	}

	@Override
	public long findUserCountByNativeQuery(Map parameterMap) {
		// TODO Auto-generated method stub
		return super.findUserCountByNativeQuery(parameterMap);
	}

}

 

4.最后是配置文件

 

	
	
		
		
		
		
		
		
		
		
		
		
		
			
				classpath*:/diagrams/*
			
		
		
		
		
		
		
		
		
		 
			 
				 
				 	
				 		
				 	
				 
				 
				 	
				 		
				 	
				 
			
		
	

 

你可能感兴趣的:(activiti5.14 扩展用户自定义表)