import GEditor, { InitialSettings } from '../geditor'; import GraphView, { IGraph, ILayout } from '../graph-view'; import { INode } from '../node-view'; import { IEdge } from '../edge-view'; import { ISlot } from '../slot-view'; import OperatorNodeView from './node/operator-node-view'; import ConditionNodeView from './node/condition-node'; import SourceTableNodeView from './node/source-table-node-view'; import TargetTableNodeView from './node/target-table-node-view'; import StreamJobNodeView from './node/stream-job-node-view'; import StartNode from './node/start-node'; import EndNode from './node/end-node'; import EdgeView from './edge/edge-view'; import SlotView from './slot/slot-view'; import FunctionNewNode from './node/function-hook-node'; import { NODE_TYPE } from './constants'; export default class DagEditor extends GEditor { getNodeViewClass(nodeConfig: INode) { const type = nodeConfig.type; if (typeof type === 'undefined' || type === NODE_TYPE.OPERATOR) { return OperatorNodeView; } if (type === NODE_TYPE.TASK) { return OperatorNodeView; } if (type === NODE_TYPE.FUNCTION || type === NODE_TYPE.LOGIC) { return FunctionNewNode; } if (type === NODE_TYPE.LOGIC) { return ConditionNodeView; } if (type === NODE_TYPE.START) { return StartNode; } if (type === 'REQUEST') { return StartNode; } if (type === 'RESPONSE') { return EndNode; } if (type === NODE_TYPE.END) { return EndNode; } if (type === NODE_TYPE.SOURCETABLE) { return SourceTableNodeView; } if (type === NODE_TYPE.TARGETTABLE) { return TargetTableNodeView; } if (type === NODE_TYPE.STREAMJOB) { return StreamJobNodeView; } return OperatorNodeView; } getEdgeViewClass(edgeConfig: IEdge) { return EdgeView; } getSlotViewClass(slotConfig: ISlot) { return SlotView; } connectable(srcSlot: SlotView, destSlot: SlotView, graphView: GraphView) { const srcElementType = srcSlot.slotConfig.elementType; const destElementType = destSlot.slotConfig.elementType; // return srcElementType.includes(destElementType) || destElementType.includes(srcElementType); return true; } static create(settings: InitialSettings) { return new DagEditor(settings); } }