Activiti exclusive gateway - using in Java

筅森魡賤 提交于 2019-12-10 17:29:24

问题


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?


回答1:


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




回答2:


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);



来源:https://stackoverflow.com/questions/36766569/activiti-exclusive-gateway-using-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!