예제 #1
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            FromVertexTraversal?.GetStartOp().InheritedVariableFromParent(inputContext);
            GremlinToSqlContext fromVertexContext = FromVertexTraversal?.GetEndOp().GetContext();

            ToVertexTraversal?.GetStartOp().InheritedVariableFromParent(inputContext);
            GremlinToSqlContext toVertexContext = ToVertexTraversal?.GetEndOp().GetContext();

            List <GremlinProperty> edgeProperties = new List <GremlinProperty>();

            edgeProperties.AddRange(EdgePropertyOps.Select(propertyOp => propertyOp.ToGremlinProperty(inputContext)));

            if (inputContext.PivotVariable == null)
            {
                if (fromVertexContext == null || toVertexContext == null)
                {
                    throw new SyntaxErrorException("The PivotVariable of addE()-step and fromTraversal( or toTraversal) can't be null at the same time.");
                }

                GremlinAddETableVariable newTableVariable = new GremlinAddETableVariable(null, EdgeLabel, edgeProperties, fromVertexContext, toVertexContext, true);
                inputContext.VariableList.Add(newTableVariable);
                inputContext.TableReferencesInFromClause.Add(newTableVariable);
                inputContext.SetPivotVariable(newTableVariable);
            }
            else
            {
                inputContext.PivotVariable.AddE(inputContext, EdgeLabel, edgeProperties, fromVertexContext, toVertexContext);
            }

            return(inputContext);
        }
예제 #2
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (inputContext.PivotVariable == null)
            {
                throw new QueryCompilationException("AddE should follow by a Vertex");
            }

            FromVertexTraversal?.GetStartOp().InheritedVariableFromParent(inputContext);
            GremlinToSqlContext fromVertexContext = FromVertexTraversal?.GetEndOp().GetContext();

            ToVertexTraversal?.GetStartOp().InheritedVariableFromParent(inputContext);
            GremlinToSqlContext toVertexContext = ToVertexTraversal?.GetEndOp().GetContext();

            inputContext.PivotVariable.AddE(inputContext, EdgeLabel, EdgeProperties, fromVertexContext, toVertexContext);

            return(inputContext);
        }