cn.lzgabel.converter.processing.gateway.ParallelGatewayProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camunda-cloud-bpmn-converter Show documentation
Show all versions of camunda-cloud-bpmn-converter Show documentation
Convert json to bpmn for Camunda Cloud.
package cn.lzgabel.converter.processing.gateway;
import cn.lzgabel.converter.bean.BaseDefinition;
import cn.lzgabel.converter.bean.gateway.BranchNode;
import cn.lzgabel.converter.bean.gateway.ParallelGatewayDefinition;
import com.google.common.collect.Lists;
import io.camunda.zeebe.model.bpmn.builder.AbstractFlowNodeBuilder;
import io.camunda.zeebe.model.bpmn.builder.ParallelGatewayBuilder;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
/**
* 〈功能简述〉
* 〈ParallelGateway节点类型详情设置〉
*
* @author lizhi
* @since 1.0.0
*/
public class ParallelGatewayProcessor
extends AbstractGatewayProcessor {
@Override
public String onComplete(
AbstractFlowNodeBuilder flowNodeBuilder, ParallelGatewayDefinition flowNode)
throws InvocationTargetException, IllegalAccessException {
String name = flowNode.getNodeName();
ParallelGatewayBuilder parallelGatewayBuilder = flowNodeBuilder.parallelGateway().name(name);
List branchNodes = flowNode.getBranchNodes();
if (CollectionUtils.isEmpty(branchNodes) && Objects.isNull(flowNode.getNextNode())) {
return parallelGatewayBuilder.getElement().getId();
}
List incoming = Lists.newArrayListWithCapacity(branchNodes.size());
for (BranchNode branchNode : branchNodes) {
BaseDefinition childNode = branchNode.getNextNode();
if (Objects.isNull(childNode)) {
incoming.add(parallelGatewayBuilder.getElement().getId());
continue;
}
String id =
onCreate(
moveToNode(parallelGatewayBuilder, parallelGatewayBuilder.getElement().getId()),
childNode);
if (StringUtils.isNotBlank(id)) {
incoming.add(id);
}
}
String id = parallelGatewayBuilder.getElement().getId();
BaseDefinition nextNode = flowNode.getNextNode();
if (Objects.nonNull(nextNode)) {
nextNode.setIncoming(incoming);
return merge(parallelGatewayBuilder, id, Collections.emptyList(), nextNode);
}
return id;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy