package com.ht.util;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipInputStream;
import javax.servlet.http.HttpSession;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.HistoryService;
import org.jbpm.api.ManagementService;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Task;
/**
* jbpm工具类
*
* @author ht
*
*/
public class JBPMUtil {
private ProcessEngine processEngine;
private RepositoryService repositoryService = null;
private ExecutionService executionService = null;
private TaskService taskService = null;
private HistoryService historyService = null;
private ManagementService managementService = null;
public JBPMUtil(){
}
public JBPMUtil(ProcessEngine processEngine) {
this.processEngine = processEngine;
repositoryService = processEngine.getRepositoryService();
executionService = processEngine.getExecutionService();
taskService = processEngine.getTaskService();
historyService = processEngine.getHistoryService();
managementService = processEngine.getManagementService();
}
public ProcessEngine getProcessEngine() {
return processEngine;
}
public void setProcessEngine(ProcessEngine processEngine) {
this.processEngine = processEngine;
System.out.println("processEngine="+processEngine);
repositoryService = processEngine.getRepositoryService();
executionService = processEngine.getExecutionService();
taskService = processEngine.getTaskService();
historyService = processEngine.getHistoryService();
managementService = processEngine.getManagementService();
}
public RepositoryService getRepositoryService() {
return repositoryService;
}
public void setRepositoryService(RepositoryService repositoryService) {
this.repositoryService = repositoryService;
}
public ExecutionService getExecutionService() {
return executionService;
}
public void setExecutionService(ExecutionService executionService) {
this.executionService = executionService;
}
public TaskService getTaskService() {
return taskService;
}
public void setTaskService(TaskService taskService) {
this.taskService = taskService;
}
public HistoryService getHistoryService() {
return historyService;
}
public void setHistoryService(HistoryService historyService) {
this.historyService = historyService;
}
public ManagementService getManagementService() {
return managementService;
}
public void setManagementService(ManagementService managementService) {
this.managementService = managementService;
}
/**
* 部署新流程定义
* @param resourceName
* @return 返回流程定义id
*/
public String deployNew(String resourceName) {
return repositoryService.createDeployment().addResourceFromClasspath(
resourceName).deploy();
}
/**
* 部署新流程定义(zip)
* @param resourceName
* @return 返回流程定义id
*/
public String deployZipNew(String resourceZipName){
ZipInputStream zis = new ZipInputStream(this.getClass().getResourceAsStream(resourceZipName));
return repositoryService.createDeployment().addResourcesFromZipInputStream(zis).deploy();
}
/**
* 开始一个流程实例
* @param id
* @param map
* @return
*/
public ProcessInstance startPIById(String id,Map<String,?> map){
return executionService.startProcessInstanceById(id, map);
}
/**
* 完成任务
* @param taskId
* @param map
*/
public void completeTask(String taskId,Map map){
taskService.completeTask(taskId, map);
}
/**
* 完成任务
* @param taskId
*/
public void completeTask(String taskId){
taskService.completeTask(taskId);
}
/**
* 将任务流转到指定名字的流程outcome中去
* @param taskId
* @param outcome
*/
public void completeTask(String taskId,String outcome){
taskService.completeTask(taskId, outcome);
}
/**
* 获得所有发布了的流程
* @return
*/
public List<ProcessDefinition> getAllPdList(){
return repositoryService.createProcessDefinitionQuery().list();
}
/**
* 获得所有流程实例
* @return
*/
public List<ProcessInstance> getAllPiList(){
return executionService.createProcessInstanceQuery().list();
}
/**
* 根据流程实例Id,即executionId获取指定的变量值
* @param executionId
* @param variableName
* @return
*/
public Object getVariableByexecutionId(String executionId,String variableName){
return executionService.getVariable(executionId, variableName);
}
/**
* 根据任务id,即taskId获取指定变量值
* @param taskId
* @param variableName
* @return
*/
public Object getVariableByTaskId(String taskId,String variableName){
return taskService.getVariable(taskId, variableName);
}
/**
* 获取指定用户名字的任务
* @param userName
* @return
*/
public List<Task> findPersonalTasks(String userName){
return taskService.findPersonalTasks(userName);
}
/**
* 根据任务id获取任务
* @param taskId
* @return
*/
public Task getTask(String taskId) {
return taskService.getTask(taskId);
}
/**
* 级联删除流程定义,直接删除该流程定义下的所有实例
*
* @param deploymentId流程定义id
*/
public void deleteDeploymentCascade(String deploymentId) {
repositoryService.deleteDeploymentCascade(deploymentId);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jBPM4.4Pssh.rar (85个子文件)
jBPM4.4+ssh
hibernate.reveng.xml 435B
.myhibernatedata 584B
.settings
com.genuitec.eclipse.j2eedt.core.prefs 1KB
org.eclipse.wst.jsdt.ui.superType.name 6B
com.genuitec.eclipse.blue.projects.properties 56B
org.eclipse.core.resources.prefs 106B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
src
daoContext.xml 2KB
logging.properties 635B
actionContext.xml 1KB
serviceContext.xml 1KB
jbpm.mail.templates.examples.xml 418B
com
ht
dao
StaffDAO.java 162B
LeaveDAO.java 307B
impl
StaffDAOImpl.java 300B
LeaveDAOImpl.java 500B
action
LoginAction.java 1KB
TaskListAction.java 1KB
DetailAction.java 826B
RequestAction.java 2KB
ExamAction.java 796B
test
testDeploy.java 141B
service
JBPMService.java 2KB
LoginService.java 124B
impl
LoginServiceImpl.java 590B
JBPMServiceImpl.java 4KB
entity
Leave.java 2KB
Staff.hbm.xml 1KB
Staff.java 1KB
Leave.hbm.xml 1KB
util
BaseAction.java 433B
BaseDAO.java 380B
JBPMUtil.java 6KB
struts.xml 2KB
jbpm.mail.properties 72B
leave.jpdl.xml 1KB
jbpm.cfg.xml 666B
leave.png 15KB
applicationContext.xml 3KB
.project 2KB
WebRoot
request.jsp 574B
reRequest.jsp 774B
META-INF
MANIFEST.MF 36B
taskDetail.jsp 773B
WEB-INF
web.xml 1KB
classes
daoContext.xml 2KB
logging.properties 635B
actionContext.xml 1KB
serviceContext.xml 1KB
jbpm.mail.templates.examples.xml 418B
com
ht
dao
LeaveDAO.class 319B
StaffDAO.class 249B
impl
StaffDAOImpl.class 646B
LeaveDAOImpl.class 1KB
action
LoginAction.class 2KB
DetailAction.class 1KB
TaskListAction.class 2KB
RequestAction.class 3KB
ExamAction.class 1KB
test
testDeploy.class 279B
service
JBPMService.class 1KB
LoginService.class 180B
impl
JBPMServiceImpl.class 5KB
LoginServiceImpl.class 1KB
entity
Staff.hbm.xml 1KB
Leave.class 2KB
Leave.hbm.xml 1KB
Staff.class 2KB
util
JBPMUtil.class 6KB
BaseDAO.class 667B
BaseAction.class 601B
struts.xml 2KB
jbpm.mail.properties 72B
leave.jpdl.xml 1KB
jbpm.cfg.xml 666B
leave.png 15KB
applicationContext.xml 3KB
lib
jbpm4.4
struts2.2.1
spring3.0.3
requestList.jsp 833B
taskList.jsp 817B
login.jsp 501B
index.jsp 525B
.mymetadata 307B
.classpath 8KB
.myeclipse
共 85 条
- 1
资源评论
JonSco
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功