public GremlinOptionalVariable(GremlinVariable inputVariable, GremlinToSqlContext context, GremlinVariableType variableType) : base(variableType) { inputVariable.ProjectedProperties.Clear(); this.OptionalContext = context; this.InputVariable = new GremlinContextVariable(inputVariable); }
internal override GremlinToSqlContext GetContext() { if (InheritedContext != null) { return(InheritedContext); } GremlinToSqlContext newContext = new GremlinToSqlContext { ParentContext = ParentContext }; if (InheritedPivotVariable != null) { GremlinContextVariable newVariable = new GremlinContextVariable(InheritedPivotVariable); newContext.VariableList.Add(newVariable); newContext.SetPivotVariable(newVariable); } return(newContext); }
internal override GremlinToSqlContext GetContext() { if (InheritedContext != null) { return(InheritedContext); } GremlinToSqlContext newContext = new GremlinToSqlContext(); newContext.PathList = InheritedPathList; newContext.ParentContext = ParentContext; if (InheritedPivotVariable != null) { GremlinContextVariable newVariable = GremlinContextVariable.Create(InheritedPivotVariable); newVariable.HomeContext = newContext; newContext.VariableList.Add(newVariable); newContext.PivotVariable = newVariable; } return(newContext); }
internal void OutV(GremlinVariable lastVariable) { if (lastVariable is GremlinFreeEdgeTableVariable) { var path = GetPathFromPathList(lastVariable); if (path != null && path.SourceVariable != null) { if (IsVariableInCurrentContext(path.SourceVariable)) { SetPivotVariable(path.SourceVariable); } else { GremlinContextVariable newContextVariable = GremlinContextVariable.Create(path.SourceVariable); VariableList.Add(newContextVariable); SetPivotVariable(newContextVariable); } } else { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinTableVariable outVertex = lastVariable.CreateAdjVertex(sourceProperty); if (path != null) { path.SetSourceVariable(outVertex); } VariableList.Add(outVertex); TableReferences.Add(outVertex); SetPivotVariable(outVertex); } } else { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinTableVariable outVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty); VariableList.Add(outVertex); TableReferences.Add(outVertex); SetPivotVariable(outVertex); } }
internal List <GremlinVariable> SelectParent(string label, GremlinVariable stopVariable) { List <GremlinVariable> taggedVariableList = ParentContext?.SelectParent(label, HomeVariable); if (taggedVariableList == null) { taggedVariableList = new List <GremlinVariable>(); } var stopIndex = stopVariable == null ? VariableList.Count : VariableList.IndexOf(stopVariable); for (var i = 0; i < stopIndex; i++) { if (VariableList[i].Labels.Contains(label)) { taggedVariableList.Add(GremlinContextVariable.Create(VariableList[i])); } else { if (VariableList[i].ContainsLabel(label)) { List <GremlinVariable> subContextVariableList = VariableList[i].PopulateAllTaggedVariable(label); foreach (var subContextVar in subContextVariableList) { if (subContextVar is GremlinGhostVariable) { var ghostVar = subContextVar as GremlinGhostVariable; var newGhostVar = GremlinGhostVariable.Create(ghostVar.RealVariable, ghostVar.AttachedVariable, label); taggedVariableList.Add(newGhostVar); } else { GremlinGhostVariable newVariable = GremlinGhostVariable.Create(subContextVar, VariableList[i], label); taggedVariableList.Add(newVariable); } } } } } return(taggedVariableList); }