package cn.axzo.workflow.core.converter.json;

import cn.axzo.workflow.common.model.request.bpmn.BpmnJsonNode;
import org.flowable.bpmn.model.ParallelGateway;
import org.flowable.bpmn.model.Process;
import org.springframework.util.StringUtils;

import java.util.Objects;

/**
 * 并行网关
 *
 * @author wangli
 * @since 2023/10/16 20:51
 */
public class ParallelGatewayJsonConverter extends AbstractBpmnJsonConverter<ParallelGateway> {

    @Override
    public ParallelGateway convertJsonToElement(BpmnJsonNode node, Process process) {
        ParallelGateway parallelGateway = new ParallelGateway();
        parallelGateway.setId(node.getId());
        parallelGateway.setName(node.getName());
        if ((Objects.isNull(node.getChildren()) || !StringUtils.hasLength(node.getId()))
                && Objects.isNull(node.getBranches())) {
            return parallelGateway;
        }
        return parallelGateway;
    }
}
