package cn.itcast.a_helloworld;

import java.util.List;

import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.task.Task;
import org.junit.Test; public class HelloWorld_API { private static ProcessEngine processEngine;
static {
Configuration cfg = new Configuration();
cfg.setResource("jbpm.cfg.xml");
processEngine = cfg.buildProcessEngine();
} // 1,部署流程定义文档
@Test
public void testDeployProcessDefinition() throws Exception {
String id = processEngine.getRepositoryService()//
.createDeployment()//
.addResourceFromClasspath("helloworld/helloworld.jpdl.xml")//
.addResourceFromClasspath("helloworld/helloworld.png")//
.deploy();
System.out.println(id);
} // 2,启动流程实例
/**
* 根据pdkey启动流程实例,是该key下,最高版本
*/
@Test
public void testStartProcessInstance() throws Exception {
ProcessInstance instance = processEngine.getExecutionService().startProcessInstanceByKey("hellokey");
System.out.println(instance.toString());
System.out.println(instance.getId() + " " + instance.getKey() + " " + instance.getName() + " " + instance.getPriority() + " " + instance.getProcessDefinitionId() + " " + instance.getState()
+ " " + instance.getProcessInstance().toString() ) ;
} // 3,查询我的任务列表
@Test
public void testFindMyTaskList() throws Exception {
// 查询
// String userId = "员工";
String userId = "部门经理";
//String userId = "总经理";
List<Task> list = processEngine.getTaskService().findPersonalTasks(userId);
// 显示
for (Task task : list) {
System.out.println("id=" + task.getId() + ", name=" + task.getName() + ", assignee=" + task.getAssignee() + " " + task.getActivityName());
System.out.println(task.getDescription() + " " + task.getFormResourceName() + " " + task.getPriority() + " " + task.getDuedate() + " " + task.getCreateTime());
System.out.println();
}
} // 4,办理任务
@Test
public void testCompleteTask() throws Exception {
String taskId = "160002";
processEngine.getTaskService().completeTask(taskId);
}
}
<?xml version="1.0" encoding="UTF-8"?>

<process name="hellokey" key="hellokey" xmlns="http://jbpm.org/4.4/jpdl">
<start g="115,21,48,48" name="start1">
<transition g="-71,-17" name="to 提交申请" to="提交申请"/>
</start>
<end g="115,353,48,48" name="end1"/>
<task assignee="员工" g="81,101,117,52" name="提交申请">
<transition g="-78,-15" name="to 部门经理[审批]" to="部门经理[审批]"/>
</task>
<task assignee="部门经理" g="81,185,117,52" name="部门经理[审批]">
<transition g="-95,-17" name="to 总经理[审批]" to="总经理[审批]"/>
</task>
<task assignee="总经理" g="81,269,117,52" name="总经理[审批]">
<transition g="-47,-17" name="to end1" to="end1"/>
</task>
</process>

下载demo

jbpm4.4 demo1的更多相关文章

  1. jBPM4.4 no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the install tool.

    jBPM4.4 no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the ...

  2. JBPM4.4业务流程管理框架详细解读

    1. 什么是JBPM4.4业务流程管理框架? JBPM,全称是JavaBusiness Process Management(业务流程管理),它是覆盖了业务流程管理.工作流.服务协作等领域的一个开源的 ...

  3. struts2 基础demo1

    我们都知道 struts2 是基于webframework 出现的 优秀的mvc 框架, 他和struts1 完全没有联系.struts2 是一个框架, 啥叫框架呢?是一个优秀的半成品 . web的框 ...

  4. struts2&&Hibernate Demo1

    这篇文章和<struts1&&Hibernate Demo1>基本类似,我这里只是拷贝代码了. 最核心的代码:LoginAction.java package action ...

  5. Tomcat6环境JBPM4.4报错:java.lang.ClassNotFoundException: de.odysseus.el.util.SimpleResolver

    Tomcat6环境JBPM4.4报错:java.lang.ClassNotFoundException: de.odysseus.el.util.SimpleResolver 报错信息:

  6. JBPM4.4学习API

    一.流程引擎API org.jbpm.api.ProcessEngine是jbpm4所有的Service API 之源. 既所有的Service API(服务接口)都从ProcessEngine中获取 ...

  7. SSH整合JBPM4.4

    第一步:导入所需jar包: 所需的jar包(使用了hibernate annotation和struts2的convention-plugin,可能有多余的包,没做清理): 第二步:修改jbpm配置文 ...

  8. JBPM4.4+SSH 整合配置及完整实例

    整合jBPM4.4+ssh过程(spring接管struts2和hibernate,例中都整合在application.xml中,没有单独的jbpm.hibernate.cfg.xml): 1.在se ...

  9. Myeclipse10 + JBPM4.4 环境搭建图文教程

    一.软件环境 IDE:Myeclipse10.0 (jbpm4.0以上版本好像只能与Myeclipse7.5以上版本集成) JBPM:4.4 与Myeclipse集成 1.解压jbpm-4.4.zip ...

随机推荐

  1. UVA 12647 Balloon

    这是一个线段树的题目: 我记得一个月前在cf上也做过一个类似的题目: #include<cstdio> #include<cstring> #include<algori ...

  2. SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-002-AOP术语解析

    一. 1.Advice Advice是切面的要做的操作,它定义了what.when(什么时候要做什么事) aspects have a purpose—a job they’re meant to d ...

  3. 167. Two Sum II - Input array is sorted

    题目: Given an array of integers that is already sorted in ascending order, find two numbers such that ...

  4. vnc执行,报xauth could not run

    /usr/bin/gnome-terminal [INFO-10%]生成随机密码 [INFO-20%]生成密码文件 [INFO-30%]完成初始化,准备打开连接 Error: could not ru ...

  5. platform_driver与file_operations两种方法开发led驱动

    下面是两个LED灯的驱动程序 一个用platform_driver 另一个用file_operations #include <linux/kernel.h> #include <l ...

  6. XSD标准架构-----<xsd:element> 元素详解

    声明一个元素.     <element abstract = Boolean : false block = (#all | List of (extension | restriction ...

  7. .NET之特性和属性

    1. 引言 attribute是.NET框架引入的有一技术亮点,因此我们有必要花点时间走进一个发现attribute登堂入室的入口.因为.NET Framework中使用了大量的定制特性来完成代码约定 ...

  8. Virtual member call in a constructor

    http://stackoverflow.com/questions/119506/virtual-member-call-in-a-constructor (Assuming you're writ ...

  9. BZOJ_1610_[Usaco2008_Feb]_Line连线游戏_(计算几何基础+暴力)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1610 给出n个点,问两两确定的直线中,斜率不同的共有多少条. 分析 暴力枚举直线,算出来斜率放 ...

  10. RMAN综合学习之备份

    rman是最经济实惠的oracle备份工具,在这里做一个rman的整体学习. 文章中大多是rman命令的语法,还是最好做做实验,以便印象深刻,因为大多数数据库的备份就是按时跑脚本,恢复也不是经常能遇到 ...