jbpm的流程demo

jbpm的流程demo_第1张图片

2、jbpm演示流程的demo为:

package com.njupt.jbpm;

import java.util.List;

import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.task.Task;
import org.junit.Test;

public class HelloWorld {

	// 生成ProcessEngine对象
	private Configuration cfg = new Configuration().setResource("jbpm.cfg.xml");
	private ProcessEngine processEngine = cfg.buildProcessEngine();

	// 部署流程定义
	@Test
	public void testDeployProcessDefinition() throws Exception {
		processEngine.getRepositoryService()//
				.createDeployment()//
				.addResourceFromClasspath("first/test.jpdl.xml")//
				.addResourceFromClasspath("first/test.png")//
				.deploy();
	}

	// 启动流程实例
	@Test
	public void testStartProcessInstance() throws Exception {
		processEngine.getExecutionService().startProcessInstanceByKey("test");
	}

	// 查询任务列表
	@Test
	public void testFindMyTaskList() throws Exception {
		// 查询
//		String userId = "学员";
		String userId = "教务";
		List<Task> taskList = processEngine.getTaskService().findPersonalTasks( userId);

		// 显示
		System.out.println("==================== 【"+userId+"】的任务列表 ==================");
		for(Task task : taskList){
			System.out.println("id="+task.getId()+", name="+task.getName()+", assignee=" + task.getAssignee());
		}
	}

	// 办理任务
	@Test
	public void testCompleteTask() throws Exception {
		String taskId = "30001";
		processEngine.getTaskService().completeTask(taskId);
	}
}


你可能感兴趣的:(jbpm,流程原理)