几天第一次接触activiti

今天接触了activiti工作流框架。

看了看终于把自己的第一个helloworld给写出来了,有一点收获感。

 

 

但是还是有好多东西不明白的,找资料,关于这方面的又少,分享一下,希望哪位大神可以知道一下.....

 

首先呢,我西安说一下,写这个helloworld容易出错的地方吧,

 

第一点呢,就是HelloWorld.bpmn20.xml 。这个很容易出错,当用eclipse创建了一个activiti Diagram后,名字还要自己改成后缀名为xml的文档,而默认的名字 name.bpmn也的在bpmn后面加上20.这个不知道是什么情况,应该是默认的....

 

第二点呢,就是在写test类的时候

repositoryService.createDeployment().addClasspathResource("hello/HelloWorld.bpmn20.xml").deploy();

 

老师后面送的deploy忘记写上,那样额话改改报no processes deploy了,所以呢,大家如果新学得注意一下了。

 

最后还有几个问题,希望看到的大神们帮我解答一下。

 

 

package hello;

import static org.junit.Assert.*;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.Test;

public class HelloWorldTest {

	@Test
	public void test() {
		ProcessEngineConfiguration processEngineConfiguration=ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
		
		ProcessEngine processEngine=processEngineConfiguration.buildProcessEngine();
		
		RepositoryService repositoryService=processEngine.getRepositoryService();
		
		RuntimeService runtimeService=processEngine.getRuntimeService();
		
		TaskService taskService=processEngine.getTaskService();
		
		
		repositoryService.createDeployment().addClasspathResource("hello/HelloWorld.bpmn20.xml").deploy();
		ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("process1");
		
		Task task=taskService.createTaskQuery().singleResult();
		System.out.println(task.getName());
		
		taskService.complete(task.getId());
		task = taskService.createTaskQuery().singleResult();
		System.out.println(task.getName());
	}

}

 taskService.complete(task.getId());

 

 

这句代码不是很了解,请帮我解答一下,下面是我的流程图。

 

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="process1" name="process1">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="HelloWorld1"></userTask>
    <userTask id="usertask2" name="HelloWorld2"></userTask>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" name="" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="hello.HelloService"></serviceTask>
    <sequenceFlow id="flow4" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow5" name="" sourceRef="servicetask1" targetRef="usertask1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_process1">
    <bpmndi:BPMNPlane bpmnElement="process1" id="BPMNPlane_process1">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="40" y="100"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="210" y="90"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55" width="105" x="390" y="90"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="425" y="210"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55" width="105" x="90" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="315" y="117"></omgdi:waypoint>
        <omgdi:waypoint x="390" y="117"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="442" y="145"></omgdi:waypoint>
        <omgdi:waypoint x="442" y="210"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="57" y="135"></omgdi:waypoint>
        <omgdi:waypoint x="142" y="200"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="142" y="200"></omgdi:waypoint>
        <omgdi:waypoint x="262" y="145"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
 

 

你可能感兴趣的:(Activiti,工作流)