package cn.stylefeng.workflow.instance.api.factory;

import cn.stylefeng.workflow.api.entity.design.Node;
import cn.stylefeng.workflow.api.entity.instance.RuntimeNode;
import cn.stylefeng.workflow.api.enums.NodeStatusEnum;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;

public class RuntimeNodeFactory {

    public static RuntimeNode initRuntimeNode(Node node, Long instanceId) {

        RuntimeNode runtimeNode = new RuntimeNode();

        runtimeNode.setRuNodeId(IdWorker.getId());
        runtimeNode.setInstanceId(instanceId);

        runtimeNode.setModelId(node.getModelId());
        runtimeNode.setDefinitionId(node.getDefinitionId());
        runtimeNode.setNodeId(node.getNodeId());

        runtimeNode.setNodeName(node.getNodeName());
        runtimeNode.setNodeType(node.getNodeType());

        runtimeNode.setNodeStatus(NodeStatusEnum.NONE.getStatus());

        return runtimeNode;
    }

}
