• jbpm4.4 demo1


    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

  • 相关阅读:
    vue 组件
    vue 中的computed和watch
    Vue 框架 笔记
    初次使用git配置以及git如何使用ssh密钥(将ssh密钥添加到github)
    JavaScript 执行机制
    Vue.js 动画
    封装nodeJS中 $on $emit $off 事件
    JS中的事件委托
    什么是“闭包”(closure)为什么要用它?
    js使用面向对象编写下拉菜单
  • 原文地址:https://www.cnblogs.com/a757956132/p/4774907.html
Copyright © 2020-2023  润新知