Repository: tinkerpop Updated Branches: refs/heads/TINKERPOP-2041 f5845c644 -> 6245880e6
wip Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6245880e Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6245880e Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6245880e Branch: refs/heads/TINKERPOP-2041 Commit: 6245880e6fc084b27e543eb12439b3975569b893 Parents: f5845c6 Author: Daniel Kuppitz <[email protected]> Authored: Thu Sep 27 14:54:34 2018 -0700 Committer: Daniel Kuppitz <[email protected]> Committed: Thu Sep 27 14:54:34 2018 -0700 ---------------------------------------------------------------------- gremlin-dotnet/glv/TP.template | 71 +++++++++++++++ gremlin-dotnet/glv/generate.groovy | 6 +- .../src/Gremlin.Net/Process/Traversal/TP.cs | 96 ++++++++++++++++++++ .../Structure/IO/GraphSON/GraphSONWriter.cs | 3 +- .../Structure/IO/GraphSON/TPSerializer.cs | 45 +++++++++ .../gremlin/process/ProcessStandardSuite.java | 8 +- 6 files changed, 223 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6245880e/gremlin-dotnet/glv/TP.template ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/TP.template b/gremlin-dotnet/glv/TP.template new file mode 100644 index 0000000..22320ea --- /dev/null +++ b/gremlin-dotnet/glv/TP.template @@ -0,0 +1,71 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace Gremlin.Net.Process.Traversal +{ +#pragma warning disable 1591 + + /// <summary> + /// A <see cref="TP" /> is a predicate of the form Func<string, bool>. + /// That is, given some string, return true or false. + /// </summary> + public class TP : P + { + /// <summary> + /// Initializes a new instance of the <see cref="TP" /> class. + /// </summary> + /// <param name="operatorName">The name of the predicate.</param> + /// <param name="value">The value of the predicate.</param> + /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param> + public TP(string operatorName, string value, P other = null) : base(operatorName, value, other) + { + } + +<% tpmethods.each { method -> %> + public static TP <%= toCSharpMethodName.call(method) %>(string value) + { + return new TP("<%= method %>", value); + } +<% } %> + + private static T[] ToGenericArray<T>(ICollection<T> collection) + { + return collection?.ToArray() ?? new T[0]; + } + + /// <inheritdoc /> + public override string ToString() + { + return Other == null ? \$"{OperatorName}({Value})" : \$"{OperatorName}({Value},{Other})"; + } + } + +#pragma warning restore 1591 +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6245880e/gremlin-dotnet/glv/generate.groovy ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy index 19c4955..3dbd959 100644 --- a/gremlin-dotnet/glv/generate.groovy +++ b/gremlin-dotnet/glv/generate.groovy @@ -342,6 +342,10 @@ def pTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/P.template def pFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/P.cs") pFile.newWriter().withWriter{ it << pTemplate } +def tpTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/TP.template")).make(binding) +def tpFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/TP.cs") +tpFile.newWriter().withWriter{ it << tpTemplate } + binding.tokens.each {k,v -> def tokenTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Token.template")).make([tokenFields: v, tokenName: k]) def tokenFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/${k}.cs") @@ -390,4 +394,4 @@ def templateCsprojFile = new File("${projectBaseDir}/src/Gremlin.Net.Template/Gr templateCsprojFile.newWriter().withWriter{ it << templateCsprojTemplate } def nuspecTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Gremlin.Net.Template.nuspec.template")).make(["projectVersion":versionToUse]) def nuspecFile = new File("${projectBaseDir}/src/Gremlin.Net.Template/Gremlin.Net.Template.nuspec") -nuspecFile.newWriter().withWriter{ it << nuspecTemplate } \ No newline at end of file +nuspecFile.newWriter().withWriter{ it << nuspecTemplate } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6245880e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TP.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TP.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TP.cs new file mode 100644 index 0000000..ac6415d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TP.cs @@ -0,0 +1,96 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace Gremlin.Net.Process.Traversal +{ +#pragma warning disable 1591 + + /// <summary> + /// A <see cref="TP" /> is a predicate of the form Func<string, bool>. + /// That is, given some string, return true or false. + /// </summary> + public class TP : P + { + /// <summary> + /// Initializes a new instance of the <see cref="P" /> class. + /// </summary> + /// <param name="operatorName">The name of the predicate.</param> + /// <param name="value">The value of the predicate.</param> + /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param> + public TP(string operatorName, string value, P other = null) : base(operatorName, value, other) + { + } + + + public static TP Absent(string value) + { + return new TP("absent", value); + } + + public static TP Contains(string value) + { + return new TP("contains", value); + } + + public static TP EndsNotWith(string value) + { + return new TP("endsNotWith", value); + } + + public static TP EndsWith(string value) + { + return new TP("endsWith", value); + } + + public static TP StartsNotWith(string value) + { + return new TP("startsNotWith", value); + } + + public static TP StartsWith(string value) + { + return new TP("startsWith", value); + } + + + private static T[] ToGenericArray<T>(ICollection<T> collection) + { + return collection?.ToArray() ?? new T[0]; + } + + /// <inheritdoc /> + public override string ToString() + { + return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})"; + } + } + +#pragma warning restore 1591 +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6245880e/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs index 9349e57..3178d21 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs @@ -58,6 +58,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON {typeof(Type), new ClassSerializer()}, {typeof(EnumWrapper), new EnumSerializer()}, {typeof(P), new PSerializer()}, + {typeof(TP), new TPSerializer()}, {typeof(Vertex), new VertexSerializer()}, {typeof(Edge), new EdgeSerializer()}, {typeof(Property), new PropertySerializer()}, @@ -163,4 +164,4 @@ namespace Gremlin.Net.Structure.IO.GraphSON yield return ToDict(e); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6245880e/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TPSerializer.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TPSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TPSerializer.cs new file mode 100644 index 0000000..22ed358 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TPSerializer.cs @@ -0,0 +1,45 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class TPSerializer : IGraphSONSerializer + { + public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer) + { + TP p = predicate; + var value = p.Other == null + ? writer.ToDict(p.Value) + : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)}; + var dict = new Dictionary<string, dynamic> + { + {"predicate", p.OperatorName}, + {"value", value} + }; + return GraphSONUtil.ToTypedValue("TP", dict); + } + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6245880e/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java index aa31319..f3eb669 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java @@ -109,7 +109,7 @@ public class ProcessStandardSuite extends AbstractGremlinSuite { */ private static final Class<?>[] allTests = new Class<?>[]{ // branch - /*BranchTest.Traversals.class, + BranchTest.Traversals.class, ChooseTest.Traversals.class, OptionalTest.Traversals.class, LocalTest.Traversals.class, @@ -122,8 +122,8 @@ public class ProcessStandardSuite extends AbstractGremlinSuite { CyclicPathTest.Traversals.class, DedupTest.Traversals.class, DropTest.Traversals.class, - FilterTest.Traversals.class,*/ - HasTest.Traversals.class/*, + FilterTest.Traversals.class, + HasTest.Traversals.class, IsTest.Traversals.class, OrTest.Traversals.class, RangeTest.Traversals.class, @@ -191,7 +191,7 @@ public class ProcessStandardSuite extends AbstractGremlinSuite { SubgraphStrategyProcessTest.class, // optimizations - IncidentToAdjacentStrategyProcessTest.class*/ + IncidentToAdjacentStrategyProcessTest.class }; /**
