博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
工作流 jbpm
阅读量:7043 次
发布时间:2019-06-28

本文共 7251 字,大约阅读时间需要 24 分钟。

 

package com.jbpm.controller;import java.io.InputStream;import java.util.List;import java.util.Map;import java.util.Set;import javax.annotation.Resource;import javax.servlet.http.HttpServletRequest;import net.sf.json.JSONArray;import org.dom4j.Document;import org.jbpm.api.ExecutionService;import org.jbpm.api.HistoryService;import org.jbpm.api.ProcessDefinition;import org.jbpm.api.ProcessEngine;import org.jbpm.api.RepositoryService;import org.jbpm.api.TaskService;import org.jbpm.api.cmd.Environment;import org.jbpm.pvm.internal.env.EnvironmentFactory;import org.jbpm.pvm.internal.env.EnvironmentImpl;import org.jbpm.pvm.internal.session.RepositorySession;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import com.jbpm.service.MyDayService;import com.jbpm.workflow.service.BpmConfigParser;/** * controller�� * @author Administrator * */@Controller@RequestMapping("flow")public class FlowController {	@Resource(name="repositoryService")	private RepositoryService repositoryService;//-流程管理,部署发布		@Resource(name="taskService")	private TaskService taskService;//任务管理		@Resource(name="executionService")	private ExecutionService executionService;//-流程实例管理		@Resource(name="myDayService")	private MyDayService myDayService;//业务逻辑		@Resource(name="historyService")	private HistoryService historyService;//业务逻辑		@Resource(name="jbpmParser")	private BpmConfigParser jbpmParser; //jbpm解析器		@Resource(name="processEngine")	private ProcessEngine processEngine;	@RequestMapping("toFlow")	public String toFlow(HttpServletRequest request){		return "projectFlowAdd";	}	@RequestMapping("deploy")	public @ResponseBody String deploy(HttpServletRequest request,String flowJson){		try{			System.out.println(flowJson);			Document doc = jbpmParser.parseEditorFile(flowJson);			String key = jbpmParser.getProcessKey(flowJson);			String resourceName = key + ".jpdl.xml";			System.out.println(doc.asXML()+","+key);			String deployId = repositoryService.createDeployment().addResourceFromString(resourceName, doc.asXML()).deploy();		}catch(Exception e){			e.printStackTrace();		}				return "success";	}	@RequestMapping("showFlowEdit")	public String showFlowEdit(HttpServletRequest request,String flowKey){		if(flowKey == null || "".endsWith(flowKey)){			request.setAttribute("flowJsonResult", "null");		}else{			InputStream ins = this.getProcessDefCfg(flowKey);			String flowName = this.getProcessDefinition(flowKey).getName();			String flowJsonResult = jbpmParser.parseBpmConfig(ins);						request.setAttribute("flowJsonResult", flowJsonResult);			request.setAttribute("flowKey", flowKey);			request.setAttribute("flowName", flowName);		}		return "projectFlowEditor";	}	public InputStream getProcessDefCfg(String flowKey) {		EnvironmentFactory environmentFactory = (EnvironmentFactory) processEngine;		Environment environment = environmentFactory.openEnvironment();							try{					RepositorySession repositorySession = environment.get(RepositorySession.class);   					ProcessDefinition pd = repositorySession.findProcessDefinitionByKey(flowKey);					Set
names = repositoryService.getResourceNames(pd.getDeploymentId());// Set
names = new GetDeploymentResourceNamesCmd(pd.getDeploymentId()).execute(environment); for (String n :names) { if (n.indexOf(".jpdl.xml") != -1) { InputStream in = repositoryService.getResourceAsStream(pd.getDeploymentId(), n); return in; } } }catch(Exception e){ e.printStackTrace(); }finally{ closeEnvironment(environment); } return null; } private void closeEnvironment(Environment environment){ if(environment!=null){ ((EnvironmentImpl)environment).close(); } } public ProcessDefinition getProcessDefinition(String flowKey) { EnvironmentFactory environmentFactory = (EnvironmentFactory) processEngine; Environment environment = environmentFactory.openEnvironment(); ProcessDefinition pd = null; try{ RepositorySession repositorySession = environment.get(RepositorySession.class); pd = repositorySession.findProcessDefinitionByKey(flowKey); }catch(Exception e){ e.printStackTrace(); } return pd; } }

 

 

 

jbpm.spring.default.cfg.xml

${task.name}
${task.name}

 

 

jbpm.hibernate.cfg.xml

com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/testjbpm
true
utf-8
org.hibernate.dialect.MySQLInnoDBDialect
root
123456
true
update
true
20

 

 

 

jbpm.cfg.xml

 

 

 

 

applicationContext-flow.xml

 

jbpm.cfg.xml

 

 

 

applicationContext-core.xml

 

classpath:jbpm.hibernate.cfg.xml
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,readOnly
PROPAGATION_NEVER
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/testjbpm
root
123456

 

 

 

 

applicationContext-bean.xml

 

 

 

转载地址:http://ihhal.baihongyu.com/

你可能感兴趣的文章
Java实现简单的RPC框架
查看>>
【SSH网上商城项目实战17】购物车基本功能的实现
查看>>
Linux +apache+fastcgi运行c/c++
查看>>
Android 4高级编程(第3版)》
查看>>
HDU 4767 Bell(矩阵+中国剩余定理)
查看>>
CTime转换
查看>>
关于字符编码,你所需要知道的
查看>>
Android Listview 隐藏滚动条
查看>>
关闭 C4996 警告(_CRT_SECURE_NO_DEPRECATE)
查看>>
[书目20150309]成功的企业级软件项目管理:优化绩效完美交付的最佳实践
查看>>
iOS 通过(lame)将录制音频转换成Mp3
查看>>
JDK7中的新特性 The try-with-resources Statement
查看>>
linux 清空文件内容命令
查看>>
Android——通知 Notification
查看>>
java.lang.InstantiationException:
查看>>
转:jmf編譯問題的解決
查看>>
Hosts文件的位置
查看>>
java设计模式演示样例
查看>>
Codeforces Round #345 (Div. 2) D. Image Preview 暴力 二分
查看>>
suggest
查看>>