Improved handling of gremlin tokens in .NET CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/fcabd01c Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fcabd01c Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fcabd01c Branch: refs/heads/master Commit: fcabd01c4425061334901082a81e62151adaeb64 Parents: 0598846 Author: Stephen Mallette <[email protected]> Authored: Fri Aug 31 14:03:50 2018 -0400 Committer: Stephen Mallette <[email protected]> Committed: Fri Aug 31 14:03:50 2018 -0400 ---------------------------------------------------------------------- gremlin-dotnet/glv/IO.template | 46 ------------------ gremlin-dotnet/glv/Token.template | 43 +++++++++++++++++ gremlin-dotnet/glv/generate.groovy | 23 ++++++--- .../Process/Traversal/ConnectedComponent.cs | 47 ++++++++++++++++++ .../src/Gremlin.Net/Process/Traversal/IO.cs | 3 -- .../Gremlin.Net/Process/Traversal/PageRank.cs | 47 ++++++++++++++++++ .../Process/Traversal/PeerPressure.cs | 47 ++++++++++++++++++ .../Process/Traversal/ShortestPath.cs | 51 ++++++++++++++++++++ 8 files changed, 251 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/glv/IO.template ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/IO.template b/gremlin-dotnet/glv/IO.template deleted file mode 100644 index 7b25c88..0000000 --- a/gremlin-dotnet/glv/IO.template +++ /dev/null @@ -1,46 +0,0 @@ -#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> - /// <see cref="IO" /> keeps configuration options for the io() step. - /// </summary> - public class IO - { - <% io.each {k,v -> %> - public const String <%= k %> = "<%= v %>"; - <% } %> - } - -#pragma warning restore 1591 -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/glv/Token.template ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/Token.template b/gremlin-dotnet/glv/Token.template new file mode 100644 index 0000000..b86634a --- /dev/null +++ b/gremlin-dotnet/glv/Token.template @@ -0,0 +1,43 @@ +#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 + + public class <%= tokenName %> + { + <% tokenFields.each {k,v -> %> + public const String <%= k %> = "<%= v %>"; + <% } %> + } + +#pragma warning restore 1591 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/glv/generate.groovy ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy index 58a5026..0c93f3d 100644 --- a/gremlin-dotnet/glv/generate.groovy +++ b/gremlin-dotnet/glv/generate.groovy @@ -18,6 +18,10 @@ */ import org.apache.tinkerpop.gremlin.jsr223.CoreImports +import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponent +import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRank +import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PeerPressure +import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ShortestPath import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource @@ -225,6 +229,12 @@ def getGraphTraversalT2ForT2 = { t2 -> return t2 } +def gatherTokensFrom = { tokenClasses -> + def m = [:] + tokenClasses.each { tc -> m << [(tc.simpleName) : tc.getFields().sort{ a, b -> a.name <=> b.name }.collectEntries{ f -> [(f.name) : f.get(null)]}]} + return m +} + def binding = ["pmethods": P.class.getMethods(). findAll { Modifier.isStatic(it.getModifiers()) }. findAll { P.class.isAssignableFrom(it.returnType) }. @@ -304,9 +314,7 @@ def binding = ["pmethods": P.class.getMethods(). def graphTraversalT2 = getGraphTraversalT2ForT2(t2) return ["methodName": javaMethod.name, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "callGenericTypeArg":callGenericTypeArg, "graphTraversalT2":graphTraversalT2] }, - "io": IO.class.getFields(). - sort{ a, b -> a.name <=> b.name }. - collectEntries{ f -> [(f.name) : f.get(null)]}, + "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]), "toCSharpMethodName": toCSharpMethodName] def engine = new groovy.text.GStringTemplateEngine() @@ -326,10 +334,11 @@ 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 ioTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/IO.template")).make(binding) -def ioFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/IO.cs") -ioFile.newWriter().withWriter{ it << ioTemplate } - +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") + tokenFile.newWriter().withWriter{ it << tokenTemplate } +} def createEnum = { enumClass -> def b = ["enumClass": enumClass, http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs new file mode 100644 index 0000000..ca1f53e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs @@ -0,0 +1,47 @@ +#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 + + public class ConnectedComponent + { + + public const String component = "gremlin.connectedComponentVertexProgram.component"; + + public const String edges = "~tinkerpop.connectedComponent.edges"; + + public const String propertyName = "~tinkerpop.connectedComponent.propertyName"; + + } + +#pragma warning restore 1591 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs index 861b431..3a57d4b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs @@ -32,9 +32,6 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - /// <summary> - /// <see cref="IO" /> keeps configuration options for the io() step. - /// </summary> public class IO { http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs new file mode 100644 index 0000000..73d248a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs @@ -0,0 +1,47 @@ +#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 + + public class PageRank + { + + public const String edges = "~tinkerpop.pageRank.edges"; + + public const String propertyName = "~tinkerpop.pageRank.propertyName"; + + public const String times = "~tinkerpop.pageRank.times"; + + } + +#pragma warning restore 1591 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs new file mode 100644 index 0000000..185879e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs @@ -0,0 +1,47 @@ +#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 + + public class PeerPressure + { + + public const String edges = "~tinkerpop.peerPressure.edges"; + + public const String propertyName = "~tinkerpop.peerPressure.propertyName"; + + public const String times = "~tinkerpop.peerPressure.times"; + + } + +#pragma warning restore 1591 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs new file mode 100644 index 0000000..f125e42 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs @@ -0,0 +1,51 @@ +#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 + + public class ShortestPath + { + + public const String distance = "~tinkerpop.shortestPath.distance"; + + public const String edges = "~tinkerpop.shortestPath.edges"; + + public const String includeEdges = "~tinkerpop.shortestPath.includeEdges"; + + public const String maxDistance = "~tinkerpop.shortestPath.maxDistance"; + + public const String target = "~tinkerpop.shortestPath.target"; + + } + +#pragma warning restore 1591 +} \ No newline at end of file
