package com.gds.web;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import static org.springframework.web.bind.annotation.RequestMethod.PUT;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.WorkflowProcessInstance;
import org.jbpm.task.AccessType;
import org.jbpm.task.Task;
import org.jbpm.task.TaskData;
import org.jbpm.task.TaskService;
import org.jbpm.task.query.TaskSummary;
import org.jbpm.task.service.ContentData;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.gds.jbpm.JbpmSupport;
import com.gds.jbpm.Order;
@Controller
public class OrderController {
private Logger log = Logger.getLogger(this.getClass());
@Resource
@Qualifier("jbpmSupport")
private JbpmSupport jbpmSupport;
@RequestMapping("/")
public String test() {
log.info("this is the index");
return "index";
}
@RequestMapping(value = "{user}/create", method = GET)
public String create(@PathVariable("user") String user) {
//log.info(user + " prepare to create");
System.out.println("用户["+user+"]进入创建界面,准备创建流程。");
return "create";
}
@RequestMapping(value = "{user}/create", method = { POST, PUT })
public String doCreate(@PathVariable("user") String user, Model model) {
//log.info(user + " create an order");
System.out.println("用户["+user+"]提交了流程单据");
StatefulKnowledgeSession ksession = jbpmSupport.getKsession();
Map<String, Object> params = new HashMap<String, Object>();
params.put("priority", "High");
params.put("modelNumber", "179");
params.put("quantity", "100");
System.out.println("用户["+user+"]赋初始值,并准备启动流程.......");
ksession.startProcess("com.gds.jbpm.sample", params);
ksession.fireAllRules();
System.out.println("用户["+user+"]创建流程,等待处理......");
model.addAttribute("message", "process created!");
System.out.println("---------------------------------------------------单据提交完成:"+user);
return "create";
}
@RequestMapping("{user}/list")
public String list(@PathVariable("user") String user, Model model) {
//log.info(user + " list his tasks");
System.out.println("用户["+user+"]读取任务列表.");
TaskService taskService = jbpmSupport.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(user, "en-UK");
log.info("\n***Task size::" + tasks.size() + "***\n");
for (TaskSummary taskSummary : tasks) {
log.info(taskSummary.getId() + " :: " + taskSummary.getActualOwner());
}
model.addAttribute("tasks", tasks);
model.addAttribute("tasksCount", tasks.size());
model.addAttribute("user", user);
System.out.println("---------------------------------------------------列表读取完成:"+user);
return "list";
}
@RequestMapping(value = "{user}/work/{task}", method = GET)
public String work(@PathVariable("user") String user, @PathVariable("task") long taskId, Model model) {
//log.info(user + " prepare to work on task " + taskId);
System.out.println("用户["+user+"]读取任务以便处理,任务ID="+taskId);
StatefulKnowledgeSession ksession = jbpmSupport.getKsession();
TaskService taskService = jbpmSupport.getTaskService();
Task task = taskService.getTask(taskId);
TaskData taskData = task.getTaskData();
WorkflowProcessInstance process = (WorkflowProcessInstance) ksession.getProcessInstance(taskData
.getProcessInstanceId());
model.addAttribute("taskData", taskData);
model.addAttribute("order", new Order(user, taskId, process));
System.out.println("---------------------------------------------------任务读取完成:"+user);
return "work";
}
@RequestMapping(value = "{user}/work/{task}", method = { POST, PUT })
public String doWork(@ModelAttribute Order order) {
System.out.println("处理任务信息:"+order.toString());
String user = order.getUser();
long taskId = order.getTaskId();
log.info(user + " complete work on task " + taskId);
TaskService taskService = jbpmSupport.getTaskService();
System.out.println("用户["+user+"]启动人工任务, taskId="+taskId);
taskService.start(taskId, user);
Map<String, Object> data = new HashMap<String, Object>();
data.put("priority", order.getPriority());
data.put("modelNumber", order.getModelNumber());
data.put("quantity", order.getQuantity());
ContentData contentData = null;
if (data != null) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream outs;
try {
outs = new ObjectOutputStream(bos);
outs.writeObject(data);
outs.close();
contentData = new ContentData();
contentData.setContent(bos.toByteArray());
contentData.setAccessType(AccessType.Inline);
} catch (IOException e) {
e.printStackTrace();
}
}
taskService.complete(taskId, user, contentData);
System.out.println("用户["+user+"]完成人工任务");
System.out.println("---------------------------------------------------处理任务完成:"+user);
return "redirect:/" + user + "/list";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Spring 3.1.x + Hibernate 4.2.x+JBPM 5.2 + Ecache例子源码
共95个文件
png:21个
xml:16个
gif:12个
4星 · 超过85%的资源 需积分: 9 16 下载量 44 浏览量
2013-05-20
15:11:38
上传
评论
收藏 212KB ZIP 举报
温馨提示
配置说明见: http://panyongzheng.iteye.com/blog/1872035
资源推荐
资源详情
资源评论
收起资源包目录
JBPM5sh.zip (95个子文件)
JBPM5sh
.project 1KB
src
test
java
main
webapp
WEB-INF
JBPM5sh-servlet.xml 1KB
web.xml 2KB
views
success.jsp 365B
failure.jsp 365B
work.jsp 3KB
index.jsp 52B
resources
images
bg-button-green.gif 169B
bg-radial-gradient.gif 17KB
bg-body.gif 21KB
menu-current-arrow.gif 59B
icons
paper_content_pencil_48.png 5KB
exclamation.png 622B
jquery.wysiwyg.gif 4KB
cross.png 540B
clock_48.png 7KB
pencil.png 497B
comment_48.png 5KB
tick_circle.png 741B
pencil_48.png 4KB
bullet_black.png 211B
cross_grey_small.png 3KB
information.png 725B
cross_circle.png 721B
image_add_48.png 5KB
hammer_screwdriver.png 780B
bg-menu-item-current.gif 315B
bg-form-field.gif 97B
tl.png 132B
bg-login-top.png 3KB
bg-menu-item-green.gif 3KB
shortcut-button-bg.gif 1KB
bl.png 124B
logo.png 10KB
b.png 84B
br.png 124B
tr.png 125B
bg-content-box.gif 126B
bg-sidebar.gif 32KB
bg-login.gif 13KB
scripts
css
invalid.css 2KB
reset.css 1KB
style.css 21KB
list.jsp 3KB
create.jsp 2KB
resources
ehcache.xml 711B
applicationContext.xml 4KB
jdbc.properties 334B
Sample.bpmn 15KB
log4j.properties 1KB
META-INF
persistence.xml 3KB
Taskorm.xml 14KB
JBPMorm.xml 548B
java
com
pandy
ssh4
service
SampleService.java 3KB
domian
BasicDomian.java 273B
Table3.java 2KB
controller
TestController.java 582B
dao
impl
Table3Dao.java 1KB
BasicDao.java 1KB
gds
jbpm
Order.java 1KB
JbpmSupport.java 3KB
web
OrderController.java 6KB
target
m2e-wtp
web-resources
META-INF
MANIFEST.MF 227B
maven
com
JBPM5sh
pom.properties 212B
pom.xml 12KB
generated-sources
annotations
classes
ehcache.xml 711B
applicationContext.xml 4KB
com
pandy
ssh4
service
SampleService.class 4KB
domian
Table3.class 2KB
BasicDomian.class 537B
controller
TestController.class 881B
dao
BasicDao.class 2KB
impl
Table3Dao.class 2KB
gds
jbpm
JbpmSupport.class 3KB
Order.class 2KB
web
OrderController.class 8KB
jdbc.properties 334B
Sample.bpmn 15KB
log4j.properties 1KB
META-INF
persistence.xml 3KB
Taskorm.xml 14KB
JBPMorm.xml 548B
work
jsp
org
apache
jsp
views
success_jsp.class 3KB
test-classes
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.jpt.core.prefs 125B
org.eclipse.wst.common.project.facet.core.xml 290B
org.eclipse.m2e.core.prefs 86B
org.eclipse.jdt.core.prefs 652B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.prefs.xml 160B
org.eclipse.wst.common.component 652B
org.hibernate.eclipse.console.prefs 84B
.jsdtscope 562B
pom.xml 12KB
.classpath 1KB
共 95 条
- 1
资源评论
- 冰火搬砖工2014-10-15感觉一般,还没运行起来呢
不净之心
- 粉丝: 49
- 资源: 49
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功