public GraphTraversal2 Or(params GraphTraversal2[] orTraversals) { if (orTraversals.Length == 0) { //Infix And step GraphTraversal2 firstTraversal = GraphTraversal2.__(); GraphTraversal2 sencondTraversal = GraphTraversal2.__(); for (var i = 1; i < GremlinTranslationOpList.Count; i++) { firstTraversal.AddGremlinOperator(GremlinTranslationOpList[i].Copy()); } for (var i = 1; i < GremlinTranslationOpList.Count; i++) { GremlinTranslationOpList.RemoveAt(i); } LastGremlinTranslationOp = GremlinTranslationOpList.First(); GremlinOrOp newOrOp = new GremlinOrOp(firstTraversal, sencondTraversal); AddGremlinOperator(newOrOp); } else { AddGremlinOperator(new GremlinOrOp(orTraversals)); } return(this); }
internal void ConfigureStartAndEndSteps(GraphTraversal2 whereTraversal) { if (whereTraversal.TranslationOpList.Count >= 2) { //__.as() GremlinAsOp asOp = whereTraversal.TranslationOpList[1] as GremlinAsOp; if (asOp != null) { whereTraversal.TranslationOpList.RemoveAt(1); //remove as-step whereTraversal.InsertOperator(1, new GremlinSelectOp(GremlinKeyword.Pop.Last, asOp.Labels.First())); } //__.Or() GremlinOrOp orOp = whereTraversal.TranslationOpList[1] as GremlinOrOp; if (orOp != null) { foreach (var traversal in orOp.OrTraversals) { ConfigureStartAndEndSteps(traversal); } } //__.And() GremlinAndOp andOp = whereTraversal.TranslationOpList[1] as GremlinAndOp; if (andOp != null) { foreach (var traversal in andOp.AndTraversals) { ConfigureStartAndEndSteps(traversal); } } //__.Not() GremlinNotOp notOp = whereTraversal.TranslationOpList[1] as GremlinNotOp; if (notOp != null) { ConfigureStartAndEndSteps(notOp.NotTraversal); } } var lastOp = WhereTraversal.GetEndOp() as GremlinAsOp; if (lastOp != null) { string label = lastOp.Labels.First(); whereTraversal.TranslationOpList.Remove(whereTraversal.GetEndOp()); //remove the last as-step whereTraversal.AddOperator(new GremlinWherePredicateOp(Predicate.eq(label))); } }