This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch TINKERPOP-2391 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 8de2aa44129604bff68070033be01a51d2143185 Author: Stephen Mallette <[email protected]> AuthorDate: Wed Jul 8 21:46:04 2020 -0400 TINKERPOP-2391 Remove GLV templating system --- gremlin-dotnet/glv/AnonymousTraversal.template | 59 --- gremlin-dotnet/glv/Enum.template | 69 ---- gremlin-dotnet/glv/GraphTraversal.template | 104 ------ gremlin-dotnet/glv/GraphTraversalSource.template | 149 -------- .../glv/Gremlin.Net.Template.csproj.template | 32 -- .../glv/Gremlin.Net.Template.nuspec.template | 23 -- gremlin-dotnet/glv/Gremlin.Net.csproj.template | 76 ---- gremlin-dotnet/glv/P.template | 113 ------ gremlin-dotnet/glv/TextP.template | 68 ---- gremlin-dotnet/glv/Token.template | 43 --- gremlin-dotnet/glv/WithOptions.template | 47 --- gremlin-dotnet/glv/generate.groovy | 406 -------------------- gremlin-dotnet/pom.xml | 48 --- .../glv/GraphTraversalSource.template | 154 -------- gremlin-javascript/glv/PackageJson.template | 62 --- gremlin-javascript/glv/TraversalSource.template | 297 --------------- gremlin-javascript/glv/generate.groovy | 134 ------- gremlin-javascript/pom.xml | 22 -- gremlin-python/glv/GraphTraversalSource.template | 206 ---------- gremlin-python/glv/TraversalSource.template | 415 --------------------- gremlin-python/glv/generate.groovy | 130 ------- gremlin-python/pom.xml | 18 - 22 files changed, 2675 deletions(-) diff --git a/gremlin-dotnet/glv/AnonymousTraversal.template b/gremlin-dotnet/glv/AnonymousTraversal.template deleted file mode 100644 index 6b1de9c..0000000 --- a/gremlin-dotnet/glv/AnonymousTraversal.template +++ /dev/null @@ -1,59 +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 - -using System.Collections.Generic; -using Gremlin.Net.Structure; - -// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml -namespace Gremlin.Net.Process.Traversal -{ - /// <summary> - /// An anonymous <see cref="GraphTraversal{SType, EType}" />. - /// </summary> - public static class __ - { - /// <summary> - /// Starts an empty <see cref="GraphTraversal{SType, EType}" />. - /// </summary> - public static GraphTraversal<object, object> Start() - { - return new GraphTraversal<object, object>(); - } -<% anonStepMethods.each { method -> %> - /// <summary> - /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the <%= method.methodName %> step to that traversal. - /// </summary> - public static GraphTraversal<object, <%= method.t2 %>> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(<%= method.parameters %>) - { - <% if (method.parameters.contains("params ")) { - %> return <%= method.paramNames.last() %>.Length == 0 - ? new GraphTraversal<object, <%= method.graphTraversalT2 %>>().<%= toCSharpMethodName.call(method.methodName) %><%= method.callGenericTypeArg %>(<%= method.paramNames.init().join(", ") %>) - : new GraphTraversal<object, <%= method.graphTraversalT2 %>>().<%= toCSharpMethodName.call(method.methodName) %><%= method.callGenericTypeArg %>(<%= method.paramNames.join(", ") %>);<% - } - else { - %> return new GraphTraversal<object, <%= method.graphTraversalT2 %>>().<%= toCSharpMethodName.call(method.methodName) %><%= method.callGenericTypeArg %>(<%= method.paramNames.join(", ") %>);<% - } %> - } -<% } %> - } -} \ No newline at end of file diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template deleted file mode 100644 index e785cd0..0000000 --- a/gremlin-dotnet/glv/Enum.template +++ /dev/null @@ -1,69 +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.Generic; - -namespace Gremlin.Net.Process.Traversal -{ -#pragma warning disable 1591 - - public class <%= enumClass.simpleName %> : <%= implementedTypes %> - { - private <%= enumClass.simpleName %>(string enumValue) - : base("<%= enumClass.simpleName %>", enumValue) - { - } -<% - def toCSharpName = { enumClass, itemName -> - if (enumClass.equals(directionClass)) { - itemName = itemName.toLowerCase() - } - - return itemName.substring(0, 1).toUpperCase() + itemName.substring(1) - } - constants.each { value -> %> - public static ${enumClass.simpleName} ${toCSharpName(enumClass, value.name())} => new ${enumClass.simpleName}("${value.name()}"); -<% }%> - private static readonly IDictionary<string, <%= enumClass.simpleName %>> Properties = new Dictionary<string, <%= enumClass.simpleName %>> - {<% constants.each { value -> %> - { "${value.name()}", ${toCSharpName(enumClass, value.name())} },<% }%> - }; - - /// <summary> - /// Gets the <%= enumClass.simpleName %> enumeration by value. - /// </summary> - public static <%= enumClass.simpleName %> GetByValue(string value) - { - if (!Properties.TryGetValue(value, out var property)) - { - throw new ArgumentException(\$"No matching <%= enumClass.simpleName%> for value '{value}'"); - } - return property; - } - } - - -#pragma warning restore 1591 -} \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversal.template b/gremlin-dotnet/glv/GraphTraversal.template deleted file mode 100644 index 4dad324..0000000 --- a/gremlin-dotnet/glv/GraphTraversal.template +++ /dev/null @@ -1,104 +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 - -using System.Collections.Generic; -using System.Linq; -using Gremlin.Net.Structure; - -// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml -namespace Gremlin.Net.Process.Traversal -{ - /// <summary> - /// Graph traversals are the primary way in which graphs are processed. - /// </summary> - public class GraphTraversal<S, E> : DefaultTraversal<S, E> - { - /// <summary> - /// Initializes a new instance of the <see cref="GraphTraversal{SType, EType}" /> class. - /// </summary> - public GraphTraversal() - : this(new List<ITraversalStrategy>(), new Bytecode(), true) - { - } - - /// <summary> - /// Initializes a new instance of the <see cref="GraphTraversal{SType, EType}" /> class. - /// </summary> - /// <param name="traversalStrategies">The traversal strategies to be used by this graph traversal at evaluation time.</param> - /// <param name="bytecode">The <see cref="Bytecode" /> associated with the construction of this graph traversal.</param> - public GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode) - : this(traversalStrategies, bytecode, false) - { - } - - /// <summary> - /// Initializes a new instance of the <see cref="GraphTraversal{SType, EType}" /> class. - /// </summary> - /// <param name="traversalStrategies">The traversal strategies to be used by this graph traversal at evaluation time.</param> - /// <param name="bytecode">The <see cref="Bytecode" /> associated with the construction of this graph traversal.</param> - /// <param name="anonymous">Set to true if spawned from an anonymous traversal source and false otherwise.</param> - private GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode, bool anonymous) - { - TraversalStrategies = traversalStrategies; - Bytecode = bytecode; - IsAnonymous = anonymous; - } - - private static GraphTraversal<S2, E2> Wrap<S2, E2>(GraphTraversal<S, E> traversal) - { - if (typeof(S2) == typeof(S) && typeof(E2) == typeof(E)) - { - return traversal as GraphTraversal<S2, E2>; - } - // New wrapper - return new GraphTraversal<S2, E2>(traversal.TraversalStrategies, traversal.Bytecode, traversal.IsAnonymous); - } - -<% graphStepMethods.each { method -> %> - /// <summary> - /// Adds the <%= method.methodName %> step to this <see cref="GraphTraversal{SType, EType}" />. - /// </summary> - public GraphTraversal<$method.t1, $method.t2> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %> (<%= method.parameters %>) - { - <% if (method.parameters.contains("params ")) { - %> var args = new List<object>(<%= method.paramNames.init().size() %> + <%= method.paramNames.last() %>.Length) {<%= method.paramNames.init().join(", ") %>}; - args.AddRange(<%= method.paramNames.last() %><% if (method.isArgsCastNecessary) { %>.Cast<object>()<% } %>); - Bytecode.AddStep("<%= method.methodName %>", args.ToArray());<% - } - else { - %> Bytecode.AddStep("<%= method.methodName %>"<% if (method.parameters) out << ', '+ method.paramNames.join(", ") %>);<% - } - %> - return Wrap<$method.t1, $method.t2>(this); - } -<% } %> - - /// <summary> - /// Make a copy of a traversal that is reset for iteration. - /// </summary> - public GraphTraversal<S, E> Clone() - { - return new GraphTraversal<S, E>(TraversalStrategies, new Bytecode(Bytecode)); - } - } -} \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversalSource.template b/gremlin-dotnet/glv/GraphTraversalSource.template deleted file mode 100644 index f3093e5..0000000 --- a/gremlin-dotnet/glv/GraphTraversalSource.template +++ /dev/null @@ -1,149 +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 - -using System; -using System.Collections.Generic; -using System.Linq; -using Gremlin.Net.Process.Remote; -using Gremlin.Net.Process.Traversal.Strategy.Decoration; -using Gremlin.Net.Structure; - -// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml -namespace Gremlin.Net.Process.Traversal -{ -#pragma warning disable 1591 - - /// <summary> - /// A <see cref="GraphTraversalSource" /> is the primary DSL of the Gremlin traversal machine. - /// It provides access to all the configurations and steps for Turing complete graph computing. - /// </summary> - public class GraphTraversalSource - { - /// <summary> - /// Gets or sets the traversal strategies associated with this graph traversal source. - /// </summary> - public ICollection<ITraversalStrategy> TraversalStrategies { get; set; } - - /// <summary> - /// Gets or sets the <see cref="Traversal.Bytecode" /> associated with the current state of this graph traversal - /// source. - /// </summary> - public Bytecode Bytecode { get; set; } - - /// <summary> - /// Initializes a new instance of the <see cref="GraphTraversalSource" /> class. - /// </summary> - public GraphTraversalSource() - : this(new List<ITraversalStrategy>(), new Bytecode()) - { - } - - /// <summary> - /// Initializes a new instance of the <see cref="GraphTraversalSource" /> class. - /// </summary> - /// <param name="traversalStrategies">The traversal strategies associated with this graph traversal source.</param> - /// <param name="bytecode"> - /// The <see cref="Traversal.Bytecode" /> associated with the current state of this graph traversal - /// source. - /// </param> - public GraphTraversalSource(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode) - { - TraversalStrategies = traversalStrategies; - Bytecode = bytecode; - } - -<% sourceStepMethods.each{ method -> %> - public GraphTraversalSource <%= toCSharpMethodName.call(method.methodName) %>(<%= method.parameters %>) - { - var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), - new Bytecode(Bytecode)); - <% if (method.parameters.contains("params ")) { - %>var args = new List<object>(<%= method.paramNames.init().size() %> + <%= method.paramNames.last() %>.Length) {<%= method.paramNames.init().join(", ") %>}; - args.AddRange(<%= method.paramNames.last() %>); - source.Bytecode.AddSource("<%= method.methodName %>", args.ToArray());<% - } - else { - %>source.Bytecode.AddSource("<%= method.methodName %>"<% if (method.parameters) out << ', '+ method.paramNames.join(", ") %>);<% - } - %> - return source; - } -<% } %> - [Obsolete("Use the Bindings class instead.", false)] - public GraphTraversalSource WithBindings(object bindings) - { - return this; - } - - /// <summary> - /// Configures the <see cref="GraphTraversalSource" /> as a "remote" to issue the - /// <see cref="GraphTraversal{SType, EType}" /> for execution elsewhere. - /// </summary> - /// <param name="remoteConnection"> - /// The <see cref="IRemoteConnection" /> instance to use to submit the - /// <see cref="GraphTraversal{SType, EType}" />. - /// </param> - /// <returns>A <see cref="GraphTraversalSource" /> configured to use the provided <see cref="IRemoteConnection" />.</returns> - public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) - { - var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), - new Bytecode(Bytecode)); - source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); - return source; - } - - /// <summary> - /// Add a GraphComputer class used to execute the traversal. - /// This adds a <see cref="VertexProgramStrategy" /> to the strategies. - /// </summary> - public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, - string result = null, ITraversal vertices = null, ITraversal edges = null, - Dictionary<string, dynamic> configuration = null) - { - return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); - } - -<% sourceSpawnMethods.each { method -> %> - /// <summary> - /// Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the <%= method.methodName %> step to that - /// traversal. - /// </summary> - public GraphTraversal<$method.t1, $method.t2> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(<%= method.parameters %>) - { - var traversal = new GraphTraversal<$method.t1, $method.t2>(TraversalStrategies, new Bytecode(Bytecode)); - <% if (method.parameters.contains("params ")) { - %>var args = new List<object>(<%= method.paramNames.init().size() %> + <%= method.paramNames.last() %>.Length) {<%= method.paramNames.init().join(", ") %>}; - args.AddRange(<%= method.paramNames.last() %><% if (method.isArgsCastNecessary) { %>.Cast<object>()<% } %>); - traversal.Bytecode.AddStep("<%= method.methodName %>", args.ToArray());<% - } - else { - %> traversal.Bytecode.AddStep("<%= method.methodName %>"<% if (method.parameters) out << ', '+ method.paramNames.join(", ") %>);<% - } - %> - return traversal; - } -<% } %> - } - -#pragma warning restore 1591 -} \ No newline at end of file diff --git a/gremlin-dotnet/glv/Gremlin.Net.Template.csproj.template b/gremlin-dotnet/glv/Gremlin.Net.Template.csproj.template deleted file mode 100644 index 3f694f6..0000000 --- a/gremlin-dotnet/glv/Gremlin.Net.Template.csproj.template +++ /dev/null @@ -1,32 +0,0 @@ -<!-- -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. ---> - -<!-- THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml --> -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <OutputType>Exe</OutputType> - <TargetFramework>netcoreapp3.1</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <!-- We need both reference elements until this is resolved: https://github.com/dotnet/sdk/issues/1151 --> - <ProjectReference Include="../Gremlin.Net/Gremlin.Net.csproj" /> - <PackageReference Include="Gremlin.Net" Version="$projectVersion" /> - </ItemGroup> - -</Project> diff --git a/gremlin-dotnet/glv/Gremlin.Net.Template.nuspec.template b/gremlin-dotnet/glv/Gremlin.Net.Template.nuspec.template deleted file mode 100644 index d77663b..0000000 --- a/gremlin-dotnet/glv/Gremlin.Net.Template.nuspec.template +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> - <metadata> - <id>Gremlin.Net.Template</id> - <title>Gremlin.Net Template</title> - <version>$projectVersion</version> - <description>Gremlin.Net template to create a console application with dotnet new.</description> - <authors>Apache TinkerPop</authors> - <license type="expression">Apache-2.0</license> - <projectUrl>http://tinkerpop.apache.org</projectUrl> - <tags>TinkerPop Gremlin Gremlin.Net</tags> - <packageTypes> - <packageType name="Template" /> - </packageTypes> - </metadata> - <files> - <file src=".template.config/template.json" target="content/.template.config" /> - <file src="Gremlin.Net.Template.csproj" target="content" /> - <file src="*.cs" target="content" /> - <file src="../../LICENSE" target="LICENSE"/> - <file src="../../NOTICE" target="NOTICE"/> - </files> -</package> \ No newline at end of file diff --git a/gremlin-dotnet/glv/Gremlin.Net.csproj.template b/gremlin-dotnet/glv/Gremlin.Net.csproj.template deleted file mode 100644 index c7d27d1..0000000 --- a/gremlin-dotnet/glv/Gremlin.Net.csproj.template +++ /dev/null @@ -1,76 +0,0 @@ -<!-- -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. ---> - -<!-- THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml --> -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup Label="Build"> - <TargetFramework>netstandard2.0</TargetFramework> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <GenerateDocumentationFile>true</GenerateDocumentationFile> - </PropertyGroup> - - <PropertyGroup Label="Package"> - <Version>$projectVersion</Version> - <FileVersion><%= (projectVersion =~ /(\d+\.\d+\.\d+).*/)[0][1] %>.0</FileVersion> - <AssemblyVersion><%= (projectVersion =~ /(\d+\.\d+)\.*/)[0][1] %>.0.0</AssemblyVersion> - <Title>Gremlin.Net</Title> - <Authors>Apache TinkerPop</Authors> - <Description>Gremlin.Net for Apache TinkerPop™ is a language variant and driver for .NET. - -Apache TinkerPop™ is a graph computing framework for both graph databases (OLTP) and graph analytic systems (OLAP). Gremlin is the graph traversal language of TinkerPop. It can be described as a functional, data-flow language that enables users to succinctly express complex traversals on (or queries of) their application's property graph. - -Gremlin.Net implements Gremlin within .NET. C# syntax has the same constructs as Java including "dot notation" for function chaining (a.b.c), round bracket function arguments (a(b,c)), and support for global namespaces (a(b()) vs a(__.b())). As such, anyone familiar with Gremlin-Java will immediately be able to work with Gremlin.Net. Moreover, there are a few added constructs to Gremlin.Net that make traversals a bit more succinct. - -Gremlin.Net is designed to connect to a "server" that is hosting a TinkerPop-enabled graph system. That "server" could be Gremlin Server - -http://tinkerpop.apache.org/docs/current/reference/#gremlin-server - -or a remote graph provider that exposes protocols by which Gremlin.Net can connect. - -Please see the reference documentation of Apache TinkerPop for more information on usage: https://s.apache.org/pgbwu - -and use our Google Group gremlin-users if there are any questions: https://s.apache.org/c8hru - -NOTE that versions suffixed with "-rc" are considered release candidates (i.e. pre-alpha, alpha, beta, etc.) and thus for early testing purposes only.</Description> - <AssemblyOriginatorKeyFile>../../build/tinkerpop.snk</AssemblyOriginatorKeyFile> - <SignAssembly>true</SignAssembly> - <PackageId>Gremlin.Net</PackageId> - <PackageTags>gremlin;tinkerpop;apache</PackageTags> - <PackageProjectUrl>http://tinkerpop.apache.org</PackageProjectUrl> - <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> - <PackageIcon>gremlin-dotnet-logo_256x256.png</PackageIcon> - <PackageIconUrl>http://tinkerpop.apache.org/docs/current/images/gremlin-dotnet-logo_256x256.png</PackageIconUrl> - <RepositoryUrl>https://github.com/apache/tinkerpop</RepositoryUrl> - <PublishRepositoryUrl>true</PublishRepositoryUrl> - <AllowedOutputExtensionsInPackageBuildOutputFolder>\$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> - <PackageReference Include="System.Text.Json" Version="4.7.1" /> - <PackageReference Include="Microsoft.CSharp" Version="4.3.0" /> - <PackageReference Include="Polly" Version="7.2.0" /> - </ItemGroup> - - <ItemGroup> - <None Include="../../LICENSE" Pack="true" PackagePath="" /> - <None Include="../../NOTICE" Pack="true" PackagePath="" /> - <None Include="../../../docs/static/images/gremlin-dotnet-logo_256x256.png" Pack="true" PackagePath="" /> - </ItemGroup> - -</Project> diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template deleted file mode 100644 index 3140475..0000000 --- a/gremlin-dotnet/glv/P.template +++ /dev/null @@ -1,113 +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.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace Gremlin.Net.Process.Traversal -{ -#pragma warning disable 1591 - - /// <summary> - /// A <see cref="P" /> is a predicate of the form Func<object, bool>. - /// That is, given some object, return true or false. - /// </summary> - public class P : IPredicate - { - /// <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 P(string operatorName, dynamic value, P other = null) - { - OperatorName = operatorName; - Value = value; - Other = other; - } - - /// <summary> - /// Gets the name of the predicate. - /// </summary> - public string OperatorName { get; } - - /// <summary> - /// Gets the value of the predicate. - /// </summary> - public dynamic Value { get; } - - /// <summary> - /// Gets an optional other predicate that is used as an argument for this predicate. - /// </summary> - public P Other { get; } - - /// <summary> - /// Returns a composed predicate that represents a logical AND of this predicate and another. - /// </summary> - /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param> - /// <returns>The composed predicate.</returns> - public P And(P otherPredicate) - { - return new P("and", this, otherPredicate); - } - - /// <summary> - /// Returns a composed predicate that represents a logical OR of this predicate and another. - /// </summary> - /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param> - /// <returns>The composed predicate.</returns> - public P Or(P otherPredicate) - { - return new P("or", this, otherPredicate); - } -<% pmethods.findAll{ !(it in ["within", "without"]) }.each { method -> %> - public static P <%= toCSharpMethodName.call(method) %>(params object[] args) - { - var value = args.Length == 1 ? args[0] : args; - return new P("<%= method %>", value); - } -<% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %> - public static P <%= toCSharpMethodName.call(method) %>(params object[] args) - { - var x = args.Length == 1 && args[0] is ICollection collection ? collection : args; - return new P("<%= method %>", ToGenericList(x)); - } -<% } %> - - private static List<object> ToGenericList(IEnumerable collection) - { - return collection?.Cast<object>().ToList() ?? Enumerable.Empty<object>().ToList(); - } - - /// <inheritdoc /> - public override string ToString() - { - return Other == null ? \$"{OperatorName}({Value})" : \$"{OperatorName}({Value},{Other})"; - } - } - -#pragma warning restore 1591 -} \ No newline at end of file diff --git a/gremlin-dotnet/glv/TextP.template b/gremlin-dotnet/glv/TextP.template deleted file mode 100644 index 7b04533..0000000 --- a/gremlin-dotnet/glv/TextP.template +++ /dev/null @@ -1,68 +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.Collections.Generic; -using System.Linq; - -namespace Gremlin.Net.Process.Traversal -{ -#pragma warning disable 1591 - - /// <summary> - /// A <see cref="TextP" /> is a predicate of the form Func<string, bool>. - /// That is, given some string, return true or false. - /// </summary> - public class TextP : P - { - /// <summary> - /// Initializes a new instance of the <see cref="TextP" /> 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 TextP(string operatorName, string value, P other = null) : base(operatorName, value, other) - { - } - -<% tpmethods.each { method -> %> - public static TextP <%= toCSharpMethodName.call(method) %>(string value) - { - return new TextP("<%= 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 -} diff --git a/gremlin-dotnet/glv/Token.template b/gremlin-dotnet/glv/Token.template deleted file mode 100644 index b86634a..0000000 --- a/gremlin-dotnet/glv/Token.template +++ /dev/null @@ -1,43 +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 - - public class <%= tokenName %> - { - <% tokenFields.each {k,v -> %> - public const String <%= k %> = "<%= v %>"; - <% } %> - } - -#pragma warning restore 1591 -} \ No newline at end of file diff --git a/gremlin-dotnet/glv/WithOptions.template b/gremlin-dotnet/glv/WithOptions.template deleted file mode 100644 index d8dd6bd..0000000 --- a/gremlin-dotnet/glv/WithOptions.template +++ /dev/null @@ -1,47 +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.Step.Util -{ -#pragma warning disable 1591 - - /// <summary> - /// Configuration options to be passed to the <c>With()</c> modulator. - /// </summary> - public class WithOptions - { -<% withOptions.each { field -> %> - - public static readonly <%= field.type %> <%= field.name %> = <%= field.value %>; -<% } %> - } - -#pragma warning restore 1591 -} diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy deleted file mode 100644 index 26daa58..0000000 --- a/gremlin-dotnet/glv/generate.groovy +++ /dev/null @@ -1,406 +0,0 @@ -/* - * 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. - */ - -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 -import org.apache.tinkerpop.gremlin.process.traversal.P -import org.apache.tinkerpop.gremlin.process.traversal.TextP -import org.apache.tinkerpop.gremlin.process.traversal.IO -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ -import org.apache.tinkerpop.gremlin.process.traversal.step.util.WithOptions -import org.apache.tinkerpop.gremlin.structure.Direction -import java.lang.reflect.Modifier -import java.lang.reflect.TypeVariable -import java.lang.reflect.GenericArrayType - -def toCSharpTypeMap = ["Long": "long", - "Double": "double", - "Integer": "int", - "String": "string", - "boolean": "bool", - "Object": "object", - "String[]": "string[]", - "Object[]": "object[]", - "Class": "Type", - "Class[]": "Type[]", - "java.util.Map<java.lang.String, java.lang.Object>": "IDictionary<string, object>", - "java.util.Map<java.lang.String, E2>": "IDictionary<string, E2>", - "java.util.Map<java.lang.String, B>": "IDictionary<string, E2>", - "java.util.Map<java.lang.Object, E2>": "IDictionary<object, E2>", - "java.util.Map<java.lang.Object, B>": "IDictionary<object, E2>", - "java.util.List<E>": "IList<E>", - "java.util.List<A>": "IList<E2>", - "java.util.Map<K, V>": "IDictionary<K, V>", - "java.util.Collection<E2>": "ICollection<E2>", - "java.util.Collection<B>": "ICollection<E2>", - "java.util.Map<K, java.lang.Long>": "IDictionary<K, long>", - "TraversalMetrics": "E2", - "Traversal": "ITraversal", - "Traversal[]": "ITraversal[]", - "Predicate": "IPredicate", - "P": "P", - "TextP": "TextP", - "TraversalStrategy": "ITraversalStrategy", - "TraversalStrategy[]": "ITraversalStrategy[]", - "Function": "IFunction", - "BiFunction": "IBiFunction", - "UnaryOperator": "IUnaryOperator", - "BinaryOperator": "IBinaryOperator", - "Consumer": "IConsumer", - "Supplier": "ISupplier", - "Comparator": "IComparator", - "VertexProgram": "object"] - -def useE2 = ["E2", "E2"] -def methodsWithSpecificTypes = ["constant": useE2, - "limit": useE2, - "mean": useE2, - "optional": useE2, - "range": useE2, - "skip": useE2, - "sum": useE2, - "tail": useE2, - "unfold": useE2, - "valueMap": ["IDictionary<TKey, TValue>", "TKey, TValue"],] - -def getCSharpGenericTypeParam = { typeName -> - def tParam = "" - if (typeName.contains("E2")) { - tParam = "<E2>" - } - else if (typeName.contains("<K, V>")) { - tParam = "<K, V>" - } - else if (typeName.contains("<K, ")) { - tParam = "<K>" - } - else if (typeName.contains("S")) { - tParam = "<S>" - } - else if (typeName.contains("A")) { - tParam = "<A>" - } - return tParam -} - -def toCSharpType = { name -> - String typeName = toCSharpTypeMap.getOrDefault(name, name) - if (typeName.equals(name) && (typeName.contains("? extends") || typeName.equals("Tree"))) { - typeName = "E2" - } - return typeName -} - -def toCSharpMethodName = { symbol -> (String) Character.toUpperCase(symbol.charAt(0)) + symbol.substring(1) } - -def toCSharpValue = { type, value -> - type == String.class && value != null ? ('"' + value + '"') : value -} - -def getJavaGenericTypeParameterTypeNames = { method -> - def typeArguments = method.genericReturnType.actualTypeArguments - return typeArguments. - collect { (it instanceof Class) ? ((Class)it).simpleName : it.typeName }. - collect { name -> - if (name.equals("A")) { - name = "object" - } - else if (name.equals("B")) { - name = "E2" - } - name - } -} - -def getJavaParameterTypeNames = { method -> - return method.parameters. - collect { param -> - param.type.simpleName - } -} - -def toCSharpParamString = { param, genTypeName -> - String csharpParamTypeName = genTypeName - if (csharpParamTypeName == null){ - csharpParamTypeName = toCSharpType(param.type.simpleName) - } - else if (csharpParamTypeName == "M") { - csharpParamTypeName = "object" - } - else if (csharpParamTypeName == "A[]") { - csharpParamTypeName = "object[]" - } - else if (csharpParamTypeName == "A" || csharpParamTypeName == "B") { - csharpParamTypeName = "E2" - } - "${csharpParamTypeName} ${param.name}" - } - -def getJavaParamTypeString = { method -> - getJavaParameterTypeNames(method).join(",") -} - -def getCSharpParamTypeString = { method -> - return method.parameters. - collect { param -> - toCSharpType(param.type.simpleName) - }.join(",") -} - -def getCSharpParamString = { method, useGenericParams -> - def parameters = method.parameters - if (parameters.length == 0) - return "" - - def genericTypes = method.getGenericParameterTypes() - def csharpParameters = parameters. - toList().indexed(). - collect { index, param -> - String genTypeName = null - if (useGenericParams) { - def genType = genericTypes[index] - if (genType instanceof TypeVariable<?>) { - genTypeName = ((TypeVariable<?>)genType).name - } - else if (genType instanceof GenericArrayType) { - if (((GenericArrayType)genType).getGenericComponentType() instanceof TypeVariable<?>) { - genTypeName = ((TypeVariable<?>)((GenericArrayType)genType).getGenericComponentType()).name + "[]" - } - } - } - toCSharpParamString(param, genTypeName) - }. - toArray() - - if (method.isVarArgs()) { - def lastIndex = csharpParameters.length-1 - csharpParameters[lastIndex] = "params " + csharpParameters[lastIndex] - } - - csharpParameters.join(", ") -} - -def getParamNames = { parameters -> - return parameters. - collect { param -> - param.name - } -} - -def isParamsArgCastNecessary = { parameterString -> - if (parameterString.contains("params ")) { - def paramsType = parameterString.substring(parameterString.indexOf("params ") + "params ".length(), parameterString.indexOf("[]")) - return paramsType == "E" || paramsType == "S" - } - return false -} - -def hasMethodNoGenericCounterPartInGraphTraversal = { method -> - def parameterTypeNames = getJavaParameterTypeNames(method) - if (method.name.equals("fold")) { - return parameterTypeNames.size() == 0 - } - return false -} - -def t2withSpecialGraphTraversalt2 = ["IList<E2>": "E2"] - -def getGraphTraversalT2ForT2 = { t2 -> - if (t2withSpecialGraphTraversalt2.containsKey(t2)) { - return t2withSpecialGraphTraversalt2.get(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) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "tpmethods": TextP.class.getMethods(). - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { TextP.class.isAssignableFrom(it.returnType) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS - findAll { GraphTraversalSource.class.equals(it.returnType) }. - findAll { - !it.name.equals("clone") && - !it.name.equals(TraversalSource.Symbols.withRemote) && - !it.name.equals(TraversalSource.Symbols.withComputer) - }. - // Select unique combination of C# parameter types and sort by Java parameter type combination - sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a) <=> getJavaParamTypeString(b) }. - unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a) <=> getCSharpParamTypeString(b) }. - collect { javaMethod -> - def parameters = getCSharpParamString(javaMethod, false) - def paramNames = getParamNames(javaMethod.parameters) - return ["methodName": javaMethod.name, "parameters":parameters, "paramNames":paramNames] - }, - "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS - findAll { GraphTraversal.class.equals(it.returnType) }. - // Select unique combination of C# parameter types and sort by Java parameter type combination - sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a) <=> getJavaParamTypeString(b) }. - unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a) <=> getCSharpParamTypeString(b) }. - collect { javaMethod -> - def typeNames = getJavaGenericTypeParameterTypeNames(javaMethod) - def t1 = toCSharpType(typeNames[0]) - def t2 = toCSharpType(typeNames[1]) - def tParam = getCSharpGenericTypeParam(t2) - def parameters = getCSharpParamString(javaMethod, true) - def paramNames = getParamNames(javaMethod.parameters) - def isArgsCastNecessary = isParamsArgCastNecessary(parameters) - return ["methodName": javaMethod.name, "t1":t1, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "isArgsCastNecessary":isArgsCastNecessary] - }, - "graphStepMethods": GraphTraversal.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { !it.name.equals("clone") && !it.name.equals("iterate") }. - // Select unique combination of C# parameter types and sort by Java parameter type combination - sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a) <=> getJavaParamTypeString(b) }. - unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a) <=> getCSharpParamTypeString(b) }. - collect { javaMethod -> - def typeNames = getJavaGenericTypeParameterTypeNames(javaMethod) - def t1 = toCSharpType(typeNames[0]) - def t2 = toCSharpType(typeNames[1]) - def tParam = getCSharpGenericTypeParam(t2) - def specificTypes = methodsWithSpecificTypes.get(javaMethod.name) - if (specificTypes) { - t2 = specificTypes[0] - tParam = specificTypes.size() > 1 ? "<" + specificTypes[1] + ">" : "" - } - def parameters = getCSharpParamString(javaMethod, true) - def paramNames = getParamNames(javaMethod.parameters) - def isArgsCastNecessary = isParamsArgCastNecessary(parameters) - return ["methodName": javaMethod.name, "t1":t1, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "isArgsCastNecessary":isArgsCastNecessary] - }, - "anonStepMethods": __.class.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { !it.name.equals("__") && !it.name.equals("start") }. - // Select unique combination of C# parameter types and sort by Java parameter type combination - sort { a, b -> a.name <=> b.name ?: getJavaParamTypeString(a) <=> getJavaParamTypeString(b) }. - unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a) <=> getCSharpParamTypeString(b) }. - collect { javaMethod -> - def typeNames = getJavaGenericTypeParameterTypeNames(javaMethod) - def t2 = toCSharpType(typeNames[1]) - def tParam = getCSharpGenericTypeParam(t2) - def specificTypes = methodsWithSpecificTypes.get(javaMethod.name) - if (specificTypes) { - t2 = specificTypes[0] - tParam = specificTypes.size() > 1 ? "<" + specificTypes[1] + ">" : "" - } - def parameters = getCSharpParamString(javaMethod, true) - def paramNames = getParamNames(javaMethod.parameters) - def callGenericTypeArg = hasMethodNoGenericCounterPartInGraphTraversal(javaMethod) ? "" : tParam - def graphTraversalT2 = getGraphTraversalT2ForT2(t2) - return ["methodName": javaMethod.name, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "callGenericTypeArg":callGenericTypeArg, "graphTraversalT2":graphTraversalT2] - }, - "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]), - "toCSharpMethodName": toCSharpMethodName, - "withOptions": WithOptions.getDeclaredFields(). - collect {["type": toCSharpType(it.type.simpleName), "name": toCSharpMethodName(it.name), "value": toCSharpValue(it.type, it.get(null))]}] - -def engine = new groovy.text.GStringTemplateEngine() -def traversalTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/GraphTraversal.template")).make(binding) -def traversalFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs") -traversalFile.newWriter().withWriter{ it << traversalTemplate } - -def graphTraversalTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/GraphTraversalSource.template")).make(binding) -def graphTraversalFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs") -graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate } - -def anonymousTraversalTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/AnonymousTraversal.template")).make(binding) -def anonymousTraversalFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/__.cs") -anonymousTraversalFile.newWriter().withWriter{ it << anonymousTraversalTemplate } - -def pTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/P.template")).make(binding) -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/TextP.template")).make(binding) -def tpFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/TextP.cs") -tpFile.newWriter().withWriter{ it << tpTemplate } - -def withOptionsTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/WithOptions.template")).make(binding) -def withOptionsFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/WithOptions.cs") -withOptionsFile.newWriter().withWriter{ it << withOptionsTemplate } - -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, - "implementedTypes": enumClass.getInterfaces(). - collect { it.getSimpleName() }. - findAll { toCSharpTypeMap.containsKey(it) }. - findAll { toCSharpTypeMap[it] != "object" }. - sort { a, b -> a <=> b }. - collect(["EnumWrapper"]) { typeName -> - return toCSharpTypeMap[typeName] - }.join(", "), - "constants": enumClass.getEnumConstants(). - sort { a, b -> a.name() <=> b.name() }, - "directionClass": Direction.class ] - - def enumTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Enum.template")).make(b) - def enumFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/" + enumClass.getSimpleName() + ".cs") - enumFile.newWriter().withWriter{ it << enumTemplate } -} - -CoreImports.getClassImports().findAll { Enum.class.isAssignableFrom(it) }. - sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }. - each { createEnum(it) } - -def determineVersion = { - def env = System.getenv() - def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("DOTNET_RELEASE_VERSION") : "${projectVersion}" - - // only want to generate a timestamp for the version if this is a nuget deploy - if (!mavenVersion.endsWith("-SNAPSHOT") || null == System.getProperty("nuget")) return mavenVersion - - return mavenVersion.replace("-SNAPSHOT", "-dev-" + System.currentTimeMillis()) -} - -def versionToUse = determineVersion() -def csprojTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Gremlin.Net.csproj.template")).make(["projectVersion":versionToUse]) -def csprojFile = new File("${projectBaseDir}/src/Gremlin.Net/Gremlin.Net.csproj") -csprojFile.newWriter().withWriter{ it << csprojTemplate } -def templateCsprojTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Gremlin.Net.Template.csproj.template")).make(["projectVersion":versionToUse]) -def templateCsprojFile = new File("${projectBaseDir}/src/Gremlin.Net.Template/Gremlin.Net.Template.csproj") -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 } diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 02f6ce8..bf5609c 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -59,54 +59,6 @@ limitations under the License. <artifactId>dotnet-maven-plugin</artifactId> <extensions>true</extensions> </plugin> - <plugin> - <groupId>org.codehaus.gmavenplus</groupId> - <artifactId>gmavenplus-plugin</artifactId> - <dependencies> - <dependency> - <groupId>org.apache.tinkerpop</groupId> - <artifactId>gremlin-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>${groovy.version}</version> - <type>pom</type> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>${log4j.version}</version> - <scope>runtime</scope> - </dependency> - </dependencies> - <executions> - <execution> - <id>generate-dsl</id> - <phase>generate-sources</phase> - <goals> - <goal>execute</goal> - </goals> - <configuration> - <properties> - <property> - <name>projectBaseDir</name> - <value>${project.basedir}</value> - </property> - <property> - <name>projectVersion</name> - <value>${project.version}</value> - </property> - </properties> - <scripts> - <script>${project.basedir}/glv/generate.groovy</script> - </scripts> - </configuration> - </execution> - </executions> - </plugin> <!-- there is no point to deploying the jvm stuff - there is no java source really - just poms --> diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template deleted file mode 100644 index 80476f1..0000000 --- a/gremlin-javascript/glv/GraphTraversalSource.template +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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. - */ - -/** - * @author Jorge Bay Gondra - */ -'use strict'; - -const { Traversal } = require('./traversal'); -const remote = require('../driver/remote-connection'); -const utils = require('../utils'); -const Bytecode = require('./bytecode'); -const { TraversalStrategies, VertexProgramStrategy } = require('./traversal-strategy'); - - -/** - * Represents the primary DSL of the Gremlin traversal machine. - */ -class GraphTraversalSource { - - /** - * Creates a new instance of {@link GraphTraversalSource}. - * @param {Graph} graph - * @param {TraversalStrategies} traversalStrategies - * @param {Bytecode} [bytecode] - * @param {Function} [graphTraversalSourceClass] Optional {@link GraphTraversalSource} constructor. - * @param {Function} [graphTraversalClass] Optional {@link GraphTraversal} constructor. - */ - constructor(graph, traversalStrategies, bytecode, graphTraversalSourceClass, graphTraversalClass) { - this.graph = graph; - this.traversalStrategies = traversalStrategies; - this.bytecode = bytecode || new Bytecode(); - this.graphTraversalSourceClass = graphTraversalSourceClass || GraphTraversalSource; - this.graphTraversalClass = graphTraversalClass || GraphTraversal; - } - - /** - * @param remoteConnection - * @returns {GraphTraversalSource} - */ - withRemote(remoteConnection) { - const traversalStrategy = new TraversalStrategies(this.traversalStrategies); - traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection)); - return new this.graphTraversalSourceClass(this.graph, traversalStrategy, new Bytecode(this.bytecode), this.graphTraversalSourceClass, this.graphTraversalClass); - } - - /** - * @param graphComputer - * @param workers - * @param result - * @param persist - * @param vertices - * @param edges - * @param configuration - * @returns {GraphTraversalSource} - */ - withComputer(graphComputer, workers, result, persist, vertices, edges, configuration) { - return this.withStrategies(new VertexProgramStrategy(graphComputer, workers, result, persist, vertices, edges, configuration)); - } - - /** - * Returns the string representation of the GraphTraversalSource. - * @returns {string} - */ - toString() { - return 'graphtraversalsource[' + this.graph.toString() + ']'; - } - <% sourceStepMethods.each{ method -> %> - /** - * Graph Traversal Source <%= method %> method. - * @param {...Object} args - * @returns {GraphTraversalSource} - */ - <%= toJs.call(method) %>(...args) { - const b = new Bytecode(this.bytecode).addSource('<%= method %>', args); - return new this.graphTraversalSourceClass(this.graph, new TraversalStrategies(this.traversalStrategies), b, this.graphTraversalSourceClass, this.graphTraversalClass); - } - <% - } - sourceSpawnMethods.each{ method -> %> - /** - * <%= method %> GraphTraversalSource step method. - * @param {...Object} args - * @returns {GraphTraversal} - */ - <%= toJs.call(method) %>(...args) { - const b = new Bytecode(this.bytecode).addStep('<%= method %>', args); - return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b); - } - <% } %> -} - -/** - * Represents a graph traversal. - */ -class GraphTraversal extends Traversal { - constructor(graph, traversalStrategies, bytecode) { - super(graph, traversalStrategies, bytecode); - } - - /** - * Copy a traversal so as to reset and re-use it. - */ - clone() { - return new GraphTraversal(this.graph, this.traversalStrategies, this.getBytecode()); - } - - <% graphStepMethods.each{ method -> %> - /** - * Graph traversal <%= method %> method. - * @param {...Object} args - * @returns {GraphTraversal} - */ - <%= toJs.call(method) %>(...args) { - this.bytecode.addStep('<%= method %>', args); - return this; - } - <% } %> -} - -function callOnEmptyTraversal(fnName, args) { - const g = new GraphTraversal(null, null, new Bytecode()); - return g[fnName].apply(g, args); -} - -/** - * Contains the static method definitions - * @type {Object} - */ -const statics = {<% anonStepMethods.eachWithIndex { method, i -> %> - <%= toJs.call(method) %>: (...args) => callOnEmptyTraversal('<%= toJs.call(method) %>', args)<%= i < anonStepMethods.size() - 1 ? "," : ""%><% } %> -}; - -module.exports = { - GraphTraversal, - GraphTraversalSource, - statics -}; \ No newline at end of file diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template deleted file mode 100644 index 4089dc2..0000000 --- a/gremlin-javascript/glv/PackageJson.template +++ /dev/null @@ -1,62 +0,0 @@ -<% -/* - 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. -*/ -%>{ - "name": "gremlin", - "version": "<%= version %>", - "description": "JavaScript Gremlin Language Variant", - "author": "Apache TinkerPop team", - "keywords": [ - "graph", - "gremlin", - "tinkerpop", - "connection", - "glv", - "driver", - "graphdb" - ], - "license": "Apache-2.0", - "dependencies": { - "ws": "^6.2.1" - }, - "devDependencies": { - "chai": "~4.1.2", - "cucumber": "~4.2.1", - "grunt": "~1.0.4", - "grunt-cli": "~1.3.2", - "grunt-jsdoc": "~2.3.1", - "mocha": "~5.2.0" - }, - "repository": { - "type": "git", - "url": "https://github.com/apache/tinkerpop.git" - }, - "homepage": "https://tinkerpop.apache.org/", - "bugs": { - "url": "https://issues.apache.org/jira/browse/TINKERPOP" - }, - "scripts": { - "test": "./node_modules/mocha/bin/mocha test/unit test/integration -t 5000", - "features": "./node_modules/.bin/cucumber-js --require test/cucumber ../../../../../gremlin-test/features/", - "unit-test": "./node_modules/mocha/bin/mocha test/unit" - }, - "engines": { - "node": ">=6" - } -} \ No newline at end of file diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template deleted file mode 100644 index 1cae123..0000000 --- a/gremlin-javascript/glv/TraversalSource.template +++ /dev/null @@ -1,297 +0,0 @@ -/* - * 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. - */ - -/** - * @author Jorge Bay Gondra - */ -'use strict'; - -const utils = require('../utils'); -const itemDone = Object.freeze({ value: null, done: true }); -const asyncIteratorSymbol = Symbol.asyncIterator || Symbol('@@asyncIterator'); - -class Traversal { - constructor(graph, traversalStrategies, bytecode) { - this.graph = graph; - this.traversalStrategies = traversalStrategies; - this.bytecode = bytecode; - /** @type {Array<Traverser>} */ - this.traversers = null; - this.sideEffects = null; - this._traversalStrategiesPromise = null; - this._traversersIteratorIndex = 0; - } - - /** - * Async iterable method implementation. - */ - [asyncIteratorSymbol]() { - return this; - } - - /** @returns {Bytecode} */ - getBytecode() { - return this.bytecode; - } - - /** - * Returns an Array containing the traverser objects. - * @returns {Promise.<Array>} - */ - toList() { - return this._applyStrategies().then(() => { - const result = []; - let it; - while ((it = this._getNext()) && !it.done) { - result.push(it.value); - } - return result; - }); - }; - - /** - * Determines if there are any more items to iterate from the traversal. - * @returns {Promise.<boolean>} - */ - hasNext() { - return this._applyStrategies().then(() => { - return this.traversers && this.traversers.length > 0 && - this._traversersIteratorIndex < this.traversers.length && - this.traversers[this._traversersIteratorIndex].bulk > 0; - }); - } - - /** - * Iterates all Traverser instances in the traversal. - * @returns {Promise} - */ - iterate() { - this.bytecode.addStep('none'); - return this._applyStrategies().then(() => { - let it; - while ((it = this._getNext()) && !it.done) { - } - }); - } - - /** - * Async iterator method implementation. - * Returns a promise containing an iterator item. - * @returns {Promise.<{value, done}>} - */ - next() { - return this._applyStrategies().then(() => this._getNext()); - } - - /** - * Synchronous iterator of traversers including - * @private - */ - _getNext() { - while (this.traversers && this._traversersIteratorIndex < this.traversers.length) { - let traverser = this.traversers[this._traversersIteratorIndex]; - if (traverser.bulk > 0) { - traverser.bulk--; - return { value: traverser.object, done: false }; - } - this._traversersIteratorIndex++; - } - return itemDone; - } - - _applyStrategies() { - if (this._traversalStrategiesPromise) { - // Apply strategies only once - return this._traversalStrategiesPromise; - } - return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this); - } - - /** - * Returns the Bytecode JSON representation of the traversal - * @returns {String} - */ - toString() { - return this.bytecode.toString(); - }; -} - -<% tokens.each { k,v -> %> -class <%= k %> { -<% v.each {a,b -> %> - static get <%= a %>() { - return "<%= b %>" - } -<% } %>} -<% } %> - -class P { - /** - * Represents an operation. - * @constructor - */ - constructor(operator, value, other) { - this.operator = operator; - this.value = value; - this.other = other; - } - - /** - * Returns the string representation of the instance. - * @returns {string} - */ - toString() { - if (this.other === undefined) { - return this.operator + '(' + this.value + ')'; - } - return this.operator + '(' + this.value + ', ' + this.other + ')'; - } - - and(arg) { - return new P('and', this, arg); - } - - or(arg) { - return new P('or', this, arg); - } - - static within(...args) { - if (args.length === 1 && Array.isArray(args[0])) { - return new P("within", args[0], null); - } else { - return new P("within", args, null); - } - } - - static without(...args) { - if (args.length === 1 && Array.isArray(args[0])) { - return new P("without", args[0], null); - } else { - return new P("without", args, null); - } - } - -<% pmethods.findAll{!(it in ["within","without"])}.each{ method -> %> - /** @param {...Object} args */ - static <%= toJs.call(method) %>(...args) { - return createP('<%= method %>', args); - } -<% } %> -} - -function createP(operator, args) { - args.unshift(null, operator); - return new (Function.prototype.bind.apply(P, args)); -} - -class TextP { - /** - * Represents an operation. - * @constructor - */ - constructor(operator, value, other) { - this.operator = operator; - this.value = value; - this.other = other; - } - - /** - * Returns the string representation of the instance. - * @returns {string} - */ - toString() { - if (this.other === undefined) { - return this.operator + '(' + this.value + ')'; - } - return this.operator + '(' + this.value + ', ' + this.other + ')'; - } - - and(arg) { - return new P('and', this, arg); - } - - or(arg) { - return new P('or', this, arg); - } -<% tpmethods.each{ method -> %> - /** @param {...Object} args */ - static <%= toJs.call(method) %>(...args) { - return createTextP('<%= method %>', args); - } -<% } %> -} - -function createTextP(operator, args) { - args.unshift(null, operator); - return new (Function.prototype.bind.apply(TextP, args)); -} - -class Traverser { - constructor(object, bulk) { - this.object = object; - this.bulk = bulk || 1; - } -} - -class TraversalSideEffects { - -} - -const withOptions = { - <%= withOptions.collect { it.name + ": " + it.value }.join(",\n ")%> -}; - -function toEnum(typeName, keys) { - const result = {}; - keys.split(' ').forEach(k => { - let jsKey = k; - if (jsKey === jsKey.toUpperCase()) { - jsKey = jsKey.toLowerCase(); - } - result[jsKey] = new EnumValue(typeName, k); - }); - return result; -} - -class EnumValue { - constructor(typeName, elementName) { - this.typeName = typeName; - this.elementName = elementName; - } - - toString() { - return this.elementName; - } -} - -module.exports = { - EnumValue, - P, - TextP, - withOptions, - IO, - Traversal, - TraversalSideEffects, - Traverser<% -enums.each{ enumClass -> - out.print ",\n " + decapitalize.call(enumClass.simpleName) + ": toEnum('" + enumClass.simpleName + "', '" + - enumClass.getEnumConstants().sort { a, b -> a.name() <=> b.name() }.collect { toJs.call(it.name()) }.join(' ') + "')" -} -%> -}; diff --git a/gremlin-javascript/glv/generate.groovy b/gremlin-javascript/glv/generate.groovy deleted file mode 100644 index cd3e899..0000000 --- a/gremlin-javascript/glv/generate.groovy +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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. - */ - - -import groovy.text.GStringTemplateEngine -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 -import org.apache.tinkerpop.gremlin.process.traversal.P -import org.apache.tinkerpop.gremlin.process.traversal.TextP -import org.apache.tinkerpop.gremlin.process.traversal.IO -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ -import org.apache.tinkerpop.gremlin.process.traversal.step.util.WithOptions -import java.lang.reflect.Modifier - -def toJsMap = ["in": "in_", - "from": "from_", - "with": "with_"] - -def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) } - -def toJSValue = { type, value -> - type == String.class && value != null ? ('"' + value + '"') : value -} - -def decapitalize = { - String string = it; - if (string == null || string.length() == 0) { - return string; - } - def c = string.toCharArray(); - c[0] = Character.toLowerCase(c[0]); - return new String(c); -} - -def determineVersion = { - def env = System.getenv() - def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : project.version - return mavenVersion.replace("-SNAPSHOT", "-alpha1") -} - -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 = ["enums": CoreImports.getClassImports() - .findAll { Enum.class.isAssignableFrom(it) } - .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }, - "pmethods": P.class.getMethods(). - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { P.class.isAssignableFrom(it.returnType) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "tpmethods": TextP.class.getMethods(). - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { TextP.class.isAssignableFrom(it.returnType) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS - findAll { GraphTraversalSource.class.equals(it.returnType) }. - findAll { - !it.name.equals("clone") && - // Use hardcoded name to be for forward-compatibility - !it.name.equals("withBindings") && - !it.name.equals(TraversalSource.Symbols.withRemote) && - !it.name.equals(TraversalSource.Symbols.withComputer) - }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS - findAll { GraphTraversal.class.equals(it.returnType) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "graphStepMethods": GraphTraversal.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { !it.name.equals("clone") && !it.name.equals("iterate") }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "anonStepMethods": __.class.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { !it.name.equals("__") && !it.name.equals("start") }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }, - "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]), - "toJs": toJs, - "version": determineVersion(), - "decapitalize": decapitalize, - "withOptions": WithOptions.getDeclaredFields(). - collect {["name": it.name, "value": toJSValue(it.type, it.get(null))]}] - -def engine = new GStringTemplateEngine() -def graphTraversalTemplate = engine.createTemplate(new File("${project.basedir}/glv/GraphTraversalSource.template")) - .make(binding) -def graphTraversalFile = - new File("${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js") -graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate } - -def traversalTemplate = engine.createTemplate(new File("${project.basedir}/glv/TraversalSource.template")).make(binding) -def traversalFile = new File("${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js") -traversalFile.newWriter().withWriter{ it << traversalTemplate } - -def packageJsonTemplate = engine.createTemplate(new File("${project.basedir}/glv/PackageJson.template")).make(binding) -def packageJsonFile = new File("${project.basedir}/src/main/javascript/gremlin-javascript/package.json") -packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate } diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml index 199af86..4ca17d4 100644 --- a/gremlin-javascript/pom.xml +++ b/gremlin-javascript/pom.xml @@ -64,28 +64,6 @@ limitations under the License. </dependencies> <executions> <execution> - <id>generate-javascript</id> - <phase>generate-sources</phase> - <goals> - <goal>execute</goal> - </goals> - <configuration> - <properties> - <property> - <name>projectBaseDir</name> - <value>${project.basedir}</value> - </property> - <property> - <name>projectVersion</name> - <value>${project.version}</value> - </property> - </properties> - <scripts> - <script>${project.basedir}/glv/generate.groovy</script> - </scripts> - </configuration> - </execution> - <execution> <id>gremlin-server-start</id> <phase>pre-integration-test</phase> <goals> diff --git a/gremlin-python/glv/GraphTraversalSource.template b/gremlin-python/glv/GraphTraversalSource.template deleted file mode 100644 index 27d9e15..0000000 --- a/gremlin-python/glv/GraphTraversalSource.template +++ /dev/null @@ -1,206 +0,0 @@ -# -# 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. -# - -import sys -import copy -from .traversal import Traversal -from .traversal import TraversalStrategies -from .strategies import VertexProgramStrategy -from .traversal import Bytecode -from ..driver.remote_connection import RemoteStrategy -from .. import statics -from ..statics import long - - -class GraphTraversalSource(object): - def __init__(self, graph, traversal_strategies, bytecode=None): - self.graph = graph - self.traversal_strategies = traversal_strategies - if bytecode is None: - bytecode = Bytecode() - self.bytecode = bytecode - self.graph_traversal = GraphTraversal - - def __repr__(self): - return "graphtraversalsource[" + str(self.graph) + "]" - - def get_graph_traversal_source(self): - return self.__class__(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode)) - - def get_graph_traversal(self): - return self.graph_traversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode)) -<% sourceStepMethods.each{ method -> %> - def <%= method %>(self, *args): - source = self.get_graph_traversal_source() - source.bytecode.add_source("<%= toJava.call(method) %>", *args) - return source -<% } %> - def withRemote(self, remote_connection): - source = self.get_graph_traversal_source() - source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)]) - return source - - def withComputer(self, graph_computer=None, workers=None, result=None, persist=None, vertices=None, - edges=None, configuration=None): - return self.withStrategies(VertexProgramStrategy(graph_computer, workers, result, persist, vertices, - edges, configuration)) -<% sourceSpawnMethods.each { method -> %> - def <%= method %>(self, *args): - traversal = self.get_graph_traversal() - traversal.bytecode.add_step("<%= toJava.call(method) %>", *args) - return traversal -<% } %> - -class GraphTraversal(Traversal): - def __init__(self, graph, traversal_strategies, bytecode): - super(GraphTraversal, self).__init__(graph, traversal_strategies, bytecode) - - def __getitem__(self, index): - if isinstance(index, int): - return self.range(long(index), long(index + 1)) - elif isinstance(index, slice): - low = long(0) if index.start is None else long(index.start) - high = long(sys.maxsize) if index.stop is None else long(index.stop) - if low == long(0): - return self.limit(high) - else: - return self.range(low,high) - else: - raise TypeError("Index must be int or slice") - - def __getattr__(self, key): - return self.values(key) - - def clone(self): - return GraphTraversal(self.graph, self.traversal_strategies, copy.deepcopy(self.bytecode)) -<% graphStepMethods.each { method -> %> - def <%= method %>(self, *args): - self.bytecode.add_step("<%= toJava.call(method) %>", *args) - return self -<% } %> - # Deprecated - prefer the underscore suffixed versions e.g filter_() - - def filter(self, *args): - self.bytecode.add_step("filter", *args) - return self - - def id(self, *args): - self.bytecode.add_step("id", *args) - return self - - def max(self, *args): - self.bytecode.add_step("max", *args) - return self - - def min(self, *args): - self.bytecode.add_step("min", *args) - return self - - def range(self, *args): - self.bytecode.add_step("range", *args) - return self - - def sum(self, *args): - self.bytecode.add_step("sum", *args) - return self - - -class __(object): - graph_traversal = GraphTraversal - - @classmethod - def start(cls): - return GraphTraversal(None, None, Bytecode()) - - @classmethod - def __(cls, *args): - return __.inject(*args) -<% anonStepMethods.each{ method -> %> - @classmethod - def <%= method %>(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).<%= method %>(*args) -<% } %> - # Deprecated - prefer the underscore suffixed versions e.g filter_() - - @classmethod - def filter(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).filter_(*args) - - @classmethod - def id(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).id_(*args) - - @classmethod - def max(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).max_(*args) - - @classmethod - def min(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).min_(*args) - - @classmethod - def range(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).range_(*args) - - @classmethod - def sum(cls, *args): - return cls.graph_traversal(None, None, Bytecode()).sum_(*args) - -<% anonStepMethods.each{ method -> %> -def <%= method %>(*args): - return __.<%= method %>(*args) - -<% } %> -# Deprecated - prefer the underscore suffixed versions e.g filter_() - -def filter(*args): - return __.filter_(*args) - - -def id(*args): - return __.id_(*args) - - -def max(*args): - return __.max_(*args) - - -def min(*args): - return __.min_(*args) - - -def range(*args): - return __.range_(*args) - - -def sum(*args): - return __.sum_(*args) - - -<% anonStepMethods.each{ method -> %>statics.add_static('<%= method %>', <%= method %>) - -<% } %> -# Deprecated - prefer the underscore suffixed versions e.g filter_() - -statics.add_static('filter', filter) -statics.add_static('id', id) -statics.add_static('max', max) -statics.add_static('min', min) -statics.add_static('range', range) -statics.add_static('sum', sum) diff --git a/gremlin-python/glv/TraversalSource.template b/gremlin-python/glv/TraversalSource.template deleted file mode 100644 index 072c410..0000000 --- a/gremlin-python/glv/TraversalSource.template +++ /dev/null @@ -1,415 +0,0 @@ -# -# 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. -# - -import copy -from aenum import Enum -from .. import statics -from ..statics import long - -class Traversal(object): - def __init__(self, graph, traversal_strategies, bytecode): - self.graph = graph - self.traversal_strategies = traversal_strategies - self.bytecode = bytecode - self.traversers = None - self.last_traverser = None - - def __repr__(self): - return str(self.bytecode) - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self.bytecode == other.bytecode - else: - return False - - def __iter__(self): - return self - - def __next__(self): - if self.traversers is None: - self.traversal_strategies.apply_strategies(self) - if self.last_traverser is None: - self.last_traverser = next(self.traversers) - object = self.last_traverser.object - self.last_traverser.bulk = self.last_traverser.bulk - 1 - if self.last_traverser.bulk <= 0: - self.last_traverser = None - return object - - def toList(self): - return list(iter(self)) - - def toSet(self): - return set(iter(self)) - - def iterate(self): - self.bytecode.add_step("none") - while True: - try: self.nextTraverser() - except StopIteration: return self - - def nextTraverser(self): - if self.traversers is None: - self.traversal_strategies.apply_strategies(self) - if self.last_traverser is None: - return next(self.traversers) - else: - temp = self.last_traverser - self.last_traverser = None - return temp - - def hasNext(self): - if self.traversers is None: - self.traversal_strategies.apply_strategies(self) - if self.last_traverser is None: - try: self.last_traverser = next(self.traversers) - except StopIteration: return False - return not(self.last_traverser is None) and self.last_traverser.bulk > 0 - - def next(self, amount=None): - if amount is None: - return self.__next__() - else: - count = 0 - tempList = [] - while count < amount: - count = count + 1 - try: temp = self.__next__() - except StopIteration: return tempList - tempList.append(temp) - return tempList - - def promise(self, cb=None): - self.traversal_strategies.apply_async_strategies(self) - future_traversal = self.remote_results - future = type(future_traversal)() - def process(f): - try: - traversal = f.result() - except Exception as e: - future.set_exception(e) - else: - self.traversers = iter(traversal.traversers) - if cb: - try: - result = cb(self) - except Exception as e: - future.set_exception(e) - else: - future.set_result(result) - else: - future.set_result(self) - future_traversal.add_done_callback(process) - return future - -<% enums.each { e -> %> -<%= e.getSimpleName() %> = Enum('<%= e.getSimpleName() %>', ' <%= e.getEnumConstants().sort{a, b -> a.name() <=> b.name()}.collect{v -> toPython.call(v.name())}.join(" ") %>') -<% e.getEnumConstants().each {v -> %> -statics.add_static('<%= toPython.call(v.name()) %>', <%= v.getDeclaringClass().getSimpleName() %>.<%= toPython.call(v.name()) %>)<% } %> -<% } %> - -T = Enum('T', ' id id_ key label value') - -statics.add_static('id', T.id) -statics.add_static('label', T.label) -statics.add_static('id_', T.id_) -statics.add_static('key', T.key) -statics.add_static('value', T.value) - - -Operator = Enum('Operator', ' addAll and_ assign div max max_ min min_ minus mult or_ sum sum_ sumLong') - -statics.add_static('sum_', Operator.sum_) -statics.add_static('sum', Operator.sum_) -statics.add_static('minus', Operator.minus) -statics.add_static('mult', Operator.mult) -statics.add_static('div', Operator.div) -statics.add_static('min', Operator.min_) -statics.add_static('min_', Operator.min_) -statics.add_static('max_', Operator.max_) -statics.add_static('assign', Operator.assign) -statics.add_static('and_', Operator.and_) -statics.add_static('or_', Operator.or_) -statics.add_static('addAll', Operator.addAll) -statics.add_static('sumLong', Operator.sumLong) - - -class P(object): - def __init__(self, operator, value, other=None): - self.operator = operator - self.value = value - self.other = other -<% pmethods.findAll{!(it in ["within","without"])}.each { method -> %> - @staticmethod - def <%= method %>(*args): - return P("<%= toJava.call(method) %>", *args) -<% } %> - @staticmethod - def within(*args): - if len(args) == 1 and type(args[0]) == list: - return P("within", args[0]) - else: - return P("within", list(args)) - - @staticmethod - def without(*args): - if len(args) == 1 and type(args[0]) == list: - return P("without", args[0]) - else: - return P("without", list(args)) - - def and_(self, arg): - return P("and", self, arg) - - def or_(self, arg): - return P("or", self, arg) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.operator == other.operator and self.value == other.value and self.other == other.other - - def __repr__(self): - return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")" - -<% pmethods.findAll{!it.equals("clone")}.each { method -> %> -def <%= method %>(*args): - return P.<%= method %>(*args) - -<% } %> -<% pmethods.findAll{!it.equals("clone")}.each { method -> %>statics.add_static('<%= method %>', <%= method %>) - -<% } %> -class TextP(P): - def __init__(self, operator, value, other=None): - P.__init__(self, operator, value, other) -<% tpmethods.each { method -> %> - @staticmethod - def <%= method %>(*args): - return TextP("<%= toJava.call(method) %>", *args) -<% } %> - def __eq__(self, other): - return isinstance(other, self.__class__) and self.operator == other.operator and self.value == other.value and self.other == other.other - - def __repr__(self): - return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")" - -<% tpmethods.findAll{!it.equals("clone")}.each { method -> %> -def <%= method %>(*args): - return TextP.<%= method %>(*args) - -<% } %> -<% tpmethods.findAll{!it.equals("clone")}.each { method -> %>statics.add_static('<%= method %>', <%= method %>) - -<% } %> -<% tokens.each { k,v -> %> - -''' -<%= k %> -''' - - -class <%= k %>(object): -<% v.each {a,b -> %> - <%= a %> = "<%= b %>" -<% }} %> - -''' -TRAVERSER -''' - - -class Traverser(object): - def __init__(self, object, bulk=None): - if bulk is None: - bulk = long(1) - self.object = object - self.bulk = bulk - - def __repr__(self): - return str(self.object) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.object == other.object - - -''' -TRAVERSAL STRATEGIES -''' - - -class TraversalStrategies(object): - global_cache = {} - - def __init__(self, traversal_strategies=None): - self.traversal_strategies = \ - traversal_strategies.traversal_strategies if traversal_strategies is not None else [] - - def add_strategies(self, traversal_strategies): - self.traversal_strategies = self.traversal_strategies + traversal_strategies - - def apply_strategies(self, traversal): - for traversal_strategy in self.traversal_strategies: - traversal_strategy.apply(traversal) - - def apply_async_strategies(self, traversal): - for traversal_strategy in self.traversal_strategies: - traversal_strategy.apply_async(traversal) - - def __repr__(self): - return str(self.traversal_strategies) - - -class TraversalStrategy(object): - def __init__(self, strategy_name=None, configuration=None, fqcn=None): - self.fqcn = fqcn - self.strategy_name = type(self).__name__ if strategy_name is None else strategy_name - self.configuration = {} if configuration is None else configuration - - def apply(self, traversal): - return - - def apply_async(self, traversal): - return - - def __eq__(self, other): - return isinstance(other, self.__class__) - - def __hash__(self): - return hash(self.strategy_name) - - def __repr__(self): - return self.strategy_name - - -''' -BYTECODE -''' - - -class Bytecode(object): - def __init__(self, bytecode=None): - self.source_instructions = [] - self.step_instructions = [] - self.bindings = {} - if bytecode is not None: - self.source_instructions = list(bytecode.source_instructions) - self.step_instructions = list(bytecode.step_instructions) - - def add_source(self, source_name, *args): - instruction = [source_name] - for arg in args: - instruction.append(self.__convertArgument(arg)) - self.source_instructions.append(instruction) - - def add_step(self, step_name, *args): - instruction = [step_name] - for arg in args: - instruction.append(self.__convertArgument(arg)) - self.step_instructions.append(instruction) - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self.source_instructions == other.source_instructions and self.step_instructions == other.step_instructions - else: - return False - - def __copy__(self): - bb = Bytecode() - bb.source_instructions = self.source_instructions - bb.step_instructions = self.step_instructions - bb.bindings = self.bindings - return bb - - def __deepcopy__(self, memo={}): - bb = Bytecode() - bb.source_instructions = copy.deepcopy(self.source_instructions, memo) - bb.step_instructions = copy.deepcopy(self.step_instructions, memo) - bb.bindings = copy.deepcopy(self.bindings, memo) - return bb - - def __convertArgument(self,arg): - if isinstance(arg, Traversal): - if arg.graph is not None: - raise TypeError("The child traversal of " + arg + " was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal") - self.bindings.update(arg.bytecode.bindings) - return arg.bytecode - elif isinstance(arg, dict): - newDict = {} - for key in arg: - newDict[self.__convertArgument(key)] = self.__convertArgument(arg[key]) - return newDict - elif isinstance(arg, list): - newList = [] - for item in arg: - newList.append(self.__convertArgument(item)) - return newList - elif isinstance(arg, set): - newSet = set() - for item in arg: - newSet.add(self.__convertArgument(item)) - return newSet - elif isinstance(arg, Binding): - self.bindings[arg.key] = arg.value - return Binding(arg.key, self.__convertArgument(arg.value)) - else: - return arg - - def __repr__(self): - return (str(self.source_instructions) if len(self.source_instructions) > 0 else "") + \\ - (str(self.step_instructions) if len(self.step_instructions) > 0 else "") - - -''' -BINDINGS -''' - - -class Bindings(object): - - @staticmethod - def of(key, value): - if not isinstance(key, str): - raise TypeError("Key must be str") - return Binding(key, value) - - -class Binding(object): - def __init__(self, key, value): - self.key = key - self.value = value - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.key == other.key and self.value == other.value - - def __hash__(self): - return hash(self.key) + hash(self.value) - - def __repr__(self): - return "binding[" + self.key + "=" + str(self.value) + "]" - - -''' -WITH OPTIONS -''' - - -class WithOptions(object): -<% withOptions.each { %> - <%= it.name %> = <%= it.value %> -<% } %> diff --git a/gremlin-python/glv/generate.groovy b/gremlin-python/glv/generate.groovy deleted file mode 100644 index 57e8aff..0000000 --- a/gremlin-python/glv/generate.groovy +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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. - */ - -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 -import org.apache.tinkerpop.gremlin.process.traversal.P -import org.apache.tinkerpop.gremlin.process.traversal.TextP -import org.apache.tinkerpop.gremlin.process.traversal.IO -import org.apache.tinkerpop.gremlin.process.traversal.Operator -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ -import org.apache.tinkerpop.gremlin.process.traversal.step.util.WithOptions -import org.apache.tinkerpop.gremlin.structure.T -import java.lang.reflect.Modifier - -// this is a bit of a copy of what's in SymbolHelper - no way around it because this code generation task occurs -// before the SymbolHelper is available to the plugin. -def toPythonMap = ["and": "and_", - "all": "all_", - "as": "as_", - "filter": "filter_", - "from": "from_", - "global": "global_", - "id": "id_", - "in": "in_", - "is": "is_", - "list": "list_", - "max": "max_", - "min": "min_", - "not": "not_", - "range": "range_", - "or": "or_", - "set": "set_", - "sum": "sum_", - "with": "with_"] - -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 toPythonValue = { type, value -> - type == String.class && value != null ? ('"' + value + '"') : value -} - -def toJavaMap = toPythonMap.collectEntries{k,v -> [(v):k]} -def toPython = { symbol -> toPythonMap.getOrDefault(symbol, symbol) } -def toJava = { symbol -> toJavaMap.getOrDefault(symbol, symbol) } - -// for enums we ignore T and handle it manually because of conflict with T.id which is trickier to deal with -// in the templating language -def binding = ["enums": CoreImports.getClassImports() - .findAll { Enum.class.isAssignableFrom(it) && !(it in [T, Operator]) } - .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }, - "pmethods": P.class.getMethods(). - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { P.class.isAssignableFrom(it.returnType) }. - collect { toPython(it.name) }. - unique(). - sort { a, b -> a <=> b }, - "tpmethods": TextP.class.getMethods(). - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { TextP.class.isAssignableFrom(it.returnType) }. - collect { toPython(it.name) }. - unique(). - sort { a, b -> a <=> b }, - "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS - findAll { GraphTraversalSource.class.equals(it.returnType) }. - findAll { - !it.name.equals("clone") && - !it.name.equals(TraversalSource.Symbols.withRemote) && - !it.name.equals(TraversalSource.Symbols.withComputer) - }. - collect { toPython(it.name) }. - unique(). - sort { a, b -> a <=> b }, - "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS - findAll { GraphTraversal.class.equals(it.returnType) }. - collect { toPython(it.name) }. - unique(). - sort { a, b -> a <=> b }, - "graphStepMethods": GraphTraversal.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { !it.name.equals("clone") && !it.name.equals("iterate") }. - collect { toPython(it.name) }. - unique(). - sort { a, b -> a <=> b }, - "anonStepMethods": __.class.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { !it.name.equals("__") && !it.name.equals("start") }. - collect { toPython(it.name) }. - unique(). - sort { a, b -> a <=> b }, - "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]), - "toPython": toPython, - "toJava": toJava, - "withOptions": WithOptions.getDeclaredFields(). - collect {["name": it.name, "value": toPythonValue(it.type, it.get(null))]}] - -def engine = new groovy.text.GStringTemplateEngine() -def traversalTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/TraversalSource.template")).make(binding) -def traversalFile = new File("${projectBaseDir}/src/main/python/gremlin_python/process/traversal.py") -traversalFile.newWriter().withWriter{ it << traversalTemplate } - -def graphTraversalTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/GraphTraversalSource.template")).make(binding) -def graphTraversalFile = new File("${projectBaseDir}/src/main/python/gremlin_python/process/graph_traversal.py") -graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate } diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml index 89b9e6c..c9edca0 100644 --- a/gremlin-python/pom.xml +++ b/gremlin-python/pom.xml @@ -260,24 +260,6 @@ limitations under the License. </dependencies> <executions> <execution> - <id>generate-dsl</id> - <phase>generate-sources</phase> - <goals> - <goal>execute</goal> - </goals> - <configuration> - <properties> - <property> - <name>projectBaseDir</name> - <value>${project.basedir}</value> - </property> - </properties> - <scripts> - <script>${project.basedir}/glv/generate.groovy</script> - </scripts> - </configuration> - </execution> - <execution> <id>gremlin-server-start</id> <phase>pre-integration-test</phase> <goals>
