启动流程:
Ø 获取最新的流程定义:
JbpmContext.getCurrentJbpmContext().getGraphSession().findLatestProcessDefinitions();//返回List
Ø 获取指定流程定义:
ProcessDefinition processDefinition =
graphSession.loadProcessDefinition(processDefinitionId);
Ø 创建流程实例:
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Ø 开始任务节点:
TaskInstance taskInstance =
processInstance.getTaskMgmtInstance().createStartTaskInstance();
Ø 获取指定任务实例(ID):
TaskMgmtSession taskMgmtSession;
taskMgmtSession = jbpmContext.getTaskMgmtSession();
TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId);
Ø 获取任务列表:
taskMgmtSession.findTaskInstances(userName);//userName为指派的人名(或角色名)
Ø 获取任务变量:
TaskController taskController = taskInstance.getTask().getTaskController();
List variableAccesses = taskController.getVariableAccesses();
注:TaskController 有两个关键的函数 initializeVariables,submitParameters,一个用来从流程中把变量置入task实例,另一个则相反,把task中变量更新到流程变量
Ø 根据流程定义找到相关的任务定义
ProcessDefinition pd = jbpmContext.getGraphSession().getProcessDefinition(id);
List tasklist = pd.getTaskMgmtDefinition().getTasks();
Ø 根据流程实例找到任务实例
taskMgmtSession.findTaskInstancesByProcessInstance(processInstance);
jBPM websale代码学习: taskBean.java