cancel
Showing results for 
Search instead for 
Did you mean: 

How to use FromServiece and exlusive Gateway?

euros
Champ in-the-making
Champ in-the-making
I am new to activiti so i followed this tutorial to get a running version i also added some code myself
http://rioasmara.wordpress.com/2013/01/26/simple-activiti-bpm-and-spring-for-task-assignment/

But I have two Problems.
First I am not able to get the formProperties.
My BPM process i wanted to use:

<blockcode>
<?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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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="vacationRequest" name="Urlaubsantrag" isExecutable="true">
    <startEvent id="startevent1" name="Start">
      <extensionElements>
        <activiti:formProperty id="okNow"></activiti:formProperty>
      </extensionElements>
    </startEvent>
    <userTask id="requestVacation1" name="RequestVacation1">
      <documentation>hallo ich will Urlaub</documentation>
      <extensionElements>
        <activiti:formProperty id="name"></activiti:formProperty>
        <activiti:formProperty id="start" type="date"></activiti:formProperty>
        <activiti:formProperty id="end" type="date"></activiti:formProperty>
        <activiti:formProperty id="motivation"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <userTask id="confirmVacation" name="ConfirmVacation">
      <extensionElements>
        <activiti:formProperty id="reject" type="boolean"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1ToRequest" sourceRef="startevent1" targetRef="requestVacation1"></sequenceFlow>
    <userTask id="registervacation" name="Register Vacation">
      <extensionElements>
        <activiti:formProperty id="submit" type="boolean"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow5" sourceRef="registervacation" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow7toConfirm" sourceRef="requestVacation1" targetRef="confirmVacation"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow8toEx" sourceRef="confirmVacation" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow9reject" sourceRef="exclusivegateway1" targetRef="startevent1">
      <conditionExpression xsi:type="tFormalExpression"><${requestVacation1==false}></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow10submit" sourceRef="exclusivegateway1" targetRef="registervacation">
      <conditionExpression xsi:type="tFormalExpression"><${requestVacation1==true}></conditionExpression>
    </sequenceFlow>
  </process>
 
</definitions>
</blockcode>

I thought i get the properties from the FormServiece but everything i try returns only empty lists.

formserviece.getRenderedTaskForm(taskId);
formserviece.getStartFormData(processDefinitionID).getFormProperties();

I hope you can help my how i get the properties.

My second Problem is that i am not able to use the exlusivegateway.
Everytime i set the the process "ConfirmVacation" to complet "Register Vacation" is automatically started.

Thank you
2 REPLIES 2

trademak
Star Contributor
Star Contributor
If you create a unit test showing your issue it's easier to look into. In general the form properties look ok to me.
If you see the process always continuing to "Register Vacation", maybe the variable value is always the one defined for that sequence flow?

Best regards,

euros
Champ in-the-making
Champ in-the-making
Ok I creat a unit test. I checked out the unit test from the git hub and added some lines.

My test BPM process looks like that
<code>
<?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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlnsSmiley Surprisedmgdi="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="my-process">

  <startEvent id="start" />
  <sequenceFlow id="flow1" sourceRef="start" targetRef="someTask" />

  <userTask id="someTask" name="Activiti is awesome!" >
  <documentation>hallo ich will Urlaub</documentation>
   <extensionElements>
    <activiti:formProperty id="name"></activiti:formProperty>
    <activiti:formProperty id="start" type="date"></activiti:formProperty>
    <activiti:formProperty id="end" type="date"></activiti:formProperty>
    <activiti:formProperty id="motivation"></activiti:formProperty>
   </extensionElements>
  </userTask>
  <sequenceFlow id="flow2" sourceRef="someTask" targetRef="end"/>

   <endEvent id="end" />

</process>

</definitions>
</code>

and my unit test like that

<java>
package org.activiti;
import org.activiti.engine.FormService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.junit.Rule;
import org.junit.Test;

import static org.junit.Assert.*;

public class MyUnitTest {

@Rule
public ActivitiRule activitiRule = new ActivitiRule();

@Test
@Deployment(resources = {"org/activiti/test/my-process.bpmn20.xml"})
public void test() {
  ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey("my-process");
  assertNotNull(processInstance);
  FormService formService = activitiRule.getFormService();
  Task task = activitiRule.getTaskService().createTaskQuery().singleResult();
  assertEquals("Activiti is awesome!", task.getName()); 
  assertTrue(formService.getRenderedTaskForm(task.getId()) != null);
  assertTrue(formService.getStartFormData(processInstance.getProcessDefinitionId()).getFormProperties().size()!=0 );
 
}

}
</java>

So i hope you can explain me why my test fails
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.