Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activiti - how to set condition for exclusive gateway in Java

I have an exclusive gateway in Activiti, how I can set the condition variable in Java code for exclusive gateway?

variableData.put("condition", conditionVar);
taskService.complete(task.getId(), variableData);

How I can extract task variable on gateway flow? Is it possible or I have to use process variable?

like image 446
J-Alex Avatar asked Apr 21 '16 10:04

J-Alex


2 Answers

When you design your workflow with conditional exclusive gateway then it will generate XML like below,

<exclusiveGateway id="exclusiveGw" name="Exclusive Gateway" />

<sequenceFlow id="flow2" sourceRef="exclusiveGw" targetRef="theTask1">
  <conditionExpression xsi:type="tFormalExpression">${input == 1}</conditionExpression>
</sequenceFlow>

so you need to provide a value of 'input' variable as

variableData.put("input", 1);

If your task is ServiceTask then you can do like below

delegateExecution.setVariable("input",1);

For more help http://www.activiti.org/userguide/#bpmnExclusiveGateway

like image 144
NIrav Modi Avatar answered Sep 25 '22 00:09

NIrav Modi


In process deploy time:

  • you can add expression condition in Java by extends org.activiti.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory and inject to ProcessEngineConfigurationImpl

In process execution time:

  • you can add process variables as variable of you defined expression. It could be result of your condition in Java: ${result == true}

    variableData.put("result", resultOfJavaCondition); taskService.complete(task.getId(), variableData);

like image 38
fersmi Avatar answered Sep 25 '22 00:09

fersmi