constructor(parent,globalFlow,subflowDef,subflowInstance) {
        // console.log("CREATE SUBFLOW",subflowDef.id,subflowInstance.id,"alias?",subflowInstance._alias);
        // console.log("SubflowInstance\n"+JSON.stringify(subflowInstance," ",2));
        // console.log("SubflowDef\n"+JSON.stringify(subflowDef," ",2));
        var subflows = parent.flow.subflows;
        var globalSubflows = parent.global.subflows;

        var node_map = {};
        var node;
        var wires;
        var i;

        var subflowInternalFlowConfig = {
            id: subflowInstance.id,
            configs: {},
            nodes: {},
            groups: {},
            subflows: {}
        }

        if (subflowDef.groups) {
            // Clone all of the subflow group definitions and give them new IDs
            for (i in subflowDef.groups) {
                if (subflowDef.groups.hasOwnProperty(i)) {
                    node = createNodeInSubflow(subflowInstance.id,subflowDef.groups[i]);
                    node_map[node._alias] = node;
                    subflowInternalFlowConfig.groups[node.id] = node;
                }
            }
        }
        if (subflowDef.configs) {
            // Clone all of the subflow config node definitions and give them new IDs
            for (i in subflowDef.configs) {
                if (subflowDef.configs.hasOwnProperty(i)) {
                    node = createNodeInSubflow(subflowInstance.id,subflowDef.configs[i]);
                    node_map[node._alias] = node;
                    subflowInternalFlowConfig.configs[node.id] = node;
                }
            }
        }
        if (subflowDef.nodes) {
            // Clone all of the subflow node definitions and give them new IDs
            for (i in subflowDef.nodes) {
                if (subflowDef.nodes.hasOwnProperty(i)) {
                    node = createNodeInSubflow(subflowInstance.id,subflowDef.nodes[i]);
                    node_map[node._alias] = node;
                    subflowInternalFlowConfig.nodes[node.id] = node;
                }
            }
        }

        subflowInternalFlowConfig.subflows = jsonClone(subflowDef.subflows || {});

        remapSubflowNodes(subflowInternalFlowConfig.configs,node_map);
        remapSubflowNodes(subflowInternalFlowConfig.nodes,node_map);
        remapSubflowNodes(subflowInternalFlowConfig.groups,node_map);

        // console.log("Instance config\n",JSON.stringify(subflowInternalFlowConfig,"",2));

        super(parent,globalFlow,subflowInternalFlowConfig);

        this.TYPE = 'subflow';
        this.subflowDef = subflowDef;
        this.subflowInstance = subflowInstance;
        this.node_map = node_map;
        this.path = parent.path+"/"+(subflowInstance._alias||subflowInstance.id);

        let id = subflowInstance.id;
        if (subflowInstance._alias) {
            id = subflowInstance._alias;
        }
        this.templateCredentials = credentials.get(subflowDef.id) || {};
        this.instanceCredentials = credentials.get(id) || {};

        var env = {};
        if (this.subflowDef.env) {
            this.subflowDef.env.forEach(e => {
                env[e.name] = e;
                if (e.type === "cred") {
                    e.value = this.templateCredentials[e.name];
                }
            });
        }
        if (this.subflowInstance.env) {
            this.subflowInstance.env.forEach(e => {
                var old = env[e.name];
                var ui = old ? old.ui : null;
                env[e.name] = e;
                if (ui) {
                    env[e.name].ui = ui;
                }
                if (e.type === "cred") {
                    if (!old || this.instanceCredentials.hasOwnProperty(e.name) ) {
                        e.value = this.instanceCredentials[e.name];
                    } else if (old) {
                        e.value = this.templateCredentials[e.name];
                    }
                }
            });
        }
        this.env = Object.values(env);
    }
Create a Subflow object.
This takes a subflow definition and instance node, creates a clone of the
definition with unique ids applied and passes to the super class.
@param {[type]} parent          [description]
@param {[type]} globalFlow      [description]
@param {[type]} subflowDef      [description]
@param {[type]} subflowInstance [description]