[list]
[*]一、定义流程模板
使用定义工具定义模板
[*]二、部署流程
[*]三、启动流程实例
[*]四、获取任务列表
[*]五、执行任务
[*]六、结束任务
[/list]
[*]一、定义流程模板
使用定义工具定义模板
[*]二、部署流程
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
jbpmConfiguration.createSchema();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
ProcessDefinition pd = ProcessDefinition
.parseXmlResource("com/jpdm/processdefinition.xml");
jbpmContext.deployProcessDefinition(pd);
[*]三、启动流程实例
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition = graphSession
.findLatestProcessDefinition("payment");
ProcessInstance processInstance = new ProcessInstance(
processDefinition);
jbpmContext.save(processInstance);
processInstance.signal();
[*]四、获取任务列表
List<TaskInstance> tasks = jbpmContext.getTaskList(actorId);
for (TaskInstance ti : tasks) {
System.out.println("id=" + ti.getId() + ", name="
+ ti.getName() + ", create=" + ti.getCreate()
+ ", start=" + ti.getStart() + ", end=" + ti.getEnd());
}
[*]五、执行任务
TaskInstance taskInstance = jbpmContext
.getTaskInstance(taskInstanceId);
taskInstance.start();
jbpmContext.save(taskInstance);
[*]六、结束任务
TaskInstance taskInstance=jbpmContext.getTaskInstance(taskInstanceId);
taskInstance.end();
jbpmContext.save(taskInstance);
[/list]