AnsweredAssumed Answered

Process via Java Class

Question asked by r_g on Jul 3, 2015
Latest reply on Jul 13, 2015 by r_g
Hi everyone,

maybe my understanding isn't good enough, but i'm trying to run process via a  Pojo with that i can set all users, all variables and claim all task. Can anyone show a what the correct commands to do this ?


<?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:xsd="http://www.w3.org/2001/XMLSchema" 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="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="170.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="250.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="400.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="205.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="355.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="400.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>





Now I'm only trying to run this process an to claim the user task.


package org.activiti.designer.test;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RuntimeService;

public class testclass {

   ProcessEngine processEngine = ProcessEngineConfiguration
         .createStandaloneInMemProcessEngineConfiguration()
          .buildProcessEngine();
      
      RuntimeService runtimeService = processEngine.getRuntimeService();
      RepositoryService repositoryService = processEngine.getRepositoryService();
      repositoryService.createDeployment().addInputStream("MyProcess.bpmn20.xml",
            new FileInputStream(filename))
         .deploy();
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put("Rechnung", "erste");
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
            "myProcess", variableMap);
      assertNotNull(processInstance.getId());
      System.out.println("id " + processInstance.getId() + " "
            + processInstance.getProcessDefinitionId());
      Task task = processEngine.getTaskService().createTaskQuery().singleResult();
      assertEquals("User Task", task.getName());
      System.out.println("id " + task.getId() + " "
            + task.getName());
      
}



can anyone show a good example to do this ? or show what i must use now to claim the task or where i can find the command ? because i didn't find it….

kind regars
Raphael

Outcomes