From 37a2471932229ae6a4c1f5e5f3f2d3d25bbf7fd4 Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Thu, 6 Apr 2017 19:02:23 +0200 Subject: [PATCH 01/28] Add Gremlin-CSharp and Gremlin-DotNet This adds Gremlin-CSharp (a C# GLV), together with a .NET driver. The driver is based on Gremlin.Net (https://github.com/FlorianHockmann/Gremlin.Net) with added support for GLVs and Gremlin-CSharp is auto generated, very similar to Gremlin-Python. This should fix TINKERPOP-1552. --- .gitignore | 9 + .travis.yml | 5 + docker/Dockerfile | 6 +- .../development-environment.asciidoc | 18 + docs/src/reference/gremlin-variants.asciidoc | 196 ++++++ gremlin-csharp-generator/pom.xml | 60 ++ .../csharp/AnonymousTraversalGenerator.groovy | 71 ++ .../gremlin/csharp/CommonContentHelper.groovy | 49 ++ .../gremlin/csharp/EnumGenerator.groovy | 62 ++ .../csharp/GenerateGremlinCSharp.groovy | 32 + .../csharp/GraphTraversalGenerator.groovy | 77 +++ .../GraphTraversalSourceGenerator.groovy | 140 ++++ .../gremlin/csharp/PredicateGenerator.groovy | 66 ++ .../gremlin/csharp/SymbolHelper.groovy | 31 + gremlin-dotnet/Gremlin.Net.sln | 80 +++ gremlin-dotnet/pom.xml | 39 ++ .../src/Gremlin.CSharp/Gremlin.CSharp.csproj | 21 + .../src/Gremlin.CSharp/Process/Barrier.cs | 30 + .../src/Gremlin.CSharp/Process/Cardinality.cs | 32 + .../src/Gremlin.CSharp/Process/Column.cs | 31 + .../src/Gremlin.CSharp/Process/Direction.cs | 32 + .../Gremlin.CSharp/Process/GraphTraversal.cs | 630 ++++++++++++++++++ .../Process/GraphTraversalSource.cs | 143 ++++ .../src/Gremlin.CSharp/Process/Operator.cs | 40 ++ .../src/Gremlin.CSharp/Process/Order.cs | 36 + .../src/Gremlin.CSharp/Process/P.cs | 108 +++ .../src/Gremlin.CSharp/Process/Pick.cs | 31 + .../src/Gremlin.CSharp/Process/Pop.cs | 32 + .../src/Gremlin.CSharp/Process/Scope.cs | 31 + .../src/Gremlin.CSharp/Process/T.cs | 33 + .../src/Gremlin.CSharp/Process/__.cs | 488 ++++++++++++++ .../src/Gremlin.CSharp/Structure/Graph.cs | 35 + .../Gremlin.Net.Process.csproj | 24 + .../Remote/IRemoteConnection.cs | 42 ++ .../Remote/RemoteStrategy.cs | 61 ++ .../Gremlin.Net.Process/Traversal/Binding.cs | 80 +++ .../Gremlin.Net.Process/Traversal/Bindings.cs | 42 ++ .../Gremlin.Net.Process/Traversal/Bytecode.cs | 85 +++ .../Traversal/DefaultTraversal.cs | 195 ++++++ .../Traversal/ITraversal.cs | 96 +++ .../Traversal/ITraversalSideEffects.cs | 52 ++ .../Traversal/ITraversalStrategy.cs | 46 ++ .../Traversal/Instruction.cs | 52 ++ .../Strategy/AbstractTraversalStrategy.cs | 86 +++ .../Strategy/Decoration/ConnectiveStrategy.cs | 33 + .../Strategy/Decoration/ElementIdStrategy.cs | 32 + .../Decoration/HaltedTraverserStrategy.cs | 34 + .../Strategy/Decoration/PartitionStrategy.cs | 56 ++ .../Strategy/Decoration/SubgraphStrategy.cs | 48 ++ .../Decoration/VertexProgramStrategy.cs | 50 ++ .../Finalization/MatchAlgorithmStrategy.cs | 34 + .../AdjacentToIncidentStrategy.cs | 32 + .../Optimization/FilterRankingStrategy.cs | 32 + .../Optimization/GraphFilterStrategy.cs | 29 + .../Optimization/IdentityRemovalStrategy.cs | 32 + .../IncidentToAdjacentStrategy.cs | 33 + .../Optimization/InlineFilterStrategy.cs | 32 + .../Optimization/LazyBarrierStrategy.cs | 33 + .../Optimization/MatchPredicateStrategy.cs | 32 + .../Optimization/OrderLimitStrategy.cs | 29 + .../Optimization/PathProcessorStrategy.cs | 32 + .../Optimization/PathRetractionStrategy.cs | 29 + .../Optimization/RangeByIsCountStrategy.cs | 32 + .../Optimization/RepeatUnrollStrategy.cs | 29 + .../Verification/LambdaRestrictionStrategy.cs | 32 + .../Strategy/Verification/ReadOnlyStrategy.cs | 32 + .../Traversal/TraversalPredicate.cs | 85 +++ .../Traversal/Traverser.cs | 75 +++ .../src/Gremlin.Net/Driver/Connection.cs | 133 ++++ .../Gremlin.Net/Driver/ConnectionFactory.cs | 47 ++ .../src/Gremlin.Net/Driver/ConnectionPool.cs | 114 ++++ .../Driver/Exceptions/ResponseException.cs | 37 + .../src/Gremlin.Net/Driver/GremlinClient.cs | 95 +++ .../Driver/GremlinClientExtensions.cs | 140 ++++ .../src/Gremlin.Net/Driver/GremlinServer.cs | 56 ++ .../src/Gremlin.Net/Driver/IConnection.cs | 35 + .../src/Gremlin.Net/Driver/IGremlinClient.cs | 48 ++ .../Driver/JsonMessageSerializer.cs | 49 ++ .../Driver/Messages/RequestMessage.cs | 143 ++++ .../Driver/Messages/ResponseMessage.cs | 40 ++ .../Driver/Messages/ResponseResult.cs | 37 + .../Driver/Messages/ResponseStatus.cs | 50 ++ .../Driver/Messages/ResponseStatusCode.cs | 67 ++ .../src/Gremlin.Net/Driver/ProxyConnection.cs | 52 ++ .../Driver/Remote/DriverRemoteConnection.cs | 80 +++ .../Driver/Remote/DriverRemoteTraversal.cs | 39 ++ .../DriverRemoteTraversalSideEffects.cs | 126 ++++ .../ResultsAggregation/AggregatorFactory.cs | 44 ++ .../ResultsAggregation/DefaultAggregator.cs | 42 ++ .../DictionaryAggregator.cs | 44 ++ .../Driver/ResultsAggregation/IAggregator.cs | 31 + .../ResultsAggregation/TraverserAggregator.cs | 44 ++ .../src/Gremlin.Net/Driver/Tokens.cs | 114 ++++ .../Gremlin.Net/Driver/WebSocketConnection.cs | 96 +++ .../src/Gremlin.Net/Gremlin.Net.csproj | 43 ++ .../Gremlin.Net/Properties/AssemblyInfo.cs | 44 ++ .../src/Gremlin.Net/Structure/Edge.cs | 61 ++ .../src/Gremlin.Net/Structure/Element.cs | 77 +++ .../IO/GraphSON/BindingSerializer.cs | 42 ++ .../IO/GraphSON/BytecodeSerializer.cs | 58 ++ .../Structure/IO/GraphSON/DateDeserializer.cs | 43 ++ .../Structure/IO/GraphSON/DateSerializer.cs | 43 ++ .../Structure/IO/GraphSON/DoubleConverter.cs | 33 + .../Structure/IO/GraphSON/EdgeDeserializer.cs | 43 ++ .../Structure/IO/GraphSON/EdgeSerializer.cs | 45 ++ .../Structure/IO/GraphSON/EnumSerializer.cs | 37 + .../Structure/IO/GraphSON/FloatConverter.cs | 33 + .../Structure/IO/GraphSON/GraphSONReader.cs | 123 ++++ .../Structure/IO/GraphSON/GraphSONTokens.cs | 32 + .../Structure/IO/GraphSON/GraphSONUtil.cs | 62 ++ .../Structure/IO/GraphSON/GraphSONWriter.cs | 146 ++++ .../IO/GraphSON/IGraphSONDeserializer.cs | 41 ++ .../IO/GraphSON/IGraphSONSerializer.cs | 41 ++ .../Structure/IO/GraphSON/Int32Converter.cs | 33 + .../Structure/IO/GraphSON/Int64Converter.cs | 33 + .../Structure/IO/GraphSON/NumberConverter.cs | 45 ++ .../Structure/IO/GraphSON/PathDeserializer.cs | 41 ++ .../IO/GraphSON/PropertyDeserializer.cs | 38 ++ .../IO/GraphSON/PropertySerializer.cs | 64 ++ .../IO/GraphSON/RequestMessageSerializer.cs | 43 ++ .../GraphSON/TraversalPredicateSerializer.cs | 45 ++ .../IO/GraphSON/TraversalSerializer.cs | 38 ++ .../GraphSON/TraversalStrategySerializer.cs | 37 + .../Structure/IO/GraphSON/TraverserReader.cs | 38 ++ .../Structure/IO/GraphSON/UuidDeserializer.cs | 36 + .../Structure/IO/GraphSON/UuidSerializer.cs | 37 + .../IO/GraphSON/VertexDeserializer.cs | 37 + .../IO/GraphSON/VertexPropertyDeserializer.cs | 41 ++ .../IO/GraphSON/VertexPropertySerializer.cs | 43 ++ .../Structure/IO/GraphSON/VertexSerializer.cs | 41 ++ .../src/Gremlin.Net/Structure/Path.cs | 193 ++++++ .../src/Gremlin.Net/Structure/Property.cs | 96 +++ .../src/Gremlin.Net/Structure/Vertex.cs | 52 ++ .../Gremlin.Net/Structure/VertexProperty.cs | 66 ++ gremlin-dotnet/src/pom.xml | 55 ++ .../BytecodeGenerationTests.cs | 76 +++ .../BytecodeGeneration/StrategiesTests.cs | 170 +++++ .../ConfigProvider.cs | 47 ++ .../DriverRemoteConnection/EnumTests.cs | 59 ++ .../GraphTraversalSourceTests.cs | 55 ++ .../GraphTraversalTests.cs | 171 +++++ .../DriverRemoteConnection/PredicateTests.cs | 58 ++ .../RemoteConnectionFactory.cs | 41 ++ .../DriverRemoteConnection/SideEffectTests.cs | 221 ++++++ .../DriverRemoteConnection/StrategiesTests.cs | 193 ++++++ .../GraphSONWriterTests.cs | 50 ++ .../Gremlin.CSharp.IntegrationTest.csproj | 38 ++ .../Properties/AssemblyInfo.cs | 44 ++ .../appsettings.json | 4 + .../GraphTraversalSourceTests.cs | 68 ++ .../Gremlin.CSharp.UnitTest.csproj | 21 + .../Gremlin.CSharp.UnitTest/PredicateTests.cs | 50 ++ .../ConfigProvider.cs | 47 ++ .../Driver/ConnectionPoolTests.cs | 90 +++ .../Driver/GremlinClientTests.cs | 212 ++++++ .../Driver/MessagesTests.cs | 147 ++++ .../Gremlin.Net.IntegrationTest.csproj | 41 ++ .../Process/Remote/RemoteStrategyTests.cs | 85 +++ .../Properties/AssemblyInfo.cs | 44 ++ .../Util/RequestMessageProvider.cs | 54 ++ .../appsettings.json | 4 + .../Gremlin.Net.Process.UnitTest.csproj | 22 + .../Traversal/BytecodeTests.cs | 44 ++ .../Traversal/Strategy/StrategyTests.cs | 109 +++ .../Traversal/TestTraversal.cs | 51 ++ .../Traversal/TestTraversalStrategy.cs | 50 ++ .../Traversal/TraversalTests.cs | 177 +++++ .../Traversal/TraverserTests.cs | 75 +++ .../Driver/DriverRemoteConnectionTests.cs | 51 ++ .../Driver/GremlinServerTests.cs | 66 ++ .../Driver/RequestMessageBuilderTests.cs | 41 ++ .../Gremlin.Net.UnitTest.csproj | 35 + .../Properties/AssemblyInfo.cs | 44 ++ .../Structure/EdgeTests.cs | 57 ++ .../BytecodeGraphSONSerializerTests.cs | 153 +++++ .../IO/GraphSON/GraphSONReaderTests.cs | 308 +++++++++ .../IO/GraphSON/GraphSONWriterTests.cs | 329 +++++++++ .../IO/GraphSON/StrategyWriterTests.cs | 66 ++ .../Structure/IO/GraphSON/TestClass.cs | 30 + .../Structure/IO/GraphSON/TestUtils.cs | 36 + .../Structure/PathTests.cs | 416 ++++++++++++ .../Structure/PropertyTests.cs | 165 +++++ .../Structure/VertexPropertyTests.cs | 69 ++ .../Structure/VertexTests.cs | 80 +++ gremlin-dotnet/test/pom.xml | 179 +++++ pom.xml | 9 + 186 files changed, 13224 insertions(+), 2 deletions(-) create mode 100644 gremlin-csharp-generator/pom.xml create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy create mode 100644 gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy create mode 100644 gremlin-dotnet/Gremlin.Net.sln create mode 100644 gremlin-dotnet/pom.xml create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs create mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Remote/IRemoteConnection.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Remote/RemoteStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Binding.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bindings.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bytecode.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/DefaultTraversal.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversal.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Instruction.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/AbstractTraversalStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/PartitionStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/TraversalPredicate.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Traverser.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/JsonMessageSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Messages/RequestMessage.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseMessage.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseResult.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/AggregatorFactory.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DefaultAggregator.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DictionaryAggregator.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/IAggregator.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/TraverserAggregator.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj create mode 100644 gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/Edge.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/Element.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DoubleConverter.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/FloatConverter.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONTokens.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int32Converter.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int64Converter.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/NumberConverter.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PathDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertyDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertySerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/RequestMessageSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalStrategySerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraverserReader.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertyDeserializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertySerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexSerializer.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/Path.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/Property.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/Vertex.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Structure/VertexProperty.cs create mode 100644 gremlin-dotnet/src/pom.xml create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj create mode 100644 gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/ConfigProvider.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Util/RequestMessageProvider.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GremlinServerTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/RequestMessageBuilderTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/EdgeTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestUtils.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PropertyTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexPropertyTests.cs create mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexTests.cs create mode 100644 gremlin-dotnet/test/pom.xml diff --git a/.gitignore b/.gitignore index ca3160b6792..fe469b048ea 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,12 @@ __pycache__/ __version__.py .glv settings.xml +tools/ +[Dd]ebug/ +[Rr]elease/ +[Oo]bj/ +*.suo +*.user +.vscode/ +.vs/ +*nupkg diff --git a/.travis.yml b/.travis.yml index f2513e6a158..31a98a539e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,11 @@ addons: apt: packages: - oracle-java8-installer +before_install: + - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' + - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 + - sudo apt-get update + - sudo apt-get install dotnet-dev-1.0.1 script: - "mvn clean install -Dci" #notifications: diff --git a/docker/Dockerfile b/docker/Dockerfile index 87e8b076e7c..932536c77b1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,11 +20,13 @@ FROM ubuntu:trusty MAINTAINER Daniel Kuppitz RUN apt-get update \ - && apt-get -y install software-properties-common python-software-properties \ + && apt-get -y install software-properties-common python-software-properties apt-transport-https \ && echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections \ && add-apt-repository -y ppa:webupd8team/java \ + && sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' \ + && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 \ && apt-get update \ - && apt-get install -y oracle-java8-installer curl gawk git maven openssh-server \ + && apt-get install -y oracle-java8-installer curl gawk git maven openssh-server dotnet-dev-1.0.1 \ && rm -rf /var/lib/apt/lists/* /var/cache/oracle-jdk8-installer RUN sed -i 's@PermitRootLogin without-password@PermitRootLogin yes@' /etc/ssh/sshd_config diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc index 2dff247af31..3d2760584d8 100644 --- a/docs/src/dev/developer/development-environment.asciidoc +++ b/docs/src/dev/developer/development-environment.asciidoc @@ -101,6 +101,24 @@ integration tests and therefore must be actively switched on with `-DskipIntegra [source,text] mvn clean install -pl gremlin-console -DskipIntegrationTests=false +[[dotnet-environment]] +.NET Environment +~~~~~~~~~~~~~~~~ + +The build optionally requires link:https://www.microsoft.com/net/core[.NET Core SDK] (>=1.1.0) to work with the +gremlin-dotnet module. If .NET Core SDK is not installed, TinkerPop will still build with Maven, but .NET projects +will be skipped. + +`gremlin-dotnet` which also includes Gremlin-Csharp can be build and tested from the command line with: + +[source,text] +mvn clean install -Pgremlin-dotnet + +which enables the „gremlin-dotnet“ Maven profile or in a more automated fashion simply add a `.glv` file to the `src` +and `test` directories of the `gremlin-dotnet` module  which will signify to Maven that the environment is .NET-ready. +The `.glv` file need not have any contents and is ignored by Git. A standard `mvn clean install` will then build +`gremlin-dotnet` in full. + [[release-environment]] Release Environment ~~~~~~~~~~~~~~~~~~~ diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc index 39b55586d49..01df63246c1 100644 --- a/docs/src/reference/gremlin-variants.asciidoc +++ b/docs/src/reference/gremlin-variants.asciidoc @@ -354,4 +354,200 @@ graphson_writer = GraphSONWriter({MyType: MyType}) connection = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g', graphson_reader=graphson_reader, graphson_writer=graphson_writer) +---- + +[[gremlin-csharp]] +Gremlin-CSharp +-------------- +Apache TinkerPop's Gremlin-CSharp implements Gremlin within the C# language. It targets .NET Standard and can +therefore be used on different operating systems and with different .NET frameworks, such as .NET Framework +and link:https://www.microsoft.com/net/core[.NET Core]. Since the C# syntax is very similar to that of Java, it should be very easy to switch between +Gremlin-Java and Gremlin-CSharp. The only major syntactical difference is that all method names in Gremlin-CSharp +use PascalCase as opposed to camelCase in Gremlin-Java in order to comply with .NET conventions. + +[source,powershell] +nuget install Gremlin.CSharp + +In Gremlin-CSharp there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes +in Gremlin-Java. The `GraphTraversalSource` requires a driver in order to communicate with <> (or any +RemoteConnection-enabled server). + +Gremlin-CSharp and Gremlin-DotNet +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Gremlin-CSharp is the C# language variant of Gremlin, but it needs a driver to communicate with a remote +Gremlin Server. Such a driver is provided as part of Apache TinkerPop’s Gremlin-DotNet that also includes other +useful functionality to work with Gremlin in .NET. +Gremlin-DotNet is currently distributed in two NuGet packages: + +* `Gremlin.Net.Process` contains core functionality for Gremlin language variants and defines interfaces for drivers. +Gremlin-CSharp depends on this package. So it will be installed automatically when you install Gremlin-CSharp. +* `Gremlin.Net` contains a driver that allows Gremlin-CSharp to be used with a remote server and GraphSON serializers and deserializers. + +IMPORTANT: For developers wishing to provide another driver implementation, be sure to implement `IRemoteConnection` in +`Gremlin.Net.Process.Remote` so it can then be used by Gremlin-CSharp’s `GraphTraversal`. + +When Gremlin Server is running, Gremlin-CSharp can communicate with Gremlin Server by sending traversals serialized as `Bytecode`. + +IMPORTANT: Gremlin-CSharp is compatible with GraphSON 2.0 only, so this serializer must be configured in Gremlin Server. + +A traversal source can be spawned with `RemoteStrategy` from an empty `Graph`. + +[source,csharp] +---- +var graph = new Graph(); +var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClient(new GremlinServer("localhost", 8182)))); +---- + +When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via the registered +`IRemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote traversal source. +Since Gremlin-CSharp currently doesn't support lambda expressions, all traversals can be translated to Gremlin-Java on the remote +location (e.g. Gremlin Server). + +IMPORTANT: Gremlin-DotNet’s `ITraversal` interface supports the standard Gremlin methods such as `Next()`, `NextTraverser()`, `ToSet()`, +`ToList()`, etc. Such "terminal" methods trigger the evaluation of the traversal. + +RemoteConnection Submission +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Very similar to Gremlin-Python and Gremlin-Java, there are various ways to submit a traversal to a `IRemoteConnection` using +terminal/action methods off of `ITraversal`. + +* `ITraversal.Next()` +* `ITraversal.NextTraverser()` +* `ITraversal.ToList()` +* `ITraversal.ToSet()` +* `ITraversal.Iterate()` + +Static Enums and Methods +~~~~~~~~~~~~~~~~~~~~~~~~ + +Gremlin has various tokens (e.g. `T`, `P`, `Order`, `Operator`, etc.) that are represented in Gremlin-CSharp as Enums. + +These can be used analogously to how they are used in Gremlin-Java. + +[source,csharp] +g.V().HasLabel("person").Has("age",P.Gt(30)).Order().By("age",Order.decr).ToList() + +Moreover, the class prefixes can be ommitted with a `using static`. + +[source,csharp] +---- +using static Gremlin.CSharp.Process.P; +using static Gremlin.CSharp.Process.Order; +---- + +Then it is possible to represent the above traversal as below. + +[source,csharp] +g.V().HasLabel("person").Has("age",Gt(30)).Order().By("age",decr).ToList() + +Finally, with using static `__`, anonymous traversals like `__.Out()` can be expressed as below. That is, without the `__.`-prefix. + +[source,csharp] +g.V().Repeat(Out()).Times(2).Values("name").Fold().ToList() + +Bindings +~~~~~~~~ + +When a traversal bytecode is sent over a `IRemoteConnection` (e.g. Gremlin Server), it will be translated, compiled, +and then executed. If the same traversal is sent again, translation and compilation can be skipped as the previously +compiled version should be cached. Many traversals are unique up to some parameterization. For instance, +`g.V(1).Out("created").Values("name")` is considered different from `g.V(4).Out('created').Values("Name")` +as they have different script "string" representations. However, `g.V(x).Out("created").Values("name")` with bindings of +`{x : 1}` and `{x : 4}` are considered the same. If a traversal is going to be executed repeatedly, but with different +parameters, then bindings should be used. In Gremlin-CSharp, bindings are objects that can be created as follows. + +[source,csharp] +---- +var b = new Bindings(); +g.V(b.Of("id", 1)).Out("created").Values("name").toList() +g.V(b.Of("id", 4)).Out("created").Values("name").toList() +---- + +Traversal Strategies +~~~~~~~~~~~~~~~~~~~~ + +In order to add and remove traversal strategies from a traversal source, Gremlin-DotNet has an `AbstractTraversalStrategy` +class along with a collection of subclasses that mirror the standard Gremlin-Java strategies. + +[source,csharp] +---- +g = g.WithStrategies(new SubgraphStrategy(vertexCriterion: HasLabel("person"), + edgeCriterion: Has("weight", Gt(0.5)))); +var names = g.V().Values("name").ToList(); // names: [marko, vadas, josh, peter] + +g = g.WithoutStrategies(new SubgraphStrategy()); +names = g.V().Values("name").ToList(); // names: [marko, vadas, lop, josh, ripple, peter] + +var edgeValueMaps = g.V().OutE().ValueMap(true).ToList(); +// edgeValueMaps: [[label:created, id:9, weight:0.4], [label:knows, id:7, weight:0.5], [label:knows, id:8, weight:1.0], +// [label:created, id:10, weight:1.0], [label:created, id:11, weight:0.4], [label:created, id:12, weight:0.2]] + +g = g.WithComputer(workers: 2, vertices: Has("name", "marko")); +names = g.V().Values("name").ToList(); // names: [marko] + +edgeValueMaps = g.V().OutE().ValueMap(true).ToList(); +// edgeValueMaps: [[label:created, id:9, weight:0.4], [label:knows, id:7, weight:0.5], [label:knows, id:8, weight:1.0]] +---- + +NOTE: Many of the TraversalStrategy classes in Gremlin-DotNet are proxies to the respective strategy on Apache TinkerPop’s +JVM-based Gremlin traversal machine. As such, their `Apply(ITraversal)` method does nothing. However, the strategy is +encoded in the Gremlin-DotNet bytecode and transmitted to the Gremlin traversal machine for re-construction machine-side. + +Custom Serialization +~~~~~~~~~~~~~~~~~~~~ + +Gremlin-DotNet provides a GraphSON 2.0 serialization package with the standard Apache TinkerPop `g`-types registered +(see link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/#graphson-2d0[GraphSON 2.0]). It is possible for users to add new +types by creating serializers and deserializers in C# (or any other .NET language) and registering them with the `GremlinClient`. + +[source,csharp] +---- +internal class MyType +{ + public static string GraphsonPrefix = "providerx"; + public static string GraphsonBaseType = "MyType"; + public static string GraphsonType = GraphSONUtil.FormatTypeName(GraphsonPrefix, GraphsonBaseType); + + public MyType(int x, int y) + { + X = x; + Y = y; + } + + public int X { get; } + public int Y { get; } +} + +internal class MyClassWriter : IGraphSONSerializer +{ + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + MyType myType = objectData; + var valueDict = new Dictionary + { + {"x", myType.X}, + {"y", myType.Y} + }; + return GraphSONUtil.ToTypedValue(nameof(TestClass), valueDict, MyType.GraphsonPrefix); + } +} + +internal class MyTypeReader : IGraphSONDeserializer +{ + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var x = reader.ToObject(graphsonObject["x"]); + var y = reader.ToObject(graphsonObject["y"]); + return new MyType(x, y); + } +} + +var graphsonReader = new GraphSONReader( + new Dictionary {{MyType.GraphsonType, new MyTypeReader()}}); +var graphsonWriter = new GraphSONWriter( + new Dictionary {{typeof(MyType), new MyClassWriter()}}); + +var gremlinClient = new GremlinClient(new GremlinServer("localhost", 8182), graphsonReader, graphsonWriter); ---- \ No newline at end of file diff --git a/gremlin-csharp-generator/pom.xml b/gremlin-csharp-generator/pom.xml new file mode 100644 index 00000000000..f488f020c57 --- /dev/null +++ b/gremlin-csharp-generator/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.apache.tinkerpop + tinkerpop + 3.2.5-SNAPSHOT + + gremlin-csharp-generator + Apache TinkerPop :: Gremlin-CSharp Generator + + + org.apache.tinkerpop + gremlin-core + ${project.version} + + + org.codehaus.groovy + groovy + ${groovy.version} + indy + + + + ${basedir}/target + ${project.artifactId}-${project.version} + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + generate-csharp + generate-test-resources + + java + + + org.apache.tinkerpop.gremlin.csharp.GenerateGremlinCSharp + + ${project.parent.basedir}/gremlin-dotnet/src/Gremlin.CSharp + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + + \ No newline at end of file diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy new file mode 100644 index 00000000000..6e2e1916fdc --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy @@ -0,0 +1,71 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ + +import java.lang.reflect.Modifier + +class AnonymousTraversalGenerator { + + public static void create(final String anonymousTraversalFile) { + + final StringBuilder csharpClass = new StringBuilder() + + csharpClass.append(CommonContentHelper.getLicense()) + + csharpClass.append( +""" +namespace Gremlin.CSharp.Process +{ + public static class __ + { + public static GraphTraversal Start() + { + return new GraphTraversal(); + } +""") + __.getMethods(). + findAll { GraphTraversal.class.equals(it.returnType) }. + findAll { Modifier.isStatic(it.getModifiers()) }. + collect { it.name }. + findAll { !it.equals("__") && !it.equals("start") }. + unique(). + sort { a, b -> a <=> b }. + forEach { javaMethodName -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) + + csharpClass.append( +""" + public static GraphTraversal ${sharpMethodName}(params object[] args) + { + return new GraphTraversal().${sharpMethodName}(args); + } +""") + } + csharpClass.append("\t}\n") + csharpClass.append("}") + + final File file = new File(anonymousTraversalFile); + file.delete() + csharpClass.eachLine { file.append(it + "\n") } + } +} diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy new file mode 100644 index 00000000000..c44bcfa5e90 --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy @@ -0,0 +1,49 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +public final class CommonContentHelper { + + public static String getLicense() { + return """#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 +""" + } +} \ No newline at end of file diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy new file mode 100644 index 00000000000..a389f9b30fd --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy @@ -0,0 +1,62 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +import org.apache.tinkerpop.gremlin.util.CoreImports + +class EnumGenerator { + + public static void create(final String enumDirectory) { + + for (final Class enumClass : CoreImports.getClassImports() + .findAll { Enum.class.isAssignableFrom(it) } + .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() } + .collect()) { + createEnum(enumDirectory, enumClass) + } + } + + private static void createEnum(final String enumDirectory, final Class enumClass){ + final StringBuilder csharpEnum = new StringBuilder() + + csharpEnum.append(CommonContentHelper.getLicense()) + + csharpEnum.append( + """ +namespace Gremlin.CSharp.Process +{ + public enum ${enumClass.getSimpleName()} + { +""") + enumClass.getEnumConstants() + .sort { a, b -> a.name() <=> b.name() } + .each { value -> csharpEnum.append(" ${value.name()},\n"); } + csharpEnum.deleteCharAt(csharpEnum.length() - 2) + + csharpEnum.append(" }\n") + csharpEnum.append("}") + + final String enumFileName = "${enumDirectory}/${enumClass.getSimpleName()}.cs" + final File file = new File(enumFileName); + file.delete() + csharpEnum.eachLine { file.append(it + "\n") } + } +} + diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy new file mode 100644 index 00000000000..7b03e5a0d40 --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy @@ -0,0 +1,32 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +public class GenerateGremlinCSharp { + + public static void main(String[] args) { + final String csharpDirectory = args[0] + GraphTraversalSourceGenerator.create(csharpDirectory + "/Process/" + "GraphTraversalSource.cs") + GraphTraversalGenerator.create(csharpDirectory + "/Process/" + "GraphTraversal.cs") + AnonymousTraversalGenerator.create(csharpDirectory + "/Process/" + "__.cs") + EnumGenerator.create(csharpDirectory + "/Process/") + PredicateGenerator.create(csharpDirectory + "/Process/" + "P.cs") + } +} \ No newline at end of file diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy new file mode 100644 index 00000000000..54183a3e2ae --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy @@ -0,0 +1,77 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal + +class GraphTraversalGenerator { + + public static void create(final String graphTraversalFile) { + + final StringBuilder csharpClass = new StringBuilder() + + csharpClass.append(CommonContentHelper.getLicense()) + + csharpClass.append( +""" +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.CSharp.Process +{ + public class GraphTraversal : DefaultTraversal + { + public GraphTraversal() + : this(new List(), new Bytecode()) + { + } + + public GraphTraversal(ICollection traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } +""") + 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 }. + forEach { javaMethodName -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) + + csharpClass.append( + """ + public GraphTraversal ${sharpMethodName}(params object[] args) + { + Bytecode.AddStep("${javaMethodName}", args); + return this; + } +""") + } + csharpClass.append("\t}\n") + csharpClass.append("}") + + final File file = new File(graphTraversalFile); + file.delete() + csharpClass.eachLine { file.append(it + "\n") } + } +} diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy new file mode 100644 index 00000000000..aaa35fb100b --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy @@ -0,0 +1,140 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource + + +class GraphTraversalSourceGenerator { + + public static void create(final String graphTraversalSourceFile) { + + final StringBuilder csharpClass = new StringBuilder() + + csharpClass.append(CommonContentHelper.getLicense()) + + csharpClass.append( +""" +using System.Collections.Generic; +using Gremlin.Net.Process.Remote; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; + +namespace Gremlin.CSharp.Process +{ + public class GraphTraversalSource + { + public ICollection TraversalStrategies { get; set; } + public Bytecode Bytecode { get; set; } + + public GraphTraversalSource() + : this(new List(), new Bytecode()) + { + } + + public GraphTraversalSource(ICollection traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } +""" + ) + + // Hold the list of methods with their overloads, so we do not create duplicates + HashMap> sharpMethods = new HashMap>() + + GraphTraversalSource.getMethods(). // SOURCE STEPS + findAll { GraphTraversalSource.class.equals(it.returnType) }. + findAll { + !it.name.equals("clone") && + // replace by TraversalSource.Symbols.XXX + !it.name.equals("withBindings") && + !it.name.equals("withRemote") && + !it.name.equals("withComputer") + }. + collect { it.name }. + unique(). + sort { a, b -> a <=> b }. + forEach { javaMethodName -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) + + csharpClass.append( +""" + public GraphTraversalSource ${sharpMethodName}(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("${javaMethodName}\", args); + return source; + } +""") + } + + csharpClass.append( + """ + public GraphTraversalSource WithBindings(object bindings) + { + return this; + } + + public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); + return source; + } + + public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, + string result = null, ITraversal vertices = null, ITraversal edges = null, + Dictionary configuration = null) + { + return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); + } +""") + + GraphTraversalSource.getMethods(). // SPAWN STEPS + findAll { GraphTraversal.class.equals(it.returnType) }. + collect { it.name }. + unique(). + sort { a, b -> a <=> b }. + forEach { javaMethodName -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) + + csharpClass.append( + """ + public GraphTraversal ${sharpMethodName}(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("${javaMethodName}\", args); + return traversal; + } +""") + } + + csharpClass.append("\t}\n") + csharpClass.append("}") + + final File file = new File(graphTraversalSourceFile); + file.delete() + csharpClass.eachLine { file.append(it + "\n") } + } +} \ No newline at end of file diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy new file mode 100644 index 00000000000..72e3dba13a0 --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy @@ -0,0 +1,66 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +import org.apache.tinkerpop.gremlin.process.traversal.P + +import java.lang.reflect.Modifier + +class PredicateGenerator { + + public static void create(final String predicateFile) { + + final StringBuilder csharpClass = new StringBuilder() + + csharpClass.append(CommonContentHelper.getLicense()) + + csharpClass.append( +""" +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.CSharp.Process +{ + public class P + {""") + P.class.getMethods(). + findAll { Modifier.isStatic(it.getModifiers()) }. + findAll { P.class.isAssignableFrom(it.returnType) }. + collect { it.name }. + unique(). + sort { a, b -> a <=> b }. + each { javaMethodName -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) + csharpClass.append( +""" + public static TraversalPredicate ${sharpMethodName}(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("${javaMethodName}", value); + } +""") + } + csharpClass.append("\t}\n") + csharpClass.append("}") + + final File file = new File(predicateFile) + file.delete() + csharpClass.eachLine { file.append(it + "\n") } + } +} diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy new file mode 100644 index 00000000000..10591d7a009 --- /dev/null +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ + +package org.apache.tinkerpop.gremlin.csharp + +public final class SymbolHelper { + + public static String toCSharp(final String symbol) { + return (String) Character.toUpperCase(symbol.charAt(0)) + symbol.substring(1) + } + + public static String toJava(final String symbol) { + return (String) Character.toLowerCase(symbol.charAt(0)) + symbol.substring(1) + } +} diff --git a/gremlin-dotnet/Gremlin.Net.sln b/gremlin-dotnet/Gremlin.Net.sln new file mode 100644 index 00000000000..bfd565fc678 --- /dev/null +++ b/gremlin-dotnet/Gremlin.Net.sln @@ -0,0 +1,80 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{584F838B-DAE2-44F5-868C-1F532949C827}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D4B935A4-93F9-4A58-BC34-E5BFE1D2E2F7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1B54FAC2-5411-4BB6-B450-FE2FFD8C4782}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.Net", "src\Gremlin.Net\Gremlin.Net.csproj", "{6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.Net.UnitTest", "test\Gremlin.Net.UnitTest\Gremlin.Net.UnitTest.csproj", "{1FAB781B-B857-4AD2-BEC8-E20C214D9E21}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.Net.IntegrationTest", "test\Gremlin.Net.IntegrationTest\Gremlin.Net.IntegrationTest.csproj", "{CC54ABE3-13D2-491C-81E2-4D0355ABFA93}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.CSharp", "src\Gremlin.CSharp\Gremlin.CSharp.csproj", "{709D235A-CA13-434F-9AF9-8C8C009B11D7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.CSharp.IntegrationTest", "test\Gremlin.CSharp.IntegrationTest\Gremlin.CSharp.IntegrationTest.csproj", "{232F0F2B-178E-4214-99C7-CC4DC6710F44}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin.Net.Process", "src\Gremlin.Net.Process\Gremlin.Net.Process.csproj", "{4949181B-C97D-4BB4-A312-9C1506EC7DA7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin.Net.Process.UnitTest", "test\Gremlin.Net.Process.UnitTest\Gremlin.Net.Process.UnitTest.csproj", "{D97CA283-AC86-4EC9-9E1D-5F9A97977687}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin.CSharp.UnitTest", "test\Gremlin.CSharp.UnitTest\Gremlin.CSharp.UnitTest.csproj", "{F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8}.Release|Any CPU.Build.0 = Release|Any CPU + {1FAB781B-B857-4AD2-BEC8-E20C214D9E21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1FAB781B-B857-4AD2-BEC8-E20C214D9E21}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1FAB781B-B857-4AD2-BEC8-E20C214D9E21}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1FAB781B-B857-4AD2-BEC8-E20C214D9E21}.Release|Any CPU.Build.0 = Release|Any CPU + {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Release|Any CPU.Build.0 = Release|Any CPU + {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Release|Any CPU.Build.0 = Release|Any CPU + {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Release|Any CPU.Build.0 = Release|Any CPU + {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Release|Any CPU.Build.0 = Release|Any CPU + {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Release|Any CPU.Build.0 = Release|Any CPU + {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8} = {584F838B-DAE2-44F5-868C-1F532949C827} + {1FAB781B-B857-4AD2-BEC8-E20C214D9E21} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} + {CC54ABE3-13D2-491C-81E2-4D0355ABFA93} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} + {709D235A-CA13-434F-9AF9-8C8C009B11D7} = {584F838B-DAE2-44F5-868C-1F532949C827} + {232F0F2B-178E-4214-99C7-CC4DC6710F44} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} + {4949181B-C97D-4BB4-A312-9C1506EC7DA7} = {584F838B-DAE2-44F5-868C-1F532949C827} + {D97CA283-AC86-4EC9-9E1D-5F9A97977687} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} + {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} + EndGlobalSection +EndGlobal diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml new file mode 100644 index 00000000000..0472324a3ba --- /dev/null +++ b/gremlin-dotnet/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + org.apache.tinkerpop + tinkerpop + 3.2.5-SNAPSHOT + + org.apache.tinkerpop + gremlin-dotnet + Apache TinkerPop :: Gremlin-DotNet + pom + + + test + src + + + + + + org.eobjects.build + dotnet-maven-plugin + true + 0.14 + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + + \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj b/gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj new file mode 100644 index 00000000000..82291fcb5a3 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj @@ -0,0 +1,21 @@ + + + + 3.2.5-SNAPSHOT + netstandard1.3 + Gremlin.CSharp + Gremlin.CSharp + False + http://tinkerpop.apache.org + https://github.com/apache/tinkerpop/blob/master/LICENSE + https://github.com/apache/tinkerpop + Apache TinkerPop’s Gremlin-CSharp implements Gremlin within C# and can be used on any platform. + gremlin-csharp;gremlin;tinkerpop + Apache TinkerPop + + + + + + + diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs new file mode 100644 index 00000000000..a74b47aa699 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs @@ -0,0 +1,30 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Barrier + { + normSack + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs new file mode 100644 index 00000000000..4b9fae82d08 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Cardinality + { + list, + set, + single + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs new file mode 100644 index 00000000000..c397b694230 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs @@ -0,0 +1,31 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Column + { + keys, + values + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs new file mode 100644 index 00000000000..abdf7a2f88a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Direction + { + BOTH, + IN, + OUT + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs new file mode 100644 index 00000000000..439783823ba --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs @@ -0,0 +1,630 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.CSharp.Process +{ + public class GraphTraversal : DefaultTraversal + { + public GraphTraversal() + : this(new List(), new Bytecode()) + { + } + + public GraphTraversal(ICollection traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } + + public GraphTraversal V(params object[] args) + { + Bytecode.AddStep("V", args); + return this; + } + + public GraphTraversal AddE(params object[] args) + { + Bytecode.AddStep("addE", args); + return this; + } + + public GraphTraversal AddInE(params object[] args) + { + Bytecode.AddStep("addInE", args); + return this; + } + + public GraphTraversal AddOutE(params object[] args) + { + Bytecode.AddStep("addOutE", args); + return this; + } + + public GraphTraversal AddV(params object[] args) + { + Bytecode.AddStep("addV", args); + return this; + } + + public GraphTraversal Aggregate(params object[] args) + { + Bytecode.AddStep("aggregate", args); + return this; + } + + public GraphTraversal And(params object[] args) + { + Bytecode.AddStep("and", args); + return this; + } + + public GraphTraversal As(params object[] args) + { + Bytecode.AddStep("as", args); + return this; + } + + public GraphTraversal Barrier(params object[] args) + { + Bytecode.AddStep("barrier", args); + return this; + } + + public GraphTraversal Both(params object[] args) + { + Bytecode.AddStep("both", args); + return this; + } + + public GraphTraversal BothE(params object[] args) + { + Bytecode.AddStep("bothE", args); + return this; + } + + public GraphTraversal BothV(params object[] args) + { + Bytecode.AddStep("bothV", args); + return this; + } + + public GraphTraversal Branch(params object[] args) + { + Bytecode.AddStep("branch", args); + return this; + } + + public GraphTraversal By(params object[] args) + { + Bytecode.AddStep("by", args); + return this; + } + + public GraphTraversal Cap(params object[] args) + { + Bytecode.AddStep("cap", args); + return this; + } + + public GraphTraversal Choose(params object[] args) + { + Bytecode.AddStep("choose", args); + return this; + } + + public GraphTraversal Coalesce(params object[] args) + { + Bytecode.AddStep("coalesce", args); + return this; + } + + public GraphTraversal Coin(params object[] args) + { + Bytecode.AddStep("coin", args); + return this; + } + + public GraphTraversal Constant(params object[] args) + { + Bytecode.AddStep("constant", args); + return this; + } + + public GraphTraversal Count(params object[] args) + { + Bytecode.AddStep("count", args); + return this; + } + + public GraphTraversal CyclicPath(params object[] args) + { + Bytecode.AddStep("cyclicPath", args); + return this; + } + + public GraphTraversal Dedup(params object[] args) + { + Bytecode.AddStep("dedup", args); + return this; + } + + public GraphTraversal Drop(params object[] args) + { + Bytecode.AddStep("drop", args); + return this; + } + + public GraphTraversal Emit(params object[] args) + { + Bytecode.AddStep("emit", args); + return this; + } + + public GraphTraversal Filter(params object[] args) + { + Bytecode.AddStep("filter", args); + return this; + } + + public GraphTraversal FlatMap(params object[] args) + { + Bytecode.AddStep("flatMap", args); + return this; + } + + public GraphTraversal Fold(params object[] args) + { + Bytecode.AddStep("fold", args); + return this; + } + + public GraphTraversal From(params object[] args) + { + Bytecode.AddStep("from", args); + return this; + } + + public GraphTraversal Group(params object[] args) + { + Bytecode.AddStep("group", args); + return this; + } + + public GraphTraversal GroupCount(params object[] args) + { + Bytecode.AddStep("groupCount", args); + return this; + } + + public GraphTraversal GroupV3d0(params object[] args) + { + Bytecode.AddStep("groupV3d0", args); + return this; + } + + public GraphTraversal Has(params object[] args) + { + Bytecode.AddStep("has", args); + return this; + } + + public GraphTraversal HasId(params object[] args) + { + Bytecode.AddStep("hasId", args); + return this; + } + + public GraphTraversal HasKey(params object[] args) + { + Bytecode.AddStep("hasKey", args); + return this; + } + + public GraphTraversal HasLabel(params object[] args) + { + Bytecode.AddStep("hasLabel", args); + return this; + } + + public GraphTraversal HasNot(params object[] args) + { + Bytecode.AddStep("hasNot", args); + return this; + } + + public GraphTraversal HasValue(params object[] args) + { + Bytecode.AddStep("hasValue", args); + return this; + } + + public GraphTraversal Id(params object[] args) + { + Bytecode.AddStep("id", args); + return this; + } + + public GraphTraversal Identity(params object[] args) + { + Bytecode.AddStep("identity", args); + return this; + } + + public GraphTraversal In(params object[] args) + { + Bytecode.AddStep("in", args); + return this; + } + + public GraphTraversal InE(params object[] args) + { + Bytecode.AddStep("inE", args); + return this; + } + + public GraphTraversal InV(params object[] args) + { + Bytecode.AddStep("inV", args); + return this; + } + + public GraphTraversal Inject(params object[] args) + { + Bytecode.AddStep("inject", args); + return this; + } + + public GraphTraversal Is(params object[] args) + { + Bytecode.AddStep("is", args); + return this; + } + + public GraphTraversal Key(params object[] args) + { + Bytecode.AddStep("key", args); + return this; + } + + public GraphTraversal Label(params object[] args) + { + Bytecode.AddStep("label", args); + return this; + } + + public GraphTraversal Limit(params object[] args) + { + Bytecode.AddStep("limit", args); + return this; + } + + public GraphTraversal Local(params object[] args) + { + Bytecode.AddStep("local", args); + return this; + } + + public GraphTraversal Loops(params object[] args) + { + Bytecode.AddStep("loops", args); + return this; + } + + public GraphTraversal Map(params object[] args) + { + Bytecode.AddStep("map", args); + return this; + } + + public GraphTraversal MapKeys(params object[] args) + { + Bytecode.AddStep("mapKeys", args); + return this; + } + + public GraphTraversal MapValues(params object[] args) + { + Bytecode.AddStep("mapValues", args); + return this; + } + + public GraphTraversal Match(params object[] args) + { + Bytecode.AddStep("match", args); + return this; + } + + public GraphTraversal Max(params object[] args) + { + Bytecode.AddStep("max", args); + return this; + } + + public GraphTraversal Mean(params object[] args) + { + Bytecode.AddStep("mean", args); + return this; + } + + public GraphTraversal Min(params object[] args) + { + Bytecode.AddStep("min", args); + return this; + } + + public GraphTraversal Not(params object[] args) + { + Bytecode.AddStep("not", args); + return this; + } + + public GraphTraversal Option(params object[] args) + { + Bytecode.AddStep("option", args); + return this; + } + + public GraphTraversal Optional(params object[] args) + { + Bytecode.AddStep("optional", args); + return this; + } + + public GraphTraversal Or(params object[] args) + { + Bytecode.AddStep("or", args); + return this; + } + + public GraphTraversal Order(params object[] args) + { + Bytecode.AddStep("order", args); + return this; + } + + public GraphTraversal OtherV(params object[] args) + { + Bytecode.AddStep("otherV", args); + return this; + } + + public GraphTraversal Out(params object[] args) + { + Bytecode.AddStep("out", args); + return this; + } + + public GraphTraversal OutE(params object[] args) + { + Bytecode.AddStep("outE", args); + return this; + } + + public GraphTraversal OutV(params object[] args) + { + Bytecode.AddStep("outV", args); + return this; + } + + public GraphTraversal PageRank(params object[] args) + { + Bytecode.AddStep("pageRank", args); + return this; + } + + public GraphTraversal Path(params object[] args) + { + Bytecode.AddStep("path", args); + return this; + } + + public GraphTraversal PeerPressure(params object[] args) + { + Bytecode.AddStep("peerPressure", args); + return this; + } + + public GraphTraversal Profile(params object[] args) + { + Bytecode.AddStep("profile", args); + return this; + } + + public GraphTraversal Program(params object[] args) + { + Bytecode.AddStep("program", args); + return this; + } + + public GraphTraversal Project(params object[] args) + { + Bytecode.AddStep("project", args); + return this; + } + + public GraphTraversal Properties(params object[] args) + { + Bytecode.AddStep("properties", args); + return this; + } + + public GraphTraversal Property(params object[] args) + { + Bytecode.AddStep("property", args); + return this; + } + + public GraphTraversal PropertyMap(params object[] args) + { + Bytecode.AddStep("propertyMap", args); + return this; + } + + public GraphTraversal Range(params object[] args) + { + Bytecode.AddStep("range", args); + return this; + } + + public GraphTraversal Repeat(params object[] args) + { + Bytecode.AddStep("repeat", args); + return this; + } + + public GraphTraversal Sack(params object[] args) + { + Bytecode.AddStep("sack", args); + return this; + } + + public GraphTraversal Sample(params object[] args) + { + Bytecode.AddStep("sample", args); + return this; + } + + public GraphTraversal Select(params object[] args) + { + Bytecode.AddStep("select", args); + return this; + } + + public GraphTraversal SideEffect(params object[] args) + { + Bytecode.AddStep("sideEffect", args); + return this; + } + + public GraphTraversal SimplePath(params object[] args) + { + Bytecode.AddStep("simplePath", args); + return this; + } + + public GraphTraversal Store(params object[] args) + { + Bytecode.AddStep("store", args); + return this; + } + + public GraphTraversal Subgraph(params object[] args) + { + Bytecode.AddStep("subgraph", args); + return this; + } + + public GraphTraversal Sum(params object[] args) + { + Bytecode.AddStep("sum", args); + return this; + } + + public GraphTraversal Tail(params object[] args) + { + Bytecode.AddStep("tail", args); + return this; + } + + public GraphTraversal TimeLimit(params object[] args) + { + Bytecode.AddStep("timeLimit", args); + return this; + } + + public GraphTraversal Times(params object[] args) + { + Bytecode.AddStep("times", args); + return this; + } + + public GraphTraversal To(params object[] args) + { + Bytecode.AddStep("to", args); + return this; + } + + public GraphTraversal ToE(params object[] args) + { + Bytecode.AddStep("toE", args); + return this; + } + + public GraphTraversal ToV(params object[] args) + { + Bytecode.AddStep("toV", args); + return this; + } + + public GraphTraversal Tree(params object[] args) + { + Bytecode.AddStep("tree", args); + return this; + } + + public GraphTraversal Unfold(params object[] args) + { + Bytecode.AddStep("unfold", args); + return this; + } + + public GraphTraversal Union(params object[] args) + { + Bytecode.AddStep("union", args); + return this; + } + + public GraphTraversal Until(params object[] args) + { + Bytecode.AddStep("until", args); + return this; + } + + public GraphTraversal Value(params object[] args) + { + Bytecode.AddStep("value", args); + return this; + } + + public GraphTraversal ValueMap(params object[] args) + { + Bytecode.AddStep("valueMap", args); + return this; + } + + public GraphTraversal Values(params object[] args) + { + Bytecode.AddStep("values", args); + return this; + } + + public GraphTraversal Where(params object[] args) + { + Bytecode.AddStep("where", args); + return this; + } + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs new file mode 100644 index 00000000000..e68fdee84cb --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs @@ -0,0 +1,143 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Remote; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; + +namespace Gremlin.CSharp.Process +{ + public class GraphTraversalSource + { + public ICollection TraversalStrategies { get; set; } + public Bytecode Bytecode { get; set; } + + public GraphTraversalSource() + : this(new List(), new Bytecode()) + { + } + + public GraphTraversalSource(ICollection traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } + + public GraphTraversalSource WithBulk(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withBulk", args); + return source; + } + + public GraphTraversalSource WithPath(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withPath", args); + return source; + } + + public GraphTraversalSource WithSack(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withSack", args); + return source; + } + + public GraphTraversalSource WithSideEffect(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withSideEffect", args); + return source; + } + + public GraphTraversalSource WithStrategies(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withStrategies", args); + return source; + } + + public GraphTraversalSource WithoutStrategies(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withoutStrategies", args); + return source; + } + + public GraphTraversalSource WithBindings(object bindings) + { + return this; + } + + public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); + return source; + } + + public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, + string result = null, ITraversal vertices = null, ITraversal edges = null, + Dictionary configuration = null) + { + return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); + } + + public GraphTraversal E(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("E", args); + return traversal; + } + + public GraphTraversal V(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("V", args); + return traversal; + } + + public GraphTraversal AddV(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("addV", args); + return traversal; + } + + public GraphTraversal Inject(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("inject", args); + return traversal; + } + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs new file mode 100644 index 00000000000..5a9f805dbe9 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs @@ -0,0 +1,40 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Operator + { + addAll, + and, + assign, + div, + max, + min, + minus, + mult, + or, + sum, + sumLong + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs new file mode 100644 index 00000000000..1a30c7d83cd --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs @@ -0,0 +1,36 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Order + { + decr, + incr, + keyDecr, + keyIncr, + shuffle, + valueDecr, + valueIncr + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs new file mode 100644 index 00000000000..62282b70732 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs @@ -0,0 +1,108 @@ +#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 Gremlin.Net.Process.Traversal; + +namespace Gremlin.CSharp.Process +{ + public class P + { + public static TraversalPredicate Between(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("between", value); + } + + public static TraversalPredicate Eq(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("eq", value); + } + + public static TraversalPredicate Gt(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("gt", value); + } + + public static TraversalPredicate Gte(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("gte", value); + } + + public static TraversalPredicate Inside(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("inside", value); + } + + public static TraversalPredicate Lt(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("lt", value); + } + + public static TraversalPredicate Lte(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("lte", value); + } + + public static TraversalPredicate Neq(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("neq", value); + } + + public static TraversalPredicate Not(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("not", value); + } + + public static TraversalPredicate Outside(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("outside", value); + } + + public static TraversalPredicate Test(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("test", value); + } + + public static TraversalPredicate Within(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("within", value); + } + + public static TraversalPredicate Without(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("without", value); + } + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs new file mode 100644 index 00000000000..17c27d7f9ff --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs @@ -0,0 +1,31 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Pick + { + any, + none + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs new file mode 100644 index 00000000000..4e14d941504 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Pop + { + all, + first, + last + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs new file mode 100644 index 00000000000..a9578ee7cce --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs @@ -0,0 +1,31 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum Scope + { + global, + local + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs new file mode 100644 index 00000000000..4bf90622ef7 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public enum T + { + id, + key, + label, + value + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs b/gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs new file mode 100644 index 00000000000..2db0082a2da --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs @@ -0,0 +1,488 @@ +#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 + +namespace Gremlin.CSharp.Process +{ + public static class __ + { + public static GraphTraversal Start() + { + return new GraphTraversal(); + } + + public static GraphTraversal V(params object[] args) + { + return new GraphTraversal().V(args); + } + + public static GraphTraversal AddE(params object[] args) + { + return new GraphTraversal().AddE(args); + } + + public static GraphTraversal AddInE(params object[] args) + { + return new GraphTraversal().AddInE(args); + } + + public static GraphTraversal AddOutE(params object[] args) + { + return new GraphTraversal().AddOutE(args); + } + + public static GraphTraversal AddV(params object[] args) + { + return new GraphTraversal().AddV(args); + } + + public static GraphTraversal Aggregate(params object[] args) + { + return new GraphTraversal().Aggregate(args); + } + + public static GraphTraversal And(params object[] args) + { + return new GraphTraversal().And(args); + } + + public static GraphTraversal As(params object[] args) + { + return new GraphTraversal().As(args); + } + + public static GraphTraversal Barrier(params object[] args) + { + return new GraphTraversal().Barrier(args); + } + + public static GraphTraversal Both(params object[] args) + { + return new GraphTraversal().Both(args); + } + + public static GraphTraversal BothE(params object[] args) + { + return new GraphTraversal().BothE(args); + } + + public static GraphTraversal BothV(params object[] args) + { + return new GraphTraversal().BothV(args); + } + + public static GraphTraversal Branch(params object[] args) + { + return new GraphTraversal().Branch(args); + } + + public static GraphTraversal Cap(params object[] args) + { + return new GraphTraversal().Cap(args); + } + + public static GraphTraversal Choose(params object[] args) + { + return new GraphTraversal().Choose(args); + } + + public static GraphTraversal Coalesce(params object[] args) + { + return new GraphTraversal().Coalesce(args); + } + + public static GraphTraversal Coin(params object[] args) + { + return new GraphTraversal().Coin(args); + } + + public static GraphTraversal Constant(params object[] args) + { + return new GraphTraversal().Constant(args); + } + + public static GraphTraversal Count(params object[] args) + { + return new GraphTraversal().Count(args); + } + + public static GraphTraversal CyclicPath(params object[] args) + { + return new GraphTraversal().CyclicPath(args); + } + + public static GraphTraversal Dedup(params object[] args) + { + return new GraphTraversal().Dedup(args); + } + + public static GraphTraversal Drop(params object[] args) + { + return new GraphTraversal().Drop(args); + } + + public static GraphTraversal Emit(params object[] args) + { + return new GraphTraversal().Emit(args); + } + + public static GraphTraversal Filter(params object[] args) + { + return new GraphTraversal().Filter(args); + } + + public static GraphTraversal FlatMap(params object[] args) + { + return new GraphTraversal().FlatMap(args); + } + + public static GraphTraversal Fold(params object[] args) + { + return new GraphTraversal().Fold(args); + } + + public static GraphTraversal Group(params object[] args) + { + return new GraphTraversal().Group(args); + } + + public static GraphTraversal GroupCount(params object[] args) + { + return new GraphTraversal().GroupCount(args); + } + + public static GraphTraversal GroupV3d0(params object[] args) + { + return new GraphTraversal().GroupV3d0(args); + } + + public static GraphTraversal Has(params object[] args) + { + return new GraphTraversal().Has(args); + } + + public static GraphTraversal HasId(params object[] args) + { + return new GraphTraversal().HasId(args); + } + + public static GraphTraversal HasKey(params object[] args) + { + return new GraphTraversal().HasKey(args); + } + + public static GraphTraversal HasLabel(params object[] args) + { + return new GraphTraversal().HasLabel(args); + } + + public static GraphTraversal HasNot(params object[] args) + { + return new GraphTraversal().HasNot(args); + } + + public static GraphTraversal HasValue(params object[] args) + { + return new GraphTraversal().HasValue(args); + } + + public static GraphTraversal Id(params object[] args) + { + return new GraphTraversal().Id(args); + } + + public static GraphTraversal Identity(params object[] args) + { + return new GraphTraversal().Identity(args); + } + + public static GraphTraversal In(params object[] args) + { + return new GraphTraversal().In(args); + } + + public static GraphTraversal InE(params object[] args) + { + return new GraphTraversal().InE(args); + } + + public static GraphTraversal InV(params object[] args) + { + return new GraphTraversal().InV(args); + } + + public static GraphTraversal Inject(params object[] args) + { + return new GraphTraversal().Inject(args); + } + + public static GraphTraversal Is(params object[] args) + { + return new GraphTraversal().Is(args); + } + + public static GraphTraversal Key(params object[] args) + { + return new GraphTraversal().Key(args); + } + + public static GraphTraversal Label(params object[] args) + { + return new GraphTraversal().Label(args); + } + + public static GraphTraversal Limit(params object[] args) + { + return new GraphTraversal().Limit(args); + } + + public static GraphTraversal Local(params object[] args) + { + return new GraphTraversal().Local(args); + } + + public static GraphTraversal Loops(params object[] args) + { + return new GraphTraversal().Loops(args); + } + + public static GraphTraversal Map(params object[] args) + { + return new GraphTraversal().Map(args); + } + + public static GraphTraversal MapKeys(params object[] args) + { + return new GraphTraversal().MapKeys(args); + } + + public static GraphTraversal MapValues(params object[] args) + { + return new GraphTraversal().MapValues(args); + } + + public static GraphTraversal Match(params object[] args) + { + return new GraphTraversal().Match(args); + } + + public static GraphTraversal Max(params object[] args) + { + return new GraphTraversal().Max(args); + } + + public static GraphTraversal Mean(params object[] args) + { + return new GraphTraversal().Mean(args); + } + + public static GraphTraversal Min(params object[] args) + { + return new GraphTraversal().Min(args); + } + + public static GraphTraversal Not(params object[] args) + { + return new GraphTraversal().Not(args); + } + + public static GraphTraversal Optional(params object[] args) + { + return new GraphTraversal().Optional(args); + } + + public static GraphTraversal Or(params object[] args) + { + return new GraphTraversal().Or(args); + } + + public static GraphTraversal Order(params object[] args) + { + return new GraphTraversal().Order(args); + } + + public static GraphTraversal OtherV(params object[] args) + { + return new GraphTraversal().OtherV(args); + } + + public static GraphTraversal Out(params object[] args) + { + return new GraphTraversal().Out(args); + } + + public static GraphTraversal OutE(params object[] args) + { + return new GraphTraversal().OutE(args); + } + + public static GraphTraversal OutV(params object[] args) + { + return new GraphTraversal().OutV(args); + } + + public static GraphTraversal Path(params object[] args) + { + return new GraphTraversal().Path(args); + } + + public static GraphTraversal Project(params object[] args) + { + return new GraphTraversal().Project(args); + } + + public static GraphTraversal Properties(params object[] args) + { + return new GraphTraversal().Properties(args); + } + + public static GraphTraversal Property(params object[] args) + { + return new GraphTraversal().Property(args); + } + + public static GraphTraversal PropertyMap(params object[] args) + { + return new GraphTraversal().PropertyMap(args); + } + + public static GraphTraversal Range(params object[] args) + { + return new GraphTraversal().Range(args); + } + + public static GraphTraversal Repeat(params object[] args) + { + return new GraphTraversal().Repeat(args); + } + + public static GraphTraversal Sack(params object[] args) + { + return new GraphTraversal().Sack(args); + } + + public static GraphTraversal Sample(params object[] args) + { + return new GraphTraversal().Sample(args); + } + + public static GraphTraversal Select(params object[] args) + { + return new GraphTraversal().Select(args); + } + + public static GraphTraversal SideEffect(params object[] args) + { + return new GraphTraversal().SideEffect(args); + } + + public static GraphTraversal SimplePath(params object[] args) + { + return new GraphTraversal().SimplePath(args); + } + + public static GraphTraversal Store(params object[] args) + { + return new GraphTraversal().Store(args); + } + + public static GraphTraversal Subgraph(params object[] args) + { + return new GraphTraversal().Subgraph(args); + } + + public static GraphTraversal Sum(params object[] args) + { + return new GraphTraversal().Sum(args); + } + + public static GraphTraversal Tail(params object[] args) + { + return new GraphTraversal().Tail(args); + } + + public static GraphTraversal TimeLimit(params object[] args) + { + return new GraphTraversal().TimeLimit(args); + } + + public static GraphTraversal Times(params object[] args) + { + return new GraphTraversal().Times(args); + } + + public static GraphTraversal To(params object[] args) + { + return new GraphTraversal().To(args); + } + + public static GraphTraversal ToE(params object[] args) + { + return new GraphTraversal().ToE(args); + } + + public static GraphTraversal ToV(params object[] args) + { + return new GraphTraversal().ToV(args); + } + + public static GraphTraversal Tree(params object[] args) + { + return new GraphTraversal().Tree(args); + } + + public static GraphTraversal Unfold(params object[] args) + { + return new GraphTraversal().Unfold(args); + } + + public static GraphTraversal Union(params object[] args) + { + return new GraphTraversal().Union(args); + } + + public static GraphTraversal Until(params object[] args) + { + return new GraphTraversal().Until(args); + } + + public static GraphTraversal Value(params object[] args) + { + return new GraphTraversal().Value(args); + } + + public static GraphTraversal ValueMap(params object[] args) + { + return new GraphTraversal().ValueMap(args); + } + + public static GraphTraversal Values(params object[] args) + { + return new GraphTraversal().Values(args); + } + + public static GraphTraversal Where(params object[] args) + { + return new GraphTraversal().Where(args); + } + } +} diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs b/gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs new file mode 100644 index 00000000000..3ae5bef4052 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs @@ -0,0 +1,35 @@ +#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 Gremlin.CSharp.Process; + +namespace Gremlin.CSharp.Structure +{ + public class Graph + { + public GraphTraversalSource Traversal() + { + return new GraphTraversalSource(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj b/gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj new file mode 100644 index 00000000000..5e2d7fc4af9 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj @@ -0,0 +1,24 @@ + + + + 3.2.5-SNAPSHOT + netstandard1.3 + False + http://tinkerpop.apache.org + https://github.com/apache/tinkerpop/blob/master/LICENSE + https://github.com/apache/tinkerpop + Apache TinkerPop + gremlin;tinkerpop;gremlin-dotnet + This package provides implementations and interfaces for Gremlin language variants. + + + + + + + + + + + + \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Remote/IRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Remote/IRemoteConnection.cs new file mode 100644 index 00000000000..8555cb3d96e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Remote/IRemoteConnection.cs @@ -0,0 +1,42 @@ +#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.Threading.Tasks; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Process.Remote +{ + /// + /// A simple abstraction of a "connection" to a "server". + /// + public interface IRemoteConnection + { + /// + /// Submits to a server and returns a + /// . + /// + /// The to send. + /// The with the results and optional side-effects. + Task SubmitAsync(Bytecode bytecode); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Remote/RemoteStrategy.cs new file mode 100644 index 00000000000..4826113444e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Remote/RemoteStrategy.cs @@ -0,0 +1,61 @@ +#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.Threading.Tasks; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Process.Remote +{ + /// + /// Reconstructs a by submitting it to a remote server via an + /// instance. + /// + public class RemoteStrategy : ITraversalStrategy + { + private readonly IRemoteConnection _remoteConnection; + + /// + /// Initializes a new instance of the class. + /// + /// The that should be used. + public RemoteStrategy(IRemoteConnection remoteConnection) + { + _remoteConnection = remoteConnection; + } + + /// + public void Apply(ITraversal traversal) + { + ApplyAsync(traversal).Wait(); + } + + /// + public async Task ApplyAsync(ITraversal traversal) + { + if (traversal.Traversers != null) return; + var remoteTraversal = await _remoteConnection.SubmitAsync(traversal.Bytecode).ConfigureAwait(false); + traversal.SideEffects = remoteTraversal.SideEffects; + traversal.Traversers = remoteTraversal.Traversers; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Binding.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Binding.cs new file mode 100644 index 00000000000..80c826930f0 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Binding.cs @@ -0,0 +1,80 @@ +#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; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// Associates a variable with a value. + /// + public class Binding : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// The key that identifies the . + /// The value of the . + public Binding(string key, object value) + { + Key = key; + Value = value; + } + + /// + /// Gets the key that identifies the . + /// + public string Key { get; } + + /// + /// Gets the value of the . + /// + public object Value { get; } + + /// + public bool Equals(Binding other) + { + if (other == null) + return false; + return Key == other.Key && Value.Equals(other.Value); + } + + /// + public override bool Equals(object other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + if (other.GetType() != GetType()) return false; + return Equals(other as Binding); + } + + /// + public override int GetHashCode() + { + unchecked + { + return ((Key?.GetHashCode() ?? 0) * 397) ^ (Value?.GetHashCode() ?? 0); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bindings.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bindings.cs new file mode 100644 index 00000000000..985369ec31c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bindings.cs @@ -0,0 +1,42 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// Bindings are used to associate a variable with a value. + /// + public class Bindings + { + /// + /// Binds the variable to the specified value. + /// + /// The variable to bind. + /// The value to which the variable should be bound. + /// The bound value. + public Binding Of(string variable, object value) + { + return new Binding(variable, value); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bytecode.cs new file mode 100644 index 00000000000..b35e8db6c4a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bytecode.cs @@ -0,0 +1,85 @@ +#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; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// A language agnostic representation of mutations. + /// + /// + /// Bytecode is simply a list of ordered instructions. + /// Bytecode can be serialized between environments and machines by way of a GraphSON representation. + /// Thus, Gremlin-CSharp can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java. + /// + public class Bytecode + { + /// + /// Initializes a new instance of the class. + /// + public Bytecode() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Already existing that should be cloned. + public Bytecode(Bytecode byteCode) + { + SourceInstructions = new List(byteCode.SourceInstructions); + StepInstructions = new List(byteCode.StepInstructions); + } + + /// + /// Gets the traversal source instructions. + /// + public List SourceInstructions { get; } = new List(); + + /// + /// Gets the instructions. + /// + public List StepInstructions { get; } = new List(); + + /// + /// Add a traversal source instruction to the bytecode. + /// + /// The traversal source method name (e.g. withSack()). + /// The traversal source method arguments. + public void AddSource(string sourceName, params object[] args) + { + SourceInstructions.Add(new Instruction(sourceName, args)); + } + + /// + /// Adds a instruction to the bytecode. + /// + /// The traversal method name (e.g. out()). + /// The traversal method arguments. + public void AddStep(string stepName, params object[] args) + { + StepInstructions.Add(new Instruction(stepName, args)); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/DefaultTraversal.cs new file mode 100644 index 00000000000..86c636ce61e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/DefaultTraversal.cs @@ -0,0 +1,195 @@ +#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.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// A traversal represents a directed walk over a graph. + /// + public abstract class DefaultTraversal : ITraversal + { + private IEnumerator _traverserEnumerator; + + /// + /// Gets the representation of this traversal. + /// + public Bytecode Bytecode { get; protected set; } + + /// + /// Gets or sets the of this traversal. + /// + public ITraversalSideEffects SideEffects { get; set; } + + /// + /// Gets or sets the 's of this traversal that hold the results of the traversal. + /// + public IEnumerable Traversers { get; set; } + + /// + /// Gets or sets the strategies of this traversal. + /// + protected ICollection TraversalStrategies { get; set; } = new List(); + + private IEnumerator TraverserEnumerator + => _traverserEnumerator ?? (_traverserEnumerator = GetTraverserEnumerator()); + + /// + public void Dispose() + { + Dispose(true); + } + + /// + public bool MoveNext() + { + var currentTraverser = TraverserEnumerator.Current; + if (currentTraverser?.Bulk > 1) + { + currentTraverser.Bulk--; + return true; + } + return TraverserEnumerator.MoveNext(); + } + + /// + /// Reset is not supported. + /// + /// Thrown always as this operation is not supported. + public void Reset() + { + throw new NotSupportedException(); + } + + /// + public object Current => TraverserEnumerator.Current?.Object; + + private IEnumerator GetTraverserEnumerator() + { + if (Traversers == null) + ApplyStrategies(); + return Traversers.GetEnumerator(); + } + + private void ApplyStrategies() + { + foreach (var strategy in TraversalStrategies) + strategy.Apply(this); + } + + private async Task ApplyStrategiesAsync() + { + foreach (var strategy in TraversalStrategies) + await strategy.ApplyAsync(this).ConfigureAwait(false); + } + + /// + /// Gets the next result from the traversal. + /// + /// The result. + public object Next() + { + MoveNext(); + return Current; + } + + /// + /// Gets the next n-number of results from the traversal. + /// + /// The number of results to get. + /// The n-results. + public IEnumerable Next(int amount) + { + for (var i = 0; i < amount; i++) + yield return Next(); + } + + /// + /// Iterates all instances in the traversal. + /// + /// The fully drained traversal. + public ITraversal Iterate() + { + while (MoveNext()) + { + } + return this; + } + + /// + /// Gets the next . + /// + /// The next . + public Traverser NextTraverser() + { + TraverserEnumerator.MoveNext(); + return TraverserEnumerator.Current; + } + + /// + /// Puts all the results into a . + /// + /// The results in a list. + public List ToList() + { + var objs = new List(); + while (MoveNext()) + objs.Add(Current); + return objs; + } + + /// + /// Puts all the results into a . + /// + /// The results in a set. + public HashSet ToSet() + { + var objs = new HashSet(); + while (MoveNext()) + objs.Add(Current); + return objs; + } + + /// + protected virtual void Dispose(bool disposing) + { + if (disposing) + SideEffects?.Dispose(); + } + + /// + /// Starts a promise to execute a function on the current traversal that will be completed in the future. + /// + /// The return type of the . + /// The function to execute on the current traversal. + /// The result of the executed . + public async Task Promise(Func callback) + { + await ApplyStrategiesAsync().ConfigureAwait(false); + return callback(this); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversal.cs new file mode 100644 index 00000000000..cb472b7c937 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversal.cs @@ -0,0 +1,96 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// A traversal represents a directed walk over a graph. + /// + public interface ITraversal : IDisposable, IEnumerator + { + /// + /// Gets the representation of this traversal. + /// + Bytecode Bytecode { get; } + + /// + /// Gets or sets the of this traversal. + /// + ITraversalSideEffects SideEffects { get; set; } + + /// + /// Gets or sets the 's of this traversal that hold the results of the traversal. + /// + IEnumerable Traversers { get; set; } + + /// + /// Gets the next result from the traversal. + /// + /// The result. + object Next(); + + /// + /// Gets the next n-number of results from the traversal. + /// + /// The number of results to get. + /// The n-results. + IEnumerable Next(int amount); + + /// + /// Iterates all instances in the traversal. + /// + /// The fully drained traversal. + ITraversal Iterate(); + + /// + /// Gets the next . + /// + /// The next . + Traverser NextTraverser(); + + /// + /// Puts all the results into a . + /// + /// The results in a list. + List ToList(); + + /// + /// Puts all the results into a . + /// + /// The results in a set. + HashSet ToSet(); + + /// + /// Starts a promise to execute a function on the current traversal that will be completed in the future. + /// + /// The return type of the . + /// The function to execute on the current traversal. + /// The result of the executed . + Task Promise(Func callback); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs new file mode 100644 index 00000000000..0378fe6cc7d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs @@ -0,0 +1,52 @@ +#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; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// A can maintain global sideEffects. + /// + public interface ITraversalSideEffects : IDisposable + { + /// + /// Retrieves the keys of the side-effect that can be supplied to . + /// + /// The keys of the side-effect. + IReadOnlyCollection Keys(); + + /// + /// Gets the side-effect associated with the provided key. + /// + /// The key to get the value for. + /// The value associated with key. + object Get(string key); + + /// + /// Invalidates the side effect cache for traversal. + /// + void Close(); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalStrategy.cs new file mode 100644 index 00000000000..991a807dbad --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalStrategy.cs @@ -0,0 +1,46 @@ +#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.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// A defines a particular atomic operation for mutating a + /// prior to its evaluation. + /// + public interface ITraversalStrategy + { + /// + /// Applies the strategy to the given . + /// + /// The the strategy should be applied to. + void Apply(ITraversal traversal); + + /// + /// Applies the strategy to the given asynchronously. + /// + /// The the strategy should be applied to. + Task ApplyAsync(ITraversal traversal); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Instruction.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Instruction.cs new file mode 100644 index 00000000000..195b7bffc12 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Instruction.cs @@ -0,0 +1,52 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// Represents a instruction by an operator name and its arguments. + /// + public class Instruction + { + /// + /// Initializes a new instance of the class. + /// + /// The name of the operator. + /// The arguments. + public Instruction(string operatorName, params dynamic[] arguments) + { + OperatorName = operatorName; + Arguments = arguments; + } + + /// + /// Gets the name of the operator. + /// + public string OperatorName { get; } + + /// + /// Gets the arguments. + /// + public dynamic[] Arguments { get; } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/AbstractTraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/AbstractTraversalStrategy.cs new file mode 100644 index 00000000000..8c9666c2dd1 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/AbstractTraversalStrategy.cs @@ -0,0 +1,86 @@ +#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.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal.Strategy +{ + /// + /// Provides a common base class for strategies that are only included in + /// to be applied remotely. + /// + public abstract class AbstractTraversalStrategy : ITraversalStrategy, IEquatable + { + /// + /// Gets the name of the strategy. + /// + public string StrategyName => GetType().Name; + + /// + /// Gets the configuration of the strategy. + /// + public Dictionary Configuration { get; } = new Dictionary(); + + /// + public bool Equals(AbstractTraversalStrategy other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return StrategyName == other.StrategyName; + } + + /// + public virtual void Apply(ITraversal traversal) + { + } + + /// + public virtual Task ApplyAsync(ITraversal traversal) + { + return Task.CompletedTask; + } + + /// + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((AbstractTraversalStrategy) obj); + } + + /// + public override int GetHashCode() + { + return StrategyName.GetHashCode(); + } + + /// + public override string ToString() + { + return StrategyName; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs new file mode 100644 index 00000000000..2bca7c2d09a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// + /// ConnectiveStrategy rewrites the binary conjunction form of a.and().b into an AndStep of + /// and(a, b) (likewise for OrStep). + /// + public class ConnectiveStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs new file mode 100644 index 00000000000..6079f58e666 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// + /// Provides a degree of control over element identifier assignment as some graphs don't provide that feature. + /// + public class ElementIdStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs new file mode 100644 index 00000000000..98f949cda00 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs @@ -0,0 +1,34 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + public class HaltedTraverserStrategy : AbstractTraversalStrategy + { + public HaltedTraverserStrategy(string haltedTraverserFactoryName = null) + { + if (haltedTraverserFactoryName != null) + Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/PartitionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/PartitionStrategy.cs new file mode 100644 index 00000000000..f89037b85af --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/PartitionStrategy.cs @@ -0,0 +1,56 @@ +#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; + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// + /// Partitions the vertices, edges and vertex properties of a graph into String named partitions. + /// + public class PartitionStrategy : AbstractTraversalStrategy + { + /// + /// Initializes a new instance of the class. + /// + /// Specifies the partition key name. + /// + /// Specifies the name of the partition to write when adding vertices, edges and vertex + /// properties. + /// + /// Specifies the partition of the graph to read from. + /// Set to true if vertex properties should get assigned to partitions. + public PartitionStrategy(string partitionKey = null, string writePartition = null, + IEnumerable readPartitions = null, bool? includeMetaProperties = null) + { + if (partitionKey != null) + Configuration["partitionKey"] = partitionKey; + if (writePartition != null) + Configuration["writePartition"] = writePartition; + if (readPartitions != null) + Configuration["readPartitions"] = readPartitions; + if (includeMetaProperties != null) + Configuration["includeMetaProperties"] = includeMetaProperties.Value; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs new file mode 100644 index 00000000000..2f0d23e198b --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs @@ -0,0 +1,48 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// + /// Provides a way to limit the view of a . + /// + public class SubgraphStrategy : AbstractTraversalStrategy + { + /// + /// Initializes a new instance of the class. + /// + /// Constrains vertices for the . + /// Constrains edges for the . + /// Constrains vertex properties for the . + public SubgraphStrategy(ITraversal vertexCriterion = null, ITraversal edgeCriterion = null, + ITraversal vertexPropertyCriterion = null) + { + if (vertexCriterion != null) + Configuration["vertices"] = vertexCriterion; + if (edgeCriterion != null) + Configuration["edges"] = edgeCriterion; + if (vertexPropertyCriterion != null) + Configuration["vertexProperties"] = vertexPropertyCriterion; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs new file mode 100644 index 00000000000..1c5b5f2cf27 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs @@ -0,0 +1,50 @@ +#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; + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + public class VertexProgramStrategy : AbstractTraversalStrategy + { + public VertexProgramStrategy(string graphComputer = null, int? workers = null, string persist = null, + string result = null, ITraversal vertices = null, ITraversal edges = null, + Dictionary configuration = null) + { + if (graphComputer != null) + Configuration["graphComputer"] = graphComputer; + if (workers != null) + Configuration["workers"] = workers; + if (persist != null) + Configuration["persist"] = persist; + if (result != null) + Configuration["result"] = result; + if (vertices != null) + Configuration["vertices"] = vertices; + if (edges != null) + Configuration["edges"] = edges; + configuration?.ToList().ForEach(x => Configuration[x.Key] = x.Value); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs new file mode 100644 index 00000000000..11a9e2c52b6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs @@ -0,0 +1,34 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Finalization +{ + public class MatchAlgorithmStrategy : AbstractTraversalStrategy + { + public MatchAlgorithmStrategy(string matchAlgorithm = null) + { + if (matchAlgorithm != null) + Configuration["matchAlgorithm"] = matchAlgorithm; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs new file mode 100644 index 00000000000..bae85d73694 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Optimizes vertex- and value-emitting steps. + /// + public class AdjacentToIncidentStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs new file mode 100644 index 00000000000..3443e7139a0 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Reorders filter- and order-steps according to their rank. + /// + public class FilterRankingStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs new file mode 100644 index 00000000000..aaaee2c617e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs @@ -0,0 +1,29 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + public class GraphFilterStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs new file mode 100644 index 00000000000..08a4c4642a9 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Looks for Identity()-steps and removes them. + /// + public class IdentityRemovalStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs new file mode 100644 index 00000000000..75b98c2fb34 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Replaces .OutE().InV() with .Out(), .InE().OutV() with In() and .BothE().BothV() + /// with Both(). + /// + public class IncidentToAdjacentStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs new file mode 100644 index 00000000000..8eade849b1c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Analyzes filter-steps with child traversals that themselves are pure filters. + /// + public class InlineFilterStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs new file mode 100644 index 00000000000..b5cac4a05cb --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Inserts Barrier()-steps into a where appropriate in order to gain the "bulking + /// optimization". + /// + public class LazyBarrierStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs new file mode 100644 index 00000000000..d5359632517 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Folds any postWhere() step that maintains a traversal constraint into Match(). + /// + public class MatchPredicateStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs new file mode 100644 index 00000000000..82a8df9e8a4 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs @@ -0,0 +1,29 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + public class OrderLimitStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs new file mode 100644 index 00000000000..2c8e1065c11 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Helps to ensure that more traversals meet the local child constraint imposed on OLAP traversals. + /// + public class PathProcessorStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs new file mode 100644 index 00000000000..e54fbb5a978 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs @@ -0,0 +1,29 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + public class PathRetractionStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs new file mode 100644 index 00000000000..e3024bceecb --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + /// + /// Optimizes any occurrence of Count()-step followed by an Is()-step. + /// + public class RangeByIsCountStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs new file mode 100644 index 00000000000..6cac454dd36 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs @@ -0,0 +1,29 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Optimization +{ + public class RepeatUnrollStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs new file mode 100644 index 00000000000..0f488ab5193 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Verification +{ + /// + /// Does not allow lambdas to be used in a . + /// + public class LambdaRestrictionStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs new file mode 100644 index 00000000000..a703e186681 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Process.Traversal.Strategy.Verification +{ + /// + /// Detects mutating steps and throws an exception if one is found. + /// + public class ReadOnlyStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/TraversalPredicate.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/TraversalPredicate.cs new file mode 100644 index 00000000000..b854213f8b3 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/TraversalPredicate.cs @@ -0,0 +1,85 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// Represents a predicate (boolean-valued function) used in a . + /// + public class TraversalPredicate + { + /// + /// Initializes a new instance of the class. + /// + /// The name of the predicate. + /// The value of the predicate. + /// An optional other predicate that is used as an argument for this predicate. + public TraversalPredicate(string operatorName, dynamic value, TraversalPredicate other = null) + { + OperatorName = operatorName; + Value = value; + Other = other; + } + + /// + /// Gets the name of the predicate. + /// + public string OperatorName { get; } + + /// + /// Gets the value of the predicate. + /// + public dynamic Value { get; } + + /// + /// Gets an optional other predicate that is used as an argument for this predicate. + /// + public TraversalPredicate Other { get; } + + /// + /// Returns a composed predicate that represents a logical AND of this predicate and another. + /// + /// A predicate that will be logically-ANDed with this predicate. + /// The composed predicate. + public TraversalPredicate And(TraversalPredicate otherPredicate) + { + return new TraversalPredicate("and", this, otherPredicate); + } + + /// + /// Returns a composed predicate that represents a logical OR of this predicate and another. + /// + /// A predicate that will be logically-ORed with this predicate. + /// The composed predicate. + public TraversalPredicate Or(TraversalPredicate otherPredicate) + { + return new TraversalPredicate("or", this, otherPredicate); + } + + /// + public override string ToString() + { + return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})"; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Traverser.cs b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Traverser.cs new file mode 100644 index 00000000000..573e57f4b4b --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Traverser.cs @@ -0,0 +1,75 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// A traverser represents the current state of an object flowing through a . + /// + public class Traverser + { + /// + /// Initializes a new instance of the class. + /// + /// The object of the traverser. + /// The number of traversers represented in this traverser. + public Traverser(dynamic obj, long bulk = 1) + { + Object = obj; + Bulk = bulk; + } + + /// + /// Gets the object of this traverser. + /// + public dynamic Object { get; } + + /// + /// Gets the number of traversers represented in this traverser. + /// + public long Bulk { get; internal set; } + + /// + public bool Equals(Traverser other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Object, other.Object); + } + + /// + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((Traverser) obj); + } + + /// + public override int GetHashCode() + { + return Object != null ? Object.GetHashCode() : 0; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs new file mode 100644 index 00000000000..2315ed49130 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs @@ -0,0 +1,133 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Messages; +using Gremlin.Net.Driver.ResultsAggregation; +using Gremlin.Net.Structure.IO.GraphSON; +using Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Driver +{ + internal class Connection : IConnection + { + private readonly GraphSONReader _graphSONReader; + private readonly GraphSONWriter _graphSONWriter; + private readonly JsonMessageSerializer _messageSerializer = new JsonMessageSerializer(); + private readonly Uri _uri; + private readonly WebSocketConnection _webSocketConnection = new WebSocketConnection(); + + public Connection(Uri uri, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter) + { + _uri = uri; + _graphSONReader = graphSONReader; + _graphSONWriter = graphSONWriter; + } + + public async Task> SubmitAsync(RequestMessage requestMessage) + { + await SendAsync(requestMessage).ConfigureAwait(false); + return await ReceiveAsync().ConfigureAwait(false); + } + + public async Task ConnectAsync() + { + await _webSocketConnection.ConnectAsync(_uri).ConfigureAwait(false); + } + + public async Task CloseAsync() + { + await _webSocketConnection.CloseAsync().ConfigureAwait(false); + } + + private async Task SendAsync(RequestMessage message) + { + var graphsonMsg = _graphSONWriter.WriteObject(message); + var serializedMsg = _messageSerializer.SerializeMessage(graphsonMsg); + await _webSocketConnection.SendMessageAsync(serializedMsg).ConfigureAwait(false); + } + + private async Task> ReceiveAsync() + { + ResponseStatus status; + IAggregator aggregator = null; + var isAggregatingSideEffects = false; + var result = new List(); + do + { + var received = await _webSocketConnection.ReceiveMessageAsync().ConfigureAwait(false); + var receivedMsg = _messageSerializer.DeserializeMessage>(received); + + status = receivedMsg.Status; + status.ThrowIfStatusIndicatesError(); + + if (status.Code != ResponseStatusCode.NoContent) + { + var receivedData = _graphSONReader.ToObject(receivedMsg.Result.Data); + foreach (var d in receivedData) + if (receivedMsg.Result.Meta.ContainsKey(Tokens.ArgsSideEffectKey)) + { + if (aggregator == null) + aggregator = + new AggregatorFactory().GetAggregatorFor( + (string) receivedMsg.Result.Meta[Tokens.ArgsAggregateTo]); + aggregator.Add(d); + isAggregatingSideEffects = true; + } + else + { + result.Add(d); + } + } + } while (status.Code == ResponseStatusCode.PartialContent); + + if (isAggregatingSideEffects) + return new List {(T) aggregator.GetAggregatedResult()}; + return result; + } + + #region IDisposable Support + + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + _webSocketConnection?.Dispose(); + _disposed = true; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs new file mode 100644 index 00000000000..d31817c306b --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs @@ -0,0 +1,47 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using Gremlin.Net.Structure.IO.GraphSON; + +namespace Gremlin.Net.Driver +{ + internal class ConnectionFactory + { + private readonly GraphSONReader _graphSONReader; + private readonly GraphSONWriter _graphSONWriter; + private readonly Uri _uri; + + public ConnectionFactory(Uri uri, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter) + { + _uri = uri; + _graphSONReader = graphSONReader; + _graphSONWriter = graphSONWriter; + } + + public Connection CreateConnection() + { + return new Connection(_uri, _graphSONReader, _graphSONWriter); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs new file mode 100644 index 00000000000..e9ce9a8ca43 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs @@ -0,0 +1,114 @@ +#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.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Gremlin.Net.Driver +{ + internal class ConnectionPool : IDisposable + { + private readonly ConnectionFactory _connectionFactory; + private readonly ConcurrentBag _connections = new ConcurrentBag(); + private readonly object _connectionsLock = new object(); + + public ConnectionPool(ConnectionFactory connectionFactory) + { + _connectionFactory = connectionFactory; + } + + public int NrConnections { get; private set; } + + public async Task GetAvailableConnectionAsync() + { + Connection connection = null; + lock (_connectionsLock) + { + if (!_connections.IsEmpty) + _connections.TryTake(out connection); + } + + if (connection == null) + connection = await CreateNewConnectionAsync().ConfigureAwait(false); + + return new ProxyConnection(connection, AddConnection); + } + + private async Task CreateNewConnectionAsync() + { + NrConnections++; + var newConnection = _connectionFactory.CreateConnection(); + await newConnection.ConnectAsync().ConfigureAwait(false); + return newConnection; + } + + private void AddConnection(Connection connection) + { + lock (_connectionsLock) + { + _connections.Add(connection); + } + } + + #region IDisposable Support + + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + lock (_connectionsLock) + { + if (_connections != null && !_connections.IsEmpty) + { + TeardownAsync().Wait(); + + foreach (var conn in _connections) + conn.Dispose(); + } + } + _disposed = true; + } + } + + private async Task TeardownAsync() + { + var closeTasks = new List(_connections.Count); + closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync())); + await Task.WhenAll(closeTasks).ConfigureAwait(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs new file mode 100644 index 00000000000..4706723ed9c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs @@ -0,0 +1,37 @@ +#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; + +namespace Gremlin.Net.Driver.Exceptions +{ + /// + /// The exception that is thrown when a response is received from Gremlin Server that indicates that an error occurred. + /// + public class ResponseException : Exception + { + internal ResponseException(string message) : base(message) + { + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs new file mode 100644 index 00000000000..783308886ba --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs @@ -0,0 +1,95 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Messages; +using Gremlin.Net.Structure.IO.GraphSON; + +namespace Gremlin.Net.Driver +{ + /// + /// Provides a mechanism for submitting Gremlin requests to one Gremlin Server. + /// + public class GremlinClient : IGremlinClient + { + private readonly ConnectionPool _connectionPool; + + /// + /// Initializes a new instance of the class for the specified Gremlin Server. + /// + /// The the requests should be sent to. + /// A instance to read received GraphSON data. + /// a instance to write GraphSON data. + public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader = null, + GraphSONWriter graphSONWriter = null) + { + var reader = graphSONReader ?? new GraphSONReader(); + var writer = graphSONWriter ?? new GraphSONWriter(); + var connectionFactory = new ConnectionFactory(gremlinServer.Uri, reader, writer); + _connectionPool = new ConnectionPool(connectionFactory); + } + + /// + /// Gets the number of open connections. + /// + public int NrConnections => _connectionPool.NrConnections; + + /// + public async Task> SubmitAsync(RequestMessage requestMessage) + { + using (var connection = await _connectionPool.GetAvailableConnectionAsync().ConfigureAwait(false)) + { + return await connection.SubmitAsync(requestMessage).ConfigureAwait(false); + } + } + + #region IDisposable Support + + private bool _disposed; + + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases the resources used by the instance. + /// + /// Specifies whether managed resources should be released. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + _connectionPool?.Dispose(); + _disposed = true; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs new file mode 100644 index 00000000000..4aad73ee6ff --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs @@ -0,0 +1,140 @@ +#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 System.Threading.Tasks; +using Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.Driver +{ + /// + /// Provides extension methods for the interface. + /// + public static class GremlinClientExtensions + { + /// + /// Submits a request message that consists of a script with bindings as an asynchronous operation where only a single + /// result gets returned. + /// + /// + /// If multiple results are received from Gremlin Server, then only the first gets returned. Use + /// instead when you expect a collection of results. + /// + /// The type of the expected result. + /// The that submits the request. + /// The Gremlin request script to send. + /// Bindings for parameters used in the requestScript. + /// A single result received from the Gremlin Server. + /// + /// Thrown when a response is received from Gremlin Server that indicates + /// that an error occurred. + /// + public static async Task SubmitWithSingleResultAsync(this IGremlinClient gremlinClient, + string requestScript, + Dictionary bindings = null) + { + var resultCollection = await gremlinClient.SubmitAsync(requestScript, bindings).ConfigureAwait(false); + return resultCollection.FirstOrDefault(); + } + + /// + /// Submits a request message as an asynchronous operation where only a single result gets returned. + /// + /// + /// If multiple results are received from Gremlin Server, then only the first gets returned. Use + /// instead when you expect a collection of results. + /// + /// The type of the expected result. + /// The that submits the request. + /// The to send. + /// A single result received from the Gremlin Server. + /// + /// Thrown when a response is received from Gremlin Server that indicates + /// that an error occurred. + /// + public static async Task SubmitWithSingleResultAsync(this IGremlinClient gremlinClient, + RequestMessage requestMessage) + { + var resultCollection = await gremlinClient.SubmitAsync(requestMessage).ConfigureAwait(false); + return resultCollection.FirstOrDefault(); + } + + /// + /// Submits a request message that consists of a script with bindings as an asynchronous operation without returning + /// the result received from the Gremlin Server. + /// + /// The that submits the request. + /// The Gremlin request script to send. + /// Bindings for parameters used in the requestScript. + /// The task object representing the asynchronous operation. + /// + /// Thrown when a response is received from Gremlin Server that indicates + /// that an error occurred. + /// + public static async Task SubmitAsync(this IGremlinClient gremlinClient, string requestScript, + Dictionary bindings = null) + { + await gremlinClient.SubmitAsync(requestScript, bindings).ConfigureAwait(false); + } + + /// + /// Submits a request message as an asynchronous operation without returning the result received from the Gremlin + /// Server. + /// + /// The that submits the request. + /// The to send. + /// The task object representing the asynchronous operation. + /// + /// Thrown when a response is received from Gremlin Server that indicates + /// that an error occurred. + /// + public static async Task SubmitAsync(this IGremlinClient gremlinClient, RequestMessage requestMessage) + { + await gremlinClient.SubmitAsync(requestMessage).ConfigureAwait(false); + } + + /// + /// Submits a request message that consists of a script with bindings as an asynchronous operation. + /// + /// The type of the expected results. + /// The that submits the request. + /// The Gremlin request script to send. + /// Bindings for parameters used in the requestScript. + /// A collection of the data returned from the server. + /// + /// Thrown when a response is received from Gremlin Server that indicates + /// that an error occurred. + /// + public static async Task> SubmitAsync(this IGremlinClient gremlinClient, + string requestScript, + Dictionary bindings = null) + { + var msgBuilder = RequestMessage.Build(Tokens.OpsEval).AddArgument(Tokens.ArgsGremlin, requestScript); + if (bindings != null) + msgBuilder.AddArgument(Tokens.ArgsBindings, bindings); + var msg = msgBuilder.Create(); + return await gremlinClient.SubmitAsync(msg).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs new file mode 100644 index 00000000000..8da6d0bd5ff --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs @@ -0,0 +1,56 @@ +#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; + +namespace Gremlin.Net.Driver +{ + /// + /// Represents a Gremlin Server. + /// + public class GremlinServer + { + /// + /// Initializes a new instance of the class with the specified connection parameters. + /// + /// The hostname of the server. + /// The port on which Gremlin Server can be reached. + /// Specifies whether SSL should be enabled. + public GremlinServer(string hostname, int port = 8182, bool enableSsl = false) + { + Uri = CreateUri(hostname, port, enableSsl); + } + + /// + /// Gets the URI of the Gremlin Server. + /// + /// The WebSocket that the Gremlin Server responds to. + public Uri Uri { get; } + + private Uri CreateUri(string hostname, int port, bool enableSsl) + { + var scheme = enableSsl ? "wss" : "ws"; + return new Uri($"{scheme}://{hostname}:{port}/gremlin"); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs new file mode 100644 index 00000000000..e1651a6724c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs @@ -0,0 +1,35 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.Driver +{ + internal interface IConnection : IDisposable + { + Task> SubmitAsync(RequestMessage requestMessage); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs new file mode 100644 index 00000000000..7a7048ab4e8 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs @@ -0,0 +1,48 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.Driver +{ + /// + /// Provides a mechanism for submitting Gremlin requests. + /// + public interface IGremlinClient : IDisposable + { + /// + /// Submits a request message as an asynchronous operation. + /// + /// The type of the expected results. + /// The to send. + /// A collection of the data returned from the server. + /// + /// Thrown when a response is received from Gremlin Server that indicates + /// that an error occurred. + /// + Task> SubmitAsync(RequestMessage requestMessage); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/JsonMessageSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/JsonMessageSerializer.cs new file mode 100644 index 00000000000..c3270bf343e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/JsonMessageSerializer.cs @@ -0,0 +1,49 @@ +#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.Text; +using Newtonsoft.Json; + +namespace Gremlin.Net.Driver +{ + internal class JsonMessageSerializer + { + private const string MimeType = "application/vnd.gremlin-v2.0+json"; + + public byte[] SerializeMessage(string msg) + { + return Encoding.UTF8.GetBytes(MessageWithHeader(msg)); + } + + private string MessageWithHeader(string messageContent) + { + return $"{(char) MimeType.Length}{MimeType}{messageContent}"; + } + + public TMessage DeserializeMessage(byte[] message) + { + var responseStr = Encoding.UTF8.GetString(message); + return JsonConvert.DeserializeObject(responseStr); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/RequestMessage.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/RequestMessage.cs new file mode 100644 index 00000000000..550d9c0d4d3 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/RequestMessage.cs @@ -0,0 +1,143 @@ +#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; + +namespace Gremlin.Net.Driver.Messages +{ + /// + /// The model for a request message sent to the server. + /// + public class RequestMessage + { + private RequestMessage(Guid requestId, string operation, string processor, Dictionary arguments) + { + RequestId = requestId; + Operation = operation; + Processor = processor; + Arguments = arguments; + } + + /// + /// Gets the ID of this request message. + /// + /// A UUID representing the unique identification for the request. + public Guid RequestId { get; } + + /// + /// Gets the name of the operation that should be executed by the Gremlin Server. + /// + /// + /// The name of the "operation" to execute based on the available OpProcessor configured in the Gremlin Server. This + /// defaults to "eval" which evaluates a request script. + /// + public string Operation { get; } + + /// + /// Gets the name of the OpProcessor to utilize. + /// + /// + /// The name of the OpProcessor to utilize. This defaults to an empty string which represents the default + /// OpProcessor for evaluating scripts. + /// + public string Processor { get; } + + /// + /// Gets arguments of the . + /// + public Dictionary Arguments { get; } + + /// + /// Initializes a to build a . + /// + /// The name of the OpProcessor to utilize. + /// A to build a . + public static Builder Build(string operation) + { + return new Builder(operation); + } + + /// + /// Allows to build objects. + /// + public class Builder + { + private const string DefaultProcessor = ""; + private readonly Dictionary _arguments = new Dictionary(); + private readonly string _operation; + private string _processor = DefaultProcessor; + private Guid _requestId = Guid.NewGuid(); + + internal Builder(string operation) + { + _operation = operation; + } + + /// + /// If this value is not set in the builder then the defaults to + /// the standard op processor (empty string). + /// + /// The name of the processor. + /// The . + public Builder Processor(string processor) + { + _processor = processor; + return this; + } + + /// + /// Overrides the request identifier with a specified one, otherwise the + /// will randomly generate a . + /// + /// The request identifier to use. + /// The . + public Builder OverrideRequestId(Guid requestId) + { + _requestId = requestId; + return this; + } + + /// + /// Adds and argument to the . + /// + /// The key of the argument. + /// The value of the argument. + /// The . + public Builder AddArgument(string key, object value) + { + _arguments.Add(key, value); + return this; + } + + /// + /// Creates the given the settings provided to the . + /// + /// The built . + public RequestMessage Create() + { + return new RequestMessage(_requestId, _operation, _processor, _arguments); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseMessage.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseMessage.cs new file mode 100644 index 00000000000..602b013bec9 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseMessage.cs @@ -0,0 +1,40 @@ +#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 Newtonsoft.Json; + +namespace Gremlin.Net.Driver.Messages +{ + internal class ResponseMessage + { + [JsonProperty(PropertyName = "requestId")] + public Guid RequestId { get; set; } + + [JsonProperty(PropertyName = "status")] + public ResponseStatus Status { get; set; } + + [JsonProperty(PropertyName = "result")] + public ResponseResult Result { get; set; } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseResult.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseResult.cs new file mode 100644 index 00000000000..643fbe8b362 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseResult.cs @@ -0,0 +1,37 @@ +#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 Newtonsoft.Json; + +namespace Gremlin.Net.Driver.Messages +{ + internal class ResponseResult + { + [JsonProperty(PropertyName = "data")] + public List Data { get; set; } + + [JsonProperty(PropertyName = "meta")] + public Dictionary Meta { get; set; } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs new file mode 100644 index 00000000000..e3c1797a2d5 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs @@ -0,0 +1,50 @@ +#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.Driver.Exceptions; +using Newtonsoft.Json; + +namespace Gremlin.Net.Driver.Messages +{ + internal class ResponseStatus + { + [JsonProperty(PropertyName = "code")] + public ResponseStatusCode Code { get; set; } + + [JsonProperty(PropertyName = "attributes")] + public Dictionary Attributes { get; set; } + + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + } + + internal static class ResponseStatusExtensions + { + public static void ThrowIfStatusIndicatesError(this ResponseStatus status) + { + if (status.Code.IndicatesError()) + throw new ResponseException($"{status.Code}: {status.Message}"); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs new file mode 100644 index 00000000000..7b0bc947a3d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs @@ -0,0 +1,67 @@ +#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; + +namespace Gremlin.Net.Driver.Messages +{ + internal enum ResponseStatusCode + { + Success = 200, + NoContent = 204, + PartialContent = 206, + Unauthorized = 401, + Authenticate = 407, + MalformedRequest = 498, + InvalidRequestArguments = 499, + ServerError = 500, + ScriptEvaluationError = 597, + ServerTimeout = 598, + ServerSerializationError = 599 + } + + internal static class ResponseStatusCodeExtensions + { + public static bool IndicatesError(this ResponseStatusCode statusCode) + { + switch (statusCode) + { + case ResponseStatusCode.Success: + case ResponseStatusCode.NoContent: + case ResponseStatusCode.PartialContent: + return false; + case ResponseStatusCode.Unauthorized: + case ResponseStatusCode.Authenticate: + case ResponseStatusCode.MalformedRequest: + case ResponseStatusCode.InvalidRequestArguments: + case ResponseStatusCode.ServerError: + case ResponseStatusCode.ScriptEvaluationError: + case ResponseStatusCode.ServerTimeout: + case ResponseStatusCode.ServerSerializationError: + return true; + default: + throw new ArgumentOutOfRangeException(nameof(statusCode), statusCode, null); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs new file mode 100644 index 00000000000..cbe15ec44f1 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs @@ -0,0 +1,52 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.Driver +{ + internal sealed class ProxyConnection : IConnection + { + private readonly Connection _realConnection; + private readonly Action _releaseAction; + + public ProxyConnection(Connection realConnection, Action releaseAction) + { + _realConnection = realConnection; + _releaseAction = releaseAction; + } + + public async Task> SubmitAsync(RequestMessage requestMessage) + { + return await _realConnection.SubmitAsync(requestMessage).ConfigureAwait(false); + } + + public void Dispose() + { + _releaseAction(_realConnection); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs new file mode 100644 index 00000000000..2ba5d6cf058 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteConnection.cs @@ -0,0 +1,80 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Messages; +using Gremlin.Net.Process.Remote; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Driver.Remote +{ + /// + /// A implementation for Gremlin Server. + /// + public class DriverRemoteConnection : IRemoteConnection, IDisposable + { + private readonly IGremlinClient _client; + + /// + /// Initializes a new . + /// + /// The that will be used for the connection. + /// Thrown when client is null. + public DriverRemoteConnection(IGremlinClient client) + { + _client = client ?? throw new ArgumentNullException(nameof(client)); + } + + /// + /// Submits for evaluation to a remote Gremlin Server. + /// + /// The to submit. + /// A allowing to access the results and side-effects. + public async Task SubmitAsync(Bytecode bytecode) + { + var requestId = Guid.NewGuid(); + var resultSet = await SubmitBytecodeAsync(requestId, bytecode).ConfigureAwait(false); + return new DriverRemoteTraversal(_client, requestId, resultSet); + } + + private async Task> SubmitBytecodeAsync(Guid requestid, Bytecode bytecode) + { + var requestMsg = + RequestMessage.Build(Tokens.OpsBytecode) + .Processor(Tokens.ProcessorTraversal) + .OverrideRequestId(requestid) + .AddArgument(Tokens.ArgsGremlin, bytecode) + .AddArgument(Tokens.ArgsAliases, new Dictionary {{"g", "g"}}) + .Create(); + return await _client.SubmitAsync(requestMsg).ConfigureAwait(false); + } + + /// + public void Dispose() + { + _client?.Dispose(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs new file mode 100644 index 00000000000..f3f26d17ae6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs @@ -0,0 +1,39 @@ +#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 Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Driver.Remote +{ + internal class DriverRemoteTraversal : DefaultTraversal + { + public DriverRemoteTraversal(IGremlinClient gremlinClient, Guid requestId, + IEnumerable traversers) + { + Traversers = traversers; + SideEffects = new DriverRemoteTraversalSideEffects(gremlinClient, requestId); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs new file mode 100644 index 00000000000..8ce495d7a87 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs @@ -0,0 +1,126 @@ +#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.Driver.Messages; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Driver.Remote +{ + internal class DriverRemoteTraversalSideEffects : ITraversalSideEffects + { + private readonly IGremlinClient _gremlinClient; + private readonly List _keys = new List(); + private readonly Guid _serverSideEffectId; + private readonly Dictionary _sideEffects = new Dictionary(); + private bool _closed; + private bool _retrievedAllKeys; + + public DriverRemoteTraversalSideEffects(IGremlinClient gremlinClient, Guid serverSideEffectId) + { + _gremlinClient = gremlinClient; + _serverSideEffectId = serverSideEffectId; + } + + public void Dispose() + { + Close(); + } + + public IReadOnlyCollection Keys() + { + if (_closed && !_retrievedAllKeys) + throw new InvalidOperationException("Traversal has been closed - side-effect keys cannot be retrieved"); + if (!_retrievedAllKeys) + { + _keys.AddRange(RetrieveKeys()); + _retrievedAllKeys = true; + } + return _keys; + } + + private IEnumerable RetrieveKeys() + { + return _gremlinClient.SubmitAsync(SideEffectKeysMessage()).Result; + } + + private RequestMessage SideEffectKeysMessage() + { + return RequestMessage.Build(Tokens.OpsKeys) + .AddArgument(Tokens.ArgsSideEffect, _serverSideEffectId) + .Processor(Tokens.ProcessorTraversal) + .Create(); + } + + public object Get(string key) + { + if (!Keys().Contains(key)) + throw new KeyNotFoundException($"Side effect key {key} does not exist"); + if (!_sideEffects.ContainsKey(key)) + { + if (_closed) + throw new InvalidOperationException( + "Traversal has been closed - no new side-effects can be retrieved"); + _sideEffects.Add(key, RetrieveSideEffectsForKey(key)); + } + return _sideEffects[key]; + } + + private object RetrieveSideEffectsForKey(string key) + { + return _gremlinClient.SubmitWithSingleResultAsync(SideEffectGatherMessage(key)).Result; + } + + private RequestMessage SideEffectGatherMessage(string key) + { + return RequestMessage.Build(Tokens.OpsGather) + .AddArgument(Tokens.ArgsSideEffect, _serverSideEffectId) + .AddArgument(Tokens.ArgsSideEffectKey, key) + .AddArgument(Tokens.ArgsAliases, new Dictionary {{"g", "g"}}) + .Processor(Tokens.ProcessorTraversal) + .Create(); + } + + public void Close() + { + if (_closed) return; + CloseSideEffects(); + _closed = true; + } + + private void CloseSideEffects() + { + _gremlinClient.SubmitAsync(SideEffectCloseMessage()).Wait(); + } + + private RequestMessage SideEffectCloseMessage() + { + return RequestMessage.Build(Tokens.OpsClose) + .AddArgument(Tokens.ArgsSideEffect, _serverSideEffectId) + .Processor(Tokens.ProcessorTraversal) + .Create(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/AggregatorFactory.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/AggregatorFactory.cs new file mode 100644 index 00000000000..26efb5d694d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/AggregatorFactory.cs @@ -0,0 +1,44 @@ +#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; + +namespace Gremlin.Net.Driver.ResultsAggregation +{ + internal class AggregatorFactory + { + private readonly Dictionary _aggregatorByAggregateToType = + new Dictionary + { + {Tokens.ValAggregateToMap, new DictionaryAggregator()}, + {Tokens.ValAggregateToBulkSet, new TraverserAggregator()} + }; + + public IAggregator GetAggregatorFor(string aggregateTo) + { + if (_aggregatorByAggregateToType.ContainsKey(aggregateTo)) + return _aggregatorByAggregateToType[aggregateTo]; + return new DefaultAggregator(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DefaultAggregator.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DefaultAggregator.cs new file mode 100644 index 00000000000..82b247b3c78 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DefaultAggregator.cs @@ -0,0 +1,42 @@ +#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; + +namespace Gremlin.Net.Driver.ResultsAggregation +{ + internal class DefaultAggregator : IAggregator + { + private readonly List _result = new List(); + + public void Add(object value) + { + _result.Add(value); + } + + public object GetAggregatedResult() + { + return _result; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DictionaryAggregator.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DictionaryAggregator.cs new file mode 100644 index 00000000000..75764e3f5e8 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/DictionaryAggregator.cs @@ -0,0 +1,44 @@ +#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; + +namespace Gremlin.Net.Driver.ResultsAggregation +{ + internal class DictionaryAggregator : IAggregator + { + private readonly Dictionary _result = new Dictionary(); + + public void Add(object value) + { + var newEntry = ((Dictionary) value).First(); + _result.Add(newEntry.Key, newEntry.Value); + } + + public object GetAggregatedResult() + { + return _result; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/IAggregator.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/IAggregator.cs new file mode 100644 index 00000000000..bcc036a47fd --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/IAggregator.cs @@ -0,0 +1,31 @@ +#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 + +namespace Gremlin.Net.Driver.ResultsAggregation +{ + internal interface IAggregator + { + void Add(object value); + object GetAggregatedResult(); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/TraverserAggregator.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/TraverserAggregator.cs new file mode 100644 index 00000000000..2d1880405fe --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultsAggregation/TraverserAggregator.cs @@ -0,0 +1,44 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Driver.ResultsAggregation +{ + internal class TraverserAggregator : IAggregator + { + private readonly Dictionary _result = new Dictionary(); + + public void Add(object value) + { + var traverser = (Traverser) value; + _result.Add(traverser.Object, traverser.Bulk); + } + + public object GetAggregatedResult() + { + return _result; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs new file mode 100644 index 00000000000..5a940cdabff --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs @@ -0,0 +1,114 @@ +#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 Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.Driver +{ + /// + /// String constants used to configure a . + /// + public class Tokens + { + /// + /// Operation used for a request that contains the Bytecode representation of a Traversal. + /// + public static string OpsBytecode = "bytecode"; + + /// + /// Operation used to evaluate a Gremlin script provided as a string. + /// + public static string OpsEval = "eval"; + + /// + /// Operation used to get a particular side-effect as produced by a previously executed Traversal. + /// + public static string OpsGather = "gather"; + + /// + /// Operation used to get all the keys of all side-effects as produced by a previously executed Traversal. + /// + public static string OpsKeys = "keys"; + + /// + /// Operation used to get all the keys of all side-effects as produced by a previously executed Traversal. + /// + public static string OpsClose = "close"; + + /// + /// Default OpProcessor. + /// + public static string ProcessorTraversal = "traversal"; + + /// + /// Argument name that allows to defines the number of iterations each ResponseMessage should contain - overrides the + /// resultIterationBatchSize server setting. + /// + public static string ArgsBatchSize = "batchSize"; + + /// + /// Argument name that allows to provide a map of key/value pairs to apply as variables in the context of the Gremlin + /// script. + /// + public static string ArgsBindings = "bindings"; + + /// + /// Argument name that allows to define aliases that represent globally bound Graph and TraversalSource objects. + /// + public static string ArgsAliases = "aliases"; + + /// + /// Argument name that corresponds to the Traversal to evaluate. + /// + public static string ArgsGremlin = "gremlin"; + + /// + /// Argument name that allows to specify the unique identifier for the request. + /// + public static string ArgsSideEffect = "sideEffect"; + + /// + /// Argument name that allows to specify the key for a specific side-effect. + /// + public static string ArgsSideEffectKey = "sideEffectKey"; + + /// + /// argument that describes how side-effect data should be treated. + /// + public static string ArgsAggregateTo = "aggregateTo"; + + /// + /// Argument name that allows to change the flavor of Gremlin used (e.g. gremlin-groovy). + /// + public static string ArgsLanguage = "language"; + + /// + /// Argument name that allows to override the server setting that determines the maximum time to wait for a script to + /// execute on the server. + /// + public static string ArgsEvalTimeout = "scriptEvaluationTimeout"; + + internal static string ValAggregateToMap = "map"; + internal static string ValAggregateToBulkSet = "bulkset"; + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs new file mode 100644 index 00000000000..5a20759763d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs @@ -0,0 +1,96 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.IO; +using System.Net.WebSockets; +using System.Threading; +using System.Threading.Tasks; + +namespace Gremlin.Net.Driver +{ + internal class WebSocketConnection : IDisposable + { + private const int ReceiveBufferSize = 1024; + private const WebSocketMessageType MessageType = WebSocketMessageType.Binary; + private ClientWebSocket _client; + + public async Task ConnectAsync(Uri uri) + { + _client = new ClientWebSocket(); + await _client.ConnectAsync(uri, CancellationToken.None).ConfigureAwait(false); + } + + public async Task CloseAsync() + { + await + _client.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None) + .ConfigureAwait(false); + } + + public async Task SendMessageAsync(byte[] message) + { + await + _client.SendAsync(new ArraySegment(message), MessageType, true, CancellationToken.None) + .ConfigureAwait(false); + } + + public async Task ReceiveMessageAsync() + { + using (var ms = new MemoryStream()) + { + WebSocketReceiveResult received; + do + { + var receiveBuffer = new ArraySegment(new byte[ReceiveBufferSize]); + received = await _client.ReceiveAsync(receiveBuffer, CancellationToken.None).ConfigureAwait(false); + ms.Write(receiveBuffer.Array, receiveBuffer.Offset, received.Count); + } while (!received.EndOfMessage); + + return ms.ToArray(); + } + } + + #region IDisposable Support + + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + _client?.Dispose(); + _disposed = true; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj new file mode 100644 index 00000000000..a909ad1eb44 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -0,0 +1,43 @@ + + + + Gremlin.Net is a cross-platform Gremlin Server driver for .NET that is written in C#. It uses WebSockets to communicate with Gremlin Server. + Gremlin.Net + Apache TinkerPop + netstandard1.3 + 3.2.5-SNAPSHOT + true + Gremlin.Net + Gremlin.Net + gremlin-dotnet;gremlin;tinkerpop;tinkerpop3 + http://tinkerpop.apache.org + https://github.com/apache/tinkerpop/blob/master/LICENSE + https://github.com/apache/tinkerpop + false + false + false + False + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs b/gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..433db198c4a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#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.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Gremlin.Net")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("6c1dd34d-e30f-4e37-aacc-beb8ad2320d8")] \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Edge.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Edge.cs new file mode 100644 index 00000000000..fddbd693aed --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Edge.cs @@ -0,0 +1,61 @@ +#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 + +namespace Gremlin.Net.Structure +{ + /// + /// Represents an edge between to vertices. + /// + public class Edge : Element + { + /// + /// Initializes a new instance of the class. + /// + /// The id of the edge. + /// The outgoing/tail vertex of the edge. + /// The label of the edge. + /// The incoming/head vertex of the edge. + public Edge(object id, Vertex outV, string label, Vertex inV) + : base(id, label) + { + OutV = outV; + InV = inV; + } + + /// + /// Gets or sets the incoming/head vertex of this edge. + /// + public Vertex InV { get; set; } + + /// + /// Gets or sets the outgoing/tail vertex of this edge. + /// + public Vertex OutV { get; set; } + + /// + public override string ToString() + { + return $"e[{Id}][{OutV.Id}-{Label}->{InV.Id}]"; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Element.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Element.cs new file mode 100644 index 00000000000..f4fc847c0b6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Element.cs @@ -0,0 +1,77 @@ +#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; + +namespace Gremlin.Net.Structure +{ + /// + /// A common base class for Graph elements. + /// + public abstract class Element : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// The id of the element. + /// The label of the element. + protected Element(object id, string label) + { + Id = id; + Label = label; + } + + /// + /// Gets the id of this . + /// + public object Id { get; } + + /// + /// Gets the label of this . + /// + public string Label { get; } + + /// + public bool Equals(Element other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Id, other.Id); + } + + /// + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((Element) obj); + } + + /// + public override int GetHashCode() + { + return Id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs new file mode 100644 index 00000000000..d183447b902 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BindingSerializer.cs @@ -0,0 +1,42 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class BindingSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + var binding = (Binding) objectData; + var valueDict = new Dictionary + { + {"value", writer.ToDict(binding.Value)}, + {"key", binding.Key} + }; + return GraphSONUtil.ToTypedValue(nameof(Binding), valueDict); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs new file mode 100644 index 00000000000..28cfe0a1d0f --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/BytecodeSerializer.cs @@ -0,0 +1,58 @@ +#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.Process.Traversal; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class BytecodeSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic bytecodeObj, GraphSONWriter writer) + { + Bytecode bytecode = bytecodeObj; + + var valueDict = new Dictionary>>(); + if (bytecode.SourceInstructions.Count > 0) + valueDict["source"] = DictifyInstructions(bytecode.SourceInstructions, writer); + if (bytecode.StepInstructions.Count > 0) + valueDict["step"] = DictifyInstructions(bytecode.StepInstructions, writer); + + return GraphSONUtil.ToTypedValue(nameof(Bytecode), valueDict); + } + + private IEnumerable> DictifyInstructions(IEnumerable instructions, + GraphSONWriter writer) + { + return instructions.Select(instruction => DictifyInstruction(instruction, writer)); + } + + private IEnumerable DictifyInstruction(Instruction instruction, GraphSONWriter writer) + { + var result = new List {instruction.OperatorName}; + result.AddRange(instruction.Arguments.Select(arg => writer.ToDict(arg))); + return result; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateDeserializer.cs new file mode 100644 index 00000000000..d8879f8871e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateDeserializer.cs @@ -0,0 +1,43 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class DateDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var javaTimestamp = graphsonObject.ToObject(); + return FromJavaTime(javaTimestamp); + } + + private DateTime FromJavaTime(long javaTimestamp) + { + var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + return epoch.AddMilliseconds(javaTimestamp); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateSerializer.cs new file mode 100644 index 00000000000..1438e024136 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DateSerializer.cs @@ -0,0 +1,43 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class DateSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + DateTime dateTime = objectData; + return GraphSONUtil.ToTypedValue("Date", ToJavaTimestamp(dateTime)); + } + + private long ToJavaTimestamp(DateTime dateTime) + { + var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + return Convert.ToInt64((dateTime - epoch).TotalMilliseconds); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DoubleConverter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DoubleConverter.cs new file mode 100644 index 00000000000..416423bf734 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/DoubleConverter.cs @@ -0,0 +1,33 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class DoubleConverter : NumberConverter + { + protected override string GraphSONTypeName => "Double"; + protected override Type HandledType => typeof(double); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeDeserializer.cs new file mode 100644 index 00000000000..6ec8694b6ab --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeDeserializer.cs @@ -0,0 +1,43 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class EdgeDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var outVId = reader.ToObject(graphsonObject["outV"]); + var outVLabel = (string) (graphsonObject["outVLabel"] ?? Vertex.DefaultLabel); + var outV = new Vertex(outVId, outVLabel); + var inVId = reader.ToObject(graphsonObject["inV"]); + var inVLabel = (string) (graphsonObject["inVLabel"] ?? Vertex.DefaultLabel); + var inV = new Vertex(inVId, inVLabel); + var edgeId = reader.ToObject(graphsonObject["id"]); + var edgeLabel = (string) graphsonObject["label"] ?? "edge"; + return new Edge(edgeId, outV, edgeLabel, inV); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeSerializer.cs new file mode 100644 index 00000000000..fd9f4963e5d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EdgeSerializer.cs @@ -0,0 +1,45 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class EdgeSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + Edge edge = objectData; + var edgeDict = new Dictionary + { + {"id", writer.ToDict(edge.Id)}, + {"outV", writer.ToDict(edge.OutV.Id)}, + {"outVLabel", edge.OutV.Label}, + {"label", edge.Label}, + {"inV", writer.ToDict(edge.InV.Id)}, + {"inVLabel", edge.InV.Label} + }; + return GraphSONUtil.ToTypedValue(nameof(Edge), edgeDict); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs new file mode 100644 index 00000000000..6ed3cd48239 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs @@ -0,0 +1,37 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class EnumSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + var enumName = objectData.GetType().Name; + var enumValue = objectData.ToString(); + return GraphSONUtil.ToTypedValue(enumName, enumValue); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/FloatConverter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/FloatConverter.cs new file mode 100644 index 00000000000..432aeabd94f --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/FloatConverter.cs @@ -0,0 +1,33 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class FloatConverter : NumberConverter + { + protected override string GraphSONTypeName => "Float"; + protected override Type HandledType => typeof(float); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs new file mode 100644 index 00000000000..aa1fc48df53 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs @@ -0,0 +1,123 @@ +#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 Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + /// + /// Allows to deserialize GraphSON to objects. + /// + public class GraphSONReader + { + private readonly Dictionary _deserializerByGraphSONType = new Dictionary + + { + {"g:Traverser", new TraverserReader()}, + {"g:Int32", new Int32Converter()}, + {"g:Int64", new Int64Converter()}, + {"g:Float", new FloatConverter()}, + {"g:Double", new DoubleConverter()}, + {"g:UUID", new UuidDeserializer()}, + {"g:Date", new DateDeserializer()}, + {"g:Timestamp", new DateDeserializer()}, + {"g:Vertex", new VertexDeserializer()}, + {"g:Edge", new EdgeDeserializer()}, + {"g:Property", new PropertyDeserializer()}, + {"g:VertexProperty", new VertexPropertyDeserializer()}, + {"g:Path", new PathDeserializer()} + }; + + /// + /// Initializes a new instance of the class. + /// + public GraphSONReader() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// deserializers identified by their + /// GraphSON type. + /// + public GraphSONReader(IReadOnlyDictionary deserializerByGraphSONType) + { + foreach (var deserializerAndGraphSONType in deserializerByGraphSONType) + _deserializerByGraphSONType[deserializerAndGraphSONType.Key] = deserializerAndGraphSONType.Value; + } + + /// + /// Deserializes a GraphSON collection to an object. + /// + /// The GraphSON collection to deserialize. + /// The deserialized object. + public dynamic ToObject(IEnumerable graphSonData) + { + return graphSonData.Select(graphson => ToObject(graphson)); + } + + /// + /// Deserializes GraphSON to an object. + /// + /// The GraphSON to deserialize. + /// The deserialized object. + public dynamic ToObject(JToken jToken) + { + if (jToken is JArray) + return jToken.Select(t => ToObject(t)); + if (!jToken.HasValues) return ((JValue) jToken).Value; + if (!HasTypeKey(jToken)) return ReadDictionary(jToken); + return ReadTypedValue(jToken); + } + + private bool HasTypeKey(JToken jToken) + { + var graphSONType = (string) jToken[GraphSONTokens.TypeKey]; + return graphSONType != null; + } + + private dynamic ReadTypedValue(JToken typedValue) + { + var graphSONType = (string) typedValue[GraphSONTokens.TypeKey]; + return _deserializerByGraphSONType[graphSONType].Objectify(typedValue[GraphSONTokens.ValueKey], this); + } + + private dynamic ReadDictionary(JToken jtokenDict) + { + var dict = new Dictionary(); + foreach (var e in jtokenDict) + { + var property = e as JProperty; + if (property == null) + throw new InvalidOperationException($"Cannot read graphson: {jtokenDict}"); + dict.Add(property.Name, ToObject(property.Value)); + } + return dict; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONTokens.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONTokens.cs new file mode 100644 index 00000000000..8beb850974b --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONTokens.cs @@ -0,0 +1,32 @@ +#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 + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class GraphSONTokens + { + public static string TypeKey = "@type"; + public static string ValueKey = "@value"; + public static string GremlinTypeNamespace = "g"; + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs new file mode 100644 index 00000000000..037839b7f85 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONUtil.cs @@ -0,0 +1,62 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + /// + /// Provides helper methods for GraphSON serialization. + /// + public static class GraphSONUtil + { + /// + /// Transforms a value intos its GraphSON representation including type information. + /// + /// The name of the type. + /// The value to transform. + /// A namespace prefix for the typename. + /// The GraphSON representation including type information. + public static Dictionary ToTypedValue(string typename, dynamic value, string prefix = "g") + { + var typedValue = new Dictionary + { + {GraphSONTokens.TypeKey, FormatTypeName(prefix, typename)} + }; + if (value != null) + typedValue[GraphSONTokens.ValueKey] = value; + return typedValue; + } + + /// + /// Formats a type name with its prefix to a GraphSON TypeID. + /// + /// The namespace prefix (default is "g"). + /// The name of the type. + /// The formatted TypeID. + public static string FormatTypeName(string namespacePrefix, string typeName) + { + return $"{namespacePrefix}:{typeName}"; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs new file mode 100644 index 00000000000..ba632b1d85a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs @@ -0,0 +1,146 @@ +#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; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Gremlin.Net.Driver.Messages; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Process.Traversal.Strategy; +using Newtonsoft.Json; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + /// + /// Allows to serialize objects to GraphSON. + /// + public class GraphSONWriter + { + private readonly Dictionary _serializerByType = new Dictionary + + { + {typeof(ITraversal), new TraversalSerializer()}, + {typeof(Bytecode), new BytecodeSerializer()}, + {typeof(Binding), new BindingSerializer()}, + {typeof(RequestMessage), new RequestMessageSerializer()}, + {typeof(int), new Int32Converter()}, + {typeof(long), new Int64Converter()}, + {typeof(float), new FloatConverter()}, + {typeof(double), new DoubleConverter()}, + {typeof(Guid), new UuidSerializer()}, + {typeof(DateTime), new DateSerializer()}, + {typeof(Enum), new EnumSerializer()}, + {typeof(TraversalPredicate), new TraversalPredicateSerializer()}, + {typeof(Vertex), new VertexSerializer()}, + {typeof(Edge), new EdgeSerializer()}, + {typeof(Property), new PropertySerializer()}, + {typeof(VertexProperty), new VertexPropertySerializer()}, + {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()} + }; + + /// + /// Initializes a new instance of the class. + /// + public GraphSONWriter() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// serializers identified by their + /// . + /// + public GraphSONWriter(IReadOnlyDictionary customSerializerByType) + { + foreach (var serializerAndType in customSerializerByType) + _serializerByType[serializerAndType.Key] = serializerAndType.Value; + } + + /// + /// Serializes an object to GraphSON. + /// + /// The object to serialize. + /// The serialized GraphSON. + public string WriteObject(dynamic objectData) + { + return JsonConvert.SerializeObject(ToDict(objectData)); + } + + internal dynamic ToDict(dynamic objectData) + { + var type = objectData.GetType(); + if (TryGetSerializerFor(out IGraphSONSerializer serializer, type)) + return serializer.Dictify(objectData, this); + if (IsDictionaryType(type)) + return DictToGraphSONDict(objectData); + if (IsCollectionType(type)) + return CollectionToGraphSONCollection(objectData); + return objectData; + } + + private bool TryGetSerializerFor(out IGraphSONSerializer serializer, Type type) + { + if (_serializerByType.ContainsKey(type)) + { + serializer = _serializerByType[type]; + return true; + } + foreach (var supportedType in _serializerByType.Keys) + if (supportedType.IsAssignableFrom(type)) + { + serializer = _serializerByType[supportedType]; + return true; + } + serializer = null; + return false; + } + + private bool IsDictionaryType(Type type) + { + return type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>); + } + + private Dictionary DictToGraphSONDict(dynamic dict) + { + var graphSONDict = new Dictionary(); + foreach (var keyValue in dict) + graphSONDict.Add(ToDict(keyValue.Key), ToDict(keyValue.Value)); + return graphSONDict; + } + + private bool IsCollectionType(Type type) + { + return type.GetInterfaces().Contains(typeof(ICollection)); + } + + private IEnumerable CollectionToGraphSONCollection(dynamic collection) + { + foreach (var e in collection) + yield return ToDict(e); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONDeserializer.cs new file mode 100644 index 00000000000..b15b169a194 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONDeserializer.cs @@ -0,0 +1,41 @@ +#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 Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + /// + /// Supports deserializing GraphSON into an object. + /// + public interface IGraphSONDeserializer + { + /// + /// Deserializes GraphSON to an object. + /// + /// The GraphSON object to objectify. + /// A that can be used to objectify properties of the GraphSON object. + /// The deserialized object. + dynamic Objectify(JToken graphsonObject, GraphSONReader reader); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONSerializer.cs new file mode 100644 index 00000000000..f5faf848607 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/IGraphSONSerializer.cs @@ -0,0 +1,41 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + /// + /// Supports serializing of an object to GraphSON. + /// + public interface IGraphSONSerializer + { + /// + /// Transforms an object into a dictionary that resembles its GraphSON representation. + /// + /// The object to dictify. + /// A that can be used to dictify properties of the object. + /// The GraphSON representation. + Dictionary Dictify(dynamic objectData, GraphSONWriter writer); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int32Converter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int32Converter.cs new file mode 100644 index 00000000000..052f93828dd --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int32Converter.cs @@ -0,0 +1,33 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class Int32Converter : NumberConverter + { + protected override string GraphSONTypeName => "Int32"; + protected override Type HandledType => typeof(int); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int64Converter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int64Converter.cs new file mode 100644 index 00000000000..dd0160f9132 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/Int64Converter.cs @@ -0,0 +1,33 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class Int64Converter : NumberConverter + { + protected override string GraphSONTypeName => "Int64"; + protected override Type HandledType => typeof(long); + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/NumberConverter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/NumberConverter.cs new file mode 100644 index 00000000000..579d20237d5 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/NumberConverter.cs @@ -0,0 +1,45 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal abstract class NumberConverter : IGraphSONDeserializer, IGraphSONSerializer + { + protected abstract string GraphSONTypeName { get; } + protected abstract Type HandledType { get; } + + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + return graphsonObject.ToObject(HandledType); + } + + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + return GraphSONUtil.ToTypedValue(GraphSONTypeName, objectData); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PathDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PathDeserializer.cs new file mode 100644 index 00000000000..afdf07cf027 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PathDeserializer.cs @@ -0,0 +1,41 @@ +#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.Linq; +using Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class PathDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var labels = + graphsonObject["labels"] + .Select(readObjLabels => readObjLabels.Select(l => (string) l).ToList()) + .ToList(); + var objects = graphsonObject["objects"].Select(o => reader.ToObject(o)).ToList(); + return new Path(labels, objects); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertyDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertyDeserializer.cs new file mode 100644 index 00000000000..11f160efbb4 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertyDeserializer.cs @@ -0,0 +1,38 @@ +#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 Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class PropertyDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var key = (string) graphsonObject["key"]; + var value = reader.ToObject(graphsonObject["value"]); + var element = graphsonObject["element"] != null ? reader.ToObject(graphsonObject["element"]) : null; + return new Property(key, value, element); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertySerializer.cs new file mode 100644 index 00000000000..0a7e6f89a3c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PropertySerializer.cs @@ -0,0 +1,64 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class PropertySerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + Property property = objectData; + var elementDict = CreateElementDict(property.Element, writer); + var valueDict = new Dictionary + { + {"key", property.Key}, + {"value", writer.ToDict(property.Value)}, + {"element", elementDict} + }; + return GraphSONUtil.ToTypedValue(nameof(Property), valueDict); + } + + private dynamic CreateElementDict(Element element, GraphSONWriter writer) + { + if (element == null) + return null; + var serializedElement = writer.ToDict(element); + Dictionary elementDict = serializedElement; + if (elementDict.ContainsKey(GraphSONTokens.ValueKey)) + { + var elementValueSerialized = elementDict[GraphSONTokens.ValueKey]; + Dictionary elementValueDict = elementValueSerialized; + if (elementValueDict != null) + { + elementValueDict.Remove("outVLabel"); + elementValueDict.Remove("inVLabel"); + elementValueDict.Remove("properties"); + elementValueDict.Remove("value"); + } + } + return serializedElement; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/RequestMessageSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/RequestMessageSerializer.cs new file mode 100644 index 00000000000..b796423ec5a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/RequestMessageSerializer.cs @@ -0,0 +1,43 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class RequestMessageSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + RequestMessage msg = objectData; + return new Dictionary + { + {"requestId", writer.ToDict(msg.RequestId)}, + {"op", msg.Operation}, + {"processor", msg.Processor}, + {"args", writer.ToDict(msg.Arguments)} + }; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs new file mode 100644 index 00000000000..937cb906117 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs @@ -0,0 +1,45 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class TraversalPredicateSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic predicate, GraphSONWriter writer) + { + TraversalPredicate p = predicate; + var value = p.Other == null + ? writer.ToDict(p.Value) + : new List {writer.ToDict(p.Value), writer.ToDict(p.Other)}; + var dict = new Dictionary + { + {"predicate", p.OperatorName}, + {"value", value} + }; + return GraphSONUtil.ToTypedValue("P", dict); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs new file mode 100644 index 00000000000..cc809aaafe1 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalSerializer.cs @@ -0,0 +1,38 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class TraversalSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + ITraversal traversal = objectData; + var bytecode = traversal.Bytecode; + return writer.ToDict(bytecode); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalStrategySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalStrategySerializer.cs new file mode 100644 index 00000000000..9b7097833da --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalStrategySerializer.cs @@ -0,0 +1,37 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal.Strategy; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class TraversalStrategySerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + AbstractTraversalStrategy strategy = objectData; + return GraphSONUtil.ToTypedValue(strategy.StrategyName, writer.ToDict(strategy.Configuration)); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraverserReader.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraverserReader.cs new file mode 100644 index 00000000000..abbb45f3416 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraverserReader.cs @@ -0,0 +1,38 @@ +#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 Gremlin.Net.Process.Traversal; +using Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class TraverserReader : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var bulkObj = reader.ToObject(graphsonObject["bulk"]); + var valueObj = reader.ToObject(graphsonObject["value"]); + return new Traverser(valueObj, bulkObj); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidDeserializer.cs new file mode 100644 index 00000000000..82ca43d62cd --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidDeserializer.cs @@ -0,0 +1,36 @@ +#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 Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class UuidDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + return graphsonObject.ToObject(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidSerializer.cs new file mode 100644 index 00000000000..5f31bfc63de --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/UuidSerializer.cs @@ -0,0 +1,37 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class UuidSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + Guid guid = objectData; + return GraphSONUtil.ToTypedValue("UUID", guid); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexDeserializer.cs new file mode 100644 index 00000000000..f1d64edf2ed --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexDeserializer.cs @@ -0,0 +1,37 @@ +#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 Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class VertexDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var id = reader.ToObject(graphsonObject["id"]); + var label = (string) graphsonObject["label"] ?? Vertex.DefaultLabel; + return new Vertex(id, label); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertyDeserializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertyDeserializer.cs new file mode 100644 index 00000000000..7c2505ff7d6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertyDeserializer.cs @@ -0,0 +1,41 @@ +#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 Newtonsoft.Json.Linq; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class VertexPropertyDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + var id = reader.ToObject(graphsonObject["id"]); + var label = (string) graphsonObject["label"]; + var value = reader.ToObject(graphsonObject["value"]); + var vertex = graphsonObject["vertex"] != null + ? new Vertex(reader.ToObject(graphsonObject["vertex"])) + : null; + return new VertexProperty(id, label, value, vertex); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertySerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertySerializer.cs new file mode 100644 index 00000000000..12cc7ac2cf6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexPropertySerializer.cs @@ -0,0 +1,43 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class VertexPropertySerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + VertexProperty vertexProperty = objectData; + var valueDict = new Dictionary + { + {"id", writer.ToDict(vertexProperty.Id)}, + {"label", vertexProperty.Label}, + {"value", writer.ToDict(vertexProperty.Value)}, + {"vertex", writer.ToDict(vertexProperty.Vertex.Id)} + }; + return GraphSONUtil.ToTypedValue(nameof(VertexProperty), valueDict); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexSerializer.cs new file mode 100644 index 00000000000..d3ad9f16ff6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/VertexSerializer.cs @@ -0,0 +1,41 @@ +#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; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class VertexSerializer : IGraphSONSerializer + { + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + Vertex vertex = objectData; + var vertexDict = new Dictionary + { + {"id", writer.ToDict(vertex.Id)}, + {"label", writer.ToDict(vertex.Label)} + }; + return GraphSONUtil.ToTypedValue(nameof(Vertex), vertexDict); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Path.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Path.cs new file mode 100644 index 00000000000..01a436a39e2 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Path.cs @@ -0,0 +1,193 @@ +#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; +using System.Collections.Generic; +using System.Linq; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Structure +{ + /// + /// A Path denotes a particular walk through a graph as defined by a . + /// + /// + /// In abstraction, any Path implementation maintains two lists: a list of sets of labels and a list of objects. + /// The list of labels are the labels of the steps traversed. The list of objects are the objects traversed. + /// + public class Path : IReadOnlyList, IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// The labels associated with the path + /// The objects in the . + public Path(List> labels, List objects) + { + Labels = labels; + Objects = objects; + } + + /// + /// Gets an ordered list of the labels associated with the . + /// + public List> Labels { get; } + + /// + /// Gets an ordered list of the objects in the . + /// + public List Objects { get; } + + /// + /// Gets the object associated with the particular label of the path. + /// + /// If the path has multiple labels of the type, then get a collection of those objects. + /// The label of the path + /// The object associated with the label of the path + /// Thrown if the path does not contain the label. + public object this[string label] + { + get + { + var objFound = TryGetValue(label, out object obj); + if (!objFound) + throw new KeyNotFoundException($"The step with label {label} does not exist"); + return obj; + } + } + + /// + public bool Equals(Path other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return ObjectsEqual(other.Objects) && LabelsEqual(other.Labels); + } + + /// + /// Get the object associated with the specified index into the path. + /// + /// The index of the path + /// The object associated with the index of the path + public dynamic this[int index] => Objects[index]; + + /// + /// Gets the number of steps in the path. + /// + public int Count => Objects.Count; + + /// + public IEnumerator GetEnumerator() + { + return ((IReadOnlyList) Objects).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IReadOnlyList) Objects).GetEnumerator(); + } + + /// + public override string ToString() + { + return $"[{string.Join(", ", Objects)}]"; + } + + /// + /// Returns true if the path has the specified label, else return false. + /// + /// The label to search for. + /// True if the label exists in the path. + public bool ContainsKey(string key) + { + return Labels.Any(objLabels => objLabels.Contains(key)); + } + + /// + /// Tries to get the object associated with the particular label of the path. + /// + /// If the path has multiple labels of the type, then get a collection of those objects. + /// The label of the path. + /// The object associated with the label of the path. + /// True, if an object was found for the label. + public bool TryGetValue(string label, out object value) + { + value = null; + for (var i = 0; i < Labels.Count; i++) + { + if (!Labels[i].Contains(label)) continue; + if (value == null) + value = Objects[i]; + else if (value.GetType() == typeof(List)) + ((List) value).Add(Objects[i]); + else + value = new List {value, Objects[i]}; + } + return value != null; + } + + private bool ObjectsEqual(IReadOnlyCollection otherObjects) + { + if (Objects == null) + return otherObjects == null; + return Objects.SequenceEqual(otherObjects); + } + + private bool LabelsEqual(IReadOnlyList> otherLabels) + { + if (Labels == null) + return otherLabels == null; + if (Labels.Count != otherLabels.Count) + return false; + var foundUnequalObjLabels = Labels.Where((objLabels, i) => !objLabels.SequenceEqual(otherLabels[i])).Any(); + return !foundUnequalObjLabels; + } + + /// + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((Path) obj); + } + + /// + public override int GetHashCode() + { + unchecked + { + var hashCode = 19; + if (Labels != null) + hashCode = Labels.Where(objLabels => objLabels != null) + .Aggregate(hashCode, + (current1, objLabels) => objLabels.Aggregate(current1, + (current, label) => current * 31 + label.GetHashCode())); + if (Objects != null) + hashCode = Objects.Aggregate(hashCode, (current, obj) => current * 31 + obj.GetHashCode()); + return hashCode; + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Property.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Property.cs new file mode 100644 index 00000000000..daa052a3809 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Property.cs @@ -0,0 +1,96 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; + +namespace Gremlin.Net.Structure +{ + /// + /// A denotes a key/value pair associated with an . + /// + public class Property : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// The key of the property. + /// The value of the property. + /// The element that the property is associated with. + public Property(string key, dynamic value, Element element) + { + Key = key; + Value = value; + Element = element; + } + + /// + /// Gets the key of the property. + /// + public string Key { get; } + + /// + /// Gets the value of the property. + /// + public dynamic Value { get; } + + /// + /// Gets the element that this property is associated with. + /// + public Element Element { get; } + + /// + public bool Equals(Property other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return string.Equals(Key, other.Key) && Equals(Value, other.Value) && Equals(Element, other.Element); + } + + /// + public override string ToString() + { + return $"p[{Key}->{Value}]"; + } + + /// + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((Property) obj); + } + + /// + public override int GetHashCode() + { + unchecked + { + var hashCode = Key?.GetHashCode() ?? 0; + hashCode = (hashCode * 397) ^ (Value != null ? Value.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (Element?.GetHashCode() ?? 0); + return hashCode; + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Vertex.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Vertex.cs new file mode 100644 index 00000000000..f667d26f30e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Vertex.cs @@ -0,0 +1,52 @@ +#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 + +namespace Gremlin.Net.Structure +{ + /// + /// Represents a vertex. + /// + public class Vertex : Element + { + /// + /// The default label to use for a vertex. + /// + public const string DefaultLabel = "vertex"; + + /// + /// Initializes a new instance of the class. + /// + /// The id of the vertex. + /// The label of the vertex. + public Vertex(object id, string label = DefaultLabel) + : base(id, label) + { + } + + /// + public override string ToString() + { + return $"v[{Id}]"; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/VertexProperty.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/VertexProperty.cs new file mode 100644 index 00000000000..8e207237af6 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/VertexProperty.cs @@ -0,0 +1,66 @@ +#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 + +namespace Gremlin.Net.Structure +{ + /// + /// A denotes a key/value pair associated with a . + /// + public class VertexProperty : Element + { + /// + /// Initializes a new instance of the class. + /// + /// The id of the vertex property. + /// The label of the vertex property. + /// The id of the vertex property. + /// The that owns this . + public VertexProperty(object id, string label, dynamic value, Vertex vertex) + : base(id, label) + { + Value = value; + Vertex = vertex; + } + + /// + /// The value of this . + /// + public dynamic Value { get; } + + /// + /// The that owns this . + /// + public Vertex Vertex { get; } + + /// + /// The key of this . + /// + public string Key => Label; + + /// + public override string ToString() + { + return $"vp[{Label}->{Value}]"; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml new file mode 100644 index 00000000000..5fef134bc0a --- /dev/null +++ b/gremlin-dotnet/src/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + org.apache.tinkerpop + gremlin-dotnet + 3.2.5-SNAPSHOT + + Gremlin-DotNet-Source + ${packaging.type} + + + gremlin-dotnet-standard + + true + + + pom + + + + + gremlin-dotnet + + false + + .glv + + + + dotnet-library + + + ${basedir}/target + ${project.artifactId}-${project.version} + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.eobjects.build + dotnet-maven-plugin + true + + ${project.parent.basedir}/target/nuget + + + + + + + \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs new file mode 100644 index 00000000000..672ff353555 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs @@ -0,0 +1,76 @@ +#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 Gremlin.CSharp.Process; +using Gremlin.CSharp.Structure; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.BytecodeGeneration +{ + public class BytecodeGenerationTests + { + [Fact] + public void g_V_OutXcreatedX() + { + var g = new Graph().Traversal(); + + var bytecode = g.V().Out("created").Bytecode; + + Assert.Equal(0, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.StepInstructions.Count); + Assert.Equal("V", bytecode.StepInstructions[0].OperatorName); + Assert.Equal("out", bytecode.StepInstructions[1].OperatorName); + Assert.Equal("created", bytecode.StepInstructions[1].Arguments[0]); + Assert.Equal(1, bytecode.StepInstructions[1].Arguments.Length); + } + + [Fact] + public void g_WithSackX1X_E_GroupCount_ByXweightX() + { + var g = new Graph().Traversal(); + + var bytecode = g.WithSack(1).E().GroupCount().By("weight").Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal("withSack", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(3, bytecode.StepInstructions.Count); + Assert.Equal("E", bytecode.StepInstructions[0].OperatorName); + Assert.Equal("groupCount", bytecode.StepInstructions[1].OperatorName); + Assert.Equal("by", bytecode.StepInstructions[2].OperatorName); + Assert.Equal("weight", bytecode.StepInstructions[2].Arguments[0]); + Assert.Equal(0, bytecode.StepInstructions[0].Arguments.Length); + Assert.Equal(0, bytecode.StepInstructions[1].Arguments.Length); + Assert.Equal(1, bytecode.StepInstructions[2].Arguments.Length); + } + + [Fact] + public void AnonymousTraversal_Start_EmptyBytecode() + { + var bytecode = __.Start().Bytecode; + + Assert.Equal(0, bytecode.SourceInstructions.Count); + Assert.Equal(0, bytecode.StepInstructions.Count); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs new file mode 100644 index 00000000000..6afda7132eb --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs @@ -0,0 +1,170 @@ +#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.CSharp.Process; +using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Process.Traversal.Strategy.Finalization; +using Gremlin.Net.Process.Traversal.Strategy.Optimization; +using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.BytecodeGeneration +{ + public class StrategiesTests + { + [Fact] + public void TraversalWithoutStrategies_AfterWithStrategiesWasCalled_WithStrategiesNotAffected() + { + var graph = new Graph(); + var g = graph.Traversal().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()); + + var bytecode = g.WithoutStrategies(new ReadOnlyStrategy()).Bytecode; + + Assert.Equal(2, bytecode.SourceInstructions.Count); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + + Assert.Equal("withoutStrategies", bytecode.SourceInstructions[1].OperatorName); + Assert.Equal(1, bytecode.SourceInstructions[1].Arguments.Length); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[1].Arguments[0]); + } + + [Fact] + public void ShouldIncludeMultipleStrategiesInBytecodeWhenGivenToWithoutStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithoutStrategies(new ReadOnlyStrategy(), new LazyBarrierStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withoutStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new LazyBarrierStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + } + + [Fact] + public void ShouldIncludeOneStrategyInBytecodeWhenGivenToWithoutStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithoutStrategies(new ReadOnlyStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withoutStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + } + + [Fact] + public void ShouldIncludeConfigurationInBytecodeWhenGivenToWithStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new MatchAlgorithmStrategy("greedy")).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new MatchAlgorithmStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Contains("greedy", + ((MatchAlgorithmStrategy) bytecode.SourceInstructions[0].Arguments[0]).Configuration.Values); + } + + [Fact] + public void ShouldIncludeMultipleStrategiesInBytecodeWhenGivenToWithStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + } + + [Fact] + public void ShouldIncludeOneStrategyInBytecodeWhenGivenToWithStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new ReadOnlyStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal("ReadOnlyStrategy", bytecode.SourceInstructions[0].Arguments[0].ToString()); + Assert.Equal(new ReadOnlyStrategy().GetHashCode(), bytecode.SourceInstructions[0].Arguments[0].GetHashCode()); + Assert.Equal(0, g.TraversalStrategies.Count); + } + + [Fact] + public void TraversalWithStrategies_Strategies_ApplyToReusedGraphTraversalSource() + { + var graph = new Graph(); + var g = graph.Traversal().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()); + + var bytecode = g.V().Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + Assert.Equal(1, bytecode.StepInstructions.Count); + Assert.Equal("V", bytecode.StepInstructions[0].OperatorName); + } + + [Fact] + public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTraversalInInConfigInBytecode() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new SubgraphStrategy(__.Has("name", "marko"))).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0]; + Assert.Equal(1, strategy.Configuration.Count); + Assert.Equal(typeof(GraphTraversal), strategy.Configuration["vertices"].GetType()); + GraphTraversal traversal = strategy.Configuration["vertices"]; + Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName); + Assert.Equal(new List {"name", "marko"}, traversal.Bytecode.StepInstructions[0].Arguments); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs new file mode 100644 index 00000000000..27e7009910c --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs @@ -0,0 +1,47 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.IO; +using Microsoft.Extensions.Configuration; + +namespace Gremlin.CSharp.IntegrationTest +{ + public static class ConfigProvider + { + static ConfigProvider() + { + Configuration = GetConfig(); + } + + public static IConfiguration Configuration { get; } + + private static IConfiguration GetConfig() + { + var configFile = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"); + var builder = new ConfigurationBuilder() + .AddJsonFile(configFile, false, false); + + return builder.Build(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs new file mode 100644 index 00000000000..a49a09de897 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs @@ -0,0 +1,59 @@ +#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.CSharp.Process; +using Gremlin.CSharp.Structure; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + public class EnumTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldUseOrderDecrInByStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var orderedAges = g.V().Values("age").Order().By(Order.decr).ToList(); + + Assert.Equal(new List {35, 32, 29, 27}, orderedAges); + } + + [Fact] + public void ShouldUseTLabelInHasStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var personsCount = g.V().Has(T.label, "person").Count().Next(); + + Assert.Equal((long) 4, personsCount); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs new file mode 100644 index 00000000000..f8c12e2823c --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs @@ -0,0 +1,55 @@ +#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.CSharp.Process; +using Gremlin.CSharp.Structure; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + public class GraphTraversalSourceTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldUseSideEffectSpecifiedInWithSideEffect() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var results = g.WithSideEffect("a", new List {"josh", "peter"}) + .V(1) + .Out("created") + .In("created") + .Values("name") + .Where(P.Within("a")) + .ToList(); + + Assert.Equal(2, results.Count); + Assert.Contains("josh", results); + Assert.Contains("peter", results); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs new file mode 100644 index 00000000000..91a41ba296f --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs @@ -0,0 +1,171 @@ +#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 System.Threading.Tasks; +using Gremlin.CSharp.Process; +using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + public class GraphTraversalTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void g_V_Count() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = g.V().Count().Next(); + + Assert.Equal((long) 6, count); + } + + [Fact] + public void g_VX1X_Next() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var vertex = (Vertex) g.V(1).Next(); + + Assert.Equal(new Vertex((long) 1), vertex); + Assert.Equal((long) 1, vertex.Id); + } + + [Fact] + public void g_VX1X_NextTraverser() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var traverser = g.V(1).NextTraverser(); + + Assert.Equal(new Traverser(new Vertex((long)1)), traverser); + } + + [Fact] + public void g_VX1X_ToList() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var list = g.V(1).ToList(); + + Assert.Equal(1, list.Count); + } + + [Fact] + public void g_V_RepeatXBothX_TimesX5X_NextX10X() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var result = g.V().Repeat(__.Both()).Times(5).Next(10); + + Assert.Equal(10, result.Count()); + } + + [Fact] + public void g_V_HasXname_markoX_ValueMap_Next() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var receivedValueMap = g.V().Has("name", "marko").ValueMap().Next(); + + var expectedValueMap = new Dictionary + { + {"age", new List {29}}, + {"name", new List {"marko"}} + }; + Assert.Equal(expectedValueMap, receivedValueMap); + } + + [Fact] + public void g_V_RepeatXOutX_TimesX2X_ValuesXNameX() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = g.V().Repeat(__.Out()).Times(2).Values("name"); + var names = t.ToList(); + + Assert.Equal((long) 2, names.Count); + Assert.Contains("lop", names); + Assert.Contains("ripple", names); + } + + [Fact] + public void ShortestPathTest() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var shortestPath = + (Path) g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit(1).Path().Next(); + + Assert.Equal((long) 4, shortestPath.Count); + Assert.Equal(new Vertex((long) 6), shortestPath[3]); + } + + [Fact] + public void ShouldUseBindingsInTraversal() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var b = new Bindings(); + var count = g.V().Has(b.Of("propertyKey", "name"), b.Of("propertyValue", "marko")).OutE().Count().Next(); + + Assert.Equal((long) 3, count); + } + + [Fact] + public async Task ShouldExecuteAsynchronouslyWhenPromiseIsCalled() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = await g.V().Count().Promise(t => t.Next()); + + Assert.Equal((long) 6, count); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs new file mode 100644 index 00000000000..8dffa432cb0 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs @@ -0,0 +1,58 @@ +#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 Gremlin.CSharp.Process; +using Gremlin.CSharp.Structure; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + public class PredicateTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldUsePredicatesCombinedWithPAndInHasStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = g.V().Has("age", P.Gt(30).And(P.Lt(35))).Count().Next(); + + Assert.Equal((long) 1, count); + } + + [Fact] + public void ShouldUsePWithinInHasStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = g.V().Has("name", P.Within("josh", "vadas")).Count().Next(); + + Assert.Equal((long) 2, count); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs new file mode 100644 index 00000000000..53b6e501434 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs @@ -0,0 +1,41 @@ +#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 Gremlin.Net.Driver; +using Gremlin.Net.Process.Remote; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + internal class RemoteConnectionFactory + { + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); + + public IRemoteConnection CreateRemoteConnection() + { + return new Net.Driver.Remote.DriverRemoteConnection( + new GremlinClient(new GremlinServer(TestHost, TestPort))); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs new file mode 100644 index 00000000000..805116734a7 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs @@ -0,0 +1,221 @@ +#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 System.Threading.Tasks; +using Gremlin.CSharp.Structure; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + public class SideEffectTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldReturnCachedSideEffectWhenGetIsCalledAfterClose() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Iterate(); + + t.SideEffects.Get("a"); + t.SideEffects.Close(); + var results = t.SideEffects.Get("a"); + + Assert.NotNull(results); + } + + [Fact] + public void ShouldThrowWhenGetIsCalledAfterCloseAndNoSideEffectsAreCachec() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Iterate(); + + t.SideEffects.Close(); + Assert.Throws(() => t.SideEffects.Get("a")); + } + + [Fact] + public void ShouldThrowWhenGetIsCalledAfterDisposeAndNoSideEffectsAreCachec() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Iterate(); + + t.SideEffects.Dispose(); + Assert.Throws(() => t.SideEffects.Get("a")); + } + + [Fact] + public void ShouldReturnSideEffectValueWhenGetIsCalledForGroupCountTraversal() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Out("created").GroupCount("m").By("name").Iterate(); + t.SideEffects.Keys(); + + var m = t.SideEffects.Get("m") as Dictionary; + + Assert.Equal(2, m.Count); + Assert.Equal((long) 3, m["lop"]); + Assert.Equal((long) 1, m["ripple"]); + } + + [Fact] + public void ShouldReturnSideEffectValueWhenGetIsCalledOnATraversalWithSideEffect() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.WithSideEffect("a", new List {"first", "second"}).V().Iterate(); + t.SideEffects.Keys(); + + var a = t.SideEffects.Get("a") as List; + + Assert.Equal(2, a.Count); + Assert.Equal("first", a[0]); + Assert.Equal("second", a[1]); + } + + [Fact] + public void ShouldThrowWhenGetIsCalledWithAnUnknownKey() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Iterate(); + + Assert.Throws(() => t.SideEffects.Get("m")); + } + + [Fact] + public void ShouldReturnBothSideEffectForTraversalWithTwoSideEffects_() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = g.V().Out("created").GroupCount("m").By("name").Values("name").Aggregate("n").Iterate(); + + var keys = t.SideEffects.Keys().ToList(); + Assert.Equal(2, keys.Count); + Assert.Contains("m", keys); + Assert.Contains("n", keys); + var n = (Dictionary) t.SideEffects.Get("n"); + Assert.Equal(2, n.Count); + Assert.Equal(3, n["lop"]); + Assert.Equal(1, n["ripple"]); + } + + [Fact] + public void ShouldReturnAnEmptyCollectionWhenKeysIsCalledForTraversalWithoutSideEffect() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = g.V().Iterate(); + var keys = t.SideEffects.Keys(); + + Assert.Equal(0, keys.Count); + } + + [Fact] + public void ShouldReturnCachedKeysWhenForCloseAfterSomeGet() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Aggregate("b").Iterate(); + + t.SideEffects.Get("a"); + t.SideEffects.Close(); + var keys = t.SideEffects.Keys(); + + Assert.Equal(2, keys.Count); + Assert.Contains("a", keys); + Assert.Contains("b", keys); + } + + [Fact] + public void ShouldReturnSideEffectKeyWhenKeysIsCalledForNamedGroupCount() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Out("created").GroupCount("m").By("name").Iterate(); + + var keys = t.SideEffects.Keys(); + + var keysList = keys.ToList(); + Assert.Equal(1, keysList.Count); + Assert.Contains("m", keysList); + } + + [Fact] + public async Task ShouldReturnSideEffectsKeysWhenKeysIsCalledOnTraversalThatExecutedAsynchronously() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = await g.V().Aggregate("a").Promise(x => x); + var keys = t.SideEffects.Keys(); + + Assert.Equal(1, keys.Count); + Assert.Contains("a", keys); + } + + [Fact] + public async Task ShouldReturnSideEffectValueWhenGetIsCalledOnTraversalThatExecutedAsynchronously() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = await g.V().Aggregate("a").Promise(x => x); + var value = t.SideEffects.Get("a"); + + Assert.NotNull(value); + } + + [Fact] + public async Task ShouldNotThrowWhenCloseIsCalledOnTraversalThatExecutedAsynchronously() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = await g.V().Aggregate("a").Promise(x => x); + t.SideEffects.Close(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs new file mode 100644 index 00000000000..59e2092f594 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs @@ -0,0 +1,193 @@ +#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.Threading.Tasks; +using Gremlin.CSharp.Process; +using Gremlin.CSharp.Structure; +using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +{ + public class StrategiesTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void g_V_Count_Next_WithVertexLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); + + var count = g.V().Count().Next(); + + Assert.Equal((long) 4, count); + } + + [Fact] + public void g_E_Count_Next_WithVertexAndEdgeLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"), + edgeCriterion: __.HasLabel("created"))); + + var count = g.E().Count().Next(); + + Assert.Equal((long)0, count); + } + + [Fact] + public void g_V_Label_Dedup_Count_Next_WithVertexLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); + + var count = g.V().Label().Dedup().Count().Next(); + + Assert.Equal((long)1, count); + } + + [Fact] + public void g_V_Label_Dedup_Next_WWithVertexLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); + + var label = g.V().Label().Dedup().Next(); + + Assert.Equal("person", label); + } + + [Fact] + public void g_V_Count_Next_WithVertexHasPropertySubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); + + var count = g.V().Count().Next(); + + Assert.Equal((long)1, count); + } + + [Fact] + public void g_E_Count_Next_WithEdgeLimitSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(edgeCriterion: __.Limit(0))); + + var count = g.E().Count().Next(); + + Assert.Equal((long)0, count); + } + + [Fact] + public void g_V_Label_Dedup_Next_WithVertexHasPropertySubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); + + var label = g.V().Label().Dedup().Next(); + + Assert.Equal("person", label); + } + + [Fact] + public void g_V_ValuesXnameX_Next_WithVertexHasPropertySubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); + + var name = g.V().Values("name").Next(); + + Assert.Equal("marko", name); + } + + [Fact] + public void g_V_Count_Next_WithComputer() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection).WithComputer(); + + var count = g.V().Count().Next(); + + Assert.Equal((long)6, count); + } + + [Fact] + public void g_E_Count_Next_WithComputer() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection).WithComputer(); + + var count = g.E().Count().Next(); + + Assert.Equal((long)6, count); + } + + [Fact] + public async Task ShouldThrowWhenModifyingTraversalSourceWithReadOnlyStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection).WithStrategies(new ReadOnlyStrategy()); + + await Assert.ThrowsAsync(async () => await g.AddV("person").Promise(t => t.Next())); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs new file mode 100644 index 00000000000..99a1b651376 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs @@ -0,0 +1,50 @@ +#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 Gremlin.CSharp.Process; +using Gremlin.Net.Structure.IO.GraphSON; +using Xunit; + +namespace Gremlin.CSharp.IntegrationTest +{ + public class GraphSONWriterTests + { + [Fact] + public void ShouldSerializeLongPredicateCorrectly() + { + var writer = CreateStandardGraphSONWriter(); + var predicate = P.Lt("b").Or(P.Gt("c")).And(P.Neq("d")); + + var graphSon = writer.WriteObject(predicate); + + const string expected = + "{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"and\",\"value\":[{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"or\",\"value\":[{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"lt\",\"value\":\"b\"}},{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"gt\",\"value\":\"c\"}}]}},{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"neq\",\"value\":\"d\"}}]}}"; + Assert.Equal(expected, graphSon); + } + + private GraphSONWriter CreateStandardGraphSONWriter() + { + return new GraphSONWriter(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj new file mode 100644 index 00000000000..1e7a7d23028 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj @@ -0,0 +1,38 @@ + + + + netcoreapp1.0 + Gremlin.CSharp.IntegrationTest + Gremlin.CSharp.IntegrationTest + true + 1.0.4 + false + false + false + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..579426b622d --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#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.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Gremlin.CSharp.IntegrationTest")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("232f0f2b-178e-4214-99c7-cc4dc6710f44")] \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json new file mode 100644 index 00000000000..38007ec1c9c --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json @@ -0,0 +1,4 @@ +{ + "TestServerIpAddress": "localhost", + "TestServerPort": 45950 +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs new file mode 100644 index 00000000000..bac2d55a2bc --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs @@ -0,0 +1,68 @@ +#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 Gremlin.CSharp.Structure; +using Xunit; + +namespace Gremlin.CSharp.UnitTest +{ + public class GraphTraversalSourceTests + { + [Fact] + public void ShouldBeIndependentFromReturnedGraphTraversalModififyingBytecode() + { + var graph = new Graph(); + var g = graph.Traversal(); + + g.V().Has("someKey", "someValue").Drop(); + + Assert.Equal(0, g.Bytecode.StepInstructions.Count); + Assert.Equal(0, g.Bytecode.SourceInstructions.Count); + } + + [Fact] + public void ShouldBeIndependentFromReturnedGraphTraversalSourceModififyingBytecode() + { + var graph = new Graph(); + var g1 = graph.Traversal(); + + var g2 = g1.WithSideEffect("someSideEffectKey", "someSideEffectValue"); + + Assert.Equal(0, g1.Bytecode.SourceInstructions.Count); + Assert.Equal(0, g1.Bytecode.StepInstructions.Count); + Assert.Equal(1, g2.Bytecode.SourceInstructions.Count); + } + + [Fact] + public void ShouldBeIndependentFromReturnedGraphTraversalSourceModififyingTraversalStrategies() + { + var graph = new Graph(); + var gLocal = graph.Traversal(); + + var gRemote = gLocal.WithRemote(null); + + Assert.Equal(0, gLocal.TraversalStrategies.Count); + Assert.Equal(1, gRemote.TraversalStrategies.Count); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj new file mode 100644 index 00000000000..ea81928688f --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj @@ -0,0 +1,21 @@ + + + + netcoreapp1.1 + + + + + + + + + + + + + + + + + diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs new file mode 100644 index 00000000000..c06fb68e4c8 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs @@ -0,0 +1,50 @@ +#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 Gremlin.CSharp.Process; +using Xunit; + +namespace Gremlin.CSharp.UnitTest +{ + public class PredicateTests + { + [Fact] + public void ShouldKeepOrderForNestedPredicate() + { + Assert.Equal("and(eq(a),lt(b))", P.Eq("a").And(P.Lt("b")).ToString()); + } + + [Fact] + public void ShouldKeepOrderForDoubleNestedPredicate() + { + Assert.Equal("and(or(lt(b),gt(c)),neq(d))", P.Lt("b").Or(P.Gt("c")).And(P.Neq("d")).ToString()); + } + + [Fact] + public void ShouldKeepOrderForTripleNestedPredicate() + { + Assert.Equal("and(or(lt(b),gt(c)),or(neq(d),gte(e)))", + P.Lt("b").Or(P.Gt("c")).And(P.Neq("d").Or(P.Gte("e"))).ToString()); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/ConfigProvider.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/ConfigProvider.cs new file mode 100644 index 00000000000..b7afe74e93a --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/ConfigProvider.cs @@ -0,0 +1,47 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.IO; +using Microsoft.Extensions.Configuration; + +namespace Gremlin.Net.IntegrationTest +{ + public static class ConfigProvider + { + static ConfigProvider() + { + Configuration = GetConfig(); + } + + public static IConfiguration Configuration { get; } + + private static IConfiguration GetConfig() + { + var configFile = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"); + var builder = new ConfigurationBuilder() + .AddJsonFile(configFile, false, false); + + return builder.Build(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs new file mode 100644 index 00000000000..21a2627155e --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ConnectionPoolTests.cs @@ -0,0 +1,90 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver; +using Gremlin.Net.IntegrationTest.Util; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Driver +{ + public class ConnectionPoolTests + { + private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); + + private async Task ExecuteMultipleLongRunningRequestsInParallel(IGremlinClient gremlinClient, int nrRequests, + int requestRunningTimeInMs) + { + var longRunningRequestMsg = _requestMessageProvider.GetSleepMessage(requestRunningTimeInMs); + var tasks = new List(nrRequests); + for (var i = 0; i < nrRequests; i++) + tasks.Add(gremlinClient.SubmitAsync(longRunningRequestMsg)); + await Task.WhenAll(tasks); + } + + [Fact] + public async Task ShouldReuseConnectionForSequentialRequests() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + await gremlinClient.SubmitAsync(""); + await gremlinClient.SubmitAsync(""); + + var nrConnections = gremlinClient.NrConnections; + Assert.Equal(1, nrConnections); + } + } + + [Fact] + public void ShouldOnlyCreateConnectionWhenNecessary() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var nrConnections = gremlinClient.NrConnections; + Assert.Equal(0, nrConnections); + } + } + + [Fact] + public async Task ShouldExecuteParallelRequestsOnDifferentConnections() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var sleepTime = 50; + var nrParallelRequests = 5; + + await ExecuteMultipleLongRunningRequestsInParallel(gremlinClient, nrParallelRequests, sleepTime); + + var nrConnections = gremlinClient.NrConnections; + Assert.Equal(nrParallelRequests, nrConnections); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs new file mode 100644 index 00000000000..351b83d1064 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs @@ -0,0 +1,212 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.Driver.Messages; +using Gremlin.Net.IntegrationTest.Util; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Driver +{ + public class GremlinClientTests + { + private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); + + [Theory] + [InlineData("'justAString'", "justAString")] + [InlineData("'Hello' + 'World'", "HelloWorld")] + public async Task ShouldSendScriptForEvaluationAndReturnCorrectResult(string requestMsg, string expectedResponse) + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var response = await gremlinClient.SubmitWithSingleResultAsync(requestMsg); + + Assert.Equal(expectedResponse, response); + } + } + + [Fact] + public async Task ShouldHandleBigResponse() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var responseMsgSize = 5000; + var requestMsg = $"'1'*{responseMsgSize}"; + + var response = await gremlinClient.SubmitWithSingleResultAsync(requestMsg); + + Assert.Equal(responseMsgSize, response.Length); + } + } + + [Fact] + public async Task ShouldHandleResponseWithoutContent() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var gremlinScript = "g.V().has(propertyKey, propertyValue);"; + var bindings = new Dictionary + { + {"propertyKey", "name"}, + {"propertyValue", "unknownTestName"} + }; + + var response = + await gremlinClient.SubmitWithSingleResultAsync(gremlinScript, bindings); + + Assert.Null(response); + } + } + + [Fact] + public async Task ShouldThrowExceptionForInvalidScript() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var requestMsg = "invalid"; + + var exception = + await Assert.ThrowsAsync(() => gremlinClient.SubmitAsync(requestMsg)); + + Assert.Equal(typeof(ResponseException), exception.GetType()); + Assert.Contains($"ScriptEvaluationError: No such property: {requestMsg}", + exception.Message); + } + } + + [Fact] + public async Task ShouldReassembleResponseBatches() + { + const int batchSize = 2; + var expectedResult = new List {1, 2, 3, 4, 5}; + var requestScript = $"{nameof(expectedResult)}"; + var bindings = new Dictionary {{nameof(expectedResult), expectedResult}}; + var requestMessage = + RequestMessage.Build(Tokens.OpsEval) + .AddArgument(Tokens.ArgsBatchSize, batchSize) + .AddArgument(Tokens.ArgsGremlin, requestScript) + .AddArgument(Tokens.ArgsBindings, bindings) + .Create(); + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var response = await gremlinClient.SubmitAsync(requestMessage); + + Assert.Equal(expectedResult, response); + } + } + + [Fact] + public async Task ShouldCorrectlyAssignResponsesToRequests() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var sleepTime = 100; + var expectedFirstResult = 1; + var gremlinScript = _requestMessageProvider.GetSleepGremlinScript(sleepTime); + gremlinScript += $"{expectedFirstResult}"; + var firstRequestMsg = RequestMessage.Build(Tokens.OpsEval) + .AddArgument(Tokens.ArgsGremlin, gremlinScript).Create(); + var expectedSecondResponse = 2; + var secondScript = $"{expectedSecondResponse}"; + + var firstResponseTask = gremlinClient.SubmitWithSingleResultAsync(firstRequestMsg); + var secondResponseTask = gremlinClient.SubmitWithSingleResultAsync(secondScript); + + var secondResponse = await secondResponseTask; + Assert.Equal(expectedSecondResponse, secondResponse); + var firstResponse = await firstResponseTask; + Assert.Equal(expectedFirstResult, firstResponse); + } + } + + [Fact] + public async Task ShouldReturnEnumerableResult() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var expectedResult = new List {1, 2, 3, 4, 5}; + var requestMsg = $"{nameof(expectedResult)}"; + var bindings = new Dictionary {{nameof(expectedResult), expectedResult}}; + + var response = await gremlinClient.SubmitAsync(requestMsg, bindings); + + Assert.Equal(expectedResult, response); + } + } + + [Fact] + public async Task ShouldThrowOnExecutionOfSimpleInvalidScript() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var invalidRequestScript = "invalid"; + + await Assert.ThrowsAsync(() => gremlinClient.SubmitAsync(invalidRequestScript)); + } + } + + [Fact] + public async Task ShouldHandleSimpleScriptWithoutErrors() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var requestMsg = _requestMessageProvider.GetDummyMessage(); + + await gremlinClient.SubmitAsync(requestMsg); + } + } + + [Fact] + public async Task ShouldUseBindingsForScript() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var requestMsg = "a + b"; + var a = 1; + var b = 2; + var bindings = new Dictionary {{"a", a}, {"b", b}}; + + var response = + await gremlinClient.SubmitWithSingleResultAsync(requestMsg, bindings); + + Assert.Equal(a + b, response); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs new file mode 100644 index 00000000000..6f6505fbb63 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/MessagesTests.cs @@ -0,0 +1,147 @@ +#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.Diagnostics; +using System.Threading.Tasks; +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.Driver.Messages; +using Gremlin.Net.IntegrationTest.Util; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Driver +{ + public class MessagesTests + { + private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); + + [Fact] + public async Task ShouldUseAliasForTraversalSource() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var aliasTraversalSource = "g2"; + var aliases = new Dictionary {{aliasTraversalSource, "g"}}; + var gremlinScript = $"{aliasTraversalSource}.V().count()"; + var requestMsg = + RequestMessage.Build(Tokens.OpsEval) + .AddArgument(Tokens.ArgsAliases, aliases) + .AddArgument(Tokens.ArgsGremlin, gremlinScript) + .Create(); + + var result = await gremlinClient.SubmitWithSingleResultAsync(requestMsg); + + Assert.NotNull(result); + } + } + + [Fact] + public async Task ShouldThrowForInvalidOperation() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var ivalidOperationName = "invalid"; + var requestMsg = RequestMessage.Build(ivalidOperationName).Create(); + + var thrownException = + await Assert.ThrowsAsync(() => gremlinClient.SubmitAsync(requestMsg)); + + Assert.Contains("MalformedRequest", thrownException.Message); + Assert.Contains(ivalidOperationName, thrownException.Message); + } + } + + [Fact] + public async Task ShouldThrowForInvalidProcessor() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var invalidProcessorName = "invalid"; + var requestMsg = RequestMessage.Build("").Processor(invalidProcessorName).Create(); + + var thrownException = + await Assert.ThrowsAsync(() => gremlinClient.SubmitAsync(requestMsg)); + + Assert.Contains("InvalidRequestArguments", thrownException.Message); + Assert.Contains(invalidProcessorName, thrownException.Message); + Assert.Contains("OpProcessor", thrownException.Message); + } + } + + [Fact] + public async Task ShouldUseSpecifiedScriptEvaluationTimeout() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + const int timeOutInMs = 1; + const int scriptSleepTimeInMs = 5000; + var sleepScript = _requestMessageProvider.GetSleepGremlinScript(scriptSleepTimeInMs); + + var requestMsg = + RequestMessage.Build(Tokens.OpsEval) + .AddArgument(Tokens.ArgsGremlin, sleepScript) + .AddArgument(Tokens.ArgsEvalTimeout, timeOutInMs) + .Create(); + var evaluationStopWatch = new Stopwatch(); + evaluationStopWatch.Start(); + + var thrownException = + await Assert.ThrowsAsync(() => gremlinClient.SubmitAsync(requestMsg)); + + evaluationStopWatch.Stop(); + Assert.Contains("ServerTimeout", thrownException.Message); + Assert.Contains(timeOutInMs.ToString(), thrownException.Message); + Assert.True(evaluationStopWatch.ElapsedMilliseconds < scriptSleepTimeInMs); + } + } + + [Fact] + public async Task ShouldThrowForUnsupportedLanguage() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var unknownLanguage = "unknown"; + var requestMsg = + RequestMessage.Build(Tokens.OpsEval) + .AddArgument(Tokens.ArgsGremlin, "1") + .AddArgument(Tokens.ArgsLanguage, unknownLanguage) + .Create(); + + var thrownException = + await Assert.ThrowsAsync(() => gremlinClient.SubmitAsync(requestMsg)); + + Assert.Contains("ScriptEvaluationError", thrownException.Message); + Assert.Contains(unknownLanguage, thrownException.Message); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj new file mode 100644 index 00000000000..f8407a93703 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj @@ -0,0 +1,41 @@ + + + + netcoreapp1.0 + portable + Gremlin.Net.IntegrationTest + Gremlin.Net.IntegrationTest + true + 1.0.4 + false + false + false + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs new file mode 100644 index 00000000000..de91152ba61 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs @@ -0,0 +1,85 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Remote; +using Gremlin.Net.Process.Remote; +using Gremlin.Net.Process.Traversal; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Remote +{ + public class RemoteStrategyTests + { + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); + + [Fact] + public void ShouldSendBytecodeToGremlinServer() + { + const string expectedResult = "gremlin"; + var testBytecode = new Bytecode(); + testBytecode.AddStep("V"); + testBytecode.AddStep("has", "test"); + testBytecode.AddStep("inject", expectedResult); + var testTraversal = CreateTraversalWithRemoteStrategy(testBytecode); + + var actualResult = testTraversal.Next(); + + Assert.Equal(expectedResult, actualResult); + } + + [Fact] + public async Task ShouldSendBytecodeToGremlinServerAsynchronouslyForTraversalPromise() + { + const string expectedResult = "gremlin"; + var testBytecode = new Bytecode(); + testBytecode.AddStep("V"); + testBytecode.AddStep("has", "test"); + testBytecode.AddStep("inject", expectedResult); + var testTraversal = CreateTraversalWithRemoteStrategy(testBytecode); + + var actualResult = await testTraversal.Promise(t => t.Next()); + + Assert.Equal(expectedResult, actualResult); + } + + private DefaultTraversal CreateTraversalWithRemoteStrategy(Bytecode bytecode) + { + var remoteStrategy = + new RemoteStrategy(new DriverRemoteConnection(new GremlinClient(new GremlinServer(TestHost, TestPort)))); + return new TestTraversal(remoteStrategy, bytecode); + } + } + + internal class TestTraversal : DefaultTraversal + { + public TestTraversal(ITraversalStrategy traversalStrategy, Bytecode bytecode) + { + TraversalStrategies.Add(traversalStrategy); + Bytecode = bytecode; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..5dea6f08894 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#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.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Gremlin.Net.IntegrationTest")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("cc54abe3-13d2-491c-81e2-4d0355abfa93")] \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Util/RequestMessageProvider.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Util/RequestMessageProvider.cs new file mode 100644 index 00000000000..eb8735f183b --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Util/RequestMessageProvider.cs @@ -0,0 +1,54 @@ +#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.Driver; +using Gremlin.Net.Driver.Messages; + +namespace Gremlin.Net.IntegrationTest.Util +{ + internal class RequestMessageProvider + { + public string GetSleepGremlinScript(int sleepTimeInMs) + { + return $"Thread.sleep({sleepTimeInMs});"; + } + + public RequestMessage GetSleepMessage(int sleepTimeInMs) + { + var gremlinScript = $"Thread.sleep({nameof(sleepTimeInMs)});"; + var bindings = new Dictionary {{nameof(sleepTimeInMs), sleepTimeInMs}}; + return + RequestMessage.Build(Tokens.OpsEval) + .AddArgument(Tokens.ArgsGremlin, gremlinScript) + .AddArgument(Tokens.ArgsBindings, bindings) + .Create(); + } + + public RequestMessage GetDummyMessage() + { + var gremlinScript = "1"; + return RequestMessage.Build(Tokens.OpsEval).AddArgument(Tokens.ArgsGremlin, gremlinScript).Create(); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json new file mode 100644 index 00000000000..38007ec1c9c --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json @@ -0,0 +1,4 @@ +{ + "TestServerIpAddress": "localhost", + "TestServerPort": 45950 +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj new file mode 100644 index 00000000000..2345f3182b5 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj @@ -0,0 +1,22 @@ + + + + netcoreapp1.1 + + + + + + + + + + + + + + + + + + diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs new file mode 100644 index 00000000000..de0a0b76202 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs @@ -0,0 +1,44 @@ +#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 Gremlin.Net.Process.Traversal; +using Xunit; + +namespace Gremlin.Net.Process.UnitTest.Traversal +{ + public class BytecodeTests + { + [Fact] + public void ShouldUseBingings() + { + var bytecode = new Bytecode(); + var bindings = new Bindings(); + + bytecode.AddStep("hasLabel", bindings.Of("label", "testLabel")); + + var arg = bytecode.StepInstructions[0].Arguments[0]; + var binding = arg as Binding; + Assert.Equal(new Binding("label", "testLabel"), binding); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs new file mode 100644 index 00000000000..2e7dc5e0c7d --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs @@ -0,0 +1,109 @@ +#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 Gremlin.Net.Process.Traversal.Strategy; +using Gremlin.Net.Process.Traversal.Strategy.Optimization; +using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Xunit; + +namespace Gremlin.Net.Process.UnitTest.Traversal.Strategy +{ + public class StrategyTests + { + [Fact] + public void ShouldReturnFalseForEqualsOfStrategiesWithDifferentStrategyNames() + { + var firstStrategy = new TestStrategy("aConfigKey", "aConfigValue"); + var secondStrategy = new IncidentToAdjacentStrategy(); + + var areEqual = firstStrategy.Equals(secondStrategy); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnTrueForEqualsOfStrategiesWithEqualNamesButDifferentConfigurations() + { + var firstStrategy = new TestStrategy("aConfigKey", "aConfigValue"); + var secondStrategy = new TestStrategy("anotherKey", "anotherValue"); + + var areEqual = firstStrategy.Equals(secondStrategy); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnDifferentHashcodesForStrategiesWithDifferentNames() + { + var firstStrategy = new TestStrategy(); + var secondStrategy = new ReadOnlyStrategy(); + + var firstHashCode = firstStrategy.GetHashCode(); + var secondHashCode = secondStrategy.GetHashCode(); + + Assert.NotEqual(firstHashCode, secondHashCode); + } + + [Fact] + public void ShouldReturnEqualHashcodesForStrategiesWithEqualNamesButDifferentConfigurations() + { + var firstStrategy = new TestStrategy("aConfigKey", "aConfigValue"); + var secondStrategy = new TestStrategy("anotherKey", "anotherValue"); + + var firstHashCode = firstStrategy.GetHashCode(); + var secondHashCode = secondStrategy.GetHashCode(); + + Assert.Equal(firstHashCode, secondHashCode); + } + + [Fact] + public void ShouldReturnClassNameForStrategyNameProperty() + { + var testStrategy = new TestStrategy(); + + Assert.Equal("TestStrategy", testStrategy.StrategyName); + } + + [Fact] + public void ShouldReturnStrategyNameWhenForToString() + { + var testStrategy = new TestStrategy(); + + var strategyStr = testStrategy.ToString(); + + Assert.Equal("TestStrategy", strategyStr); + } + } + + internal class TestStrategy : AbstractTraversalStrategy + { + public TestStrategy() + { + } + + public TestStrategy(string configKey, dynamic configValue) + { + Configuration[configKey] = configValue; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs new file mode 100644 index 00000000000..34f88dfaf57 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs @@ -0,0 +1,51 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using System.Linq; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Process.UnitTest.Traversal +{ + public class TestTraversal : Process.Traversal.DefaultTraversal + { + public TestTraversal(List traverserObjs) + { + var traversers = new List(traverserObjs.Count); + traverserObjs.ForEach(o => traversers.Add(new Traverser(o))); + Traversers = traversers; + } + + public TestTraversal(IReadOnlyList traverserObjs, IReadOnlyList traverserBulks) + { + var traversers = new List(traverserObjs.Count); + traversers.AddRange(traverserObjs.Select((t, i) => new Traverser(t, traverserBulks[i]))); + Traversers = traversers; + } + + public TestTraversal(IList traversalStrategies) + { + TraversalStrategies = traversalStrategies; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs new file mode 100644 index 00000000000..d64344068ef --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs @@ -0,0 +1,50 @@ +#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.Threading.Tasks; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Process.UnitTest.Traversal +{ + public class TestTraversalStrategy : ITraversalStrategy + { + private readonly IEnumerable _traversers; + + public TestTraversalStrategy(IEnumerable traversersToAddOnApplication) + { + _traversers = traversersToAddOnApplication; + } + + public void Apply(ITraversal traversal) + { + traversal.Traversers = _traversers; + } + + public Task ApplyAsync(ITraversal traversal) + { + traversal.Traversers = _traversers; + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs new file mode 100644 index 00000000000..a823a5d6d5a --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs @@ -0,0 +1,177 @@ +#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.Traversal; +using Moq; +using Xunit; + +namespace Gremlin.Net.Process.UnitTest.Traversal +{ + public class TraversalTests + { + [Theory] + [InlineData(1)] + [InlineData("test")] + public void ShouldReturnAvailableTraverserObjWhenNextIsCalled(object traverserObj) + { + var traversal = new TestTraversal(new List {traverserObj}); + + var actualObj = traversal.Next(); + + Assert.Equal(traverserObj, actualObj); + } + + [Theory] + [InlineData(3)] + [InlineData(10)] + public void ShouldReturnCorrectNrOfResultObjsWhenNextIsCalledWithAmountArgument(int nrOfResults) + { + var objs = new List(20); + for (var i = 0; i < 20; i++) + objs.Add(i); + var traversal = new TestTraversal(objs); + + var traversedObjs = traversal.Next(nrOfResults); + + var traversedObjsList = traversedObjs.ToList(); + Assert.Equal(nrOfResults, traversedObjsList.Count); + for (var i = 0; i < nrOfResults; i++) + Assert.Equal(objs[i], traversedObjsList[i]); + } + + private List UnfoldBulks(IReadOnlyList objs, IReadOnlyList bulks) + { + var unfoldedObjs = new List(); + for (var traverserIdx = 0; traverserIdx < objs.Count; traverserIdx++) + for (var currentBulkObjIdx = 0; currentBulkObjIdx < bulks[traverserIdx]; currentBulkObjIdx++) + unfoldedObjs.Add(objs[traverserIdx]); + return unfoldedObjs; + } + + [Fact] + public void ShouldDrainAllTraversersWhenIterateIsCalled() + { + var someObjs = new List {1, 2, 3}; + var traversal = new TestTraversal(someObjs); + + var drainedTraversal = traversal.Iterate(); + + Assert.Null(drainedTraversal.Next()); + } + + [Fact] + public void ShouldReturnNullWhenNextIsCalledAndNoTraverserIsAvailable() + { + var expectedFirstObj = 1; + var traversal = new TestTraversal(new List {expectedFirstObj}); + + var actualFirstObj = traversal.Next(); + var actualSecondObj = traversal.Next(); + + Assert.Equal(expectedFirstObj, actualFirstObj); + Assert.Null(actualSecondObj); + } + + [Fact] + public void ShouldReturnTraversalsTraverserWhenNextTraverserIsCalled() + { + var someObjs = new List {1, 2, 3}; + var traversal = new TestTraversal(someObjs); + + var traverser = traversal.NextTraverser(); + + Assert.Equal(traversal.Traversers.First(), traverser); + } + + [Fact] + public void ShouldThrowNotSupportedExceptionWhenResetIsCalled() + { + var someObjs = new List {1, 2, 3}; + var traversal = new TestTraversal(someObjs); + + Assert.Throws(() => traversal.Reset()); + } + + [Fact] + public void ShouldReturnAllTraverserObjsWhenToListIsCalled() + { + var expectedObjs = new List {1, 2, 3}; + var traversal = new TestTraversal(expectedObjs); + + var traversedObjs = traversal.ToList(); + + Assert.Equal(expectedObjs, traversedObjs); + } + + [Fact] + public void ShouldReturnAllTraverserObjWithoutDuplicatesWhenToSetIsCalled() + { + var traverserObjs = new List {1, 1, 2, 3}; + var traversal = new TestTraversal(traverserObjs); + + var traversedObjSet = traversal.ToSet(); + + Assert.Equal(3, traversedObjSet.Count); + Assert.Equal(new HashSet(traverserObjs), traversedObjSet); + } + + [Fact] + public void ShouldApplyStrategiesWhenNextIsCalledAndNoTraversersPresent() + { + const int expectedObj = 531; + var testStrategy = new TestTraversalStrategy(new List {new Traverser(expectedObj)}); + var testTraversal = new TestTraversal(new List {testStrategy}); + + var actualObj = testTraversal.Next(); + + Assert.Equal(expectedObj, actualObj); + } + + [Fact] + public void ShouldBeUnfoldTraverserBulksWhenToListIsCalled() + { + var objs = new List {1, 2, 3}; + var bulks = new List {3, 2, 1}; + var traversal = new TestTraversal(objs, bulks); + + var traversedObjs = traversal.ToList(); + + var expectedObjs = UnfoldBulks(objs, bulks); + Assert.Equal(expectedObjs, traversedObjs); + } + + [Fact] + public void ShouldDisposeSideEffectsWhenDisposeIsCalled() + { + var sideEffectsMock = new Mock(); + var traversal = new TestTraversal(new List()) {SideEffects = sideEffectsMock.Object}; + + traversal.Dispose(); + + sideEffectsMock.Verify(m => m.Dispose()); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs new file mode 100644 index 00000000000..4f6d2b5f34b --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs @@ -0,0 +1,75 @@ +#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 Gremlin.Net.Process.Traversal; +using Xunit; + +namespace Gremlin.Net.Process.UnitTest.Traversal +{ + public class TraverserTests + { + [Fact] + public void ShouldReturnFalseForEqualsWhereOtherIsNull() + { + var traverser = new Traverser("anObject"); + + var areEqual = traverser.Equals(null); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnTrueForEqualsWithSameObjectAndDifferentBulk() + { + var firstTraverser = new Traverser("anObject", 1234); + var secondTraverser = new Traverser("anObject", 9876); + + var areEqual = firstTraverser.Equals(secondTraverser); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnTrueForEqualsObjectWithSameObjectAndDifferentBulk() + { + var firstTraverser = new Traverser("anObject", 1234); + object secondTraverser = new Traverser("anObject", 9876); + + var areEqual = firstTraverser.Equals(secondTraverser); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnEqualHashcodesForTraversersWithSameObjectAndDifferentBulk() + { + var firstTraverser = new Traverser("anObject", 1234); + var secondTraverser = new Traverser("anObject", 9876); + + var firstHashCode = firstTraverser.GetHashCode(); + var secondHashCode = secondTraverser.GetHashCode(); + + Assert.Equal(firstHashCode, secondHashCode); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs new file mode 100644 index 00000000000..7ed9c96fef8 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/DriverRemoteConnectionTests.cs @@ -0,0 +1,51 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Remote; +using Moq; +using Xunit; + +namespace Gremlin.Net.UnitTest.Driver +{ + public class DriverRemoteConnectionTests + { + [Fact] + public void ShouldDisposeProvidedGremlinClientOnDispose() + { + var gremlinClientMock = new Mock(); + var driverRemoteConnection = new DriverRemoteConnection(gremlinClientMock.Object); + + driverRemoteConnection.Dispose(); + + gremlinClientMock.Verify(m => m.Dispose()); + } + + [Fact] + public void ShouldThrowWhenGivenNullAsGremlinClient() + { + Assert.Throws(() => new DriverRemoteConnection(null)); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GremlinServerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GremlinServerTests.cs new file mode 100644 index 00000000000..54c5a06962f --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/GremlinServerTests.cs @@ -0,0 +1,66 @@ +#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 Gremlin.Net.Driver; +using Xunit; + +namespace Gremlin.Net.UnitTest.Driver +{ + public class GremlinServerTests + { + [Theory] + [InlineData("localhost", 8182)] + [InlineData("1.2.3.4", 5678)] + public void ShouldBuildCorrectUri(string host, int port) + { + var gremlinServer = new GremlinServer(host, port); + + var uri = gremlinServer.Uri; + + Assert.Equal($"ws://{host}:{port}/gremlin", uri.AbsoluteUri); + } + + [Fact] + public void ShouldBuildCorrectUriForSsl() + { + var host = "localhost"; + var port = 8181; + var gremlinServer = new GremlinServer(host, port, true); + + var uri = gremlinServer.Uri; + + Assert.Equal($"wss://{host}:{port}/gremlin", uri.AbsoluteUri); + } + + [Fact] + public void ShouldUseCorrectDefaultPortWhenNoneProvided() + { + var host = "testHost"; + var gremlinServer = new GremlinServer(host); + + var uri = gremlinServer.Uri; + + Assert.Equal(8182, uri.Port); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/RequestMessageBuilderTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/RequestMessageBuilderTests.cs new file mode 100644 index 00000000000..cc5d2eed0f6 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/RequestMessageBuilderTests.cs @@ -0,0 +1,41 @@ +#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 Gremlin.Net.Driver; +using Gremlin.Net.Driver.Messages; +using Xunit; + +namespace Gremlin.Net.UnitTest.Driver +{ + public class RequestMessageBuilderTests + { + [Fact] + public void ShouldUseUniqueRequestIds() + { + var firstMsg = RequestMessage.Build(Tokens.OpsEval).Create(); + var secondMsg = RequestMessage.Build(Tokens.OpsEval).Create(); + + Assert.NotEqual(firstMsg.RequestId, secondMsg.RequestId); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj new file mode 100644 index 00000000000..3d2da0ded27 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj @@ -0,0 +1,35 @@ + + + + netcoreapp1.0 + portable + Gremlin.Net.UnitTest + Gremlin.Net.UnitTest + true + 1.0.4 + false + false + false + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..f339aa098d5 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#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.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Gremlin.Net.UnitTest")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("1fab781b-b857-4ad2-bec8-e20c214d9e21")] \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/EdgeTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/EdgeTests.cs new file mode 100644 index 00000000000..e6365807ac1 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/EdgeTests.cs @@ -0,0 +1,57 @@ +#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 Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure +{ + public class EdgeTests + { + [Fact] + public void ShouldAssignPropertiesCorrectly() + { + const int id = 2; + var outV = new Vertex(1); + const string edgeLabel = "said"; + var inV = new Vertex("hello", "phrase"); + + var edge = new Edge(id, outV, edgeLabel, inV); + + Assert.Equal(outV, edge.OutV); + Assert.Equal(inV, edge.InV); + Assert.Equal(edgeLabel, edge.Label); + Assert.NotEqual(edge.InV, edge.OutV); + } + + [Fact] + public void ShouldReturnCommonStringRepresentationForToString() + { + var edge = new Edge(2, new Vertex(1), "said", new Vertex("hello", "phrase")); + + var edgeStr = edge.ToString(); + + Assert.Equal("e[2][1-said->hello]", edgeStr); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs new file mode 100644 index 00000000000..e367124522c --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs @@ -0,0 +1,153 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure.IO.GraphSON; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON +{ + public class BytecodeGraphSONSerializerTests + { + private GraphSONWriter CreateGraphSONWriter() + { + return new GraphSONWriter(); + } + + [Fact] + public void ShouldSerializeByteCodeWithNestedTraversal() + { + var bytecode = new Bytecode(); + bytecode.AddStep("V"); + var nestedBytecode = new Bytecode(); + var nestedTraversal = new TestTraversal(nestedBytecode); + nestedBytecode.AddStep("out"); + bytecode.AddStep("repeat", nestedTraversal); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSON = graphsonWriter.WriteObject(bytecode); + + var expectedGraphSon = + "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"repeat\",{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"out\"]]}}]]}}"; + Assert.Equal(expectedGraphSon, graphSON); + } + + [Fact] + public void ShouldSerializeBytecodeWithNumbers() + { + var bytecode = new Bytecode(); + bytecode.AddStep("V", (long) 1); + bytecode.AddStep("has", "age", 20); + bytecode.AddStep("has", "height", 6.5); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSON = graphsonWriter.WriteObject(bytecode); + + var expectedGraphSon = + "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\",{\"@type\":\"g:Int64\",\"@value\":1}],[\"has\",\"age\",{\"@type\":\"g:Int32\",\"@value\":20}],[\"has\",\"height\",{\"@type\":\"g:Double\",\"@value\":6.5}]]}}"; + Assert.Equal(expectedGraphSon, graphSON); + } + + [Fact] + public void ShouldSerialize_g_V() + { + var bytecode = new Bytecode(); + bytecode.AddStep("V"); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSON = graphsonWriter.WriteObject(bytecode); + + Assert.Equal("{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"]]}}", graphSON); + } + + [Fact] + public void ShouldSerialize_g_V_Count() + { + var bytecode = new Bytecode(); + bytecode.AddStep("V"); + bytecode.AddStep("count"); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSON = graphsonWriter.WriteObject(bytecode); + + var expectedGraphSon = "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"count\"]]}}"; + Assert.Equal(expectedGraphSon, graphSON); + } + + [Fact] + public void ShouldSerialize_g_V_HasXPerson_Name_GremlinX_Count() + { + var bytecode = new Bytecode(); + bytecode.AddStep("V"); + bytecode.AddStep("has", "Person", "Name", "Gremlin"); + bytecode.AddStep("count"); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSON = graphsonWriter.WriteObject(bytecode); + + var expectedGraphSon = + "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"has\",\"Person\",\"Name\",\"Gremlin\"],[\"count\"]]}}"; + Assert.Equal(expectedGraphSon, graphSON); + } + + [Fact] + public void ShouldSerializeBytecodeWithSourcesStep() + { + var bytecode = new Bytecode(); + bytecode.AddSource("withSideEffect", "a", new List {"josh", "peter"}); + bytecode.AddStep("V", 1); + bytecode.AddStep("values", "name"); + bytecode.AddStep("where", new TraversalPredicate("within", "a")); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSON = graphsonWriter.WriteObject(bytecode); + + var expectedGraphSon = + "{\"@type\":\"g:Bytecode\",\"@value\":{\"source\":[[\"withSideEffect\",\"a\",[\"josh\",\"peter\"]]],\"step\":[[\"V\",{\"@type\":\"g:Int32\",\"@value\":1}],[\"values\",\"name\"],[\"where\",{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"within\",\"value\":\"a\"}}]]}}"; + Assert.Equal(expectedGraphSon, graphSON); + } + + [Fact] + public void ShouldSerializeBytecodeWithBindings() + { + var bytecode = new Bytecode(); + bytecode.AddStep("V", new Binding("id", 123)); + var graphsonWriter = CreateGraphSONWriter(); + + var graphSon = graphsonWriter.WriteObject(bytecode); + + var expectedGraphSon = + "{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\",{\"@type\":\"g:Binding\",\"@value\":{\"value\":{\"@type\":\"g:Int32\",\"@value\":123},\"key\":\"id\"}}]]}}"; + Assert.Equal(expectedGraphSon, graphSon); + } + } + + internal class TestTraversal : DefaultTraversal + { + public TestTraversal(Bytecode bytecode) + { + Bytecode = bytecode; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs new file mode 100644 index 00000000000..747a94e2f88 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs @@ -0,0 +1,308 @@ +#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 Gremlin.Net.Structure; +using Gremlin.Net.Structure.IO.GraphSON; +using Moq; +using Newtonsoft.Json.Linq; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON +{ + public class GraphSONReaderTests + { + private GraphSONReader CreateStandardGraphSONReader() + { + return new GraphSONReader(); + } + + [Fact] + public void ShouldDeserializeWithCustomDeserializerForNewType() + { + var deserializerByGraphSONType = new Dictionary + { + {"NS:TestClass", new TestGraphSONDeserializer()} + }; + var reader = new GraphSONReader(deserializerByGraphSONType); + var graphSON = "{\"@type\":\"NS:TestClass\",\"@value\":\"test\"}"; + + var jObject = JObject.Parse(graphSON); + var readObj = reader.ToObject(jObject); + + Assert.Equal("test", readObj.Value); + } + + [Fact] + public void ShouldDeserializeWithCustomDeserializerForCommonType() + { + var customSerializerMock = new Mock(); + var overrideTypeString = "g:Int64"; + var customSerializerByType = new Dictionary + { + {overrideTypeString, customSerializerMock.Object} + }; + var reader = new GraphSONReader(customSerializerByType); + + + reader.ToObject(JObject.Parse($"{{\"@type\":\"{overrideTypeString}\",\"@value\":12}}")); + + customSerializerMock.Verify(m => m.Objectify(It.IsAny(), It.IsAny())); + } + + [Fact] + public void ShouldDeserializeDateToDateTime() + { + var graphSon = "{\"@type\":\"g:Date\",\"@value\":1475583442552}"; + var reader = CreateStandardGraphSONReader(); + + DateTime readDateTime = reader.ToObject(JObject.Parse(graphSon)); + + var expectedDateTime = TestUtils.FromJavaTime(1475583442552); + Assert.Equal(expectedDateTime, readDateTime); + } + + [Fact] + public void ShouldDeserializeDictionary() + { + var serializedDict = "{\"age\":[{\"@type\":\"g:Int32\",\"@value\":29}],\"name\":[\"marko\"]}"; + var reader = CreateStandardGraphSONReader(); + + var jObject = JObject.Parse(serializedDict); + var deserializedDict = reader.ToObject(jObject); + + var expectedDict = new Dictionary + { + {"age", new List {29}}, + {"name", new List {"marko"}} + }; + Assert.Equal(expectedDict, deserializedDict); + } + + [Fact] + public void ShouldDeserializeEdge() + { + var graphSon = + "{\"@type\":\"g:Edge\", \"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":17},\"label\":\"knows\",\"inV\":\"x\",\"outV\":\"y\",\"inVLabel\":\"xLab\",\"properties\":{\"aKey\":\"aValue\",\"bKey\":true}}}"; + var reader = CreateStandardGraphSONReader(); + + Edge readEdge = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal((long) 17, readEdge.Id); + Assert.Equal("knows", readEdge.Label); + Assert.Equal(new Vertex("x", "xLabel"), readEdge.InV); + Assert.Equal(new Vertex("y"), readEdge.OutV); + } + + [Fact] + public void ShouldDeserializeInt() + { + var serializedValue = "{\"@type\":\"g:Int32\",\"@value\":5}"; + var reader = CreateStandardGraphSONReader(); + + var jObject = JObject.Parse(serializedValue); + var deserializedValue = reader.ToObject(jObject); + + Assert.Equal(5, deserializedValue); + } + + [Fact] + public void ShouldDeserializeLong() + { + var serializedValue = "{\"@type\":\"g:Int64\",\"@value\":5}"; + var reader = CreateStandardGraphSONReader(); + + var jObject = JObject.Parse(serializedValue); + var deserializedValue = reader.ToObject(jObject); + + Assert.Equal((long) 5, deserializedValue); + } + + [Fact] + public void ShouldDeserializeFloat() + { + var serializedValue = "{\"@type\":\"g:Float\",\"@value\":31.3}"; + var reader = CreateStandardGraphSONReader(); + + var jObject = JObject.Parse(serializedValue); + var deserializedValue = reader.ToObject(jObject); + + Assert.Equal((float) 31.3, deserializedValue); + } + + [Fact] + public void ShouldDeserializeDouble() + { + var serializedValue = "{\"@type\":\"g:Double\",\"@value\":31.2}"; + var reader = CreateStandardGraphSONReader(); + + var jObject = JObject.Parse(serializedValue); + var deserializedValue = reader.ToObject(jObject); + + Assert.Equal(31.2, deserializedValue); + } + + [Fact] + public void ShouldDeserializeList() + { + var serializedValue = "[{\"@type\":\"g:Int32\",\"@value\":5},{\"@type\":\"g:Int32\",\"@value\":6}]"; + var reader = CreateStandardGraphSONReader(); + + var jObject = JArray.Parse(serializedValue); + var deserializedValue = reader.ToObject(jObject); + + Assert.Equal(new List {5, 6}, deserializedValue); + } + + [Fact] + public void ShouldDeserializePath() + { + var graphSon = + "{\"@type\":\"g:Path\",\"@value\":{\"labels\":[[\"a\"],[\"b\",\"c\"],[]],\"objects\":[{\"@type\":\"g:Vertex\",\"@value\":{\"id\":{\"@type\":\"g:Int32\",\"@value\":1},\"label\":\"person\",\"properties\":{\"name\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":0},\"value\":\"marko\",\"label\":\"name\"}}],\"age\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":1},\"value\":{\"@type\":\"g:Int32\",\"@value\":29},\"label\":\"age\"}}]}}},{\"@type\":\"g:Vertex\",\"@value\":{\"id\":{\"@type\":\"g:Int32\",\"@value\":3},\"label\":\"software\",\"properties\":{\"name\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":4},\"value\":\"lop\",\"label\":\"name\"}}],\"lang\":[{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":5},\"value\":\"java\",\"label\":\"lang\"}}]}}},\"lop\"]}}"; + var reader = CreateStandardGraphSONReader(); + + Path readPath = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal("[v[1], v[3], lop]", readPath.ToString()); + Assert.Equal(new Vertex(1), readPath[0]); + Assert.Equal(new Vertex(1), readPath["a"]); + Assert.Equal("lop", readPath[2]); + Assert.Equal(3, readPath.Count); + } + + [Fact] + public void ShouldDeserializePropertyWithEdgeElement() + { + var graphSon = + "{\"@type\":\"g:Property\",\"@value\":{\"key\":\"aKey\",\"value\":{\"@type\":\"g:Int64\",\"@value\":17},\"element\":{\"@type\":\"g:Edge\",\"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":122},\"label\":\"knows\",\"inV\":\"x\",\"outV\":\"y\",\"inVLabel\":\"xLab\"}}}}"; + var reader = CreateStandardGraphSONReader(); + + Property readProperty = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal("aKey", readProperty.Key); + Assert.Equal((long) 17, readProperty.Value); + Assert.Equal(typeof(Edge), readProperty.Element.GetType()); + var edge = readProperty.Element as Edge; + Assert.Equal((long) 122, edge.Id); + Assert.Equal("knows", edge.Label); + Assert.Equal("x", edge.InV.Id); + Assert.Equal("y", edge.OutV.Id); + } + + [Fact] + public void ShouldDeserializeTimestampToDateTime() + { + var graphSon = "{\"@type\":\"g:Timestamp\",\"@value\":1475583442558}"; + var reader = CreateStandardGraphSONReader(); + + DateTime readDateTime = reader.ToObject(JObject.Parse(graphSon)); + + var expectedDateTime = TestUtils.FromJavaTime(1475583442558); + Assert.Equal(expectedDateTime, readDateTime); + } + + [Fact] + public void ShouldDeserializeGuid() + { + var graphSon = "{\"@type\":\"g:UUID\",\"@value\":\"41d2e28a-20a4-4ab0-b379-d810dede3786\"}"; + var reader = CreateStandardGraphSONReader(); + + Guid readGuid = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal(Guid.Parse("41d2e28a-20a4-4ab0-b379-d810dede3786"), readGuid); + } + + [Fact] + public void ShouldDeserializeVertexProperty() + { + var graphSon = + "{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":\"anId\",\"label\":\"aKey\",\"value\":true,\"vertex\":{\"@type\":\"g:Int32\",\"@value\":9}}}"; + var reader = CreateStandardGraphSONReader(); + + VertexProperty readVertexProperty = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal("anId", readVertexProperty.Id); + Assert.Equal("aKey", readVertexProperty.Label); + Assert.True(readVertexProperty.Value); + Assert.NotNull(readVertexProperty.Vertex); + } + + [Fact] + public void ShouldDeserializeVertexPropertyWithLabel() + { + var graphSon = + "{\"@type\":\"g:VertexProperty\", \"@value\":{\"id\":{\"@type\":\"g:Int32\",\"@value\":1},\"label\":\"name\",\"value\":\"marko\"}}"; + var reader = CreateStandardGraphSONReader(); + + VertexProperty readVertexProperty = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal(1, readVertexProperty.Id); + Assert.Equal("name", readVertexProperty.Label); + Assert.Equal("marko", readVertexProperty.Value); + Assert.Null(readVertexProperty.Vertex); + } + + [Fact] + public void ShouldDeserializeVertex() + { + var graphSon = "{\"@type\":\"g:Vertex\", \"@value\":{\"id\":{\"@type\":\"g:Float\",\"@value\":45.23}}}"; + var reader = CreateStandardGraphSONReader(); + + var readVertex = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal(new Vertex(45.23f), readVertex); + } + + [Fact] + public void ShouldDeserializeVertexWithEdges() + { + var graphSon = + "{\"@type\":\"g:Vertex\", \"@value\":{\"id\":{\"@type\":\"g:Int32\",\"@value\":1},\"label\":\"person\",\"outE\":{\"created\":[{\"id\":{\"@type\":\"g:Int32\",\"@value\":9},\"inV\":{\"@type\":\"g:Int32\",\"@value\":3},\"properties\":{\"weight\":{\"@type\":\"g:Double\",\"@value\":0.4}}}],\"knows\":[{\"id\":{\"@type\":\"g:Int32\",\"@value\":7},\"inV\":{\"@type\":\"g:Int32\",\"@value\":2},\"properties\":{\"weight\":{\"@type\":\"g:Double\",\"@value\":0.5}}},{\"id\":{\"@type\":\"g:Int32\",\"@value\":8},\"inV\":{\"@type\":\"g:Int32\",\"@value\":4},\"properties\":{\"weight\":{\"@type\":\"g:Double\",\"@value\":1.0}}}]},\"properties\":{\"name\":[{\"id\":{\"@type\":\"g:Int64\",\"@value\":0},\"value\":\"marko\"}],\"age\":[{\"id\":{\"@type\":\"g:Int64\",\"@value\":1},\"value\":{\"@type\":\"g:Int32\",\"@value\":29}}]}}}"; + var reader = CreateStandardGraphSONReader(); + + var readVertex = reader.ToObject(JObject.Parse(graphSon)); + + Assert.Equal(new Vertex(1), readVertex); + Assert.Equal("person", readVertex.Label); + Assert.Equal(typeof(int), readVertex.Id.GetType()); + } + + [Fact] + public void ShouldDeserializeTraverser() + { + dynamic d = JObject.Parse("{\"@type\":\"g:Traverser\",\"@value\":1}"); + + Assert.NotNull(d); + Assert.Equal("g:Traverser", (string)d["@type"]); + } + } + + internal class TestGraphSONDeserializer : IGraphSONDeserializer + { + public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) + { + return new TestClass {Value = graphsonObject.ToString()}; + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs new file mode 100644 index 00000000000..49786d7766b --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs @@ -0,0 +1,329 @@ +#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 Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; +using Gremlin.Net.Structure.IO.GraphSON; +using Moq; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON +{ + public class GraphSONWriterTests + { + private GraphSONWriter CreateStandardGraphSONWriter() + { + return new GraphSONWriter(); + } + + [Fact] + public void ShouldSerializeInt() + { + var writer = CreateStandardGraphSONWriter(); + + var graphSon = writer.WriteObject(1); + + Assert.Equal("{\"@type\":\"g:Int32\",\"@value\":1}", graphSon); + } + + [Fact] + public void ShouldSerializeLong() + { + var writer = CreateStandardGraphSONWriter(); + + var graphSon = writer.WriteObject((long) 2); + + Assert.Equal("{\"@type\":\"g:Int64\",\"@value\":2}", graphSon); + } + + [Fact] + public void ShouldSerializeFloat() + { + var writer = CreateStandardGraphSONWriter(); + + var graphSon = writer.WriteObject((float) 3.2); + + Assert.Equal("{\"@type\":\"g:Float\",\"@value\":3.2}", graphSon); + } + + [Fact] + public void ShouldSerializeDouble() + { + var writer = CreateStandardGraphSONWriter(); + + var graphSon = writer.WriteObject(3.2); + + Assert.Equal("{\"@type\":\"g:Double\",\"@value\":3.2}", graphSon); + } + + [Fact] + public void ShouldSerializeBoolean() + { + var writer = CreateStandardGraphSONWriter(); + + var graphSon = writer.WriteObject(true); + + Assert.Equal("true", graphSon); + } + + [Fact] + public void ShouldSerializeArray() + { + var writer = CreateStandardGraphSONWriter(); + var array = new[] {5, 6}; + + var serializedGraphSON = writer.WriteObject(array); + + var expectedGraphSON = "[{\"@type\":\"g:Int32\",\"@value\":5},{\"@type\":\"g:Int32\",\"@value\":6}]"; + Assert.Equal(expectedGraphSON, serializedGraphSON); + } + + [Fact] + public void ShouldSerializeBinding() + { + var writer = CreateStandardGraphSONWriter(); + var binding = new Binding("theKey", 123); + + var graphSon = writer.WriteObject(binding); + + const string expected = + "{\"@type\":\"g:Binding\",\"@value\":{\"value\":{\"@type\":\"g:Int32\",\"@value\":123},\"key\":\"theKey\"}}"; + Assert.Equal(expected, graphSon); + } + + [Fact] + public void ShouldSerializeWithCustomSerializerForNewType() + { + var customSerializerByType = new Dictionary + { + {typeof(TestClass), new TestGraphSONSerializer {TestNamespace = "NS"}} + }; + var writer = new GraphSONWriter(customSerializerByType); + var testObj = new TestClass {Value = "test"}; + + var serialized = writer.WriteObject(testObj); + + Assert.Equal("{\"@type\":\"NS:TestClass\",\"@value\":\"test\"}", serialized); + } + + [Fact] + public void ShouldSerializeWithCustomSerializerForCommonType() + { + var customSerializerMock = new Mock(); + var customSerializerByType = new Dictionary + { + {typeof(int), customSerializerMock.Object} + }; + var writer = new GraphSONWriter(customSerializerByType); + + writer.WriteObject(12); + + customSerializerMock.Verify(m => m.Dictify(It.Is(v => v == 12), It.IsAny())); + } + + [Fact] + public void ShouldSerializeDateTime() + { + var writer = CreateStandardGraphSONWriter(); + var dateTime = TestUtils.FromJavaTime(1475583442552); + + var graphSon = writer.WriteObject(dateTime); + + const string expected = "{\"@type\":\"g:Date\",\"@value\":1475583442552}"; + Assert.Equal(expected, graphSon); + } + + [Fact] + public void ShouldSerializeDictionary() + { + var writer = CreateStandardGraphSONWriter(); + var dictionary = new Dictionary + { + {"age", new List {29}}, + {"name", new List {"marko"}} + }; + + var serializedDict = writer.WriteObject(dictionary); + + var expectedGraphSON = "{\"age\":[{\"@type\":\"g:Int32\",\"@value\":29}],\"name\":[\"marko\"]}"; + Assert.Equal(expectedGraphSON, serializedDict); + } + + [Fact] + public void ShouldSerializeEdge() + { + var writer = CreateStandardGraphSONWriter(); + var edge = new Edge(7, new Vertex(0, "person"), "knows", new Vertex(1, "dog")); + + var graphSON = writer.WriteObject(edge); + + const string expected = + "{\"@type\":\"g:Edge\",\"@value\":{\"id\":{\"@type\":\"g:Int32\",\"@value\":7},\"outV\":{\"@type\":\"g:Int32\",\"@value\":0},\"outVLabel\":\"person\",\"label\":\"knows\",\"inV\":{\"@type\":\"g:Int32\",\"@value\":1},\"inVLabel\":\"dog\"}}"; + Assert.Equal(expected, graphSON); + } + + [Fact] + public void ShouldSerializeEnum() + { + var writer = CreateStandardGraphSONWriter(); + + var serializedEnum = writer.WriteObject(T.label); + + var expectedGraphSON = "{\"@type\":\"g:T\",\"@value\":\"label\"}"; + Assert.Equal(expectedGraphSON, serializedEnum); + } + + [Fact] + public void ShouldSerializeList() + { + var writer = CreateStandardGraphSONWriter(); + var list = new List {5, 6}; + + var serializedGraphSON = writer.WriteObject(list.ToArray()); + + var expectedGraphSON = "[{\"@type\":\"g:Int32\",\"@value\":5},{\"@type\":\"g:Int32\",\"@value\":6}]"; + Assert.Equal(expectedGraphSON, serializedGraphSON); + } + + [Fact] + public void ShouldSerializePredicateWithTwoValues() + { + var writer = CreateStandardGraphSONWriter(); + var predicate = new TraversalPredicate("within", new List {1, 2}); + + var serializedPredicate = writer.WriteObject(predicate); + + var expectedGraphSON = + "{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"within\",\"value\":[{\"@type\":\"g:Int32\",\"@value\":1},{\"@type\":\"g:Int32\",\"@value\":2}]}}"; + Assert.Equal(expectedGraphSON, serializedPredicate); + } + + [Fact] + public void ShouldSerializePredicateWithSingleValue() + { + var writer = CreateStandardGraphSONWriter(); + var predicate = new TraversalPredicate("lt", 5); + + var serializedPredicate = writer.WriteObject(predicate); + + var expectedGraphSON = + "{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"lt\",\"value\":{\"@type\":\"g:Int32\",\"@value\":5}}}"; + Assert.Equal(expectedGraphSON, serializedPredicate); + } + + [Fact] + public void ShouldSerializePropertyWithEdgeElement() + { + var writer = CreateStandardGraphSONWriter(); + var property = new Property("aKey", "aValue", new Edge("anId", new Vertex(1), "edgeLabel", new Vertex(2))); + + var graphSON = writer.WriteObject(property); + + const string expected = + "{\"@type\":\"g:Property\",\"@value\":{\"key\":\"aKey\",\"value\":\"aValue\",\"element\":{\"@type\":\"g:Edge\",\"@value\":{\"id\":\"anId\",\"outV\":{\"@type\":\"g:Int32\",\"@value\":1},\"label\":\"edgeLabel\",\"inV\":{\"@type\":\"g:Int32\",\"@value\":2}}}}}"; + Assert.Equal(expected, graphSON); + } + + [Fact] + public void ShouldSerializePropertyWithVertexPropertyElement() + { + var writer = CreateStandardGraphSONWriter(); + var property = new Property("name", "marko", + new VertexProperty("anId", "aKey", 21345, new Vertex("vertexId"))); + + var graphSON = writer.WriteObject(property); + + const string expected = + "{\"@type\":\"g:Property\",\"@value\":{\"key\":\"name\",\"value\":\"marko\",\"element\":{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":\"anId\",\"label\":\"aKey\",\"vertex\":\"vertexId\"}}}}"; + Assert.Equal(expected, graphSON); + } + + [Fact] + public void ShouldSerializeVertexProperty() + { + var writer = CreateStandardGraphSONWriter(); + var vertexProperty = new VertexProperty("blah", "keyA", true, new Vertex("stephen")); + + var graphSON = writer.WriteObject(vertexProperty); + + const string expected = + "{\"@type\":\"g:VertexProperty\",\"@value\":{\"id\":\"blah\",\"label\":\"keyA\",\"value\":true,\"vertex\":\"stephen\"}}"; + Assert.Equal(expected, graphSON); + } + + [Fact] + public void ShouldSerializeGuid() + { + var writer = CreateStandardGraphSONWriter(); + var guid = Guid.Parse("41d2e28a-20a4-4ab0-b379-d810dede3786"); + + var graphSon = writer.WriteObject(guid); + + const string expected = "{\"@type\":\"g:UUID\",\"@value\":\"41d2e28a-20a4-4ab0-b379-d810dede3786\"}"; + Assert.Equal(expected, graphSon); + } + + [Fact] + public void ShouldSerializeVertex() + { + var writer = CreateStandardGraphSONWriter(); + var vertex = new Vertex(45.23f); + + var graphSON = writer.WriteObject(vertex); + + const string expected = + "{\"@type\":\"g:Vertex\",\"@value\":{\"id\":{\"@type\":\"g:Float\",\"@value\":45.23},\"label\":\"vertex\"}}"; + Assert.Equal(expected, graphSON); + } + + [Fact] + public void ShouldSerializeVertexWithLabel() + { + var writer = CreateStandardGraphSONWriter(); + var vertex = new Vertex((long) 123, "project"); + + var graphSON = writer.WriteObject(vertex); + + const string expected = + "{\"@type\":\"g:Vertex\",\"@value\":{\"id\":{\"@type\":\"g:Int64\",\"@value\":123},\"label\":\"project\"}}"; + Assert.Equal(expected, graphSON); + } + } + + internal enum T + { + label + } + + internal class TestGraphSONSerializer : IGraphSONSerializer + { + public string TestNamespace { get; set; } + + public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) + { + return GraphSONUtil.ToTypedValue(nameof(TestClass), objectData.Value, TestNamespace); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs new file mode 100644 index 00000000000..4bdb1416614 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/StrategyWriterTests.cs @@ -0,0 +1,66 @@ +#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 Gremlin.Net.Process.Traversal; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Structure.IO.GraphSON; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON +{ + public class StrategyWriterTests + { + private GraphSONWriter CreateGraphSONWriter() + { + return new GraphSONWriter(); + } + + [Fact] + public void ShouldSerializeSubgraphStrategyWithoutValues() + { + var subgraphStrategy = new SubgraphStrategy(); + var writer = CreateGraphSONWriter(); + + var graphSon = writer.WriteObject(subgraphStrategy); + + const string expected = "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{}}"; + Assert.Equal(expected, graphSon); + } + + [Fact] + public void ShouldDeserializeSubgraphStrategyWithVertexCriterion() + { + var vertexCriterionBytecode = new Bytecode(); + vertexCriterionBytecode.AddStep("has", "name", "marko"); + var vertexCriterion = new TestTraversal(vertexCriterionBytecode); + var subgraphStrategy = new SubgraphStrategy(vertexCriterion); + var writer = CreateGraphSONWriter(); + + var graphSon = writer.WriteObject(subgraphStrategy); + + const string expected = + "{\"@type\":\"g:SubgraphStrategy\",\"@value\":{\"vertices\":{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"has\",\"name\",\"marko\"]]}}}}"; + Assert.Equal(expected, graphSon); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs new file mode 100644 index 00000000000..13d1bca9e7e --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestClass.cs @@ -0,0 +1,30 @@ +#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 + +namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON +{ + internal class TestClass + { + public dynamic Value { get; set; } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestUtils.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestUtils.cs new file mode 100644 index 00000000000..7ed754237b6 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/TestUtils.cs @@ -0,0 +1,36 @@ +#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; + +namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON +{ + internal class TestUtils + { + public static DateTime FromJavaTime(long javaTimestamp) + { + var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + return epoch.AddMilliseconds(javaTimestamp); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs new file mode 100644 index 00000000000..e4ffb6e17f0 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PathTests.cs @@ -0,0 +1,416 @@ +#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.Structure; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure +{ + public class PathTests + { + [Fact] + public void ShouldAssignPropertiesCorrectly() + { + var labels = new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }; + var objects = new List {1, new Vertex(1), "hello"}; + + var path = new Path(labels, objects); + + Assert.Equal(labels, path.Labels); + Assert.Equal(objects, path.Objects); + } + + [Fact] + public void ShouldReturnTrueForContainsKeyWhenGivenKeyExists() + { + var labels = new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }; + var path = new Path(labels, new List()); + + var containsKey = path.ContainsKey("c"); + + Assert.True(containsKey); + } + + [Fact] + public void ShouldReturnFalseForContainsKeyWhenGivenKeyDoesNotExist() + { + var labels = new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }; + var path = new Path(labels, new List()); + + var containsKey = path.ContainsKey("z"); + + Assert.False(containsKey); + } + + [Fact] + public void ShouldReturnCountOfObjectsForCountProperty() + { + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(new List>(), objects); + + var count = path.Count; + + Assert.Equal(3, count); + } + + [Fact] + public void ShouldEnumeratorObjectsIntoListWhenToListIsCalled() + { + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(new List>(), objects); + + var enumeratedObj = path.ToList(); + + Assert.Equal(objects, enumeratedObj); + } + + [Fact] + public void ShouldReturnTrueForEqualsOfTwoEqualPaths() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List {1, new Vertex(1), "hello"}); + var secondPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List {1, new Vertex(1), "hello"}); + + var equals = firstPath.Equals(secondPath); + + Assert.True(equals); + } + + [Fact] + public void ShouldReturnFalseForEqualsOfPathsWithDifferentLabels() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List {1, new Vertex(1), "hello"}); + var secondPath = + new Path( + new List> + { + new List {"a"}, + new List {"c", "b"}, + new List() + }, new List {1, new Vertex(1), "hello"}); + + var equals = firstPath.Equals(secondPath); + + Assert.False(equals); + } + + [Fact] + public void ShouldReturnFalseForEqualsOfPathsWithDifferentObjects() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List {1, new Vertex(1), "hello"}); + var secondPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List {3, new Vertex(1), "hello"}); + + var equals = firstPath.Equals(secondPath); + + Assert.False(equals); + } + + [Fact] + public void ShouldReturnTrueForEqualsObjectOfTwoEqualPaths() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + object secondPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + + var equals = firstPath.Equals(secondPath); + + Assert.True(equals); + } + + [Fact] + public void ShouldReturnFalseForEqualsObjectOfPathsWithDifferentLabels() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + object secondPath = + new Path( + new List> + { + new List {"a"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + + var equals = firstPath.Equals(secondPath); + + Assert.False(equals); + } + + [Fact] + public void ShouldReturnFalseForEqualsObjectOfPathsWithDifferentObjects() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + object secondPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 3, new Vertex(1), "hello" }); + + var equals = firstPath.Equals(secondPath); + + Assert.False(equals); + } + + [Fact] + public void ShouldReturnFalseForEqualsWhereOtherIsNull() + { + var path = new Path(new List> {new List {"a", "b"},}, new List {1}); + + var equals = path.Equals(null); + + Assert.False(equals); + } + + [Fact] + public void ShouldReturnEqualHashcodesForEqualPaths() + { + var firstPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + var secondPath = + new Path( + new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }, new List { 1, new Vertex(1), "hello" }); + + var firstHashCode = firstPath.GetHashCode(); + var secondHashCode = secondPath.GetHashCode(); + + Assert.Equal(firstHashCode, secondHashCode); + } + + [Fact] + public void ShouldThrowWhenInvalidIndexIsAccessed() + { + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(new List>(), objects); + + Assert.Throws(() => path[3]); + } + + [Fact] + public void ShouldReturnObjectsByTheirIndex() + { + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(new List>(), objects); + + Assert.Equal(1, path[0]); + Assert.Equal(new Vertex(1), path[1]); + Assert.Equal("hello", path[2]); + } + + [Fact] + public void ShouldReturnAllObjectsWhenTheirKeyIsAccessed() + { + var labels = new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }; + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(labels, objects); + + var bObjects = path["b"]; + + Assert.Equal(new List {1, new Vertex(1)}, bObjects); + } + + [Fact] + public void ShouldReturnObjectsByTheirKey() + { + var labels = new List> + { + new List {"a"}, + new List {"c", "b"}, + new List() + }; + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(labels, objects); + + Assert.Equal(1, path["a"]); + Assert.Equal(new Vertex(1), path["c"]); + Assert.Equal(new Vertex(1), path["b"]); + } + + [Fact] + public void ShouldThrowWhenUnknownKeyIsAccessed() + { + var path = new Path(new List>(), new List()); + + Assert.Throws(() => path["unknownKey"]); + } + + [Fact] + public void ShouldReturnCommonStringRepresentationForToString() + { + var labels = new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }; + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(labels, objects); + + var pathStr = path.ToString(); + + Assert.Equal("[1, v[1], hello]", pathStr); + } + + [Fact] + public void ShouldReturnTrueAndObjectsForTryGetWhenKeyWithMultipleObjectsIsProvided() + { + var labels = new List> + { + new List {"a", "b"}, + new List {"c", "b"}, + new List() + }; + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(labels, objects); + + var success = path.TryGetValue("b", out object actualObj); + + Assert.True(success); + Assert.Equal(new List {1, new Vertex(1)}, actualObj); + } + + [Fact] + public void ShouldReturnTrueAndCorrectObjectForTryGet() + { + var labels = new List> + { + new List {"a"}, + new List {"c", "b"}, + new List() + }; + var objects = new List {1, new Vertex(1), "hello"}; + var path = new Path(labels, objects); + + var success = path.TryGetValue("b", out object actualObj); + + Assert.True(success); + Assert.Equal(new Vertex(1), actualObj); + } + + [Fact] + public void ShouldReturnFalseForTryGetWhenUnknownKeyIsProvided() + { + var path = new Path(new List>(), new List()); + + var success = path.TryGetValue("unknownKey", out object _); + + Assert.False(success); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PropertyTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PropertyTests.cs new file mode 100644 index 00000000000..e457dbd5c79 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/PropertyTests.cs @@ -0,0 +1,165 @@ +#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 Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure +{ + public class PropertyTests + { + [Fact] + public void ShouldAssignPropertiesCorrectly() + { + const string key = "age"; + const int value = 29; + var element = new Vertex(1); + + var property = new Property(key, value, element); + + Assert.Equal(key, property.Key); + Assert.Equal(value, property.Value); + Assert.Equal(element, property.Element); + } + + [Fact] + public void ShouldReturnTrueForEqualsOfTwoEqualProperties() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + var secondProperty = new Property("age", 29, new Vertex(1)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsWhereOtherIsNull() + { + var property = new Property("age", 29, new Vertex(1)); + + var areEqual = property.Equals(null); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsOfPropertiesWithDifferentKeys() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + var secondProperty = new Property("aDifferentKey", 29, new Vertex(1)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsOfPropertiesWithDifferentValues() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + var secondProperty = new Property("age", 12, new Vertex(1)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsOfPropertiesWithDifferentElements() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + var secondProperty = new Property("age", 29, new Vertex(1234)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnTrueForEqualsObjectOfTwoEqualProperties() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + object secondProperty = new Property("age", 29, new Vertex(1)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsObjectOfPropertiesWithDifferentKeys() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + object secondProperty = new Property("aDifferentKey", 29, new Vertex(1)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsObjectOfPropertiesWithDifferentValues() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + object secondProperty = new Property("age", 12, new Vertex(1)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsObjectOfPropertiesWithDifferentElements() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + object secondProperty = new Property("age", 29, new Vertex(1234)); + + var areEqual = firstProperty.Equals(secondProperty); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnEqualHashcodesForEqualProperties() + { + var firstProperty = new Property("age", 29, new Vertex(1)); + var secondProperty = new Property("age", 29, new Vertex(1)); + + var firstHashCode = firstProperty.GetHashCode(); + var secondHashCode = secondProperty.GetHashCode(); + + Assert.Equal(firstHashCode, secondHashCode); + } + + [Fact] + public void ShouldReturnCommonStringRepresentationForToString() + { + var property = new Property("age", 29, new Vertex(1)); + + var stringRepresentation = property.ToString(); + + Assert.Equal("p[age->29]", stringRepresentation); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexPropertyTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexPropertyTests.cs new file mode 100644 index 00000000000..9288940847d --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexPropertyTests.cs @@ -0,0 +1,69 @@ +#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 Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure +{ + public class VertexPropertyTests + { + [Fact] + public void ShouldAssignPropertiesCorrectly() + { + const long id = 24; + const string label = "name"; + const string value = "marko"; + var vertex = new Vertex(1); + + var vertexProperty = new VertexProperty(id, label, value, vertex); + + Assert.Equal(label, vertexProperty.Label); + Assert.Equal(label, vertexProperty.Key); + Assert.Equal(value, vertexProperty.Value); + Assert.Equal(id, vertexProperty.Id); + Assert.Equal(vertex, vertexProperty.Vertex); + } + + [Fact] + public void ShouldReturnTrueForEqualsOfTwoEqualVertexProperties() + { + var firstVertexProperty = new VertexProperty((long) 24, "name", "marko", new Vertex(1)); + var secondVertexProperty = new VertexProperty((long) 24, "name", "marko", new Vertex(1)); + + var areEqual = firstVertexProperty.Equals(secondVertexProperty); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnCommonStringRepresentationForToString() + { + var vertexProperty = new VertexProperty((long) 24, "name", "marko", new Vertex(1)); + + var stringRepresentation = vertexProperty.ToString(); + + Assert.Equal("vp[name->marko]", stringRepresentation); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexTests.cs new file mode 100644 index 00000000000..8a93da5eed3 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/VertexTests.cs @@ -0,0 +1,80 @@ +#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 Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.UnitTest.Structure +{ + public class VertexTests + { + [Fact] + public void ShouldReturnCommonStringRepresentationForToString() + { + var vertex = new Vertex(12345); + + var vertexString = vertex.ToString(); + + Assert.Equal("v[12345]", vertexString); + } + + [Fact] + public void ShouldReturnTrueForEqualsOfTwoEqualVertices() + { + var firstVertex = new Vertex(1); + var secondVertex = new Vertex(1); + + var areEqual = firstVertex.Equals(secondVertex); + + Assert.True(areEqual); + } + + [Fact] + public void ShouldReturnFalseForEqualsWhereOtherIsNull() + { + var vertex = new Vertex(1); + + var areEqual = vertex.Equals(null); + + Assert.False(areEqual); + } + + [Fact] + public void ShouldReturnSpecifiedLabelForLabelProperty() + { + const string specifiedLabel = "person"; + + var vertex = new Vertex(1, specifiedLabel); + + Assert.Equal(specifiedLabel, vertex.Label); + } + + [Fact] + public void ShouldReturnDefaultLabelForLabelPropertyWhenNoLabelSpecified() + { + var vertex = new Vertex(1); + + Assert.Equal("vertex", vertex.Label); + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml new file mode 100644 index 00000000000..e625d604382 --- /dev/null +++ b/gremlin-dotnet/test/pom.xml @@ -0,0 +1,179 @@ + + + 4.0.0 + + org.apache.tinkerpop + gremlin-dotnet + 3.2.5-SNAPSHOT + + Gremlin-DotNet-Tests + ${packaging.type} + + + false + ${maven.test.skip} + + ${project.parent.parent.basedir}/gremlin-server + + + + org.apache.tinkerpop + gremlin-core + ${project.version} + + + org.codehaus.groovy + groovy + ${groovy.version} + indy + + + + org.apache.tinkerpop + tinkergraph-gremlin + ${project.version} + test + + + org.apache.tinkerpop + gremlin-test + ${project.version} + test + + + org.apache.tinkerpop + gremlin-server + ${project.version} + test + + + org.slf4j + slf4j-log4j12 + test + ${slf4j.version} + + + + + + gremlin-dotnet-standard + + true + + + pom + + + + + gremlin-dotnet + + false + + .glv + + + + dotnet-integration-test + + + ${basedir}/target + ${project.artifactId}-${project.version} + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.eobjects.build + dotnet-maven-plugin + true + + ${skipTests} + + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + org.codehaus.groovy + groovy-all + ${groovy.version} + runtime + + + log4j + log4j + 1.2.17 + runtime + + + + + gremlin-server-start + pre-integration-test + + execute + + + + + + + + + gremlin-server-stop + post-integration-test + + execute + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7b9c57a2be5..d6192781419 100644 --- a/pom.xml +++ b/pom.xml @@ -121,6 +121,8 @@ limitations under the License. gremlin-groovy-test tinkergraph-gremlin gremlin-python + gremlin-csharp-generator + gremlin-dotnet hadoop-gremlin spark-gremlin giraph-gremlin @@ -311,6 +313,13 @@ limitations under the License. **/.glv bin/gremlin.sh gremlin-console/bin/gremlin.sh + **/Debug/** + **/Release/** + **/obj/** + **/*.sln + **/*.user + **/*.csproj + **/.vs/** From 0cab22ede371b648985d1921cb62afd75b170be2 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 18 May 2017 15:53:06 -0400 Subject: [PATCH 02/28] TINKERPOP-1552 Added license to poms for dotnet --- gremlin-csharp-generator/pom.xml | 17 ++++++++++++++++- gremlin-dotnet/pom.xml | 17 ++++++++++++++++- gremlin-dotnet/src/pom.xml | 17 ++++++++++++++++- gremlin-dotnet/test/pom.xml | 17 ++++++++++++++++- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/gremlin-csharp-generator/pom.xml b/gremlin-csharp-generator/pom.xml index f488f020c57..af0ae60c2b8 100644 --- a/gremlin-csharp-generator/pom.xml +++ b/gremlin-csharp-generator/pom.xml @@ -1,4 +1,19 @@ - + diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 0472324a3ba..9bdff543bc2 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -1,4 +1,19 @@ - + diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 5fef134bc0a..2d05d7fcd46 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -1,4 +1,19 @@ - + diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index e625d604382..d91ca85cf5e 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -1,4 +1,19 @@ - + From 980c774b3aa5d92fc9e3f16c4fbabaf751bf211a Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 18 May 2017 16:42:16 -0400 Subject: [PATCH 03/28] TINKERPOP-1552 Minor dev docs formatting --- docs/src/dev/developer/development-environment.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc index 3d2760584d8..2e48b8711b8 100644 --- a/docs/src/dev/developer/development-environment.asciidoc +++ b/docs/src/dev/developer/development-environment.asciidoc @@ -106,7 +106,7 @@ mvn clean install -pl gremlin-console -DskipIntegrationTests=false ~~~~~~~~~~~~~~~~ The build optionally requires link:https://www.microsoft.com/net/core[.NET Core SDK] (>=1.1.0) to work with the -gremlin-dotnet module. If .NET Core SDK is not installed, TinkerPop will still build with Maven, but .NET projects +`gremlin-dotnet` module. If .NET Core SDK is not installed, TinkerPop will still build with Maven, but .NET projects will be skipped. `gremlin-dotnet` which also includes Gremlin-Csharp can be build and tested from the command line with: @@ -114,7 +114,7 @@ will be skipped. [source,text] mvn clean install -Pgremlin-dotnet -which enables the „gremlin-dotnet“ Maven profile or in a more automated fashion simply add a `.glv` file to the `src` +which enables the "gremlin-dotnet" Maven profile or in a more automated fashion simply add a `.glv` file to the `src` and `test` directories of the `gremlin-dotnet` module  which will signify to Maven that the environment is .NET-ready. The `.glv` file need not have any contents and is ignored by Git. A standard `mvn clean install` will then build `gremlin-dotnet` in full. From f61227bc6bc7969e74e854830ec8d4eec00efe5e Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Tue, 6 Jun 2017 17:41:10 +0200 Subject: [PATCH 04/28] Reorganize Gremlin-DotNet This merges the formerly three .NET projects into just one: Gremlin.Net. For more information see the discussion in TINKERPOP-1552. --- docs/src/reference/gremlin-variants.asciidoc | 42 +++++++---------- gremlin-csharp-generator/pom.xml | 2 +- .../csharp/AnonymousTraversalGenerator.groovy | 2 +- .../gremlin/csharp/EnumGenerator.groovy | 2 +- .../csharp/GenerateGremlinCSharp.groovy | 10 ++-- .../csharp/GraphTraversalGenerator.groovy | 3 +- .../GraphTraversalSourceGenerator.groovy | 3 +- .../gremlin/csharp/PredicateGenerator.groovy | 3 +- gremlin-dotnet/Gremlin.Net.sln | 37 +-------------- .../src/Gremlin.CSharp/Gremlin.CSharp.csproj | 21 --------- .../Gremlin.Net.Process.csproj | 24 ---------- .../src/Gremlin.Net/Gremlin.Net.csproj | 9 ++-- .../Process}/Remote/IRemoteConnection.cs | 0 .../Process}/Remote/RemoteStrategy.cs | 0 .../Process/Traversal}/Barrier.cs | 2 +- .../Process}/Traversal/Binding.cs | 0 .../Process}/Traversal/Bindings.cs | 0 .../Process}/Traversal/Bytecode.cs | 0 .../Process/Traversal}/Cardinality.cs | 2 +- .../Process/Traversal}/Column.cs | 2 +- .../Process}/Traversal/DefaultTraversal.cs | 0 .../Process/Traversal}/Direction.cs | 2 +- .../Process/Traversal}/GraphTraversal.cs | 3 +- .../Traversal}/GraphTraversalSource.cs | 3 +- .../Process}/Traversal/ITraversal.cs | 0 .../Traversal/ITraversalSideEffects.cs | 2 +- .../Process}/Traversal/ITraversalStrategy.cs | 0 .../Process}/Traversal/Instruction.cs | 0 .../Process/Traversal}/Operator.cs | 2 +- .../Process/Traversal}/Order.cs | 2 +- .../Process/Traversal}/P.cs | 3 +- .../Process/Traversal}/Pick.cs | 2 +- .../Process/Traversal}/Pop.cs | 2 +- .../Process/Traversal}/Scope.cs | 2 +- .../Strategy/AbstractTraversalStrategy.cs | 0 .../Strategy/Decoration/ConnectiveStrategy.cs | 0 .../Strategy/Decoration/ElementIdStrategy.cs | 0 .../Decoration/HaltedTraverserStrategy.cs | 0 .../Strategy/Decoration/PartitionStrategy.cs | 0 .../Strategy/Decoration/SubgraphStrategy.cs | 0 .../Decoration/VertexProgramStrategy.cs | 0 .../Finalization/MatchAlgorithmStrategy.cs | 0 .../AdjacentToIncidentStrategy.cs | 0 .../Optimization/FilterRankingStrategy.cs | 0 .../Optimization/GraphFilterStrategy.cs | 0 .../Optimization/IdentityRemovalStrategy.cs | 0 .../IncidentToAdjacentStrategy.cs | 0 .../Optimization/InlineFilterStrategy.cs | 0 .../Optimization/LazyBarrierStrategy.cs | 0 .../Optimization/MatchPredicateStrategy.cs | 0 .../Optimization/OrderLimitStrategy.cs | 0 .../Optimization/PathProcessorStrategy.cs | 0 .../Optimization/PathRetractionStrategy.cs | 0 .../Optimization/RangeByIsCountStrategy.cs | 0 .../Optimization/RepeatUnrollStrategy.cs | 0 .../Verification/LambdaRestrictionStrategy.cs | 0 .../Strategy/Verification/ReadOnlyStrategy.cs | 0 .../Process/Traversal}/T.cs | 2 +- .../Process}/Traversal/TraversalPredicate.cs | 0 .../Process}/Traversal/Traverser.cs | 0 .../Process/Traversal}/__.cs | 2 +- .../Structure/Graph.cs | 4 +- .../ConfigProvider.cs | 47 ------------------- .../Gremlin.CSharp.IntegrationTest.csproj | 38 --------------- .../Properties/AssemblyInfo.cs | 44 ----------------- .../appsettings.json | 4 -- .../Gremlin.CSharp.UnitTest.csproj | 21 --------- .../Gremlin.Net.IntegrationTest.csproj | 1 - .../BytecodeGenerationTests.cs | 6 +-- .../BytecodeGeneration/StrategiesTests.cs | 6 +-- .../DriverRemoteConnection/EnumTests.cs | 6 +-- .../GraphTraversalSourceTests.cs | 6 +-- .../GraphTraversalTests.cs | 4 +- .../DriverRemoteConnection/PredicateTests.cs | 6 +-- .../RemoteConnectionFactory.cs | 2 +- .../DriverRemoteConnection/SideEffectTests.cs | 4 +- .../DriverRemoteConnection/StrategiesTests.cs | 6 +-- .../Process/Traversal}/GraphSONWriterTests.cs | 4 +- .../Gremlin.Net.Process.UnitTest.csproj | 22 --------- .../Gremlin.Net.UnitTest.csproj | 1 - .../Process}/Traversal/BytecodeTests.cs | 2 +- .../Traversal}/GraphTraversalSourceTests.cs | 4 +- .../Process/Traversal}/PredicateTests.cs | 4 +- .../Traversal/Strategy/StrategyTests.cs | 2 +- .../Process}/Traversal/TestTraversal.cs | 4 +- .../Traversal/TestTraversalStrategy.cs | 2 +- .../Process}/Traversal/TraversalTests.cs | 4 +- .../Process}/Traversal/TraverserTests.cs | 2 +- 88 files changed, 85 insertions(+), 362 deletions(-) delete mode 100644 gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj delete mode 100644 gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Remote/IRemoteConnection.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Remote/RemoteStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Barrier.cs (95%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Binding.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Bindings.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Bytecode.cs (100%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Cardinality.cs (95%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Column.cs (95%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/DefaultTraversal.cs (100%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Direction.cs (95%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/GraphTraversal.cs (99%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/GraphTraversalSource.cs (98%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/ITraversal.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/ITraversalSideEffects.cs (97%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/ITraversalStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Instruction.cs (100%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Operator.cs (96%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Order.cs (96%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/P.cs (98%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Pick.cs (95%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Pop.cs (95%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/Scope.cs (95%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/AbstractTraversalStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Decoration/ConnectiveStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Decoration/ElementIdStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Decoration/PartitionStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Decoration/SubgraphStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Decoration/VertexProgramStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/FilterRankingStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/GraphFilterStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/InlineFilterStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/OrderLimitStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/PathProcessorStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/PathRetractionStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Strategy/Verification/ReadOnlyStrategy.cs (100%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/T.cs (95%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/TraversalPredicate.cs (100%) rename gremlin-dotnet/src/{Gremlin.Net.Process => Gremlin.Net/Process}/Traversal/Traverser.cs (100%) rename gremlin-dotnet/src/{Gremlin.CSharp/Process => Gremlin.Net/Process/Traversal}/__.cs (99%) rename gremlin-dotnet/src/{Gremlin.CSharp => Gremlin.Net}/Structure/Graph.cs (93%) delete mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs delete mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj delete mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs delete mode 100644 gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json delete mode 100644 gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/BytecodeGeneration/BytecodeGenerationTests.cs (95%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/BytecodeGeneration/StrategiesTests.cs (98%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/EnumTests.cs (92%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/GraphTraversalSourceTests.cs (92%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/GraphTraversalTests.cs (97%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/PredicateTests.cs (92%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/RemoteConnectionFactory.cs (94%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/SideEffectTests.cs (98%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/DriverRemoteConnection/StrategiesTests.cs (97%) rename gremlin-dotnet/test/{Gremlin.CSharp.IntegrationTest => Gremlin.Net.IntegrationTest/Process/Traversal}/GraphSONWriterTests.cs (95%) delete mode 100644 gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj rename gremlin-dotnet/test/{Gremlin.Net.Process.UnitTest => Gremlin.Net.UnitTest/Process}/Traversal/BytecodeTests.cs (96%) rename gremlin-dotnet/test/{Gremlin.CSharp.UnitTest => Gremlin.Net.UnitTest/Process/Traversal}/GraphTraversalSourceTests.cs (96%) rename gremlin-dotnet/test/{Gremlin.CSharp.UnitTest => Gremlin.Net.UnitTest/Process/Traversal}/PredicateTests.cs (94%) rename gremlin-dotnet/test/{Gremlin.Net.Process.UnitTest => Gremlin.Net.UnitTest/Process}/Traversal/Strategy/StrategyTests.cs (98%) rename gremlin-dotnet/test/{Gremlin.Net.Process.UnitTest => Gremlin.Net.UnitTest/Process}/Traversal/TestTraversal.cs (93%) rename gremlin-dotnet/test/{Gremlin.Net.Process.UnitTest => Gremlin.Net.UnitTest/Process}/Traversal/TestTraversalStrategy.cs (96%) rename gremlin-dotnet/test/{Gremlin.Net.Process.UnitTest => Gremlin.Net.UnitTest/Process}/Traversal/TraversalTests.cs (99%) rename gremlin-dotnet/test/{Gremlin.Net.Process.UnitTest => Gremlin.Net.UnitTest/Process}/Traversal/TraverserTests.cs (97%) diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc index 01df63246c1..763ab4aa179 100644 --- a/docs/src/reference/gremlin-variants.asciidoc +++ b/docs/src/reference/gremlin-variants.asciidoc @@ -356,40 +356,30 @@ connection = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g', graphson_writer=graphson_writer) ---- -[[gremlin-csharp]] -Gremlin-CSharp +[[gremlin-DotNet]] +Gremlin-DotNet -------------- -Apache TinkerPop's Gremlin-CSharp implements Gremlin within the C# language. It targets .NET Standard and can +Apache TinkerPop's Gremlin-DotNet implements Gremlin within the C# language. It targets .NET Standard and can therefore be used on different operating systems and with different .NET frameworks, such as .NET Framework and link:https://www.microsoft.com/net/core[.NET Core]. Since the C# syntax is very similar to that of Java, it should be very easy to switch between -Gremlin-Java and Gremlin-CSharp. The only major syntactical difference is that all method names in Gremlin-CSharp +Gremlin-Java and Gremlin-DotNet. The only major syntactical difference is that all method names in Gremlin-DotNet use PascalCase as opposed to camelCase in Gremlin-Java in order to comply with .NET conventions. [source,powershell] -nuget install Gremlin.CSharp +nuget install Gremlin.Net -In Gremlin-CSharp there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes +In Gremlin-DotNet there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes in Gremlin-Java. The `GraphTraversalSource` requires a driver in order to communicate with <> (or any RemoteConnection-enabled server). -Gremlin-CSharp and Gremlin-DotNet -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Gremlin-CSharp is the C# language variant of Gremlin, but it needs a driver to communicate with a remote -Gremlin Server. Such a driver is provided as part of Apache TinkerPop’s Gremlin-DotNet that also includes other -useful functionality to work with Gremlin in .NET. -Gremlin-DotNet is currently distributed in two NuGet packages: - -* `Gremlin.Net.Process` contains core functionality for Gremlin language variants and defines interfaces for drivers. -Gremlin-CSharp depends on this package. So it will be installed automatically when you install Gremlin-CSharp. -* `Gremlin.Net` contains a driver that allows Gremlin-CSharp to be used with a remote server and GraphSON serializers and deserializers. +The `Gremlin.Net.Driver.Remote.DriverRemoteConnection` is provided as part of Apache TinkerPop’s Gremlin-DotNet. IMPORTANT: For developers wishing to provide another driver implementation, be sure to implement `IRemoteConnection` in -`Gremlin.Net.Process.Remote` so it can then be used by Gremlin-CSharp’s `GraphTraversal`. +`Gremlin.Net.Process.Remote` so it can then be used by Gremlin-DotNet’s `GraphTraversal`. -When Gremlin Server is running, Gremlin-CSharp can communicate with Gremlin Server by sending traversals serialized as `Bytecode`. +When Gremlin Server is running, Gremlin-DotNet can communicate with Gremlin Server by sending traversals serialized as `Bytecode`. -IMPORTANT: Gremlin-CSharp is compatible with GraphSON 2.0 only, so this serializer must be configured in Gremlin Server. +IMPORTANT: Gremlin-DotNet is compatible with GraphSON 2.0 only, so this serializer must be configured in Gremlin Server. A traversal source can be spawned with `RemoteStrategy` from an empty `Graph`. @@ -401,7 +391,7 @@ var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClien When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via the registered `IRemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote traversal source. -Since Gremlin-CSharp currently doesn't support lambda expressions, all traversals can be translated to Gremlin-Java on the remote +Since Gremlin-DotNet currently doesn't support lambda expressions, all traversals can be translated to Gremlin-Java on the remote location (e.g. Gremlin Server). IMPORTANT: Gremlin-DotNet’s `ITraversal` interface supports the standard Gremlin methods such as `Next()`, `NextTraverser()`, `ToSet()`, @@ -422,7 +412,7 @@ terminal/action methods off of `ITraversal`. Static Enums and Methods ~~~~~~~~~~~~~~~~~~~~~~~~ -Gremlin has various tokens (e.g. `T`, `P`, `Order`, `Operator`, etc.) that are represented in Gremlin-CSharp as Enums. +Gremlin has various tokens (e.g. `T`, `P`, `Order`, `Operator`, etc.) that are represented in Gremlin-DotNet as Enums. These can be used analogously to how they are used in Gremlin-Java. @@ -433,8 +423,8 @@ Moreover, the class prefixes can be ommitted with a `using static`. [source,csharp] ---- -using static Gremlin.CSharp.Process.P; -using static Gremlin.CSharp.Process.Order; +using static Gremlin.Net.Process.Traversal.P; +using static Gremlin.Net.Process.Traversal.Order; ---- Then it is possible to represent the above traversal as below. @@ -453,10 +443,10 @@ Bindings When a traversal bytecode is sent over a `IRemoteConnection` (e.g. Gremlin Server), it will be translated, compiled, and then executed. If the same traversal is sent again, translation and compilation can be skipped as the previously compiled version should be cached. Many traversals are unique up to some parameterization. For instance, -`g.V(1).Out("created").Values("name")` is considered different from `g.V(4).Out('created').Values("Name")` +`g.V(1).Out("created").Values("name")` is considered different from `g.V(4).Out("created").Values("Name")` as they have different script "string" representations. However, `g.V(x).Out("created").Values("name")` with bindings of `{x : 1}` and `{x : 4}` are considered the same. If a traversal is going to be executed repeatedly, but with different -parameters, then bindings should be used. In Gremlin-CSharp, bindings are objects that can be created as follows. +parameters, then bindings should be used. In Gremlin-DotNet, bindings are objects that can be created as follows. [source,csharp] ---- diff --git a/gremlin-csharp-generator/pom.xml b/gremlin-csharp-generator/pom.xml index af0ae60c2b8..4e8989a5305 100644 --- a/gremlin-csharp-generator/pom.xml +++ b/gremlin-csharp-generator/pom.xml @@ -56,7 +56,7 @@ limitations under the License. org.apache.tinkerpop.gremlin.csharp.GenerateGremlinCSharp - ${project.parent.basedir}/gremlin-dotnet/src/Gremlin.CSharp + ${project.parent.basedir}/gremlin-dotnet/src/Gremlin.Net diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy index 6e2e1916fdc..ccb22fccfb7 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy @@ -34,7 +34,7 @@ class AnonymousTraversalGenerator { csharpClass.append( """ -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public static class __ { diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy index a389f9b30fd..9214e0fc51d 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy @@ -40,7 +40,7 @@ class EnumGenerator { csharpEnum.append( """ -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum ${enumClass.getSimpleName()} { diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy index 7b03e5a0d40..53eba178330 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy @@ -23,10 +23,10 @@ public class GenerateGremlinCSharp { public static void main(String[] args) { final String csharpDirectory = args[0] - GraphTraversalSourceGenerator.create(csharpDirectory + "/Process/" + "GraphTraversalSource.cs") - GraphTraversalGenerator.create(csharpDirectory + "/Process/" + "GraphTraversal.cs") - AnonymousTraversalGenerator.create(csharpDirectory + "/Process/" + "__.cs") - EnumGenerator.create(csharpDirectory + "/Process/") - PredicateGenerator.create(csharpDirectory + "/Process/" + "P.cs") + GraphTraversalSourceGenerator.create(csharpDirectory + "/Process/Traversal/" + "GraphTraversalSource.cs") + GraphTraversalGenerator.create(csharpDirectory + "/Process/Traversal/" + "GraphTraversal.cs") + AnonymousTraversalGenerator.create(csharpDirectory + "/Process/Traversal/" + "__.cs") + EnumGenerator.create(csharpDirectory + "/Process/Traversal/") + PredicateGenerator.create(csharpDirectory + "/Process/Traversal/" + "P.cs") } } \ No newline at end of file diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy index 54183a3e2ae..f8ecfb14449 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy @@ -32,9 +32,8 @@ class GraphTraversalGenerator { csharpClass.append( """ using System.Collections.Generic; -using Gremlin.Net.Process.Traversal; -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public class GraphTraversal : DefaultTraversal { diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy index aaa35fb100b..6b93d73cf3e 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy @@ -35,10 +35,9 @@ class GraphTraversalSourceGenerator { """ using System.Collections.Generic; using Gremlin.Net.Process.Remote; -using Gremlin.Net.Process.Traversal; using Gremlin.Net.Process.Traversal.Strategy.Decoration; -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public class GraphTraversalSource { diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy index 72e3dba13a0..0748ae97890 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy +++ b/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy @@ -33,9 +33,8 @@ class PredicateGenerator { csharpClass.append( """ -using Gremlin.Net.Process.Traversal; -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public class P {""") diff --git a/gremlin-dotnet/Gremlin.Net.sln b/gremlin-dotnet/Gremlin.Net.sln index bfd565fc678..b1a5d19e7e7 100644 --- a/gremlin-dotnet/Gremlin.Net.sln +++ b/gremlin-dotnet/Gremlin.Net.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26430.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{584F838B-DAE2-44F5-868C-1F532949C827}" EndProject @@ -15,16 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.Net.UnitTest", "tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.Net.IntegrationTest", "test\Gremlin.Net.IntegrationTest\Gremlin.Net.IntegrationTest.csproj", "{CC54ABE3-13D2-491C-81E2-4D0355ABFA93}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.CSharp", "src\Gremlin.CSharp\Gremlin.CSharp.csproj", "{709D235A-CA13-434F-9AF9-8C8C009B11D7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin.CSharp.IntegrationTest", "test\Gremlin.CSharp.IntegrationTest\Gremlin.CSharp.IntegrationTest.csproj", "{232F0F2B-178E-4214-99C7-CC4DC6710F44}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin.Net.Process", "src\Gremlin.Net.Process\Gremlin.Net.Process.csproj", "{4949181B-C97D-4BB4-A312-9C1506EC7DA7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin.Net.Process.UnitTest", "test\Gremlin.Net.Process.UnitTest\Gremlin.Net.Process.UnitTest.csproj", "{D97CA283-AC86-4EC9-9E1D-5F9A97977687}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin.CSharp.UnitTest", "test\Gremlin.CSharp.UnitTest\Gremlin.CSharp.UnitTest.csproj", "{F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,26 +33,6 @@ Global {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC54ABE3-13D2-491C-81E2-4D0355ABFA93}.Release|Any CPU.Build.0 = Release|Any CPU - {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {709D235A-CA13-434F-9AF9-8C8C009B11D7}.Release|Any CPU.Build.0 = Release|Any CPU - {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Debug|Any CPU.Build.0 = Debug|Any CPU - {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Release|Any CPU.ActiveCfg = Release|Any CPU - {232F0F2B-178E-4214-99C7-CC4DC6710F44}.Release|Any CPU.Build.0 = Release|Any CPU - {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4949181B-C97D-4BB4-A312-9C1506EC7DA7}.Release|Any CPU.Build.0 = Release|Any CPU - {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D97CA283-AC86-4EC9-9E1D-5F9A97977687}.Release|Any CPU.Build.0 = Release|Any CPU - {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -71,10 +41,5 @@ Global {6C1DD34D-E30F-4E37-AACC-BEB8AD2320D8} = {584F838B-DAE2-44F5-868C-1F532949C827} {1FAB781B-B857-4AD2-BEC8-E20C214D9E21} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} {CC54ABE3-13D2-491C-81E2-4D0355ABFA93} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} - {709D235A-CA13-434F-9AF9-8C8C009B11D7} = {584F838B-DAE2-44F5-868C-1F532949C827} - {232F0F2B-178E-4214-99C7-CC4DC6710F44} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} - {4949181B-C97D-4BB4-A312-9C1506EC7DA7} = {584F838B-DAE2-44F5-868C-1F532949C827} - {D97CA283-AC86-4EC9-9E1D-5F9A97977687} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} - {F2D976C2-D5EC-4BE5-9F6F-FCFAA9F59858} = {1B54FAC2-5411-4BB6-B450-FE2FFD8C4782} EndGlobalSection EndGlobal diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj b/gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj deleted file mode 100644 index 82291fcb5a3..00000000000 --- a/gremlin-dotnet/src/Gremlin.CSharp/Gremlin.CSharp.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 3.2.5-SNAPSHOT - netstandard1.3 - Gremlin.CSharp - Gremlin.CSharp - False - http://tinkerpop.apache.org - https://github.com/apache/tinkerpop/blob/master/LICENSE - https://github.com/apache/tinkerpop - Apache TinkerPop’s Gremlin-CSharp implements Gremlin within C# and can be used on any platform. - gremlin-csharp;gremlin;tinkerpop - Apache TinkerPop - - - - - - - diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj b/gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj deleted file mode 100644 index 5e2d7fc4af9..00000000000 --- a/gremlin-dotnet/src/Gremlin.Net.Process/Gremlin.Net.Process.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - 3.2.5-SNAPSHOT - netstandard1.3 - False - http://tinkerpop.apache.org - https://github.com/apache/tinkerpop/blob/master/LICENSE - https://github.com/apache/tinkerpop - Apache TinkerPop - gremlin;tinkerpop;gremlin-dotnet - This package provides implementations and interfaces for Gremlin language variants. - - - - - - - - - - - - \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index a909ad1eb44..a1fc9ef7d7b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -6,7 +6,6 @@ Apache TinkerPop netstandard1.3 3.2.5-SNAPSHOT - true Gremlin.Net Gremlin.Net gremlin-dotnet;gremlin;tinkerpop;tinkerpop3 @@ -23,6 +22,10 @@ + + + + @@ -36,8 +39,4 @@ - - - - diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Remote/IRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Remote/IRemoteConnection.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Remote/RemoteStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs index a74b47aa699..13d179649a8 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Barrier.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Barrier { diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Binding.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Binding.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bindings.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bindings.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Bytecode.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs index 4b9fae82d08..f2365c32b54 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Cardinality.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Cardinality { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index c397b694230..ee591dad95e 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Column { diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/DefaultTraversal.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs index abdf7a2f88a..413e11feafc 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Direction.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Direction { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs similarity index 99% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 439783823ba..88e9261d273 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -22,9 +22,8 @@ #endregion using System.Collections.Generic; -using Gremlin.Net.Process.Traversal; -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public class GraphTraversal : DefaultTraversal { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs similarity index 98% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs index e68fdee84cb..638278185e6 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/GraphTraversalSource.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -23,10 +23,9 @@ using System.Collections.Generic; using Gremlin.Net.Process.Remote; -using Gremlin.Net.Process.Traversal; using Gremlin.Net.Process.Traversal.Strategy.Decoration; -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public class GraphTraversalSource { diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversal.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs similarity index 97% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs index 0378fe6cc7d..7e7b450176e 100644 --- a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalSideEffects.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs @@ -32,7 +32,7 @@ namespace Gremlin.Net.Process.Traversal public interface ITraversalSideEffects : IDisposable { /// - /// Retrieves the keys of the side-effect that can be supplied to . + /// Retrieves the keys of the side-effect that can be supplied to . /// /// The keys of the side-effect. IReadOnlyCollection Keys(); diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/ITraversalStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Instruction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Instruction.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs similarity index 96% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index 5a9f805dbe9..563f0917eda 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Operator { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs similarity index 96% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index 1a30c7d83cd..bbd0eab692e 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Order { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs similarity index 98% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs index 62282b70732..0ecdccd605c 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/P.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs @@ -21,9 +21,8 @@ #endregion -using Gremlin.Net.Process.Traversal; -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public class P { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs index 17c27d7f9ff..f16aa20b79b 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Pick.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Pick { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs index 4e14d941504..e0cf62e7fcd 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Pop.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Pop { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs index a9578ee7cce..c4af316c42f 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/Scope.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum Scope { diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/AbstractTraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/AbstractTraversalStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/PartitionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/PartitionStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/PartitionStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/PartitionStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/AdjacentToIncidentStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/FilterRankingStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/IdentityRemovalStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/IncidentToAdjacentStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/InlineFilterStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/LazyBarrierStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/MatchPredicateStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathProcessorStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RangeByIsCountStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/LambdaRestrictionStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Verification/ReadOnlyStrategy.cs diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs similarity index 95% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index 4bf90622ef7..50c15d9f12a 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public enum T { diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/TraversalPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/TraversalPredicate.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs diff --git a/gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Traverser.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Traverser.cs similarity index 100% rename from gremlin-dotnet/src/Gremlin.Net.Process/Traversal/Traverser.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Traverser.cs diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs similarity index 99% rename from gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs rename to gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index 2db0082a2da..e12037296b5 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Process/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -21,7 +21,7 @@ #endregion -namespace Gremlin.CSharp.Process +namespace Gremlin.Net.Process.Traversal { public static class __ { diff --git a/gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs similarity index 93% rename from gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs rename to gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs index 3ae5bef4052..0a077637025 100644 --- a/gremlin-dotnet/src/Gremlin.CSharp/Structure/Graph.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs @@ -21,9 +21,9 @@ #endregion -using Gremlin.CSharp.Process; +using Gremlin.Net.Process.Traversal; -namespace Gremlin.CSharp.Structure +namespace Gremlin.Net.Structure { public class Graph { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs deleted file mode 100644 index 27e7009910c..00000000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/ConfigProvider.cs +++ /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 - -using System.IO; -using Microsoft.Extensions.Configuration; - -namespace Gremlin.CSharp.IntegrationTest -{ - public static class ConfigProvider - { - static ConfigProvider() - { - Configuration = GetConfig(); - } - - public static IConfiguration Configuration { get; } - - private static IConfiguration GetConfig() - { - var configFile = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"); - var builder = new ConfigurationBuilder() - .AddJsonFile(configFile, false, false); - - return builder.Build(); - } - } -} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj deleted file mode 100644 index 1e7a7d23028..00000000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - netcoreapp1.0 - Gremlin.CSharp.IntegrationTest - Gremlin.CSharp.IntegrationTest - true - 1.0.4 - false - false - false - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 579426b622d..00000000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,44 +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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Gremlin.CSharp.IntegrationTest")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("232f0f2b-178e-4214-99c7-cc4dc6710f44")] \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json deleted file mode 100644 index 38007ec1c9c..00000000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "TestServerIpAddress": "localhost", - "TestServerPort": 45950 -} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj deleted file mode 100644 index ea81928688f..00000000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netcoreapp1.1 - - - - - - - - - - - - - - - - - diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj index f8407a93703..c5f29da98bc 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj @@ -19,7 +19,6 @@ - diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs similarity index 95% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs index 672ff353555..1afb7bb798a 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/BytecodeGenerationTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs @@ -21,11 +21,11 @@ #endregion -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.BytecodeGeneration +namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration { public class BytecodeGenerationTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs similarity index 98% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs index 6afda7132eb..418b0e22cc4 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/BytecodeGeneration/StrategiesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs @@ -22,15 +22,15 @@ #endregion using System.Collections.Generic; -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal; using Gremlin.Net.Process.Traversal.Strategy.Decoration; using Gremlin.Net.Process.Traversal.Strategy.Finalization; using Gremlin.Net.Process.Traversal.Strategy.Optimization; using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.BytecodeGeneration +namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration { public class StrategiesTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs similarity index 92% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs index a49a09de897..6d0f5299091 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/EnumTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs @@ -22,11 +22,11 @@ #endregion using System.Collections.Generic; -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { public class EnumTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs similarity index 92% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs index f8c12e2823c..0e56c2e379d 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalSourceTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs @@ -22,11 +22,11 @@ #endregion using System.Collections.Generic; -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { public class GraphTraversalSourceTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs similarity index 97% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs index 91a41ba296f..ba999f3a913 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/GraphTraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs @@ -24,13 +24,11 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; using Gremlin.Net.Process.Traversal; using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { public class GraphTraversalTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs similarity index 92% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs index 8dffa432cb0..88587f6cd12 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/PredicateTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs @@ -21,11 +21,11 @@ #endregion -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { public class PredicateTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs similarity index 94% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs index 53b6e501434..ab67c266134 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/RemoteConnectionFactory.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs @@ -25,7 +25,7 @@ using Gremlin.Net.Driver; using Gremlin.Net.Process.Remote; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { internal class RemoteConnectionFactory { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs similarity index 98% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs index 805116734a7..c3629bcdc6f 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs @@ -25,10 +25,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Gremlin.CSharp.Structure; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { public class SideEffectTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs similarity index 97% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs index 59e2092f594..6c7d8b619f6 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs @@ -22,14 +22,14 @@ #endregion using System.Threading.Tasks; -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.Process.Traversal; using Gremlin.Net.Process.Traversal.Strategy.Decoration; using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection { public class StrategiesTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs similarity index 95% rename from gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs rename to gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs index 99a1b651376..d8ccabe8bd2 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs @@ -21,11 +21,11 @@ #endregion -using Gremlin.CSharp.Process; +using Gremlin.Net.Process.Traversal; using Gremlin.Net.Structure.IO.GraphSON; using Xunit; -namespace Gremlin.CSharp.IntegrationTest +namespace Gremlin.Net.IntegrationTest.Process.Traversal { public class GraphSONWriterTests { diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj deleted file mode 100644 index 2345f3182b5..00000000000 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - netcoreapp1.1 - - - - - - - - - - - - - - - - - - diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj index 3d2da0ded27..6cf88ac9396 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj @@ -13,7 +13,6 @@ - diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs similarity index 96% rename from gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs index de0a0b76202..da77223e7bf 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs @@ -24,7 +24,7 @@ using Gremlin.Net.Process.Traversal; using Xunit; -namespace Gremlin.Net.Process.UnitTest.Traversal +namespace Gremlin.Net.UnitTest.Process.Traversal { public class BytecodeTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs similarity index 96% rename from gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs index bac2d55a2bc..1ce1ec0407f 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs @@ -21,10 +21,10 @@ #endregion -using Gremlin.CSharp.Structure; +using Gremlin.Net.Structure; using Xunit; -namespace Gremlin.CSharp.UnitTest +namespace Gremlin.Net.UnitTest.Process.Traversal { public class GraphTraversalSourceTests { diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs similarity index 94% rename from gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs index c06fb68e4c8..59af6819ce0 100644 --- a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs @@ -21,10 +21,10 @@ #endregion -using Gremlin.CSharp.Process; +using Gremlin.Net.Process.Traversal; using Xunit; -namespace Gremlin.CSharp.UnitTest +namespace Gremlin.Net.UnitTest.Process.Traversal { public class PredicateTests { diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs similarity index 98% rename from gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs index 2e7dc5e0c7d..47adb29948c 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs @@ -26,7 +26,7 @@ using Gremlin.Net.Process.Traversal.Strategy.Verification; using Xunit; -namespace Gremlin.Net.Process.UnitTest.Traversal.Strategy +namespace Gremlin.Net.UnitTest.Process.Traversal.Strategy { public class StrategyTests { diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs similarity index 93% rename from gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs index 34f88dfaf57..4be682358ab 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs @@ -25,9 +25,9 @@ using System.Linq; using Gremlin.Net.Process.Traversal; -namespace Gremlin.Net.Process.UnitTest.Traversal +namespace Gremlin.Net.UnitTest.Process.Traversal { - public class TestTraversal : Process.Traversal.DefaultTraversal + public class TestTraversal : DefaultTraversal { public TestTraversal(List traverserObjs) { diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs similarity index 96% rename from gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs index d64344068ef..111469c6837 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs @@ -25,7 +25,7 @@ using System.Threading.Tasks; using Gremlin.Net.Process.Traversal; -namespace Gremlin.Net.Process.UnitTest.Traversal +namespace Gremlin.Net.UnitTest.Process.Traversal { public class TestTraversalStrategy : ITraversalStrategy { diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs similarity index 99% rename from gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs index a823a5d6d5a..f32b56741ee 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs @@ -24,11 +24,11 @@ using System; using System.Collections.Generic; using System.Linq; -using Gremlin.Net.Process.Traversal; using Moq; using Xunit; +using Gremlin.Net.Process.Traversal; -namespace Gremlin.Net.Process.UnitTest.Traversal +namespace Gremlin.Net.UnitTest.Process.Traversal { public class TraversalTests { diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs similarity index 97% rename from gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs rename to gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs index 4f6d2b5f34b..f8963d3a2c5 100644 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs @@ -24,7 +24,7 @@ using Gremlin.Net.Process.Traversal; using Xunit; -namespace Gremlin.Net.Process.UnitTest.Traversal +namespace Gremlin.Net.UnitTest.Process.Traversal { public class TraverserTests { From 3f8d2f50122d4a04682ebe598bee28b5f37b813e Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Tue, 6 Jun 2017 17:50:55 +0200 Subject: [PATCH 05/28] Rename gremlin-csharp-generator to gremlin-dotnet-generator --- .../pom.xml | 8 ++++---- .../dotnet}/AnonymousTraversalGenerator.groovy | 2 +- .../gremlin/dotnet}/CommonContentHelper.groovy | 2 +- .../gremlin/dotnet}/EnumGenerator.groovy | 2 +- .../gremlin/dotnet/GenerateGremlinDotNet.groovy | 16 ++++++++-------- .../dotnet}/GraphTraversalGenerator.groovy | 2 +- .../dotnet}/GraphTraversalSourceGenerator.groovy | 2 +- .../gremlin/dotnet}/PredicateGenerator.groovy | 2 +- .../gremlin/dotnet}/SymbolHelper.groovy | 2 +- pom.xml | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) rename {gremlin-csharp-generator => gremlin-dotnet-generator}/pom.xml (93%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/AnonymousTraversalGenerator.groovy (98%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/CommonContentHelper.groovy (97%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/EnumGenerator.groovy (98%) rename gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy (69%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/GraphTraversalGenerator.groovy (98%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/GraphTraversalSourceGenerator.groovy (99%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/PredicateGenerator.groovy (97%) rename {gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp => gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet}/SymbolHelper.groovy (96%) diff --git a/gremlin-csharp-generator/pom.xml b/gremlin-dotnet-generator/pom.xml similarity index 93% rename from gremlin-csharp-generator/pom.xml rename to gremlin-dotnet-generator/pom.xml index 4e8989a5305..a0a9ff6719a 100644 --- a/gremlin-csharp-generator/pom.xml +++ b/gremlin-dotnet-generator/pom.xml @@ -23,8 +23,8 @@ limitations under the License. tinkerpop 3.2.5-SNAPSHOT - gremlin-csharp-generator - Apache TinkerPop :: Gremlin-CSharp Generator + gremlin-dotnet-generator + Apache TinkerPop :: Gremlin-DotNet Generator org.apache.tinkerpop @@ -48,13 +48,13 @@ limitations under the License. 1.2.1 - generate-csharp + generate-dotnet generate-test-resources java - org.apache.tinkerpop.gremlin.csharp.GenerateGremlinCSharp + org.apache.tinkerpop.gremlin.dotnet.GenerateGremlinDotNet ${project.parent.basedir}/gremlin-dotnet/src/Gremlin.Net diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy similarity index 98% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy index ccb22fccfb7..ca5fadb0e6d 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/AnonymousTraversalGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy similarity index 97% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy index c44bcfa5e90..825e23012e5 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/CommonContentHelper.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet public final class CommonContentHelper { diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy similarity index 98% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy index 9214e0fc51d..799e0010821 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/EnumGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.util.CoreImports diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy similarity index 69% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy index 53eba178330..0d09d5b05e8 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GenerateGremlinCSharp.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy @@ -17,16 +17,16 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet -public class GenerateGremlinCSharp { +public class GenerateGremlinDotNet { public static void main(String[] args) { - final String csharpDirectory = args[0] - GraphTraversalSourceGenerator.create(csharpDirectory + "/Process/Traversal/" + "GraphTraversalSource.cs") - GraphTraversalGenerator.create(csharpDirectory + "/Process/Traversal/" + "GraphTraversal.cs") - AnonymousTraversalGenerator.create(csharpDirectory + "/Process/Traversal/" + "__.cs") - EnumGenerator.create(csharpDirectory + "/Process/Traversal/") - PredicateGenerator.create(csharpDirectory + "/Process/Traversal/" + "P.cs") + final String dotnetDirectory = args[0] + GraphTraversalSourceGenerator.create(dotnetDirectory + "/Process/Traversal/" + "GraphTraversalSource.cs") + GraphTraversalGenerator.create(dotnetDirectory + "/Process/Traversal/" + "GraphTraversal.cs") + AnonymousTraversalGenerator.create(dotnetDirectory + "/Process/Traversal/" + "__.cs") + EnumGenerator.create(dotnetDirectory + "/Process/Traversal/") + PredicateGenerator.create(dotnetDirectory + "/Process/Traversal/" + "P.cs") } } \ No newline at end of file diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy similarity index 98% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy index f8ecfb14449..58a399110fb 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy similarity index 99% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy index 6b93d73cf3e..fce4b70a6a9 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/GraphTraversalSourceGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy similarity index 97% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy index 0748ae97890..2633de6e498 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/PredicateGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.process.traversal.P diff --git a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy similarity index 96% rename from gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy rename to gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy index 10591d7a009..6c237e8e394 100644 --- a/gremlin-csharp-generator/src/main/groovy/org/apache/tinkerpop/gremlin/csharp/SymbolHelper.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.csharp +package org.apache.tinkerpop.gremlin.dotnet public final class SymbolHelper { diff --git a/pom.xml b/pom.xml index d6192781419..888e35d6efb 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ limitations under the License. gremlin-groovy-test tinkergraph-gremlin gremlin-python - gremlin-csharp-generator + gremlin-dotnet-generator gremlin-dotnet hadoop-gremlin spark-gremlin From 852ff1f699d3255c19524dff392ef634653fd7d7 Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Tue, 6 Jun 2017 19:03:09 +0200 Subject: [PATCH 06/28] Fix method reference in XML comment --- .../src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs index 7e7b450176e..0378fe6cc7d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs @@ -32,7 +32,7 @@ namespace Gremlin.Net.Process.Traversal public interface ITraversalSideEffects : IDisposable { /// - /// Retrieves the keys of the side-effect that can be supplied to . + /// Retrieves the keys of the side-effect that can be supplied to . /// /// The keys of the side-effect. IReadOnlyCollection Keys(); From e2453a1802b3f0f91933e44d7ec5aa7b9a963c4b Mon Sep 17 00:00:00 2001 From: Jorge Bay Gondra Date: Wed, 31 May 2017 17:19:55 +0200 Subject: [PATCH 07/28] C# GLV: Generics and enum generation --- .../dotnet/AnonymousTraversalGenerator.groovy | 53 ++- .../gremlin/dotnet/EnumGenerator.groovy | 60 ++- .../dotnet/GraphTraversalGenerator.groovy | 40 +- .../GraphTraversalSourceGenerator.groovy | 33 +- .../gremlin/dotnet/PredicateGenerator.groovy | 3 +- .../gremlin/dotnet/SymbolHelper.groovy | 58 +++ .../Driver/Remote/DriverRemoteConnection.cs | 4 +- .../Driver/Remote/DriverRemoteTraversal.cs | 2 +- .../Process/Remote/IRemoteConnection.cs | 2 +- .../Process/Remote/RemoteStrategy.cs | 6 +- .../Gremlin.Net/Process/Traversal/Barrier.cs | 2 +- .../Process/Traversal/Cardinality.cs | 6 +- .../Gremlin.Net/Process/Traversal/Column.cs | 4 +- .../Process/Traversal/DefaultTraversal.cs | 23 +- .../Process/Traversal/Direction.cs | 6 +- .../Process/Traversal/GraphTraversal.cs | 408 +++++++++--------- .../Process/Traversal/GraphTraversalSource.cs | 22 +- .../Process/Traversal/ITraversal.cs | 27 +- .../Process/Traversal/ITraversalStrategy.cs | 4 +- .../Process/Traversal/NamingConversions.cs | 86 ++++ .../Gremlin.Net/Process/Traversal/Operator.cs | 22 +- .../Gremlin.Net/Process/Traversal/Order.cs | 14 +- .../src/Gremlin.Net/Process/Traversal/P.cs | 2 +- .../src/Gremlin.Net/Process/Traversal/Pick.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/Pop.cs | 6 +- .../Gremlin.Net/Process/Traversal/Scope.cs | 4 +- .../Strategy/AbstractTraversalStrategy.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/T.cs | 8 +- .../src/Gremlin.Net/Process/Traversal/__.cs | 373 ++++++++-------- .../Structure/IO/GraphSON/EnumSerializer.cs | 5 +- .../Process/Remote/RemoteStrategyTests.cs | 6 +- .../BytecodeGeneration/StrategiesTests.cs | 6 +- .../DriverRemoteConnection/EnumTests.cs | 6 +- .../GraphTraversalSourceTests.cs | 4 +- .../GraphTraversalTests.cs | 13 +- .../DriverRemoteConnection/SideEffectTests.cs | 4 +- .../DriverRemoteConnection/StrategiesTests.cs | 6 +- .../Process/Traversal/TestTraversal.cs | 4 +- .../Traversal/TestTraversalStrategy.cs | 6 +- .../BytecodeGraphSONSerializerTests.cs | 4 +- .../IO/GraphSON/GraphSONWriterTests.cs | 9 +- 41 files changed, 808 insertions(+), 551 deletions(-) create mode 100644 gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy index ca5fadb0e6d..b65b2b0450d 100644 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy @@ -26,43 +26,70 @@ import java.lang.reflect.Modifier class AnonymousTraversalGenerator { + private static final Map METHODS_WITH_SPECIFIC_TYPES = new HashMap<>(); + + static { + String[] useE2 = ["E2", "E2"]; + METHODS_WITH_SPECIFIC_TYPES.put("constant", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("limit", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("mean", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("optional", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("range", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("select", ["IDictionary", "E2"] as String[]); + METHODS_WITH_SPECIFIC_TYPES.put("sum", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("tail", useE2); + METHODS_WITH_SPECIFIC_TYPES.put("tree", ["object"] as String[]); + METHODS_WITH_SPECIFIC_TYPES.put("unfold", useE2); + } + public static void create(final String anonymousTraversalFile) { + final StringBuilder csharpClass = new StringBuilder() csharpClass.append(CommonContentHelper.getLicense()) csharpClass.append( """ +using System.Collections.Generic; +using Gremlin.Net.Structure; + namespace Gremlin.Net.Process.Traversal { public static class __ { - public static GraphTraversal Start() + public static GraphTraversal Start() { - return new GraphTraversal(); + return new GraphTraversal(); } """) __.getMethods(). findAll { GraphTraversal.class.equals(it.returnType) }. findAll { Modifier.isStatic(it.getModifiers()) }. - collect { it.name }. - findAll { !it.equals("__") && !it.equals("start") }. - unique(). - sort { a, b -> a <=> b }. - forEach { javaMethodName -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) - + findAll { !it.name.equals("__") && !it.name.equals("start") }. + groupBy { it.name }. + // Select unique by name, with the most amount of parameters + collect { it.value.sort { a, b -> b.parameterCount <=> a.parameterCount }.first() }. + sort { it.name }. + forEach { javaMethod -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethod.name); + String[] typeNames = SymbolHelper.getJavaParameterTypeNames(javaMethod); + def t2 = SymbolHelper.toCSharpType(typeNames[1]); + def tParam = SymbolHelper.getCSharpGenericTypeParam(t2); + def specificTypes = METHODS_WITH_SPECIFIC_TYPES.get(javaMethod.name); + if (specificTypes) { + t2 = specificTypes[0]; + tParam = specificTypes.length > 1 ? "<" + specificTypes[1] + ">" : ""; + } csharpClass.append( """ - public static GraphTraversal ${sharpMethodName}(params object[] args) + public static GraphTraversal $sharpMethodName$tParam(params object[] args) { - return new GraphTraversal().${sharpMethodName}(args); + return new GraphTraversal().$sharpMethodName$tParam(args); } """) } - csharpClass.append("\t}\n") - csharpClass.append("}") + csharpClass.append(" }\n}") final File file = new File(anonymousTraversalFile); file.delete() diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy index 799e0010821..840b604dbca 100644 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy @@ -20,20 +20,66 @@ package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.util.CoreImports +import org.apache.tinkerpop.gremlin.structure.Direction class EnumGenerator { public static void create(final String enumDirectory) { + Map enumCSharpToJavaNames = new HashMap(); for (final Class enumClass : CoreImports.getClassImports() .findAll { Enum.class.isAssignableFrom(it) } .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() } .collect()) { - createEnum(enumDirectory, enumClass) + createEnum(enumDirectory, enumClass, enumCSharpToJavaNames) } + + // Write a file containing the equivalence in names between Java and C# + final String enumCSharpToJavaFile = "$enumDirectory/NamingConversions.cs" + final File file = new File(enumCSharpToJavaFile); + file.delete(); + file.append(CommonContentHelper.getLicense()); + file.append(""" +using System.Collections.Generic; + +namespace Gremlin.Net.Process.Traversal +{ + internal static class NamingConversions + { + /// + /// Gets the Java name equivalent for a given enum value + /// + internal static string GetEnumJavaName(string typeName, string value) + { + var key = \$"{typeName}.{value}"; + string javaName; + if (!CSharpToJavaEnums.TryGetValue(key, out javaName)) + { + throw new KeyNotFoundException(\$"Java name for {key} not found"); + } + return javaName; + } + + internal static readonly IDictionary CSharpToJavaEnums = new Dictionary + { +""" ); + def lastIndex = (enumCSharpToJavaNames.size() - 1); + enumCSharpToJavaNames.eachWithIndex{ node, i -> + file.append(""" {"$node.key", "$node.value"}${i == lastIndex ? "" : ","}\n""") + } + file.append(" };\n }\n}"); + + } + + public static String toCSharpName(final Class enumClass, String itemName) { + if (enumClass.equals(Direction.class)) { + itemName = itemName.toLowerCase(); + } + return itemName.substring(0, 1).toUpperCase() + itemName.substring(1); } - private static void createEnum(final String enumDirectory, final Class enumClass){ + private static void createEnum(final String enumDirectory, final Class enumClass, + final Map csharpToJava) { final StringBuilder csharpEnum = new StringBuilder() csharpEnum.append(CommonContentHelper.getLicense()) @@ -45,9 +91,13 @@ namespace Gremlin.Net.Process.Traversal public enum ${enumClass.getSimpleName()} { """) - enumClass.getEnumConstants() - .sort { a, b -> a.name() <=> b.name() } - .each { value -> csharpEnum.append(" ${value.name()},\n"); } + enumClass.getEnumConstants(). + sort { a, b -> a.name() <=> b.name() }. + each { value -> + def csharpName = toCSharpName(enumClass, value.name()); + csharpEnum.append(" $csharpName,\n"); + csharpToJava.put(enumClass.simpleName + "." + csharpName, value.name()); + } csharpEnum.deleteCharAt(csharpEnum.length() - 2) csharpEnum.append(" }\n") diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy index 58a399110fb..d3bade53a26 100644 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy @@ -32,10 +32,11 @@ class GraphTraversalGenerator { csharpClass.append( """ using System.Collections.Generic; +using Gremlin.Net.Structure; namespace Gremlin.Net.Process.Traversal { - public class GraphTraversal : DefaultTraversal + public class GraphTraversal : DefaultTraversal { public GraphTraversal() : this(new List(), new Bytecode()) @@ -47,27 +48,40 @@ namespace Gremlin.Net.Process.Traversal TraversalStrategies = traversalStrategies; Bytecode = bytecode; } + + private static GraphTraversal Wrap(GraphTraversal traversal) + { + if (typeof(S2) == typeof(S) && typeof(E2) == typeof(E)) + { + return traversal as GraphTraversal; + } + // New wrapper + return new GraphTraversal(traversal.TraversalStrategies, traversal.Bytecode); + } + """) 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 }. - forEach { javaMethodName -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) - + groupBy { it.name }. + // Select unique by name, with the most amount of parameters + collect { it.value.sort { a, b -> b.parameterCount <=> a.parameterCount }.first() }. + sort { it.name }. + forEach { javaMethod -> + String[] typeNames = SymbolHelper.getJavaParameterTypeNames(javaMethod); + def t1 = SymbolHelper.toCSharpType(typeNames[0]); + def t2 = SymbolHelper.toCSharpType(typeNames[1]); + def tParam = SymbolHelper.getCSharpGenericTypeParam(t2); csharpClass.append( - """ - public GraphTraversal ${sharpMethodName}(params object[] args) +""" + public GraphTraversal<$t1, $t2> ${SymbolHelper.toCSharp(javaMethod.name)}$tParam(params object[] args) { - Bytecode.AddStep("${javaMethodName}", args); - return this; + Bytecode.AddStep("$javaMethod.name", args); + return Wrap<$t1, $t2>(this); } """) } - csharpClass.append("\t}\n") - csharpClass.append("}") + csharpClass.append(" }\n}") final File file = new File(graphTraversalFile); file.delete() diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy index fce4b70a6a9..7cb41da67a9 100644 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy @@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.dotnet import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource - +import java.lang.reflect.* class GraphTraversalSourceGenerator { @@ -36,6 +36,7 @@ class GraphTraversalSourceGenerator { using System.Collections.Generic; using Gremlin.Net.Process.Remote; using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Structure; namespace Gremlin.Net.Process.Traversal { @@ -57,9 +58,6 @@ namespace Gremlin.Net.Process.Traversal """ ) - // Hold the list of methods with their overloads, so we do not create duplicates - HashMap> sharpMethods = new HashMap>() - GraphTraversalSource.getMethods(). // SOURCE STEPS findAll { GraphTraversalSource.class.equals(it.returnType) }. findAll { @@ -110,27 +108,32 @@ namespace Gremlin.Net.Process.Traversal } """) - GraphTraversalSource.getMethods(). // SPAWN STEPS + GraphTraversalSource.getMethods(). findAll { GraphTraversal.class.equals(it.returnType) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }. - forEach { javaMethodName -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) + unique{ a -> a.name }. + sort { a, b -> a.name <=> b.name }. + forEach { javaMethod -> + String sharpMethodName = SymbolHelper.toCSharp(javaMethod.name); + Type[] typeArguments = ((ParameterizedType)javaMethod.getGenericReturnType()).actualTypeArguments; + if (typeArguments.length != 2 || !(typeArguments[0] instanceof Class)) { + return; + } + def returnType = """GraphTraversal<${ + ((Class)typeArguments[0]).getSimpleName()}, ${((Class)typeArguments[1]).getSimpleName()}>"""; + csharpClass.append( """ - public GraphTraversal ${sharpMethodName}(params object[] args) + public ${returnType} ${sharpMethodName}(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); - traversal.Bytecode.AddStep("${javaMethodName}\", args); + var traversal = new ${returnType}(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("${javaMethod.name}\", args); return traversal; } """) } - csharpClass.append("\t}\n") - csharpClass.append("}") + csharpClass.append(" }\n}") final File file = new File(graphTraversalSourceFile); file.delete() diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy index 2633de6e498..c5c9c10906b 100644 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy @@ -55,8 +55,7 @@ namespace Gremlin.Net.Process.Traversal } """) } - csharpClass.append("\t}\n") - csharpClass.append("}") + csharpClass.append(" }\n}") final File file = new File(predicateFile) file.delete() diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy index 6c237e8e394..c041062cbe7 100644 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy +++ b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy @@ -19,8 +19,29 @@ package org.apache.tinkerpop.gremlin.dotnet +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; + public final class SymbolHelper { + private static final Map TO_CSHARP_TYPE_MAP = new HashMap<>(); + + static { + TO_CSHARP_TYPE_MAP.put("Long", "long"); + TO_CSHARP_TYPE_MAP.put("Integer", "int"); + TO_CSHARP_TYPE_MAP.put("String", "string"); + TO_CSHARP_TYPE_MAP.put("Object", "object"); + TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary"); + TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary") + TO_CSHARP_TYPE_MAP.put("java.util.List", "IList"); + TO_CSHARP_TYPE_MAP.put("java.util.List", "IList"); + TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary"); + TO_CSHARP_TYPE_MAP.put("java.util.Collection", "ICollection"); + TO_CSHARP_TYPE_MAP.put("java.util.Collection", "ICollection") + TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary"); + TO_CSHARP_TYPE_MAP.put("TraversalMetrics", "E2"); + } + public static String toCSharp(final String symbol) { return (String) Character.toUpperCase(symbol.charAt(0)) + symbol.substring(1) } @@ -28,4 +49,41 @@ public final class SymbolHelper { public static String toJava(final String symbol) { return (String) Character.toLowerCase(symbol.charAt(0)) + symbol.substring(1) } + + public static String toCSharpType(final String name) { + String typeName = TO_CSHARP_TYPE_MAP.getOrDefault(name, name); + if (typeName.equals(name) && (typeName.contains("? extends") || typeName.equals("Tree"))) { + typeName = "E2"; + } + return typeName; + } + + public static String[] getJavaParameterTypeNames(final Method method) { + def typeArguments = ((ParameterizedType)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; + }; + } + + public static String getCSharpGenericTypeParam(String typeName) { + def tParam = ""; + if (typeName.contains("E2")) { + tParam = ""; + } + else if (typeName.contains("")) { + tParam = ""; + } + else if (typeName.contains(" /// The to submit. /// A allowing to access the results and side-effects. - public async Task SubmitAsync(Bytecode bytecode) + public async Task> SubmitAsync(Bytecode bytecode) { var requestId = Guid.NewGuid(); var resultSet = await SubmitBytecodeAsync(requestId, bytecode).ConfigureAwait(false); - return new DriverRemoteTraversal(_client, requestId, resultSet); + return new DriverRemoteTraversal(_client, requestId, resultSet); } private async Task> SubmitBytecodeAsync(Guid requestid, Bytecode bytecode) diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs index f3f26d17ae6..5ce835fcb27 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversal.cs @@ -27,7 +27,7 @@ namespace Gremlin.Net.Driver.Remote { - internal class DriverRemoteTraversal : DefaultTraversal + internal class DriverRemoteTraversal : DefaultTraversal { public DriverRemoteTraversal(IGremlinClient gremlinClient, Guid requestId, IEnumerable traversers) diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs index 8555cb3d96e..5393bcbd19f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/IRemoteConnection.cs @@ -37,6 +37,6 @@ public interface IRemoteConnection /// /// The to send. /// The with the results and optional side-effects. - Task SubmitAsync(Bytecode bytecode); + Task> SubmitAsync(Bytecode bytecode); } } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs index 4826113444e..b3f8c4426d9 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs @@ -44,16 +44,16 @@ public RemoteStrategy(IRemoteConnection remoteConnection) } /// - public void Apply(ITraversal traversal) + public void Apply(ITraversal traversal) { ApplyAsync(traversal).Wait(); } /// - public async Task ApplyAsync(ITraversal traversal) + public async Task ApplyAsync(ITraversal traversal) { if (traversal.Traversers != null) return; - var remoteTraversal = await _remoteConnection.SubmitAsync(traversal.Bytecode).ConfigureAwait(false); + var remoteTraversal = await _remoteConnection.SubmitAsync(traversal.Bytecode).ConfigureAwait(false); traversal.SideEffects = remoteTraversal.SideEffects; traversal.Traversers = remoteTraversal.Traversers; } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs index 13d179649a8..6ef1d4f41c3 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -25,6 +25,6 @@ namespace Gremlin.Net.Process.Traversal { public enum Barrier { - normSack + NormSack } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs index f2365c32b54..b158d09a8a4 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -25,8 +25,8 @@ namespace Gremlin.Net.Process.Traversal { public enum Cardinality { - list, - set, - single + List, + Set, + Single } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index ee591dad95e..0f3556c11f2 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -25,7 +25,7 @@ namespace Gremlin.Net.Process.Traversal { public enum Column { - keys, - values + Keys, + Values } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs index 86c636ce61e..2652df3a508 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs @@ -22,6 +22,7 @@ #endregion using System; +using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; @@ -30,7 +31,7 @@ namespace Gremlin.Net.Process.Traversal /// /// A traversal represents a directed walk over a graph. /// - public abstract class DefaultTraversal : ITraversal + public abstract class DefaultTraversal : ITraversal { private IEnumerator _traverserEnumerator; @@ -85,7 +86,9 @@ public void Reset() } /// - public object Current => TraverserEnumerator.Current?.Object; + public E Current => (E)TraverserEnumerator.Current?.Object; + + object IEnumerator.Current => Current; private IEnumerator GetTraverserEnumerator() { @@ -110,7 +113,7 @@ private async Task ApplyStrategiesAsync() /// Gets the next result from the traversal. /// /// The result. - public object Next() + public E Next() { MoveNext(); return Current; @@ -121,7 +124,7 @@ public object Next() /// /// The number of results to get. /// The n-results. - public IEnumerable Next(int amount) + public IEnumerable Next(int amount) { for (var i = 0; i < amount; i++) yield return Next(); @@ -131,7 +134,7 @@ public IEnumerable Next(int amount) /// Iterates all instances in the traversal. /// /// The fully drained traversal. - public ITraversal Iterate() + public ITraversal Iterate() { while (MoveNext()) { @@ -153,9 +156,9 @@ public Traverser NextTraverser() /// Puts all the results into a . /// /// The results in a list. - public List ToList() + public IList ToList() { - var objs = new List(); + var objs = new List(); while (MoveNext()) objs.Add(Current); return objs; @@ -165,9 +168,9 @@ public List ToList() /// Puts all the results into a . /// /// The results in a set. - public HashSet ToSet() + public ISet ToSet() { - var objs = new HashSet(); + var objs = new HashSet(); while (MoveNext()) objs.Add(Current); return objs; @@ -186,7 +189,7 @@ protected virtual void Dispose(bool disposing) /// The return type of the . /// The function to execute on the current traversal. /// The result of the executed . - public async Task Promise(Func callback) + public async Task Promise(Func, TReturn> callback) { await ApplyStrategiesAsync().ConfigureAwait(false); return callback(this); diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs index 413e11feafc..100296cf0f8 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -25,8 +25,8 @@ namespace Gremlin.Net.Process.Traversal { public enum Direction { - BOTH, - IN, - OUT + Both, + In, + Out } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 88e9261d273..0f3fbb70f9f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -22,10 +22,11 @@ #endregion using System.Collections.Generic; +using Gremlin.Net.Structure; namespace Gremlin.Net.Process.Traversal { - public class GraphTraversal : DefaultTraversal + public class GraphTraversal : DefaultTraversal { public GraphTraversal() : this(new List(), new Bytecode()) @@ -38,592 +39,603 @@ public GraphTraversal(ICollection traversalStrategies, Bytec Bytecode = bytecode; } - public GraphTraversal V(params object[] args) + private static GraphTraversal Wrap(GraphTraversal traversal) + { + if (typeof(S2) == typeof(S) && typeof(E2) == typeof(E)) + { + return traversal as GraphTraversal; + } + // New wrapper + return new GraphTraversal(traversal.TraversalStrategies, traversal.Bytecode); + } + + + public GraphTraversal V(params object[] args) { Bytecode.AddStep("V", args); - return this; + return Wrap(this); } - public GraphTraversal AddE(params object[] args) + public GraphTraversal AddE(params object[] args) { Bytecode.AddStep("addE", args); - return this; + return Wrap(this); } - public GraphTraversal AddInE(params object[] args) + public GraphTraversal AddInE(params object[] args) { Bytecode.AddStep("addInE", args); - return this; + return Wrap(this); } - public GraphTraversal AddOutE(params object[] args) + public GraphTraversal AddOutE(params object[] args) { Bytecode.AddStep("addOutE", args); - return this; + return Wrap(this); } - public GraphTraversal AddV(params object[] args) + public GraphTraversal AddV(params object[] args) { Bytecode.AddStep("addV", args); - return this; + return Wrap(this); } - public GraphTraversal Aggregate(params object[] args) + public GraphTraversal Aggregate(params object[] args) { Bytecode.AddStep("aggregate", args); - return this; + return Wrap(this); } - public GraphTraversal And(params object[] args) + public GraphTraversal And(params object[] args) { Bytecode.AddStep("and", args); - return this; + return Wrap(this); } - public GraphTraversal As(params object[] args) + public GraphTraversal As(params object[] args) { Bytecode.AddStep("as", args); - return this; + return Wrap(this); } - public GraphTraversal Barrier(params object[] args) + public GraphTraversal Barrier(params object[] args) { Bytecode.AddStep("barrier", args); - return this; + return Wrap(this); } - public GraphTraversal Both(params object[] args) + public GraphTraversal Both(params object[] args) { Bytecode.AddStep("both", args); - return this; + return Wrap(this); } - public GraphTraversal BothE(params object[] args) + public GraphTraversal BothE(params object[] args) { Bytecode.AddStep("bothE", args); - return this; + return Wrap(this); } - public GraphTraversal BothV(params object[] args) + public GraphTraversal BothV(params object[] args) { Bytecode.AddStep("bothV", args); - return this; + return Wrap(this); } - public GraphTraversal Branch(params object[] args) + public GraphTraversal Branch(params object[] args) { Bytecode.AddStep("branch", args); - return this; + return Wrap(this); } - public GraphTraversal By(params object[] args) + public GraphTraversal By(params object[] args) { Bytecode.AddStep("by", args); - return this; + return Wrap(this); } - public GraphTraversal Cap(params object[] args) + public GraphTraversal Cap(params object[] args) { Bytecode.AddStep("cap", args); - return this; + return Wrap(this); } - public GraphTraversal Choose(params object[] args) + public GraphTraversal Choose(params object[] args) { Bytecode.AddStep("choose", args); - return this; + return Wrap(this); } - public GraphTraversal Coalesce(params object[] args) + public GraphTraversal Coalesce(params object[] args) { Bytecode.AddStep("coalesce", args); - return this; + return Wrap(this); } - public GraphTraversal Coin(params object[] args) + public GraphTraversal Coin(params object[] args) { Bytecode.AddStep("coin", args); - return this; + return Wrap(this); } - public GraphTraversal Constant(params object[] args) + public GraphTraversal Constant(params object[] args) { Bytecode.AddStep("constant", args); - return this; + return Wrap(this); } - public GraphTraversal Count(params object[] args) + public GraphTraversal Count(params object[] args) { Bytecode.AddStep("count", args); - return this; + return Wrap(this); } - public GraphTraversal CyclicPath(params object[] args) + public GraphTraversal CyclicPath(params object[] args) { Bytecode.AddStep("cyclicPath", args); - return this; + return Wrap(this); } - public GraphTraversal Dedup(params object[] args) + public GraphTraversal Dedup(params object[] args) { Bytecode.AddStep("dedup", args); - return this; + return Wrap(this); } - public GraphTraversal Drop(params object[] args) + public GraphTraversal Drop(params object[] args) { Bytecode.AddStep("drop", args); - return this; + return Wrap(this); } - public GraphTraversal Emit(params object[] args) + public GraphTraversal Emit(params object[] args) { Bytecode.AddStep("emit", args); - return this; + return Wrap(this); } - public GraphTraversal Filter(params object[] args) + public GraphTraversal Filter(params object[] args) { Bytecode.AddStep("filter", args); - return this; + return Wrap(this); } - public GraphTraversal FlatMap(params object[] args) + public GraphTraversal FlatMap(params object[] args) { Bytecode.AddStep("flatMap", args); - return this; + return Wrap(this); } - public GraphTraversal Fold(params object[] args) + public GraphTraversal Fold(params object[] args) { Bytecode.AddStep("fold", args); - return this; + return Wrap(this); } - public GraphTraversal From(params object[] args) + public GraphTraversal From(params object[] args) { Bytecode.AddStep("from", args); - return this; + return Wrap(this); } - public GraphTraversal Group(params object[] args) + public GraphTraversal Group(params object[] args) { Bytecode.AddStep("group", args); - return this; + return Wrap(this); } - public GraphTraversal GroupCount(params object[] args) + public GraphTraversal GroupCount(params object[] args) { Bytecode.AddStep("groupCount", args); - return this; + return Wrap(this); } - public GraphTraversal GroupV3d0(params object[] args) + public GraphTraversal GroupV3d0(params object[] args) { Bytecode.AddStep("groupV3d0", args); - return this; + return Wrap(this); } - public GraphTraversal Has(params object[] args) + public GraphTraversal Has(params object[] args) { Bytecode.AddStep("has", args); - return this; + return Wrap(this); } - public GraphTraversal HasId(params object[] args) + public GraphTraversal HasId(params object[] args) { Bytecode.AddStep("hasId", args); - return this; + return Wrap(this); } - public GraphTraversal HasKey(params object[] args) + public GraphTraversal HasKey(params object[] args) { Bytecode.AddStep("hasKey", args); - return this; + return Wrap(this); } - public GraphTraversal HasLabel(params object[] args) + public GraphTraversal HasLabel(params object[] args) { Bytecode.AddStep("hasLabel", args); - return this; + return Wrap(this); } - public GraphTraversal HasNot(params object[] args) + public GraphTraversal HasNot(params object[] args) { Bytecode.AddStep("hasNot", args); - return this; + return Wrap(this); } - public GraphTraversal HasValue(params object[] args) + public GraphTraversal HasValue(params object[] args) { Bytecode.AddStep("hasValue", args); - return this; + return Wrap(this); } - public GraphTraversal Id(params object[] args) + public GraphTraversal Id(params object[] args) { Bytecode.AddStep("id", args); - return this; + return Wrap(this); } - public GraphTraversal Identity(params object[] args) + public GraphTraversal Identity(params object[] args) { Bytecode.AddStep("identity", args); - return this; + return Wrap(this); } - public GraphTraversal In(params object[] args) + public GraphTraversal In(params object[] args) { Bytecode.AddStep("in", args); - return this; + return Wrap(this); } - public GraphTraversal InE(params object[] args) + public GraphTraversal InE(params object[] args) { Bytecode.AddStep("inE", args); - return this; + return Wrap(this); } - public GraphTraversal InV(params object[] args) + public GraphTraversal InV(params object[] args) { Bytecode.AddStep("inV", args); - return this; + return Wrap(this); } - public GraphTraversal Inject(params object[] args) + public GraphTraversal Inject(params object[] args) { Bytecode.AddStep("inject", args); - return this; + return Wrap(this); } - public GraphTraversal Is(params object[] args) + public GraphTraversal Is(params object[] args) { Bytecode.AddStep("is", args); - return this; + return Wrap(this); } - public GraphTraversal Key(params object[] args) + public GraphTraversal Key(params object[] args) { Bytecode.AddStep("key", args); - return this; + return Wrap(this); } - public GraphTraversal Label(params object[] args) + public GraphTraversal Label(params object[] args) { Bytecode.AddStep("label", args); - return this; + return Wrap(this); } - public GraphTraversal Limit(params object[] args) + public GraphTraversal Limit(params object[] args) { Bytecode.AddStep("limit", args); - return this; + return Wrap(this); } - public GraphTraversal Local(params object[] args) + public GraphTraversal Local(params object[] args) { Bytecode.AddStep("local", args); - return this; + return Wrap(this); } - public GraphTraversal Loops(params object[] args) + public GraphTraversal Loops(params object[] args) { Bytecode.AddStep("loops", args); - return this; + return Wrap(this); } - public GraphTraversal Map(params object[] args) + public GraphTraversal Map(params object[] args) { Bytecode.AddStep("map", args); - return this; + return Wrap(this); } - public GraphTraversal MapKeys(params object[] args) + public GraphTraversal MapKeys(params object[] args) { Bytecode.AddStep("mapKeys", args); - return this; + return Wrap(this); } - public GraphTraversal MapValues(params object[] args) + public GraphTraversal MapValues(params object[] args) { Bytecode.AddStep("mapValues", args); - return this; + return Wrap(this); } - public GraphTraversal Match(params object[] args) + public GraphTraversal> Match(params object[] args) { Bytecode.AddStep("match", args); - return this; + return Wrap>(this); } - public GraphTraversal Max(params object[] args) + public GraphTraversal Max(params object[] args) { Bytecode.AddStep("max", args); - return this; + return Wrap(this); } - public GraphTraversal Mean(params object[] args) + public GraphTraversal Mean(params object[] args) { Bytecode.AddStep("mean", args); - return this; + return Wrap(this); } - public GraphTraversal Min(params object[] args) + public GraphTraversal Min(params object[] args) { Bytecode.AddStep("min", args); - return this; + return Wrap(this); } - public GraphTraversal Not(params object[] args) + public GraphTraversal Not(params object[] args) { Bytecode.AddStep("not", args); - return this; + return Wrap(this); } - public GraphTraversal Option(params object[] args) + public GraphTraversal Option(params object[] args) { Bytecode.AddStep("option", args); - return this; + return Wrap(this); } - public GraphTraversal Optional(params object[] args) + public GraphTraversal Optional(params object[] args) { Bytecode.AddStep("optional", args); - return this; + return Wrap(this); } - public GraphTraversal Or(params object[] args) + public GraphTraversal Or(params object[] args) { Bytecode.AddStep("or", args); - return this; + return Wrap(this); } - public GraphTraversal Order(params object[] args) + public GraphTraversal Order(params object[] args) { Bytecode.AddStep("order", args); - return this; + return Wrap(this); } - public GraphTraversal OtherV(params object[] args) + public GraphTraversal OtherV(params object[] args) { Bytecode.AddStep("otherV", args); - return this; + return Wrap(this); } - public GraphTraversal Out(params object[] args) + public GraphTraversal Out(params object[] args) { Bytecode.AddStep("out", args); - return this; + return Wrap(this); } - public GraphTraversal OutE(params object[] args) + public GraphTraversal OutE(params object[] args) { Bytecode.AddStep("outE", args); - return this; + return Wrap(this); } - public GraphTraversal OutV(params object[] args) + public GraphTraversal OutV(params object[] args) { Bytecode.AddStep("outV", args); - return this; + return Wrap(this); } - public GraphTraversal PageRank(params object[] args) + public GraphTraversal PageRank(params object[] args) { Bytecode.AddStep("pageRank", args); - return this; + return Wrap(this); } - public GraphTraversal Path(params object[] args) + public GraphTraversal Path(params object[] args) { Bytecode.AddStep("path", args); - return this; + return Wrap(this); } - public GraphTraversal PeerPressure(params object[] args) + public GraphTraversal PeerPressure(params object[] args) { Bytecode.AddStep("peerPressure", args); - return this; + return Wrap(this); } - public GraphTraversal Profile(params object[] args) + public GraphTraversal Profile(params object[] args) { Bytecode.AddStep("profile", args); - return this; + return Wrap(this); } - public GraphTraversal Program(params object[] args) + public GraphTraversal Program(params object[] args) { Bytecode.AddStep("program", args); - return this; + return Wrap(this); } - public GraphTraversal Project(params object[] args) + public GraphTraversal> Project(params object[] args) { Bytecode.AddStep("project", args); - return this; + return Wrap>(this); } - public GraphTraversal Properties(params object[] args) + public GraphTraversal Properties(params object[] args) { Bytecode.AddStep("properties", args); - return this; + return Wrap(this); } - public GraphTraversal Property(params object[] args) + public GraphTraversal Property(params object[] args) { Bytecode.AddStep("property", args); - return this; + return Wrap(this); } - public GraphTraversal PropertyMap(params object[] args) + public GraphTraversal> PropertyMap(params object[] args) { Bytecode.AddStep("propertyMap", args); - return this; + return Wrap>(this); } - public GraphTraversal Range(params object[] args) + public GraphTraversal Range(params object[] args) { Bytecode.AddStep("range", args); - return this; + return Wrap(this); } - public GraphTraversal Repeat(params object[] args) + public GraphTraversal Repeat(params object[] args) { Bytecode.AddStep("repeat", args); - return this; + return Wrap(this); } - public GraphTraversal Sack(params object[] args) + public GraphTraversal Sack(params object[] args) { Bytecode.AddStep("sack", args); - return this; + return Wrap(this); } - public GraphTraversal Sample(params object[] args) + public GraphTraversal Sample(params object[] args) { Bytecode.AddStep("sample", args); - return this; + return Wrap(this); } - public GraphTraversal Select(params object[] args) + public GraphTraversal> Select(params object[] args) { Bytecode.AddStep("select", args); - return this; + return Wrap>(this); } - public GraphTraversal SideEffect(params object[] args) + public GraphTraversal SideEffect(params object[] args) { Bytecode.AddStep("sideEffect", args); - return this; + return Wrap(this); } - public GraphTraversal SimplePath(params object[] args) + public GraphTraversal SimplePath(params object[] args) { Bytecode.AddStep("simplePath", args); - return this; + return Wrap(this); } - public GraphTraversal Store(params object[] args) + public GraphTraversal Store(params object[] args) { Bytecode.AddStep("store", args); - return this; + return Wrap(this); } - public GraphTraversal Subgraph(params object[] args) + public GraphTraversal Subgraph(params object[] args) { Bytecode.AddStep("subgraph", args); - return this; + return Wrap(this); } - public GraphTraversal Sum(params object[] args) + public GraphTraversal Sum(params object[] args) { Bytecode.AddStep("sum", args); - return this; + return Wrap(this); } - public GraphTraversal Tail(params object[] args) + public GraphTraversal Tail(params object[] args) { Bytecode.AddStep("tail", args); - return this; + return Wrap(this); } - public GraphTraversal TimeLimit(params object[] args) + public GraphTraversal TimeLimit(params object[] args) { Bytecode.AddStep("timeLimit", args); - return this; + return Wrap(this); } - public GraphTraversal Times(params object[] args) + public GraphTraversal Times(params object[] args) { Bytecode.AddStep("times", args); - return this; + return Wrap(this); } - public GraphTraversal To(params object[] args) + public GraphTraversal To(params object[] args) { Bytecode.AddStep("to", args); - return this; + return Wrap(this); } - public GraphTraversal ToE(params object[] args) + public GraphTraversal ToE(params object[] args) { Bytecode.AddStep("toE", args); - return this; + return Wrap(this); } - public GraphTraversal ToV(params object[] args) + public GraphTraversal ToV(params object[] args) { Bytecode.AddStep("toV", args); - return this; + return Wrap(this); } - public GraphTraversal Tree(params object[] args) + public GraphTraversal Tree(params object[] args) { Bytecode.AddStep("tree", args); - return this; + return Wrap(this); } - public GraphTraversal Unfold(params object[] args) + public GraphTraversal Unfold(params object[] args) { Bytecode.AddStep("unfold", args); - return this; + return Wrap(this); } - public GraphTraversal Union(params object[] args) + public GraphTraversal Union(params object[] args) { Bytecode.AddStep("union", args); - return this; + return Wrap(this); } - public GraphTraversal Until(params object[] args) + public GraphTraversal Until(params object[] args) { Bytecode.AddStep("until", args); - return this; + return Wrap(this); } - public GraphTraversal Value(params object[] args) + public GraphTraversal Value(params object[] args) { Bytecode.AddStep("value", args); - return this; + return Wrap(this); } - public GraphTraversal ValueMap(params object[] args) + public GraphTraversal> ValueMap(params object[] args) { Bytecode.AddStep("valueMap", args); - return this; + return Wrap>(this); } - public GraphTraversal Values(params object[] args) + public GraphTraversal Values(params object[] args) { Bytecode.AddStep("values", args); - return this; + return Wrap(this); } - public GraphTraversal Where(params object[] args) + public GraphTraversal Where(params object[] args) { Bytecode.AddStep("where", args); - return this; + return Wrap(this); } - } + } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs index 638278185e6..07d98fb23a8 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -24,6 +24,7 @@ using System.Collections.Generic; using Gremlin.Net.Process.Remote; using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Structure; namespace Gremlin.Net.Process.Traversal { @@ -111,32 +112,25 @@ public GraphTraversalSource WithComputer(string graphComputer = null, int? worke return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); } - public GraphTraversal E(params object[] args) + public GraphTraversal E(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); traversal.Bytecode.AddStep("E", args); return traversal; } - public GraphTraversal V(params object[] args) + public GraphTraversal V(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); traversal.Bytecode.AddStep("V", args); return traversal; } - public GraphTraversal AddV(params object[] args) + public GraphTraversal AddV(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); traversal.Bytecode.AddStep("addV", args); return traversal; } - - public GraphTraversal Inject(params object[] args) - { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); - traversal.Bytecode.AddStep("inject", args); - return traversal; - } - } + } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs index cb472b7c937..cb1c80e2272 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs @@ -29,9 +29,10 @@ namespace Gremlin.Net.Process.Traversal { /// - /// A traversal represents a directed walk over a graph. + /// Represents the basic information for a walk over a graph. /// - public interface ITraversal : IDisposable, IEnumerator + /// + public interface ITraversal { /// /// Gets the representation of this traversal. @@ -47,25 +48,31 @@ public interface ITraversal : IDisposable, IEnumerator /// Gets or sets the 's of this traversal that hold the results of the traversal. /// IEnumerable Traversers { get; set; } + } + /// + /// A traversal represents a directed walk over a graph. + /// + public interface ITraversal : ITraversal, IEnumerator + { /// /// Gets the next result from the traversal. /// /// The result. - object Next(); + E Next(); /// /// Gets the next n-number of results from the traversal. /// /// The number of results to get. /// The n-results. - IEnumerable Next(int amount); + IEnumerable Next(int amount); /// /// Iterates all instances in the traversal. /// /// The fully drained traversal. - ITraversal Iterate(); + ITraversal Iterate(); /// /// Gets the next . @@ -74,16 +81,16 @@ public interface ITraversal : IDisposable, IEnumerator Traverser NextTraverser(); /// - /// Puts all the results into a . + /// Puts all the results into a . /// /// The results in a list. - List ToList(); + IList ToList(); /// - /// Puts all the results into a . + /// Puts all the results into a . /// /// The results in a set. - HashSet ToSet(); + ISet ToSet(); /// /// Starts a promise to execute a function on the current traversal that will be completed in the future. @@ -91,6 +98,6 @@ public interface ITraversal : IDisposable, IEnumerator /// The return type of the . /// The function to execute on the current traversal. /// The result of the executed . - Task Promise(Func callback); + Task Promise(Func, TReturn> callback); } } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs index 991a807dbad..013d62ad503 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs @@ -35,12 +35,12 @@ public interface ITraversalStrategy /// Applies the strategy to the given . /// /// The the strategy should be applied to. - void Apply(ITraversal traversal); + void Apply(ITraversal traversal); /// /// Applies the strategy to the given asynchronously. /// /// The the strategy should be applied to. - Task ApplyAsync(ITraversal traversal); + Task ApplyAsync(ITraversal traversal); } } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs new file mode 100644 index 00000000000..6f5fec53e2f --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs @@ -0,0 +1,86 @@ +#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; + +namespace Gremlin.Net.Process.Traversal +{ + internal static class NamingConversions + { + /// + /// Gets the Java name equivalent for a given enum value + /// + internal static string GetEnumJavaName(string typeName, string value) + { + var key = $"{typeName}.{value}"; + string javaName; + if (!CSharpToJavaEnums.TryGetValue(key, out javaName)) + { + throw new KeyNotFoundException($"Java name for {key} not found"); + } + return javaName; + } + + internal static readonly IDictionary CSharpToJavaEnums = new Dictionary + { + {"T.Value", "value"}, + {"Order.Decr", "decr"}, + {"Order.KeyDecr", "keyDecr"}, + {"T.Key", "key"}, + {"Column.Values", "values"}, + {"Order.KeyIncr", "keyIncr"}, + {"Operator.Or", "or"}, + {"Order.ValueIncr", "valueIncr"}, + {"Cardinality.List", "list"}, + {"Order.Incr", "incr"}, + {"Pop.All", "all"}, + {"Operator.SumLong", "sumLong"}, + {"Pop.First", "first"}, + {"T.Label", "label"}, + {"Cardinality.Set", "set"}, + {"Order.Shuffle", "shuffle"}, + {"Direction.In", "IN"}, + {"Direction.Both", "BOTH"}, + {"Scope.Local", "local"}, + {"Operator.Max", "max"}, + {"Direction.Out", "OUT"}, + {"Scope.Global", "global"}, + {"Pick.Any", "any"}, + {"Order.ValueDecr", "valueDecr"}, + {"Column.Keys", "keys"}, + {"Operator.AddAll", "addAll"}, + {"Operator.Mult", "mult"}, + {"Pick.None", "none"}, + {"Pop.Last", "last"}, + {"Operator.And", "and"}, + {"T.Id", "id"}, + {"Operator.Min", "min"}, + {"Barrier.NormSack", "normSack"}, + {"Operator.Minus", "minus"}, + {"Cardinality.Single", "single"}, + {"Operator.Assign", "assign"}, + {"Operator.Div", "div"}, + {"Operator.Sum", "sum"} + }; + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index 563f0917eda..17b44a42a91 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -25,16 +25,16 @@ namespace Gremlin.Net.Process.Traversal { public enum Operator { - addAll, - and, - assign, - div, - max, - min, - minus, - mult, - or, - sum, - sumLong + AddAll, + And, + Assign, + Div, + Max, + Min, + Minus, + Mult, + Or, + Sum, + SumLong } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index bbd0eab692e..179182b46fe 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -25,12 +25,12 @@ namespace Gremlin.Net.Process.Traversal { public enum Order { - decr, - incr, - keyDecr, - keyIncr, - shuffle, - valueDecr, - valueIncr + Decr, + Incr, + KeyDecr, + KeyIncr, + Shuffle, + ValueDecr, + ValueIncr } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs index 0ecdccd605c..cf388bd005b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs @@ -103,5 +103,5 @@ public static TraversalPredicate Without(params object[] args) var value = args.Length == 1 ? args[0] : args; return new TraversalPredicate("without", value); } - } + } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs index f16aa20b79b..624f66e82e6 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -25,7 +25,7 @@ namespace Gremlin.Net.Process.Traversal { public enum Pick { - any, - none + Any, + None } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs index e0cf62e7fcd..dcbe698e7e6 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -25,8 +25,8 @@ namespace Gremlin.Net.Process.Traversal { public enum Pop { - all, - first, - last + All, + First, + Last } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs index c4af316c42f..f27725e8a9d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -25,7 +25,7 @@ namespace Gremlin.Net.Process.Traversal { public enum Scope { - global, - local + Global, + Local } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs index 8c9666c2dd1..e5d3dfe2bd4 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs @@ -52,12 +52,12 @@ public bool Equals(AbstractTraversalStrategy other) } /// - public virtual void Apply(ITraversal traversal) + public virtual void Apply(ITraversal traversal) { } /// - public virtual Task ApplyAsync(ITraversal traversal) + public virtual Task ApplyAsync(ITraversal traversal) { return Task.CompletedTask; } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index 50c15d9f12a..76ca40f5a98 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -25,9 +25,9 @@ namespace Gremlin.Net.Process.Traversal { public enum T { - id, - key, - label, - value + Id, + Key, + Label, + Value } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index e12037296b5..f2e6162921b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -21,468 +21,471 @@ #endregion +using System.Collections.Generic; +using Gremlin.Net.Structure; + namespace Gremlin.Net.Process.Traversal { public static class __ { - public static GraphTraversal Start() + public static GraphTraversal Start() { - return new GraphTraversal(); + return new GraphTraversal(); } - public static GraphTraversal V(params object[] args) + public static GraphTraversal V(params object[] args) { - return new GraphTraversal().V(args); + return new GraphTraversal().V(args); } - public static GraphTraversal AddE(params object[] args) + public static GraphTraversal AddE(params object[] args) { - return new GraphTraversal().AddE(args); + return new GraphTraversal().AddE(args); } - public static GraphTraversal AddInE(params object[] args) + public static GraphTraversal AddInE(params object[] args) { - return new GraphTraversal().AddInE(args); + return new GraphTraversal().AddInE(args); } - public static GraphTraversal AddOutE(params object[] args) + public static GraphTraversal AddOutE(params object[] args) { - return new GraphTraversal().AddOutE(args); + return new GraphTraversal().AddOutE(args); } - public static GraphTraversal AddV(params object[] args) + public static GraphTraversal AddV(params object[] args) { - return new GraphTraversal().AddV(args); + return new GraphTraversal().AddV(args); } - public static GraphTraversal Aggregate(params object[] args) + public static GraphTraversal Aggregate(params object[] args) { - return new GraphTraversal().Aggregate(args); + return new GraphTraversal().Aggregate(args); } - public static GraphTraversal And(params object[] args) + public static GraphTraversal And(params object[] args) { - return new GraphTraversal().And(args); + return new GraphTraversal().And(args); } - public static GraphTraversal As(params object[] args) + public static GraphTraversal As(params object[] args) { - return new GraphTraversal().As(args); + return new GraphTraversal().As(args); } - public static GraphTraversal Barrier(params object[] args) + public static GraphTraversal Barrier(params object[] args) { - return new GraphTraversal().Barrier(args); + return new GraphTraversal().Barrier(args); } - public static GraphTraversal Both(params object[] args) + public static GraphTraversal Both(params object[] args) { - return new GraphTraversal().Both(args); + return new GraphTraversal().Both(args); } - public static GraphTraversal BothE(params object[] args) + public static GraphTraversal BothE(params object[] args) { - return new GraphTraversal().BothE(args); + return new GraphTraversal().BothE(args); } - public static GraphTraversal BothV(params object[] args) + public static GraphTraversal BothV(params object[] args) { - return new GraphTraversal().BothV(args); + return new GraphTraversal().BothV(args); } - public static GraphTraversal Branch(params object[] args) + public static GraphTraversal Branch(params object[] args) { - return new GraphTraversal().Branch(args); + return new GraphTraversal().Branch(args); } - public static GraphTraversal Cap(params object[] args) + public static GraphTraversal Cap(params object[] args) { - return new GraphTraversal().Cap(args); + return new GraphTraversal().Cap(args); } - public static GraphTraversal Choose(params object[] args) + public static GraphTraversal Choose(params object[] args) { - return new GraphTraversal().Choose(args); + return new GraphTraversal().Choose(args); } - public static GraphTraversal Coalesce(params object[] args) + public static GraphTraversal Coalesce(params object[] args) { - return new GraphTraversal().Coalesce(args); + return new GraphTraversal().Coalesce(args); } - public static GraphTraversal Coin(params object[] args) + public static GraphTraversal Coin(params object[] args) { - return new GraphTraversal().Coin(args); + return new GraphTraversal().Coin(args); } - public static GraphTraversal Constant(params object[] args) + public static GraphTraversal Constant(params object[] args) { - return new GraphTraversal().Constant(args); + return new GraphTraversal().Constant(args); } - public static GraphTraversal Count(params object[] args) + public static GraphTraversal Count(params object[] args) { - return new GraphTraversal().Count(args); + return new GraphTraversal().Count(args); } - public static GraphTraversal CyclicPath(params object[] args) + public static GraphTraversal CyclicPath(params object[] args) { - return new GraphTraversal().CyclicPath(args); + return new GraphTraversal().CyclicPath(args); } - public static GraphTraversal Dedup(params object[] args) + public static GraphTraversal Dedup(params object[] args) { - return new GraphTraversal().Dedup(args); + return new GraphTraversal().Dedup(args); } - public static GraphTraversal Drop(params object[] args) + public static GraphTraversal Drop(params object[] args) { - return new GraphTraversal().Drop(args); + return new GraphTraversal().Drop(args); } - public static GraphTraversal Emit(params object[] args) + public static GraphTraversal Emit(params object[] args) { - return new GraphTraversal().Emit(args); + return new GraphTraversal().Emit(args); } - public static GraphTraversal Filter(params object[] args) + public static GraphTraversal Filter(params object[] args) { - return new GraphTraversal().Filter(args); + return new GraphTraversal().Filter(args); } - public static GraphTraversal FlatMap(params object[] args) + public static GraphTraversal FlatMap(params object[] args) { - return new GraphTraversal().FlatMap(args); + return new GraphTraversal().FlatMap(args); } - public static GraphTraversal Fold(params object[] args) + public static GraphTraversal Fold(params object[] args) { - return new GraphTraversal().Fold(args); + return new GraphTraversal().Fold(args); } - public static GraphTraversal Group(params object[] args) + public static GraphTraversal Group(params object[] args) { - return new GraphTraversal().Group(args); + return new GraphTraversal().Group(args); } - public static GraphTraversal GroupCount(params object[] args) + public static GraphTraversal GroupCount(params object[] args) { - return new GraphTraversal().GroupCount(args); + return new GraphTraversal().GroupCount(args); } - public static GraphTraversal GroupV3d0(params object[] args) + public static GraphTraversal GroupV3d0(params object[] args) { - return new GraphTraversal().GroupV3d0(args); + return new GraphTraversal().GroupV3d0(args); } - public static GraphTraversal Has(params object[] args) + public static GraphTraversal Has(params object[] args) { - return new GraphTraversal().Has(args); + return new GraphTraversal().Has(args); } - public static GraphTraversal HasId(params object[] args) + public static GraphTraversal HasId(params object[] args) { - return new GraphTraversal().HasId(args); + return new GraphTraversal().HasId(args); } - public static GraphTraversal HasKey(params object[] args) + public static GraphTraversal HasKey(params object[] args) { - return new GraphTraversal().HasKey(args); + return new GraphTraversal().HasKey(args); } - public static GraphTraversal HasLabel(params object[] args) + public static GraphTraversal HasLabel(params object[] args) { - return new GraphTraversal().HasLabel(args); + return new GraphTraversal().HasLabel(args); } - public static GraphTraversal HasNot(params object[] args) + public static GraphTraversal HasNot(params object[] args) { - return new GraphTraversal().HasNot(args); + return new GraphTraversal().HasNot(args); } - public static GraphTraversal HasValue(params object[] args) + public static GraphTraversal HasValue(params object[] args) { - return new GraphTraversal().HasValue(args); + return new GraphTraversal().HasValue(args); } - public static GraphTraversal Id(params object[] args) + public static GraphTraversal Id(params object[] args) { - return new GraphTraversal().Id(args); + return new GraphTraversal().Id(args); } - public static GraphTraversal Identity(params object[] args) + public static GraphTraversal Identity(params object[] args) { - return new GraphTraversal().Identity(args); + return new GraphTraversal().Identity(args); } - public static GraphTraversal In(params object[] args) + public static GraphTraversal In(params object[] args) { - return new GraphTraversal().In(args); + return new GraphTraversal().In(args); } - public static GraphTraversal InE(params object[] args) + public static GraphTraversal InE(params object[] args) { - return new GraphTraversal().InE(args); + return new GraphTraversal().InE(args); } - public static GraphTraversal InV(params object[] args) + public static GraphTraversal InV(params object[] args) { - return new GraphTraversal().InV(args); + return new GraphTraversal().InV(args); } - public static GraphTraversal Inject(params object[] args) + public static GraphTraversal Inject(params object[] args) { - return new GraphTraversal().Inject(args); + return new GraphTraversal().Inject(args); } - public static GraphTraversal Is(params object[] args) + public static GraphTraversal Is(params object[] args) { - return new GraphTraversal().Is(args); + return new GraphTraversal().Is(args); } - public static GraphTraversal Key(params object[] args) + public static GraphTraversal Key(params object[] args) { - return new GraphTraversal().Key(args); + return new GraphTraversal().Key(args); } - public static GraphTraversal Label(params object[] args) + public static GraphTraversal Label(params object[] args) { - return new GraphTraversal().Label(args); + return new GraphTraversal().Label(args); } - public static GraphTraversal Limit(params object[] args) + public static GraphTraversal Limit(params object[] args) { - return new GraphTraversal().Limit(args); + return new GraphTraversal().Limit(args); } - public static GraphTraversal Local(params object[] args) + public static GraphTraversal Local(params object[] args) { - return new GraphTraversal().Local(args); + return new GraphTraversal().Local(args); } - public static GraphTraversal Loops(params object[] args) + public static GraphTraversal Loops(params object[] args) { - return new GraphTraversal().Loops(args); + return new GraphTraversal().Loops(args); } - public static GraphTraversal Map(params object[] args) + public static GraphTraversal Map(params object[] args) { - return new GraphTraversal().Map(args); + return new GraphTraversal().Map(args); } - public static GraphTraversal MapKeys(params object[] args) + public static GraphTraversal MapKeys(params object[] args) { - return new GraphTraversal().MapKeys(args); + return new GraphTraversal().MapKeys(args); } - public static GraphTraversal MapValues(params object[] args) + public static GraphTraversal MapValues(params object[] args) { - return new GraphTraversal().MapValues(args); + return new GraphTraversal().MapValues(args); } - public static GraphTraversal Match(params object[] args) + public static GraphTraversal> Match(params object[] args) { - return new GraphTraversal().Match(args); + return new GraphTraversal().Match(args); } - public static GraphTraversal Max(params object[] args) + public static GraphTraversal Max(params object[] args) { - return new GraphTraversal().Max(args); + return new GraphTraversal().Max(args); } - public static GraphTraversal Mean(params object[] args) + public static GraphTraversal Mean(params object[] args) { - return new GraphTraversal().Mean(args); + return new GraphTraversal().Mean(args); } - public static GraphTraversal Min(params object[] args) + public static GraphTraversal Min(params object[] args) { - return new GraphTraversal().Min(args); + return new GraphTraversal().Min(args); } - public static GraphTraversal Not(params object[] args) + public static GraphTraversal Not(params object[] args) { - return new GraphTraversal().Not(args); + return new GraphTraversal().Not(args); } - public static GraphTraversal Optional(params object[] args) + public static GraphTraversal Optional(params object[] args) { - return new GraphTraversal().Optional(args); + return new GraphTraversal().Optional(args); } - public static GraphTraversal Or(params object[] args) + public static GraphTraversal Or(params object[] args) { - return new GraphTraversal().Or(args); + return new GraphTraversal().Or(args); } - public static GraphTraversal Order(params object[] args) + public static GraphTraversal Order(params object[] args) { - return new GraphTraversal().Order(args); + return new GraphTraversal().Order(args); } - public static GraphTraversal OtherV(params object[] args) + public static GraphTraversal OtherV(params object[] args) { - return new GraphTraversal().OtherV(args); + return new GraphTraversal().OtherV(args); } - public static GraphTraversal Out(params object[] args) + public static GraphTraversal Out(params object[] args) { - return new GraphTraversal().Out(args); + return new GraphTraversal().Out(args); } - public static GraphTraversal OutE(params object[] args) + public static GraphTraversal OutE(params object[] args) { - return new GraphTraversal().OutE(args); + return new GraphTraversal().OutE(args); } - public static GraphTraversal OutV(params object[] args) + public static GraphTraversal OutV(params object[] args) { - return new GraphTraversal().OutV(args); + return new GraphTraversal().OutV(args); } - public static GraphTraversal Path(params object[] args) + public static GraphTraversal Path(params object[] args) { - return new GraphTraversal().Path(args); + return new GraphTraversal().Path(args); } - public static GraphTraversal Project(params object[] args) + public static GraphTraversal> Project(params object[] args) { - return new GraphTraversal().Project(args); + return new GraphTraversal().Project(args); } - public static GraphTraversal Properties(params object[] args) + public static GraphTraversal Properties(params object[] args) { - return new GraphTraversal().Properties(args); + return new GraphTraversal().Properties(args); } - public static GraphTraversal Property(params object[] args) + public static GraphTraversal Property(params object[] args) { - return new GraphTraversal().Property(args); + return new GraphTraversal().Property(args); } - public static GraphTraversal PropertyMap(params object[] args) + public static GraphTraversal> PropertyMap(params object[] args) { - return new GraphTraversal().PropertyMap(args); + return new GraphTraversal().PropertyMap(args); } - public static GraphTraversal Range(params object[] args) + public static GraphTraversal Range(params object[] args) { - return new GraphTraversal().Range(args); + return new GraphTraversal().Range(args); } - public static GraphTraversal Repeat(params object[] args) + public static GraphTraversal Repeat(params object[] args) { - return new GraphTraversal().Repeat(args); + return new GraphTraversal().Repeat(args); } - public static GraphTraversal Sack(params object[] args) + public static GraphTraversal Sack(params object[] args) { - return new GraphTraversal().Sack(args); + return new GraphTraversal().Sack(args); } - public static GraphTraversal Sample(params object[] args) + public static GraphTraversal Sample(params object[] args) { - return new GraphTraversal().Sample(args); + return new GraphTraversal().Sample(args); } - public static GraphTraversal Select(params object[] args) + public static GraphTraversal> Select(params object[] args) { - return new GraphTraversal().Select(args); + return new GraphTraversal().Select(args); } - public static GraphTraversal SideEffect(params object[] args) + public static GraphTraversal SideEffect(params object[] args) { - return new GraphTraversal().SideEffect(args); + return new GraphTraversal().SideEffect(args); } - public static GraphTraversal SimplePath(params object[] args) + public static GraphTraversal SimplePath(params object[] args) { - return new GraphTraversal().SimplePath(args); + return new GraphTraversal().SimplePath(args); } - public static GraphTraversal Store(params object[] args) + public static GraphTraversal Store(params object[] args) { - return new GraphTraversal().Store(args); + return new GraphTraversal().Store(args); } - public static GraphTraversal Subgraph(params object[] args) + public static GraphTraversal Subgraph(params object[] args) { - return new GraphTraversal().Subgraph(args); + return new GraphTraversal().Subgraph(args); } - public static GraphTraversal Sum(params object[] args) + public static GraphTraversal Sum(params object[] args) { - return new GraphTraversal().Sum(args); + return new GraphTraversal().Sum(args); } - public static GraphTraversal Tail(params object[] args) + public static GraphTraversal Tail(params object[] args) { - return new GraphTraversal().Tail(args); + return new GraphTraversal().Tail(args); } - public static GraphTraversal TimeLimit(params object[] args) + public static GraphTraversal TimeLimit(params object[] args) { - return new GraphTraversal().TimeLimit(args); + return new GraphTraversal().TimeLimit(args); } - public static GraphTraversal Times(params object[] args) + public static GraphTraversal Times(params object[] args) { - return new GraphTraversal().Times(args); + return new GraphTraversal().Times(args); } - public static GraphTraversal To(params object[] args) + public static GraphTraversal To(params object[] args) { - return new GraphTraversal().To(args); + return new GraphTraversal().To(args); } - public static GraphTraversal ToE(params object[] args) + public static GraphTraversal ToE(params object[] args) { - return new GraphTraversal().ToE(args); + return new GraphTraversal().ToE(args); } - public static GraphTraversal ToV(params object[] args) + public static GraphTraversal ToV(params object[] args) { - return new GraphTraversal().ToV(args); + return new GraphTraversal().ToV(args); } - public static GraphTraversal Tree(params object[] args) + public static GraphTraversal Tree(params object[] args) { - return new GraphTraversal().Tree(args); + return new GraphTraversal().Tree(args); } - public static GraphTraversal Unfold(params object[] args) + public static GraphTraversal Unfold(params object[] args) { - return new GraphTraversal().Unfold(args); + return new GraphTraversal().Unfold(args); } - public static GraphTraversal Union(params object[] args) + public static GraphTraversal Union(params object[] args) { - return new GraphTraversal().Union(args); + return new GraphTraversal().Union(args); } - public static GraphTraversal Until(params object[] args) + public static GraphTraversal Until(params object[] args) { - return new GraphTraversal().Until(args); + return new GraphTraversal().Until(args); } - public static GraphTraversal Value(params object[] args) + public static GraphTraversal Value(params object[] args) { - return new GraphTraversal().Value(args); + return new GraphTraversal().Value(args); } - public static GraphTraversal ValueMap(params object[] args) + public static GraphTraversal> ValueMap(params object[] args) { - return new GraphTraversal().ValueMap(args); + return new GraphTraversal().ValueMap(args); } - public static GraphTraversal Values(params object[] args) + public static GraphTraversal Values(params object[] args) { - return new GraphTraversal().Values(args); + return new GraphTraversal().Values(args); } - public static GraphTraversal Where(params object[] args) + public static GraphTraversal Where(params object[] args) { - return new GraphTraversal().Where(args); + return new GraphTraversal().Where(args); } - } + } } diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs index 6ed3cd48239..b4ab8703835 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs @@ -22,6 +22,7 @@ #endregion using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; namespace Gremlin.Net.Structure.IO.GraphSON { @@ -30,8 +31,8 @@ internal class EnumSerializer : IGraphSONSerializer public Dictionary Dictify(dynamic objectData, GraphSONWriter writer) { var enumName = objectData.GetType().Name; - var enumValue = objectData.ToString(); - return GraphSONUtil.ToTypedValue(enumName, enumValue); + var valueJavaName = NamingConversions.GetEnumJavaName(enumName, objectData.ToString()); + return GraphSONUtil.ToTypedValue(enumName, valueJavaName); } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs index de91152ba61..7b99371c225 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -66,7 +66,7 @@ public async Task ShouldSendBytecodeToGremlinServerAsynchronouslyForTraversalPro Assert.Equal(expectedResult, actualResult); } - private DefaultTraversal CreateTraversalWithRemoteStrategy(Bytecode bytecode) + private DefaultTraversal CreateTraversalWithRemoteStrategy(Bytecode bytecode) { var remoteStrategy = new RemoteStrategy(new DriverRemoteConnection(new GremlinClient(new GremlinServer(TestHost, TestPort)))); @@ -74,7 +74,7 @@ private DefaultTraversal CreateTraversalWithRemoteStrategy(Bytecode bytecode) } } - internal class TestTraversal : DefaultTraversal + internal class TestTraversal : DefaultTraversal { public TestTraversal(ITraversalStrategy traversalStrategy, Bytecode bytecode) { diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs index 418b0e22cc4..ba01526c9f1 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -161,8 +161,8 @@ public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTravers Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]); SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0]; Assert.Equal(1, strategy.Configuration.Count); - Assert.Equal(typeof(GraphTraversal), strategy.Configuration["vertices"].GetType()); - GraphTraversal traversal = strategy.Configuration["vertices"]; + Assert.Equal(typeof(GraphTraversal), strategy.Configuration["vertices"].GetType()); + ITraversal traversal = strategy.Configuration["vertices"]; Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName); Assert.Equal(new List {"name", "marko"}, traversal.Bytecode.StepInstructions[0].Arguments); } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs index 6d0f5299091..562aa6e5825 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs @@ -39,9 +39,9 @@ public void ShouldUseOrderDecrInByStep() var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); - var orderedAges = g.V().Values("age").Order().By(Order.decr).ToList(); + var orderedAges = g.V().Values("age").Order().By(Order.Decr).ToList(); - Assert.Equal(new List {35, 32, 29, 27}, orderedAges); + Assert.Equal(new List {35, 32, 29, 27}, orderedAges); } [Fact] @@ -51,7 +51,7 @@ public void ShouldUseTLabelInHasStep() var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); - var personsCount = g.V().Has(T.label, "person").Count().Next(); + var personsCount = g.V().Has(T.Label, "person").Count().Next(); Assert.Equal((long) 4, personsCount); } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs index 0e56c2e379d..d471af34577 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -43,7 +43,7 @@ public void ShouldUseSideEffectSpecifiedInWithSideEffect() .V(1) .Out("created") .In("created") - .Values("name") + .Values("name") .Where(P.Within("a")) .ToList(); diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs index ba999f3a913..51efa7fdf27 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs @@ -98,13 +98,18 @@ public void g_V_RepeatXBothX_TimesX5X_NextX10X() [Fact] public void g_V_HasXname_markoX_ValueMap_Next() { + //Unable to cast object of type + //'System.Collections.Generic.Dictionary`2[System.String,System.Object]' to type + //'System.Collections.Generic.IDictionary`2[System.String,System.Collections.Generic.IList`1[System.Object]]'. + + var graph = new Graph(); var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); - var receivedValueMap = g.V().Has("name", "marko").ValueMap().Next(); + var receivedValueMap = g.V().Has("name", "marko").ValueMap().Next(); - var expectedValueMap = new Dictionary + var expectedValueMap = new Dictionary { {"age", new List {29}}, {"name", new List {"marko"}} @@ -119,7 +124,7 @@ public void g_V_RepeatXOutX_TimesX2X_ValuesXNameX() var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); - var t = g.V().Repeat(__.Out()).Times(2).Values("name"); + var t = g.V().Repeat(__.Out()).Times(2).Values("name"); var names = t.ToList(); Assert.Equal((long) 2, names.Count); @@ -135,7 +140,7 @@ public void ShortestPathTest() var g = graph.Traversal().WithRemote(connection); var shortestPath = - (Path) g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit(1).Path().Next(); + (Path)g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit(1).Path().Next(); Assert.Equal((long) 4, shortestPath.Count); Assert.Equal(new Vertex((long) 6), shortestPath[3]); diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs index c3629bcdc6f..f100e046062 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -123,7 +123,7 @@ public void ShouldReturnBothSideEffectForTraversalWithTwoSideEffects_() var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); - var t = g.V().Out("created").GroupCount("m").By("name").Values("name").Aggregate("n").Iterate(); + var t = g.V().Out("created").GroupCount("m").By("name").Values("name").Aggregate("n").Iterate(); var keys = t.SideEffects.Keys().ToList(); Assert.Equal(2, keys.Count); diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs index 6c7d8b619f6..ba56de96a3b 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -119,7 +119,7 @@ public void g_E_Count_Next_WithEdgeLimitSubgraphStrategy() var g = graph.Traversal() .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(edgeCriterion: __.Limit(0))); + .WithStrategies(new SubgraphStrategy(edgeCriterion: __.Limit(0))); var count = g.E().Count().Next(); @@ -151,7 +151,7 @@ public void g_V_ValuesXnameX_Next_WithVertexHasPropertySubgraphStrategy() .WithRemote(connection) .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); - var name = g.V().Values("name").Next(); + var name = g.V().Values("name").Next(); Assert.Equal("marko", name); } diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs index 4be682358ab..bf9b6d1d2d7 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -27,7 +27,7 @@ namespace Gremlin.Net.UnitTest.Process.Traversal { - public class TestTraversal : DefaultTraversal + public class TestTraversal : DefaultTraversal { public TestTraversal(List traverserObjs) { diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs index 111469c6837..ded419d751d 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -36,12 +36,12 @@ public TestTraversalStrategy(IEnumerable traversersToAddOnApplication _traversers = traversersToAddOnApplication; } - public void Apply(ITraversal traversal) + public void Apply(ITraversal traversal) { traversal.Traversers = _traversers; } - public Task ApplyAsync(ITraversal traversal) + public Task ApplyAsync(ITraversal traversal) { traversal.Traversers = _traversers; return Task.CompletedTask; diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs index e367124522c..8ed7a3d4657 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs @@ -1,4 +1,4 @@ -#region License +#region License /* * Licensed to the Apache Software Foundation (ASF) under one @@ -143,7 +143,7 @@ public void ShouldSerializeBytecodeWithBindings() } } - internal class TestTraversal : DefaultTraversal + internal class TestTraversal : DefaultTraversal { public TestTraversal(Bytecode bytecode) { diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs index 49786d7766b..77af2558f05 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs @@ -189,9 +189,9 @@ public void ShouldSerializeEnum() { var writer = CreateStandardGraphSONWriter(); - var serializedEnum = writer.WriteObject(T.label); + var serializedEnum = writer.WriteObject(Direction.Both); - var expectedGraphSON = "{\"@type\":\"g:T\",\"@value\":\"label\"}"; + var expectedGraphSON = "{\"@type\":\"g:Direction\",\"@value\":\"BOTH\"}"; Assert.Equal(expectedGraphSON, serializedEnum); } @@ -312,11 +312,6 @@ public void ShouldSerializeVertexWithLabel() } } - internal enum T - { - label - } - internal class TestGraphSONSerializer : IGraphSONSerializer { public string TestNamespace { get; set; } From 090834347de1c27c1556b410aabd18368dad9968 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 8 Jun 2017 11:50:31 -0400 Subject: [PATCH 08/28] TINKERPOP-1552 Cleaned up the poms for the dotnet GLV Removed a bunch of uncessary declarations. Build still seems to work nicely after all the deleting and moving stuff around. --- gremlin-dotnet/pom.xml | 9 ------- gremlin-dotnet/src/pom.xml | 7 ++--- gremlin-dotnet/test/pom.xml | 53 ++++++------------------------------- 3 files changed, 10 insertions(+), 59 deletions(-) diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 9bdff543bc2..ea3ae12de8e 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -23,7 +23,6 @@ limitations under the License. tinkerpop 3.2.5-SNAPSHOT - org.apache.tinkerpop gremlin-dotnet Apache TinkerPop :: Gremlin-DotNet pom @@ -41,14 +40,6 @@ limitations under the License. true 0.14 - - org.apache.maven.plugins - maven-surefire-plugin - - - org.codehaus.gmavenplus - gmavenplus-plugin - \ No newline at end of file diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 2d05d7fcd46..3b0bf68c9a2 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -23,7 +23,8 @@ limitations under the License. gremlin-dotnet 3.2.5-SNAPSHOT - Gremlin-DotNet-Source + gremlin-dotnet-source + Apache TinkerPop :: Gremlin-DotNet - Source ${packaging.type} @@ -51,10 +52,6 @@ limitations under the License. ${basedir}/target ${project.artifactId}-${project.version} - - org.apache.maven.plugins - maven-surefire-plugin - org.eobjects.build dotnet-maven-plugin diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index d91ca85cf5e..6bd24416b16 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -23,7 +23,8 @@ limitations under the License. gremlin-dotnet 3.2.5-SNAPSHOT - Gremlin-DotNet-Tests + gremlin-dotnet-tests + Apache TinkerPop :: Gremlin-DotNet - Tests ${packaging.type} @@ -32,44 +33,6 @@ limitations under the License. ${project.parent.parent.basedir}/gremlin-server - - - org.apache.tinkerpop - gremlin-core - ${project.version} - - - org.codehaus.groovy - groovy - ${groovy.version} - indy - - - - org.apache.tinkerpop - tinkergraph-gremlin - ${project.version} - test - - - org.apache.tinkerpop - gremlin-test - ${project.version} - test - - - org.apache.tinkerpop - gremlin-server - ${project.version} - test - - - org.slf4j - slf4j-log4j12 - test - ${slf4j.version} - - @@ -113,18 +76,18 @@ limitations under the License. org.codehaus.gmavenplus gmavenplus-plugin - - org.codehaus.groovy - groovy-all - ${groovy.version} - runtime - log4j log4j 1.2.17 runtime + + org.apache.tinkerpop + gremlin-server + ${project.version} + runtime + From 339e293f0311bb84872ccce39ad96e393b8e789b Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 8 Jun 2017 13:06:43 -0400 Subject: [PATCH 09/28] TINKERPOP-1552 Added groovy-ant to csharp build Fixed a warning message in the build. --- gremlin-dotnet/test/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index 6bd24416b16..488a7726834 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -88,6 +88,11 @@ limitations under the License. ${project.version} runtime + + org.codehaus.groovy + groovy-ant + ${groovy.version} + From 1daf48b20de100e05f38202cdd1b3405fb16932a Mon Sep 17 00:00:00 2001 From: Jorge Bay Gondra Date: Fri, 9 Jun 2017 10:20:55 +0200 Subject: [PATCH 10/28] Remove unintended comment --- .../Traversal/DriverRemoteConnection/GraphTraversalTests.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs index 51efa7fdf27..e1e4338d54b 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs @@ -98,11 +98,6 @@ public void g_V_RepeatXBothX_TimesX5X_NextX10X() [Fact] public void g_V_HasXname_markoX_ValueMap_Next() { - //Unable to cast object of type - //'System.Collections.Generic.Dictionary`2[System.String,System.Object]' to type - //'System.Collections.Generic.IDictionary`2[System.String,System.Collections.Generic.IList`1[System.Object]]'. - - var graph = new Graph(); var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); From ca3da92801aa350ff2a6042ad149ab29040e3c64 Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Fri, 9 Jun 2017 16:14:49 +0200 Subject: [PATCH 11/28] Minor code cleanup for Gremlin.Net This mainly removes explicit type casting that are now obsolete thanks to changes from the pull request #620. It also makes the Dictionary CSharpToJavaEnums in NamingConversions private to avoid direct access to it as GetEnumJavaName should be used instead. --- .../Gremlin.Net/Process/Traversal/ITraversal.cs | 1 - .../Process/Traversal/NamingConversions.cs | 2 +- .../Traversal/DriverRemoteConnection/EnumTests.cs | 2 +- .../DriverRemoteConnection/GraphTraversalTests.cs | 12 ++++++------ .../DriverRemoteConnection/PredicateTests.cs | 4 ++-- .../DriverRemoteConnection/StrategiesTests.cs | 14 +++++++------- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs index cb1c80e2272..c519ee6e643 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs @@ -22,7 +22,6 @@ #endregion using System; -using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs index 6f5fec53e2f..2e95da15a80 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs @@ -41,7 +41,7 @@ internal static string GetEnumJavaName(string typeName, string value) return javaName; } - internal static readonly IDictionary CSharpToJavaEnums = new Dictionary + private static readonly IDictionary CSharpToJavaEnums = new Dictionary { {"T.Value", "value"}, {"Order.Decr", "decr"}, diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs index 562aa6e5825..00541ad190e 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs @@ -53,7 +53,7 @@ public void ShouldUseTLabelInHasStep() var personsCount = g.V().Has(T.Label, "person").Count().Next(); - Assert.Equal((long) 4, personsCount); + Assert.Equal(4, personsCount); } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs index e1e4338d54b..2156ff3b920 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs @@ -43,7 +43,7 @@ public void g_V_Count() var count = g.V().Count().Next(); - Assert.Equal((long) 6, count); + Assert.Equal(6, count); } [Fact] @@ -53,7 +53,7 @@ public void g_VX1X_Next() var connection = _connectionFactory.CreateRemoteConnection(); var g = graph.Traversal().WithRemote(connection); - var vertex = (Vertex) g.V(1).Next(); + var vertex = g.V(1).Next(); Assert.Equal(new Vertex((long) 1), vertex); Assert.Equal((long) 1, vertex.Id); @@ -135,9 +135,9 @@ public void ShortestPathTest() var g = graph.Traversal().WithRemote(connection); var shortestPath = - (Path)g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit(1).Path().Next(); + g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit(1).Path().Next(); - Assert.Equal((long) 4, shortestPath.Count); + Assert.Equal(4, shortestPath.Count); Assert.Equal(new Vertex((long) 6), shortestPath[3]); } @@ -151,7 +151,7 @@ public void ShouldUseBindingsInTraversal() var b = new Bindings(); var count = g.V().Has(b.Of("propertyKey", "name"), b.Of("propertyValue", "marko")).OutE().Count().Next(); - Assert.Equal((long) 3, count); + Assert.Equal(3, count); } [Fact] @@ -163,7 +163,7 @@ public async Task ShouldExecuteAsynchronouslyWhenPromiseIsCalled() var count = await g.V().Count().Promise(t => t.Next()); - Assert.Equal((long) 6, count); + Assert.Equal(6, count); } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs index 88587f6cd12..9ab53a49392 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs @@ -40,7 +40,7 @@ public void ShouldUsePredicatesCombinedWithPAndInHasStep() var count = g.V().Has("age", P.Gt(30).And(P.Lt(35))).Count().Next(); - Assert.Equal((long) 1, count); + Assert.Equal(1, count); } [Fact] @@ -52,7 +52,7 @@ public void ShouldUsePWithinInHasStep() var count = g.V().Has("name", P.Within("josh", "vadas")).Count().Next(); - Assert.Equal((long) 2, count); + Assert.Equal(2, count); } } } \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs index ba56de96a3b..21aee57b5fb 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs @@ -47,7 +47,7 @@ public void g_V_Count_Next_WithVertexLabelSubgraphStrategy() var count = g.V().Count().Next(); - Assert.Equal((long) 4, count); + Assert.Equal(4, count); } [Fact] @@ -63,7 +63,7 @@ public void g_E_Count_Next_WithVertexAndEdgeLabelSubgraphStrategy() var count = g.E().Count().Next(); - Assert.Equal((long)0, count); + Assert.Equal(0, count); } [Fact] @@ -78,7 +78,7 @@ public void g_V_Label_Dedup_Count_Next_WithVertexLabelSubgraphStrategy() var count = g.V().Label().Dedup().Count().Next(); - Assert.Equal((long)1, count); + Assert.Equal(1, count); } [Fact] @@ -108,7 +108,7 @@ public void g_V_Count_Next_WithVertexHasPropertySubgraphStrategy() var count = g.V().Count().Next(); - Assert.Equal((long)1, count); + Assert.Equal(1, count); } [Fact] @@ -123,7 +123,7 @@ public void g_E_Count_Next_WithEdgeLimitSubgraphStrategy() var count = g.E().Count().Next(); - Assert.Equal((long)0, count); + Assert.Equal(0, count); } [Fact] @@ -165,7 +165,7 @@ public void g_V_Count_Next_WithComputer() var count = g.V().Count().Next(); - Assert.Equal((long)6, count); + Assert.Equal(6, count); } [Fact] @@ -177,7 +177,7 @@ public void g_E_Count_Next_WithComputer() var count = g.E().Count().Next(); - Assert.Equal((long)6, count); + Assert.Equal(6, count); } [Fact] From 1fa9a601a9d8ca48b0b569ef0d59f60d0c8f78db Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Mon, 12 Jun 2017 22:09:24 +0200 Subject: [PATCH 12/28] Add support for authentication (Plain SASL) to Gremlin.Net --- .../src/Gremlin.Net/Driver/Connection.cs | 35 +++++++- .../Gremlin.Net/Driver/ConnectionFactory.cs | 11 +-- .../src/Gremlin.Net/Driver/GremlinClient.cs | 2 +- .../src/Gremlin.Net/Driver/GremlinServer.cs | 16 +++- .../Driver/Messages/ResponseStatusCode.cs | 2 +- .../src/Gremlin.Net/Driver/Tokens.cs | 11 +++ .../GremlinClientAuthenticationTests.cs | 86 +++++++++++++++++++ .../appsettings.json | 3 +- gremlin-dotnet/test/pom.xml | 17 ++++ 9 files changed, 171 insertions(+), 12 deletions(-) create mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs index 2315ed49130..126b46117c4 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; +using System.Text; using System.Threading.Tasks; using Gremlin.Net.Driver.Messages; using Gremlin.Net.Driver.ResultsAggregation; @@ -38,10 +39,15 @@ internal class Connection : IConnection private readonly JsonMessageSerializer _messageSerializer = new JsonMessageSerializer(); private readonly Uri _uri; private readonly WebSocketConnection _webSocketConnection = new WebSocketConnection(); + private readonly string _username; + private readonly string _password; - public Connection(Uri uri, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter) + public Connection(Uri uri, string username, string password, GraphSONReader graphSONReader, + GraphSONWriter graphSONWriter) { _uri = uri; + _username = username; + _password = password; _graphSONReader = graphSONReader; _graphSONWriter = graphSONWriter; } @@ -83,7 +89,11 @@ private async Task> ReceiveAsync() status = receivedMsg.Status; status.ThrowIfStatusIndicatesError(); - if (status.Code != ResponseStatusCode.NoContent) + if (status.Code == ResponseStatusCode.Authenticate) + { + await AuthenticateAsync().ConfigureAwait(false); + } + else if (status.Code != ResponseStatusCode.NoContent) { var receivedData = _graphSONReader.ToObject(receivedMsg.Result.Data); foreach (var d in receivedData) @@ -101,13 +111,32 @@ private async Task> ReceiveAsync() result.Add(d); } } - } while (status.Code == ResponseStatusCode.PartialContent); + } while (status.Code == ResponseStatusCode.PartialContent || status.Code == ResponseStatusCode.Authenticate); if (isAggregatingSideEffects) return new List {(T) aggregator.GetAggregatedResult()}; return result; } + private async Task AuthenticateAsync() + { + if (string.IsNullOrEmpty(_username) || string.IsNullOrEmpty(_password)) + throw new InvalidOperationException( + $"The Gremlin Server requires authentication, but no credentials are specified - username: {_username}, password: {_password}."); + + var message = RequestMessage.Build(Tokens.OpsAuthentication).Processor(Tokens.ProcessorTraversal) + .AddArgument(Tokens.ArgsSasl, SaslArgument()).Create(); + + await SendAsync(message).ConfigureAwait(false); + } + + private string SaslArgument() + { + var auth = $"\0{_username}\0{_password}"; + var authBytes = Encoding.UTF8.GetBytes(auth); + return Convert.ToBase64String(authBytes); + } + #region IDisposable Support private bool _disposed; diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs index d31817c306b..0041a67b35c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionFactory.cs @@ -21,7 +21,6 @@ #endregion -using System; using Gremlin.Net.Structure.IO.GraphSON; namespace Gremlin.Net.Driver @@ -30,18 +29,20 @@ internal class ConnectionFactory { private readonly GraphSONReader _graphSONReader; private readonly GraphSONWriter _graphSONWriter; - private readonly Uri _uri; + private readonly GremlinServer _gremlinServer; - public ConnectionFactory(Uri uri, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter) + public ConnectionFactory(GremlinServer gremlinServer, GraphSONReader graphSONReader, + GraphSONWriter graphSONWriter) { - _uri = uri; + _gremlinServer = gremlinServer; _graphSONReader = graphSONReader; _graphSONWriter = graphSONWriter; } public Connection CreateConnection() { - return new Connection(_uri, _graphSONReader, _graphSONWriter); + return new Connection(_gremlinServer.Uri, _gremlinServer.Username, _gremlinServer.Password, _graphSONReader, + _graphSONWriter); } } } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs index 783308886ba..46dd8a6f82c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs @@ -47,7 +47,7 @@ public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader { var reader = graphSONReader ?? new GraphSONReader(); var writer = graphSONWriter ?? new GraphSONWriter(); - var connectionFactory = new ConnectionFactory(gremlinServer.Uri, reader, writer); + var connectionFactory = new ConnectionFactory(gremlinServer, reader, writer); _connectionPool = new ConnectionPool(connectionFactory); } diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs index 8da6d0bd5ff..601bbae3b31 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinServer.cs @@ -36,9 +36,13 @@ public class GremlinServer /// The hostname of the server. /// The port on which Gremlin Server can be reached. /// Specifies whether SSL should be enabled. - public GremlinServer(string hostname, int port = 8182, bool enableSsl = false) + /// The username to submit on requests that require authentication. + /// The password to submit on requests that require authentication. + public GremlinServer(string hostname, int port = 8182, bool enableSsl = false, string username = null, string password = null) { Uri = CreateUri(hostname, port, enableSsl); + Username = username; + Password = password; } /// @@ -47,6 +51,16 @@ public GremlinServer(string hostname, int port = 8182, bool enableSsl = false) /// The WebSocket that the Gremlin Server responds to. public Uri Uri { get; } + /// + /// Gets the username to submit on requests that require authentication. + /// + public string Username { get; } + + /// + /// Gets the password to submit on requests that require authentication. + /// + public string Password { get; } + private Uri CreateUri(string hostname, int port, bool enableSsl) { var scheme = enableSsl ? "wss" : "ws"; diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs index 7b0bc947a3d..558e4f62c0b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs @@ -49,9 +49,9 @@ public static bool IndicatesError(this ResponseStatusCode statusCode) case ResponseStatusCode.Success: case ResponseStatusCode.NoContent: case ResponseStatusCode.PartialContent: + case ResponseStatusCode.Authenticate: return false; case ResponseStatusCode.Unauthorized: - case ResponseStatusCode.Authenticate: case ResponseStatusCode.MalformedRequest: case ResponseStatusCode.InvalidRequestArguments: case ResponseStatusCode.ServerError: diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs index 5a940cdabff..c9dc0fbd673 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Tokens.cs @@ -30,6 +30,11 @@ namespace Gremlin.Net.Driver /// public class Tokens { + /// + /// Operation used by the client to authenticate itself. + /// + public static string OpsAuthentication = "authentication"; + /// /// Operation used for a request that contains the Bytecode representation of a Traversal. /// @@ -108,6 +113,12 @@ public class Tokens /// public static string ArgsEvalTimeout = "scriptEvaluationTimeout"; + /// + /// Argument name for the response to the server authentication challenge. This value is dependent on the SASL + /// authentication mechanism required by the server. + /// + public static string ArgsSasl = "sasl"; + internal static string ValAggregateToMap = "map"; internal static string ValAggregateToBulkSet = "bulkset"; } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs new file mode 100644 index 00000000000..5045f3ccf22 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientAuthenticationTests.cs @@ -0,0 +1,86 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.IntegrationTest.Util; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Driver +{ + public class GremlinClientAuthenticationTests + { + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestSecureServerPort"]); + private readonly RequestMessageProvider _requestMessageProvider = new RequestMessageProvider(); + + [Fact] + public async Task ShouldThrowForMissingCredentials() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var exception = await Assert.ThrowsAsync( + async () => await gremlinClient.SubmitWithSingleResultAsync(_requestMessageProvider + .GetDummyMessage())); + + Assert.Contains("authentication", exception.Message); + Assert.Contains("credentials", exception.Message); + } + } + + [Theory] + [InlineData("unknownUser", "passwordDoesntMatter")] + [InlineData("stephen", "wrongPassword")] + public async Task ShouldThrowForWrongCredentials(string username, string password) + { + var gremlinServer = new GremlinServer(TestHost, TestPort, username: username, password: password); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var exception = await Assert.ThrowsAsync( + async () => await gremlinClient.SubmitWithSingleResultAsync(_requestMessageProvider + .GetDummyMessage())); + + Assert.Contains("Unauthorized", exception.Message); + } + } + + [Theory] + [InlineData("'Hello' + 'World'", "HelloWorld")] + public async Task ScriptShouldBeEvaluatedAndResultReturnedForCorrectCredentials(string requestMsg, + string expectedResponse) + { + const string username = "stephen"; + const string password = "password"; + var gremlinServer = new GremlinServer(TestHost, TestPort, username: username, password: password); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var response = await gremlinClient.SubmitWithSingleResultAsync(requestMsg); + + Assert.Equal(expectedResponse, response); + } + } + } +} \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json index 38007ec1c9c..5788e506ef1 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/appsettings.json @@ -1,4 +1,5 @@ { "TestServerIpAddress": "localhost", - "TestServerPort": 45950 + "TestServerPort": 45950, + "TestSecureServerPort": 45951 } \ No newline at end of file diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index 488a7726834..d0626209a62 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -122,6 +122,19 @@ server.start().join() project.setContextValue("gremlin.dotnet.server", server) log.info("Gremlin Server with no authentication started on port 45950") + +def settingsSecure = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern.yaml") +settingsSecure.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties" +settingsSecure.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] +settingsSecure.port = 45951 +settingsSecure.authentication.className = "org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator" +settingsSecure.authentication.config = [credentialsDb: "${gremlin.server.dir}/conf/tinkergraph-credentials.properties", credentialsDbLocation: "${gremlin.server.dir}/data/credentials.kryo"] + +def serverSecure = new GremlinServer(settingsSecure) +serverSecure.start().join() + +project.setContextValue("gremlin.dotnet.server.secure", serverSecure) +log.info("Gremlin Server with authentication started on port 45951") ]]> @@ -147,6 +160,10 @@ def server = project.getContextValue("gremlin.dotnet.server") log.info("Shutting down $server") server.stop().join() +def serverSecure = project.getContextValue("gremlin.dotnet.server.secure") +log.info("Shutting down $serverSecure") +serverSecure.stop().join() + log.info("Gremlin Server instance shutdown for gremlin-dotnet") ]]> From 21843ce422aecd4bcd6b0cab9825f737f6c06f46 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 13 Jun 2017 13:07:55 -0400 Subject: [PATCH 13/28] TINKERPOP-1552 Removed the dotnet generator module Moved GLV generation to the gremlin-dotnet pom and gmaveplus plugin. --- gremlin-dotnet-generator/pom.xml | 75 ---- .../dotnet/AnonymousTraversalGenerator.groovy | 98 ----- .../gremlin/dotnet/CommonContentHelper.groovy | 49 --- .../gremlin/dotnet/EnumGenerator.groovy | 112 ----- .../dotnet/GenerateGremlinDotNet.groovy | 32 -- .../dotnet/GraphTraversalGenerator.groovy | 90 ---- .../GraphTraversalSourceGenerator.groovy | 142 ------- .../gremlin/dotnet/PredicateGenerator.groovy | 64 --- .../gremlin/dotnet/SymbolHelper.groovy | 89 ---- .../glv/AnonymousTraversal.template | 45 ++ gremlin-dotnet/glv/Enum.template | 33 ++ gremlin-dotnet/glv/GraphTraversal.template | 64 +++ .../glv/GraphTraversalSource.template | 88 ++++ gremlin-dotnet/glv/NamingConversions.template | 52 +++ gremlin-dotnet/glv/P.template | 39 ++ gremlin-dotnet/pom.xml | 229 +++++++++- .../Gremlin.Net/Process/Traversal/Barrier.cs | 5 +- .../Process/Traversal/Cardinality.cs | 9 +- .../Gremlin.Net/Process/Traversal/Column.cs | 8 +- .../Process/Traversal/Direction.cs | 9 +- .../Process/Traversal/GraphSONVersion.cs | 33 ++ .../Process/Traversal/GraphTraversal.cs | 399 +++++++++--------- .../Process/Traversal/GraphTraversalSource.cs | 34 +- .../Process/Traversal/GryoVersion.cs | 33 ++ .../Process/Traversal/NamingConversions.cs | 67 +-- .../Gremlin.Net/Process/Traversal/Operator.cs | 17 +- .../Gremlin.Net/Process/Traversal/Order.cs | 13 +- .../src/Gremlin.Net/Process/Traversal/P.cs | 8 +- .../src/Gremlin.Net/Process/Traversal/Pick.cs | 8 +- .../src/Gremlin.Net/Process/Traversal/Pop.cs | 9 +- .../Gremlin.Net/Process/Traversal/Scope.cs | 8 +- .../src/Gremlin.Net/Process/Traversal/T.cs | 10 +- .../src/Gremlin.Net/Process/Traversal/__.cs | 6 +- gremlin-dotnet/src/pom.xml | 17 + gremlin-dotnet/test/pom.xml | 16 + pom.xml | 1 - 36 files changed, 967 insertions(+), 1044 deletions(-) delete mode 100644 gremlin-dotnet-generator/pom.xml delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy delete mode 100644 gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy create mode 100644 gremlin-dotnet/glv/AnonymousTraversal.template create mode 100644 gremlin-dotnet/glv/Enum.template create mode 100644 gremlin-dotnet/glv/GraphTraversal.template create mode 100644 gremlin-dotnet/glv/GraphTraversalSource.template create mode 100644 gremlin-dotnet/glv/NamingConversions.template create mode 100644 gremlin-dotnet/glv/P.template create mode 100644 gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs create mode 100644 gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs diff --git a/gremlin-dotnet-generator/pom.xml b/gremlin-dotnet-generator/pom.xml deleted file mode 100644 index a0a9ff6719a..00000000000 --- a/gremlin-dotnet-generator/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - 4.0.0 - - org.apache.tinkerpop - tinkerpop - 3.2.5-SNAPSHOT - - gremlin-dotnet-generator - Apache TinkerPop :: Gremlin-DotNet Generator - - - org.apache.tinkerpop - gremlin-core - ${project.version} - - - org.codehaus.groovy - groovy - ${groovy.version} - indy - - - - ${basedir}/target - ${project.artifactId}-${project.version} - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - generate-dotnet - generate-test-resources - - java - - - org.apache.tinkerpop.gremlin.dotnet.GenerateGremlinDotNet - - ${project.parent.basedir}/gremlin-dotnet/src/Gremlin.Net - - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - - \ No newline at end of file diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy deleted file mode 100644 index b65b2b0450d..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/AnonymousTraversalGenerator.groovy +++ /dev/null @@ -1,98 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ - -import java.lang.reflect.Modifier - -class AnonymousTraversalGenerator { - - private static final Map METHODS_WITH_SPECIFIC_TYPES = new HashMap<>(); - - static { - String[] useE2 = ["E2", "E2"]; - METHODS_WITH_SPECIFIC_TYPES.put("constant", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("limit", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("mean", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("optional", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("range", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("select", ["IDictionary", "E2"] as String[]); - METHODS_WITH_SPECIFIC_TYPES.put("sum", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("tail", useE2); - METHODS_WITH_SPECIFIC_TYPES.put("tree", ["object"] as String[]); - METHODS_WITH_SPECIFIC_TYPES.put("unfold", useE2); - } - - public static void create(final String anonymousTraversalFile) { - - - final StringBuilder csharpClass = new StringBuilder() - - csharpClass.append(CommonContentHelper.getLicense()) - - csharpClass.append( -""" -using System.Collections.Generic; -using Gremlin.Net.Structure; - -namespace Gremlin.Net.Process.Traversal -{ - public static class __ - { - public static GraphTraversal Start() - { - return new GraphTraversal(); - } -""") - __.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { !it.name.equals("__") && !it.name.equals("start") }. - groupBy { it.name }. - // Select unique by name, with the most amount of parameters - collect { it.value.sort { a, b -> b.parameterCount <=> a.parameterCount }.first() }. - sort { it.name }. - forEach { javaMethod -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethod.name); - String[] typeNames = SymbolHelper.getJavaParameterTypeNames(javaMethod); - def t2 = SymbolHelper.toCSharpType(typeNames[1]); - def tParam = SymbolHelper.getCSharpGenericTypeParam(t2); - def specificTypes = METHODS_WITH_SPECIFIC_TYPES.get(javaMethod.name); - if (specificTypes) { - t2 = specificTypes[0]; - tParam = specificTypes.length > 1 ? "<" + specificTypes[1] + ">" : ""; - } - csharpClass.append( -""" - public static GraphTraversal $sharpMethodName$tParam(params object[] args) - { - return new GraphTraversal().$sharpMethodName$tParam(args); - } -""") - } - csharpClass.append(" }\n}") - - final File file = new File(anonymousTraversalFile); - file.delete() - csharpClass.eachLine { file.append(it + "\n") } - } -} diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy deleted file mode 100644 index 825e23012e5..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/CommonContentHelper.groovy +++ /dev/null @@ -1,49 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -public final class CommonContentHelper { - - public static String getLicense() { - return """#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 -""" - } -} \ No newline at end of file diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy deleted file mode 100644 index 840b604dbca..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/EnumGenerator.groovy +++ /dev/null @@ -1,112 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -import org.apache.tinkerpop.gremlin.util.CoreImports -import org.apache.tinkerpop.gremlin.structure.Direction - -class EnumGenerator { - - public static void create(final String enumDirectory) { - - Map enumCSharpToJavaNames = new HashMap(); - for (final Class enumClass : CoreImports.getClassImports() - .findAll { Enum.class.isAssignableFrom(it) } - .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() } - .collect()) { - createEnum(enumDirectory, enumClass, enumCSharpToJavaNames) - } - - // Write a file containing the equivalence in names between Java and C# - final String enumCSharpToJavaFile = "$enumDirectory/NamingConversions.cs" - final File file = new File(enumCSharpToJavaFile); - file.delete(); - file.append(CommonContentHelper.getLicense()); - file.append(""" -using System.Collections.Generic; - -namespace Gremlin.Net.Process.Traversal -{ - internal static class NamingConversions - { - /// - /// Gets the Java name equivalent for a given enum value - /// - internal static string GetEnumJavaName(string typeName, string value) - { - var key = \$"{typeName}.{value}"; - string javaName; - if (!CSharpToJavaEnums.TryGetValue(key, out javaName)) - { - throw new KeyNotFoundException(\$"Java name for {key} not found"); - } - return javaName; - } - - internal static readonly IDictionary CSharpToJavaEnums = new Dictionary - { -""" ); - def lastIndex = (enumCSharpToJavaNames.size() - 1); - enumCSharpToJavaNames.eachWithIndex{ node, i -> - file.append(""" {"$node.key", "$node.value"}${i == lastIndex ? "" : ","}\n""") - } - file.append(" };\n }\n}"); - - } - - public static String toCSharpName(final Class enumClass, String itemName) { - if (enumClass.equals(Direction.class)) { - itemName = itemName.toLowerCase(); - } - return itemName.substring(0, 1).toUpperCase() + itemName.substring(1); - } - - private static void createEnum(final String enumDirectory, final Class enumClass, - final Map csharpToJava) { - final StringBuilder csharpEnum = new StringBuilder() - - csharpEnum.append(CommonContentHelper.getLicense()) - - csharpEnum.append( - """ -namespace Gremlin.Net.Process.Traversal -{ - public enum ${enumClass.getSimpleName()} - { -""") - enumClass.getEnumConstants(). - sort { a, b -> a.name() <=> b.name() }. - each { value -> - def csharpName = toCSharpName(enumClass, value.name()); - csharpEnum.append(" $csharpName,\n"); - csharpToJava.put(enumClass.simpleName + "." + csharpName, value.name()); - } - csharpEnum.deleteCharAt(csharpEnum.length() - 2) - - csharpEnum.append(" }\n") - csharpEnum.append("}") - - final String enumFileName = "${enumDirectory}/${enumClass.getSimpleName()}.cs" - final File file = new File(enumFileName); - file.delete() - csharpEnum.eachLine { file.append(it + "\n") } - } -} - diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy deleted file mode 100644 index 0d09d5b05e8..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GenerateGremlinDotNet.groovy +++ /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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -public class GenerateGremlinDotNet { - - public static void main(String[] args) { - final String dotnetDirectory = args[0] - GraphTraversalSourceGenerator.create(dotnetDirectory + "/Process/Traversal/" + "GraphTraversalSource.cs") - GraphTraversalGenerator.create(dotnetDirectory + "/Process/Traversal/" + "GraphTraversal.cs") - AnonymousTraversalGenerator.create(dotnetDirectory + "/Process/Traversal/" + "__.cs") - EnumGenerator.create(dotnetDirectory + "/Process/Traversal/") - PredicateGenerator.create(dotnetDirectory + "/Process/Traversal/" + "P.cs") - } -} \ No newline at end of file diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy deleted file mode 100644 index d3bade53a26..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalGenerator.groovy +++ /dev/null @@ -1,90 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal - -class GraphTraversalGenerator { - - public static void create(final String graphTraversalFile) { - - final StringBuilder csharpClass = new StringBuilder() - - csharpClass.append(CommonContentHelper.getLicense()) - - csharpClass.append( -""" -using System.Collections.Generic; -using Gremlin.Net.Structure; - -namespace Gremlin.Net.Process.Traversal -{ - public class GraphTraversal : DefaultTraversal - { - public GraphTraversal() - : this(new List(), new Bytecode()) - { - } - - public GraphTraversal(ICollection traversalStrategies, Bytecode bytecode) - { - TraversalStrategies = traversalStrategies; - Bytecode = bytecode; - } - - private static GraphTraversal Wrap(GraphTraversal traversal) - { - if (typeof(S2) == typeof(S) && typeof(E2) == typeof(E)) - { - return traversal as GraphTraversal; - } - // New wrapper - return new GraphTraversal(traversal.TraversalStrategies, traversal.Bytecode); - } - -""") - GraphTraversal.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - findAll { !it.name.equals("clone") && !it.name.equals("iterate") }. - groupBy { it.name }. - // Select unique by name, with the most amount of parameters - collect { it.value.sort { a, b -> b.parameterCount <=> a.parameterCount }.first() }. - sort { it.name }. - forEach { javaMethod -> - String[] typeNames = SymbolHelper.getJavaParameterTypeNames(javaMethod); - def t1 = SymbolHelper.toCSharpType(typeNames[0]); - def t2 = SymbolHelper.toCSharpType(typeNames[1]); - def tParam = SymbolHelper.getCSharpGenericTypeParam(t2); - csharpClass.append( -""" - public GraphTraversal<$t1, $t2> ${SymbolHelper.toCSharp(javaMethod.name)}$tParam(params object[] args) - { - Bytecode.AddStep("$javaMethod.name", args); - return Wrap<$t1, $t2>(this); - } -""") - } - csharpClass.append(" }\n}") - - final File file = new File(graphTraversalFile); - file.delete() - csharpClass.eachLine { file.append(it + "\n") } - } -} diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy deleted file mode 100644 index 7cb41da67a9..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/GraphTraversalSourceGenerator.groovy +++ /dev/null @@ -1,142 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource -import java.lang.reflect.* - -class GraphTraversalSourceGenerator { - - public static void create(final String graphTraversalSourceFile) { - - final StringBuilder csharpClass = new StringBuilder() - - csharpClass.append(CommonContentHelper.getLicense()) - - csharpClass.append( -""" -using System.Collections.Generic; -using Gremlin.Net.Process.Remote; -using Gremlin.Net.Process.Traversal.Strategy.Decoration; -using Gremlin.Net.Structure; - -namespace Gremlin.Net.Process.Traversal -{ - public class GraphTraversalSource - { - public ICollection TraversalStrategies { get; set; } - public Bytecode Bytecode { get; set; } - - public GraphTraversalSource() - : this(new List(), new Bytecode()) - { - } - - public GraphTraversalSource(ICollection traversalStrategies, Bytecode bytecode) - { - TraversalStrategies = traversalStrategies; - Bytecode = bytecode; - } -""" - ) - - GraphTraversalSource.getMethods(). // SOURCE STEPS - findAll { GraphTraversalSource.class.equals(it.returnType) }. - findAll { - !it.name.equals("clone") && - // replace by TraversalSource.Symbols.XXX - !it.name.equals("withBindings") && - !it.name.equals("withRemote") && - !it.name.equals("withComputer") - }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }. - forEach { javaMethodName -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) - - csharpClass.append( -""" - public GraphTraversalSource ${sharpMethodName}(params object[] args) - { - var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); - source.Bytecode.AddSource("${javaMethodName}\", args); - return source; - } -""") - } - - csharpClass.append( - """ - public GraphTraversalSource WithBindings(object bindings) - { - return this; - } - - public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) - { - var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); - source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); - return source; - } - - public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, - string result = null, ITraversal vertices = null, ITraversal edges = null, - Dictionary configuration = null) - { - return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); - } -""") - - GraphTraversalSource.getMethods(). - findAll { GraphTraversal.class.equals(it.returnType) }. - unique{ a -> a.name }. - sort { a, b -> a.name <=> b.name }. - forEach { javaMethod -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethod.name); - Type[] typeArguments = ((ParameterizedType)javaMethod.getGenericReturnType()).actualTypeArguments; - if (typeArguments.length != 2 || !(typeArguments[0] instanceof Class)) { - return; - } - def returnType = """GraphTraversal<${ - ((Class)typeArguments[0]).getSimpleName()}, ${((Class)typeArguments[1]).getSimpleName()}>"""; - - - csharpClass.append( - """ - public ${returnType} ${sharpMethodName}(params object[] args) - { - var traversal = new ${returnType}(TraversalStrategies, new Bytecode(Bytecode)); - traversal.Bytecode.AddStep("${javaMethod.name}\", args); - return traversal; - } -""") - } - - csharpClass.append(" }\n}") - - final File file = new File(graphTraversalSourceFile); - file.delete() - csharpClass.eachLine { file.append(it + "\n") } - } -} \ No newline at end of file diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy deleted file mode 100644 index c5c9c10906b..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/PredicateGenerator.groovy +++ /dev/null @@ -1,64 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -import org.apache.tinkerpop.gremlin.process.traversal.P - -import java.lang.reflect.Modifier - -class PredicateGenerator { - - public static void create(final String predicateFile) { - - final StringBuilder csharpClass = new StringBuilder() - - csharpClass.append(CommonContentHelper.getLicense()) - - csharpClass.append( -""" - -namespace Gremlin.Net.Process.Traversal -{ - public class P - {""") - P.class.getMethods(). - findAll { Modifier.isStatic(it.getModifiers()) }. - findAll { P.class.isAssignableFrom(it.returnType) }. - collect { it.name }. - unique(). - sort { a, b -> a <=> b }. - each { javaMethodName -> - String sharpMethodName = SymbolHelper.toCSharp(javaMethodName) - csharpClass.append( -""" - public static TraversalPredicate ${sharpMethodName}(params object[] args) - { - var value = args.Length == 1 ? args[0] : args; - return new TraversalPredicate("${javaMethodName}", value); - } -""") - } - csharpClass.append(" }\n}") - - final File file = new File(predicateFile) - file.delete() - csharpClass.eachLine { file.append(it + "\n") } - } -} diff --git a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy b/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy deleted file mode 100644 index c041062cbe7..00000000000 --- a/gremlin-dotnet-generator/src/main/groovy/org/apache/tinkerpop/gremlin/dotnet/SymbolHelper.groovy +++ /dev/null @@ -1,89 +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. - */ - -package org.apache.tinkerpop.gremlin.dotnet - -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; - -public final class SymbolHelper { - - private static final Map TO_CSHARP_TYPE_MAP = new HashMap<>(); - - static { - TO_CSHARP_TYPE_MAP.put("Long", "long"); - TO_CSHARP_TYPE_MAP.put("Integer", "int"); - TO_CSHARP_TYPE_MAP.put("String", "string"); - TO_CSHARP_TYPE_MAP.put("Object", "object"); - TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary"); - TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary") - TO_CSHARP_TYPE_MAP.put("java.util.List", "IList"); - TO_CSHARP_TYPE_MAP.put("java.util.List", "IList"); - TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary"); - TO_CSHARP_TYPE_MAP.put("java.util.Collection", "ICollection"); - TO_CSHARP_TYPE_MAP.put("java.util.Collection", "ICollection") - TO_CSHARP_TYPE_MAP.put("java.util.Map", "IDictionary"); - TO_CSHARP_TYPE_MAP.put("TraversalMetrics", "E2"); - } - - public static String toCSharp(final String symbol) { - return (String) Character.toUpperCase(symbol.charAt(0)) + symbol.substring(1) - } - - public static String toJava(final String symbol) { - return (String) Character.toLowerCase(symbol.charAt(0)) + symbol.substring(1) - } - - public static String toCSharpType(final String name) { - String typeName = TO_CSHARP_TYPE_MAP.getOrDefault(name, name); - if (typeName.equals(name) && (typeName.contains("? extends") || typeName.equals("Tree"))) { - typeName = "E2"; - } - return typeName; - } - - public static String[] getJavaParameterTypeNames(final Method method) { - def typeArguments = ((ParameterizedType)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; - }; - } - - public static String getCSharpGenericTypeParam(String typeName) { - def tParam = ""; - if (typeName.contains("E2")) { - tParam = ""; - } - else if (typeName.contains("")) { - tParam = ""; - } - else if (typeName.contains(" + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public static class __ + { + public static GraphTraversal Start() + { + return new GraphTraversal(); + } +<% anonStepMethods.each { method -> %> + public static GraphTraversal> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(params object[] args) + { + return new GraphTraversal().<%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(args); + } +<% } %> + } +} \ No newline at end of file diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template new file mode 100644 index 00000000000..664db45a608 --- /dev/null +++ b/gremlin-dotnet/glv/Enum.template @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public enum <%= enumClass.simpleName %> + { + <%= constants %> + } +} \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversal.template b/gremlin-dotnet/glv/GraphTraversal.template new file mode 100644 index 00000000000..b782ffa9a3c --- /dev/null +++ b/gremlin-dotnet/glv/GraphTraversal.template @@ -0,0 +1,64 @@ +#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; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public class GraphTraversal : DefaultTraversal + { + public GraphTraversal() + : this(new List(), new Bytecode()) + { + } + + public GraphTraversal(ICollection traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } + + private static GraphTraversal Wrap(GraphTraversal traversal) + { + if (typeof(S2) == typeof(S) && typeof(E2) == typeof(E)) + { + return traversal as GraphTraversal; + } + // New wrapper + return new GraphTraversal(traversal.TraversalStrategies, traversal.Bytecode); + } + +<% graphStepMethods.each { method -> %> + public GraphTraversal< <%= method.t1 %> , <%= method.t2 %> > <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %> (params object[] args) + { + Bytecode.AddStep("<%= method.methodName %>", args); + return Wrap< <%= method.t1 %> , <%= method.t2 %> >(this); + } +<% } %> + + } +} \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversalSource.template b/gremlin-dotnet/glv/GraphTraversalSource.template new file mode 100644 index 00000000000..880f793c19e --- /dev/null +++ b/gremlin-dotnet/glv/GraphTraversalSource.template @@ -0,0 +1,88 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Remote; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Structure; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public class GraphTraversalSource + { + public ICollection TraversalStrategies { get; set; } + public Bytecode Bytecode { get; set; } + + public GraphTraversalSource() + : this(new List(), new Bytecode()) + { + } + + public GraphTraversalSource(ICollection traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } + +<% sourceStepMethods.each{ method -> %> + public GraphTraversalSource <%= toCSharpMethodName.call(method) %>(params object[] args) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("<%= method %>", args); + return source; + } +<% } %> + public GraphTraversalSource WithBindings(object bindings) + { + return this; + } + + public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) + { + var source = new GraphTraversalSource(new List(TraversalStrategies), + new Bytecode(Bytecode)); + source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); + return source; + } + + public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, + string result = null, ITraversal vertices = null, ITraversal edges = null, + Dictionary configuration = null) + { + return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); + } + +<% sourceSpawnMethods.each { method -> %> + public GraphTraversal< <%= method.typeArguments.join(",") %> > <%= toCSharpMethodName.call(method.methodName) %>(params object[] args) + { + var traversal = new GraphTraversal< <%= method.typeArguments.join(",") %> >(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("<%= method.methodName %>", args); + return traversal; + } +<% } %> + } +} \ No newline at end of file diff --git a/gremlin-dotnet/glv/NamingConversions.template b/gremlin-dotnet/glv/NamingConversions.template new file mode 100644 index 00000000000..b997dee1f53 --- /dev/null +++ b/gremlin-dotnet/glv/NamingConversions.template @@ -0,0 +1,52 @@ +#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; + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + internal static class NamingConversions + { + /// + /// Gets the Java name equivalent for a given enum value + /// + internal static string GetEnumJavaName(string typeName, string value) + { + var key = \$"{typeName}.{value}"; + string javaName; + if (!CSharpToJavaEnums.TryGetValue(key, out javaName)) + { + throw new KeyNotFoundException(\$"Java name for {key} not found"); + } + return javaName; + } + + internal static readonly IDictionary CSharpToJavaEnums = new Dictionary + { + <%= body %> + }; + } +} \ No newline at end of file diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template new file mode 100644 index 00000000000..5be695dc279 --- /dev/null +++ b/gremlin-dotnet/glv/P.template @@ -0,0 +1,39 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public class P + { +<% pmethods.each { method -> %> + public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("<%= method %>", value); + } +<% } %> + } +} \ No newline at end of file diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index ea3ae12de8e..4bdf1e39746 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -28,8 +28,8 @@ limitations under the License. pom - test src + test @@ -40,6 +40,233 @@ limitations under the License. true 0.14 + + org.codehaus.gmavenplus + gmavenplus-plugin + + + org.apache.tinkerpop + gremlin-core + ${project.version} + runtime + + + org.codehaus.groovy + groovy-all + ${groovy.version} + runtime + + + log4j + log4j + 1.2.17 + runtime + + + + + generate-dsl + generate-sources + + execute + + + + + + + + + \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs index 6ef1d4f41c3..543fda61e96 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -23,8 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Barrier { NormSack } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs index b158d09a8a4..b47dd32c89a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -23,10 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Cardinality { - List, - Set, - Single + List,Set,Single } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index 0f3556c11f2..063c26e5eb5 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -23,9 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Column { - Keys, - Values + Keys,Values } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs index 100296cf0f8..5f6717ef498 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -23,10 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Direction { - Both, - In, - Out + Both,In,Out } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs new file mode 100644 index 00000000000..c72ae8ec1ec --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public enum GraphSONVersion + { + V1_0,V2_0 + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 0f3fbb70f9f..5aaaef0bc0d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -26,6 +26,9 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public class GraphTraversal : DefaultTraversal { public GraphTraversal() @@ -50,592 +53,594 @@ private static GraphTraversal Wrap(GraphTraversal traversa } - public GraphTraversal V(params object[] args) + public GraphTraversal< S , Vertex > V (params object[] args) { Bytecode.AddStep("V", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal AddE(params object[] args) + public GraphTraversal< S , Edge > AddE (params object[] args) { Bytecode.AddStep("addE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal AddInE(params object[] args) + public GraphTraversal< S , Edge > AddInE (params object[] args) { Bytecode.AddStep("addInE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal AddOutE(params object[] args) + public GraphTraversal< S , Edge > AddOutE (params object[] args) { Bytecode.AddStep("addOutE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal AddV(params object[] args) + public GraphTraversal< S , Vertex > AddV (params object[] args) { Bytecode.AddStep("addV", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal Aggregate(params object[] args) + public GraphTraversal< S , E > Aggregate (params object[] args) { Bytecode.AddStep("aggregate", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal And(params object[] args) + public GraphTraversal< S , E > And (params object[] args) { Bytecode.AddStep("and", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal As(params object[] args) + public GraphTraversal< S , E > As (params object[] args) { Bytecode.AddStep("as", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Barrier(params object[] args) + public GraphTraversal< S , E > Barrier (params object[] args) { Bytecode.AddStep("barrier", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Both(params object[] args) + public GraphTraversal< S , Vertex > Both (params object[] args) { Bytecode.AddStep("both", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal BothE(params object[] args) + public GraphTraversal< S , Edge > BothE (params object[] args) { Bytecode.AddStep("bothE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal BothV(params object[] args) + public GraphTraversal< S , Vertex > BothV (params object[] args) { Bytecode.AddStep("bothV", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal Branch(params object[] args) + public GraphTraversal< S , E2 > Branch (params object[] args) { Bytecode.AddStep("branch", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal By(params object[] args) + public GraphTraversal< S , E > By (params object[] args) { Bytecode.AddStep("by", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Cap(params object[] args) + public GraphTraversal< S , E2 > Cap (params object[] args) { Bytecode.AddStep("cap", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Choose(params object[] args) + public GraphTraversal< S , E2 > Choose (params object[] args) { Bytecode.AddStep("choose", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Coalesce(params object[] args) + public GraphTraversal< S , E2 > Coalesce (params object[] args) { Bytecode.AddStep("coalesce", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Coin(params object[] args) + public GraphTraversal< S , E > Coin (params object[] args) { Bytecode.AddStep("coin", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Constant(params object[] args) + public GraphTraversal< S , E2 > Constant (params object[] args) { Bytecode.AddStep("constant", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Count(params object[] args) + public GraphTraversal< S , long > Count (params object[] args) { Bytecode.AddStep("count", args); - return Wrap(this); + return Wrap< S , long >(this); } - public GraphTraversal CyclicPath(params object[] args) + public GraphTraversal< S , E > CyclicPath (params object[] args) { Bytecode.AddStep("cyclicPath", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Dedup(params object[] args) + public GraphTraversal< S , E > Dedup (params object[] args) { Bytecode.AddStep("dedup", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Drop(params object[] args) + public GraphTraversal< S , E > Drop (params object[] args) { Bytecode.AddStep("drop", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Emit(params object[] args) + public GraphTraversal< S , E > Emit (params object[] args) { Bytecode.AddStep("emit", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Filter(params object[] args) + public GraphTraversal< S , E > Filter (params object[] args) { Bytecode.AddStep("filter", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal FlatMap(params object[] args) + public GraphTraversal< S , E2 > FlatMap (params object[] args) { Bytecode.AddStep("flatMap", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Fold(params object[] args) + public GraphTraversal< S , E2 > Fold (params object[] args) { Bytecode.AddStep("fold", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal From(params object[] args) + public GraphTraversal< S , E > From (params object[] args) { Bytecode.AddStep("from", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Group(params object[] args) + public GraphTraversal< S , E > Group (params object[] args) { Bytecode.AddStep("group", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal GroupCount(params object[] args) + public GraphTraversal< S , E > GroupCount (params object[] args) { Bytecode.AddStep("groupCount", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal GroupV3d0(params object[] args) + public GraphTraversal< S , E > GroupV3d0 (params object[] args) { Bytecode.AddStep("groupV3d0", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Has(params object[] args) + public GraphTraversal< S , E > Has (params object[] args) { Bytecode.AddStep("has", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal HasId(params object[] args) + public GraphTraversal< S , E > HasId (params object[] args) { Bytecode.AddStep("hasId", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal HasKey(params object[] args) + public GraphTraversal< S , E > HasKey (params object[] args) { Bytecode.AddStep("hasKey", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal HasLabel(params object[] args) + public GraphTraversal< S , E > HasLabel (params object[] args) { Bytecode.AddStep("hasLabel", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal HasNot(params object[] args) + public GraphTraversal< S , E > HasNot (params object[] args) { Bytecode.AddStep("hasNot", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal HasValue(params object[] args) + public GraphTraversal< S , E > HasValue (params object[] args) { Bytecode.AddStep("hasValue", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Id(params object[] args) + public GraphTraversal< S , object > Id (params object[] args) { Bytecode.AddStep("id", args); - return Wrap(this); + return Wrap< S , object >(this); } - public GraphTraversal Identity(params object[] args) + public GraphTraversal< S , E > Identity (params object[] args) { Bytecode.AddStep("identity", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal In(params object[] args) + public GraphTraversal< S , Vertex > In (params object[] args) { Bytecode.AddStep("in", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal InE(params object[] args) + public GraphTraversal< S , Edge > InE (params object[] args) { Bytecode.AddStep("inE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal InV(params object[] args) + public GraphTraversal< S , Vertex > InV (params object[] args) { Bytecode.AddStep("inV", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal Inject(params object[] args) + public GraphTraversal< S , E > Inject (params object[] args) { Bytecode.AddStep("inject", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Is(params object[] args) + public GraphTraversal< S , E > Is (params object[] args) { Bytecode.AddStep("is", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Key(params object[] args) + public GraphTraversal< S , string > Key (params object[] args) { Bytecode.AddStep("key", args); - return Wrap(this); + return Wrap< S , string >(this); } - public GraphTraversal Label(params object[] args) + public GraphTraversal< S , string > Label (params object[] args) { Bytecode.AddStep("label", args); - return Wrap(this); + return Wrap< S , string >(this); } - public GraphTraversal Limit(params object[] args) + public GraphTraversal< S , E2 > Limit (params object[] args) { Bytecode.AddStep("limit", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Local(params object[] args) + public GraphTraversal< S , E2 > Local (params object[] args) { Bytecode.AddStep("local", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Loops(params object[] args) + public GraphTraversal< S , int > Loops (params object[] args) { Bytecode.AddStep("loops", args); - return Wrap(this); + return Wrap< S , int >(this); } - public GraphTraversal Map(params object[] args) + public GraphTraversal< S , E2 > Map (params object[] args) { Bytecode.AddStep("map", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal MapKeys(params object[] args) + public GraphTraversal< S , E2 > MapKeys (params object[] args) { Bytecode.AddStep("mapKeys", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal MapValues(params object[] args) + public GraphTraversal< S , E2 > MapValues (params object[] args) { Bytecode.AddStep("mapValues", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal> Match(params object[] args) + public GraphTraversal< S , IDictionary > Match (params object[] args) { Bytecode.AddStep("match", args); - return Wrap>(this); + return Wrap< S , IDictionary >(this); } - public GraphTraversal Max(params object[] args) + public GraphTraversal< S , E2 > Max (params object[] args) { Bytecode.AddStep("max", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Mean(params object[] args) + public GraphTraversal< S , E2 > Mean (params object[] args) { Bytecode.AddStep("mean", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Min(params object[] args) + public GraphTraversal< S , E2 > Min (params object[] args) { Bytecode.AddStep("min", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Not(params object[] args) + public GraphTraversal< S , E > Not (params object[] args) { Bytecode.AddStep("not", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Option(params object[] args) + public GraphTraversal< S , E > Option (params object[] args) { Bytecode.AddStep("option", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Optional(params object[] args) + public GraphTraversal< S , E2 > Optional (params object[] args) { Bytecode.AddStep("optional", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Or(params object[] args) + public GraphTraversal< S , E > Or (params object[] args) { Bytecode.AddStep("or", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Order(params object[] args) + public GraphTraversal< S , E > Order (params object[] args) { Bytecode.AddStep("order", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal OtherV(params object[] args) + public GraphTraversal< S , Vertex > OtherV (params object[] args) { Bytecode.AddStep("otherV", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal Out(params object[] args) + public GraphTraversal< S , Vertex > Out (params object[] args) { Bytecode.AddStep("out", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal OutE(params object[] args) + public GraphTraversal< S , Edge > OutE (params object[] args) { Bytecode.AddStep("outE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal OutV(params object[] args) + public GraphTraversal< S , Vertex > OutV (params object[] args) { Bytecode.AddStep("outV", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal PageRank(params object[] args) + public GraphTraversal< S , E > PageRank (params object[] args) { Bytecode.AddStep("pageRank", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Path(params object[] args) + public GraphTraversal< S , Path > Path (params object[] args) { Bytecode.AddStep("path", args); - return Wrap(this); + return Wrap< S , Path >(this); } - public GraphTraversal PeerPressure(params object[] args) + public GraphTraversal< S , E > PeerPressure (params object[] args) { Bytecode.AddStep("peerPressure", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Profile(params object[] args) + public GraphTraversal< S , E > Profile (params object[] args) { Bytecode.AddStep("profile", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Program(params object[] args) + public GraphTraversal< S , E > Program (params object[] args) { Bytecode.AddStep("program", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal> Project(params object[] args) + public GraphTraversal< S , IDictionary > Project (params object[] args) { Bytecode.AddStep("project", args); - return Wrap>(this); + return Wrap< S , IDictionary >(this); } - public GraphTraversal Properties(params object[] args) + public GraphTraversal< S , E2 > Properties (params object[] args) { Bytecode.AddStep("properties", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Property(params object[] args) + public GraphTraversal< S , E > Property (params object[] args) { Bytecode.AddStep("property", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal> PropertyMap(params object[] args) + public GraphTraversal< S , IDictionary > PropertyMap (params object[] args) { Bytecode.AddStep("propertyMap", args); - return Wrap>(this); + return Wrap< S , IDictionary >(this); } - public GraphTraversal Range(params object[] args) + public GraphTraversal< S , E2 > Range (params object[] args) { Bytecode.AddStep("range", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Repeat(params object[] args) + public GraphTraversal< S , E > Repeat (params object[] args) { Bytecode.AddStep("repeat", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Sack(params object[] args) + public GraphTraversal< S , E > Sack (params object[] args) { Bytecode.AddStep("sack", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Sample(params object[] args) + public GraphTraversal< S , E > Sample (params object[] args) { Bytecode.AddStep("sample", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal> Select(params object[] args) + public GraphTraversal< S , IDictionary > Select (params object[] args) { Bytecode.AddStep("select", args); - return Wrap>(this); + return Wrap< S , IDictionary >(this); } - public GraphTraversal SideEffect(params object[] args) + public GraphTraversal< S , E > SideEffect (params object[] args) { Bytecode.AddStep("sideEffect", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal SimplePath(params object[] args) + public GraphTraversal< S , E > SimplePath (params object[] args) { Bytecode.AddStep("simplePath", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Store(params object[] args) + public GraphTraversal< S , E > Store (params object[] args) { Bytecode.AddStep("store", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Subgraph(params object[] args) + public GraphTraversal< S , Edge > Subgraph (params object[] args) { Bytecode.AddStep("subgraph", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal Sum(params object[] args) + public GraphTraversal< S , E2 > Sum (params object[] args) { Bytecode.AddStep("sum", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Tail(params object[] args) + public GraphTraversal< S , E2 > Tail (params object[] args) { Bytecode.AddStep("tail", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal TimeLimit(params object[] args) + public GraphTraversal< S , E > TimeLimit (params object[] args) { Bytecode.AddStep("timeLimit", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Times(params object[] args) + public GraphTraversal< S , E > Times (params object[] args) { Bytecode.AddStep("times", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal To(params object[] args) + public GraphTraversal< S , Vertex > To (params object[] args) { Bytecode.AddStep("to", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal ToE(params object[] args) + public GraphTraversal< S , Edge > ToE (params object[] args) { Bytecode.AddStep("toE", args); - return Wrap(this); + return Wrap< S , Edge >(this); } - public GraphTraversal ToV(params object[] args) + public GraphTraversal< S , Vertex > ToV (params object[] args) { Bytecode.AddStep("toV", args); - return Wrap(this); + return Wrap< S , Vertex >(this); } - public GraphTraversal Tree(params object[] args) + public GraphTraversal< S , E > Tree (params object[] args) { Bytecode.AddStep("tree", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Unfold(params object[] args) + public GraphTraversal< S , E2 > Unfold (params object[] args) { Bytecode.AddStep("unfold", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Union(params object[] args) + public GraphTraversal< S , E2 > Union (params object[] args) { Bytecode.AddStep("union", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Until(params object[] args) + public GraphTraversal< S , E > Until (params object[] args) { Bytecode.AddStep("until", args); - return Wrap(this); + return Wrap< S , E >(this); } - public GraphTraversal Value(params object[] args) + public GraphTraversal< S , E2 > Value (params object[] args) { Bytecode.AddStep("value", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal> ValueMap(params object[] args) + public GraphTraversal< S , IDictionary > ValueMap (params object[] args) { Bytecode.AddStep("valueMap", args); - return Wrap>(this); + return Wrap< S , IDictionary >(this); } - public GraphTraversal Values(params object[] args) + public GraphTraversal< S , E2 > Values (params object[] args) { Bytecode.AddStep("values", args); - return Wrap(this); + return Wrap< S , E2 >(this); } - public GraphTraversal Where(params object[] args) + public GraphTraversal< S , E > Where (params object[] args) { Bytecode.AddStep("where", args); - return Wrap(this); + return Wrap< S , E >(this); } + + } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs index 07d98fb23a8..1380be789c6 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -28,6 +28,9 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public class GraphTraversalSource { public ICollection TraversalStrategies { get; set; } @@ -44,10 +47,11 @@ public GraphTraversalSource(ICollection traversalStrategies, Bytecode = bytecode; } + public GraphTraversalSource WithBulk(params object[] args) { var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); + new Bytecode(Bytecode)); source.Bytecode.AddSource("withBulk", args); return source; } @@ -55,7 +59,7 @@ public GraphTraversalSource WithBulk(params object[] args) public GraphTraversalSource WithPath(params object[] args) { var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); + new Bytecode(Bytecode)); source.Bytecode.AddSource("withPath", args); return source; } @@ -63,7 +67,7 @@ public GraphTraversalSource WithPath(params object[] args) public GraphTraversalSource WithSack(params object[] args) { var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); + new Bytecode(Bytecode)); source.Bytecode.AddSource("withSack", args); return source; } @@ -71,7 +75,7 @@ public GraphTraversalSource WithSack(params object[] args) public GraphTraversalSource WithSideEffect(params object[] args) { var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); + new Bytecode(Bytecode)); source.Bytecode.AddSource("withSideEffect", args); return source; } @@ -79,7 +83,7 @@ public GraphTraversalSource WithSideEffect(params object[] args) public GraphTraversalSource WithStrategies(params object[] args) { var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); + new Bytecode(Bytecode)); source.Bytecode.AddSource("withStrategies", args); return source; } @@ -87,7 +91,7 @@ public GraphTraversalSource WithStrategies(params object[] args) public GraphTraversalSource WithoutStrategies(params object[] args) { var source = new GraphTraversalSource(new List(TraversalStrategies), - new Bytecode(Bytecode)); + new Bytecode(Bytecode)); source.Bytecode.AddSource("withoutStrategies", args); return source; } @@ -104,7 +108,7 @@ public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); return source; } - + public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, string result = null, ITraversal vertices = null, ITraversal edges = null, Dictionary configuration = null) @@ -112,25 +116,27 @@ public GraphTraversalSource WithComputer(string graphComputer = null, int? worke return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); } - public GraphTraversal E(params object[] args) + + public GraphTraversal< Edge,Edge > E(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + var traversal = new GraphTraversal< Edge,Edge >(TraversalStrategies, new Bytecode(Bytecode)); traversal.Bytecode.AddStep("E", args); return traversal; } - public GraphTraversal V(params object[] args) + public GraphTraversal< Vertex,Vertex > V(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + var traversal = new GraphTraversal< Vertex,Vertex >(TraversalStrategies, new Bytecode(Bytecode)); traversal.Bytecode.AddStep("V", args); return traversal; } - public GraphTraversal AddV(params object[] args) + public GraphTraversal< Vertex,Vertex > AddV(params object[] args) { - var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + var traversal = new GraphTraversal< Vertex,Vertex >(TraversalStrategies, new Bytecode(Bytecode)); traversal.Bytecode.AddStep("addV", args); return traversal; } + } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs new file mode 100644 index 00000000000..c271a9ff3be --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs @@ -0,0 +1,33 @@ +#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 + +namespace Gremlin.Net.Process.Traversal +{ + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// + public enum GryoVersion + { + V1_0 + } +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs index 2e95da15a80..bfee0dae5d1 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs @@ -25,6 +25,9 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// internal static class NamingConversions { /// @@ -41,46 +44,50 @@ internal static string GetEnumJavaName(string typeName, string value) return javaName; } - private static readonly IDictionary CSharpToJavaEnums = new Dictionary + internal static readonly IDictionary CSharpToJavaEnums = new Dictionary { - {"T.Value", "value"}, - {"Order.Decr", "decr"}, - {"Order.KeyDecr", "keyDecr"}, - {"T.Key", "key"}, - {"Column.Values", "values"}, - {"Order.KeyIncr", "keyIncr"}, - {"Operator.Or", "or"}, - {"Order.ValueIncr", "valueIncr"}, + {"Barrier.NormSack", "normSack"}, {"Cardinality.List", "list"}, - {"Order.Incr", "incr"}, - {"Pop.All", "all"}, - {"Operator.SumLong", "sumLong"}, - {"Pop.First", "first"}, - {"T.Label", "label"}, {"Cardinality.Set", "set"}, - {"Order.Shuffle", "shuffle"}, - {"Direction.In", "IN"}, + {"Cardinality.Single", "single"}, + {"Column.Keys", "keys"}, + {"Column.Values", "values"}, {"Direction.Both", "BOTH"}, - {"Scope.Local", "local"}, - {"Operator.Max", "max"}, + {"Direction.In", "IN"}, {"Direction.Out", "OUT"}, - {"Scope.Global", "global"}, - {"Pick.Any", "any"}, - {"Order.ValueDecr", "valueDecr"}, - {"Column.Keys", "keys"}, + {"GraphSONVersion.V1_0", "V1_0"}, + {"GraphSONVersion.V2_0", "V2_0"}, + {"GryoVersion.V1_0", "V1_0"}, {"Operator.AddAll", "addAll"}, + {"Operator.And", "and"}, + {"Operator.Assign", "assign"}, + {"Operator.Div", "div"}, + {"Operator.Max", "max"}, + {"Operator.Min", "min"}, + {"Operator.Minus", "minus"}, {"Operator.Mult", "mult"}, + {"Operator.Or", "or"}, + {"Operator.Sum", "sum"}, + {"Operator.SumLong", "sumLong"}, + {"Order.Decr", "decr"}, + {"Order.Incr", "incr"}, + {"Order.KeyDecr", "keyDecr"}, + {"Order.KeyIncr", "keyIncr"}, + {"Order.Shuffle", "shuffle"}, + {"Order.ValueDecr", "valueDecr"}, + {"Order.ValueIncr", "valueIncr"}, + {"Pick.Any", "any"}, {"Pick.None", "none"}, + {"Pop.All", "all"}, + {"Pop.First", "first"}, {"Pop.Last", "last"}, - {"Operator.And", "and"}, + {"Scope.Global", "global"}, + {"Scope.Local", "local"}, {"T.Id", "id"}, - {"Operator.Min", "min"}, - {"Barrier.NormSack", "normSack"}, - {"Operator.Minus", "minus"}, - {"Cardinality.Single", "single"}, - {"Operator.Assign", "assign"}, - {"Operator.Div", "div"}, - {"Operator.Sum", "sum"} + {"T.Key", "key"}, + {"T.Label", "label"}, + {"T.Value", "value"} + }; } } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index 17b44a42a91..a7a01eed2d6 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -23,18 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Operator { - AddAll, - And, - Assign, - Div, - Max, - Min, - Minus, - Mult, - Or, - Sum, - SumLong + AddAll,And,Assign,Div,Max,Min,Minus,Mult,Or,Sum,SumLong } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index 179182b46fe..a59daf5dd2a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -23,14 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Order { - Decr, - Incr, - KeyDecr, - KeyIncr, - Shuffle, - ValueDecr, - ValueIncr + Decr,Incr,KeyDecr,KeyIncr,Shuffle,ValueDecr,ValueIncr } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs index cf388bd005b..ee184e6e1c4 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs @@ -21,11 +21,14 @@ #endregion - namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public class P { + public static TraversalPredicate Between(params object[] args) { var value = args.Length == 1 ? args[0] : args; @@ -103,5 +106,6 @@ public static TraversalPredicate Without(params object[] args) var value = args.Length == 1 ? args[0] : args; return new TraversalPredicate("without", value); } + } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs index 624f66e82e6..2306cc05ba6 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -23,9 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Pick { - Any, - None + Any,None } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs index dcbe698e7e6..72ea8d992fe 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -23,10 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Pop { - All, - First, - Last + All,First,Last } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs index f27725e8a9d..b19d709ecab 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -23,9 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum Scope { - Global, - Local + Global,Local } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index 76ca40f5a98..ccd02421330 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -23,11 +23,11 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public enum T { - Id, - Key, - Label, - Value + Id,Key,Label,Value } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index f2e6162921b..aaf61aa2f56 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -26,6 +26,9 @@ namespace Gremlin.Net.Process.Traversal { + /// + /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// public static class __ { public static GraphTraversal Start() @@ -487,5 +490,6 @@ public static GraphTraversal Where(params object[] args) { return new GraphTraversal().Where(args); } + } -} +} \ No newline at end of file diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 3b0bf68c9a2..dd43b1f628e 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -26,6 +26,23 @@ limitations under the License. gremlin-dotnet-source Apache TinkerPop :: Gremlin-DotNet - Source ${packaging.type} + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + generate-dsl + + + + + + + gremlin-dotnet-standard diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index d0626209a62..8cdffa9ec97 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -34,6 +34,22 @@ limitations under the License. ${project.parent.parent.basedir}/gremlin-server + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + generate-dsl + + + + + + + gremlin-dotnet-standard diff --git a/pom.xml b/pom.xml index 888e35d6efb..36d8d320c2d 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,6 @@ limitations under the License. gremlin-groovy-test tinkergraph-gremlin gremlin-python - gremlin-dotnet-generator gremlin-dotnet hadoop-gremlin spark-gremlin From 74f9115f2b90514121e012ac1f2665c88c09f216 Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Thu, 15 Jun 2017 15:09:58 +0200 Subject: [PATCH 14/28] Improve comments in Gremlin-DotNet, especially for the GLV part --- .../glv/AnonymousTraversal.template | 9 +- gremlin-dotnet/glv/Enum.template | 4 +- gremlin-dotnet/glv/GraphTraversal.template | 14 +- .../glv/GraphTraversalSource.template | 44 ++- gremlin-dotnet/glv/NamingConversions.template | 6 +- gremlin-dotnet/glv/P.template | 4 +- .../Gremlin.Net/Process/Traversal/Barrier.cs | 4 +- .../Gremlin.Net/Process/Traversal/Bytecode.cs | 2 +- .../Process/Traversal/Cardinality.cs | 4 +- .../Gremlin.Net/Process/Traversal/Column.cs | 4 +- .../Process/Traversal/DefaultTraversal.cs | 2 +- .../Process/Traversal/Direction.cs | 4 +- .../Process/Traversal/GraphSONVersion.cs | 4 +- .../Process/Traversal/GraphTraversal.cs | 305 +++++++++++++++++- .../Process/Traversal/GraphTraversalSource.cs | 52 ++- .../Process/Traversal/GryoVersion.cs | 4 +- .../Process/Traversal/NamingConversions.cs | 6 +- .../Gremlin.Net/Process/Traversal/Operator.cs | 4 +- .../Gremlin.Net/Process/Traversal/Order.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/P.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/Pick.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/Pop.cs | 4 +- .../Gremlin.Net/Process/Traversal/Scope.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/T.cs | 4 +- .../src/Gremlin.Net/Process/Traversal/__.cs | 279 +++++++++++++++- .../src/Gremlin.Net/Structure/Graph.cs | 8 + 26 files changed, 728 insertions(+), 59 deletions(-) diff --git a/gremlin-dotnet/glv/AnonymousTraversal.template b/gremlin-dotnet/glv/AnonymousTraversal.template index 33002bf2659..9bc72576b33 100644 --- a/gremlin-dotnet/glv/AnonymousTraversal.template +++ b/gremlin-dotnet/glv/AnonymousTraversal.template @@ -24,18 +24,25 @@ 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 { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// An anonymous . /// public static class __ { + /// + /// Starts an empty . + /// public static GraphTraversal Start() { return new GraphTraversal(); } <% anonStepMethods.each { method -> %> + /// + /// Spawns a and adds the <%= method.methodName %> step to that traversal. + /// public static GraphTraversal> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(params object[] args) { return new GraphTraversal().<%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(args); diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template index 664db45a608..25537f4720b 100644 --- a/gremlin-dotnet/glv/Enum.template +++ b/gremlin-dotnet/glv/Enum.template @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum <%= enumClass.simpleName %> { <%= constants %> diff --git a/gremlin-dotnet/glv/GraphTraversal.template b/gremlin-dotnet/glv/GraphTraversal.template index b782ffa9a3c..d514e163ca9 100644 --- a/gremlin-dotnet/glv/GraphTraversal.template +++ b/gremlin-dotnet/glv/GraphTraversal.template @@ -24,18 +24,27 @@ 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 { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// Graph traversals are the primary way in which graphs are processed. /// public class GraphTraversal : DefaultTraversal { + /// + /// Initializes a new instance of the class. + /// public GraphTraversal() : this(new List(), new Bytecode()) { } + /// + /// Initializes a new instance of the class. + /// + /// The traversal strategies to be used by this graph traversal at evaluation time. + /// The associated with the construction of this graph traversal. public GraphTraversal(ICollection traversalStrategies, Bytecode bytecode) { TraversalStrategies = traversalStrategies; @@ -53,6 +62,9 @@ namespace Gremlin.Net.Process.Traversal } <% graphStepMethods.each { method -> %> + /// + /// Adds the <%= method.methodName %> step to this . + /// public GraphTraversal< <%= method.t1 %> , <%= method.t2 %> > <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %> (params object[] args) { Bytecode.AddStep("<%= method.methodName %>", args); diff --git a/gremlin-dotnet/glv/GraphTraversalSource.template b/gremlin-dotnet/glv/GraphTraversalSource.template index 880f793c19e..7a945f8604e 100644 --- a/gremlin-dotnet/glv/GraphTraversalSource.template +++ b/gremlin-dotnet/glv/GraphTraversalSource.template @@ -21,26 +21,48 @@ #endregion +using System; using System.Collections.Generic; 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 { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// A is the primary DSL of the Gremlin traversal machine. + /// It provides access to all the configurations and steps for Turing complete graph computing. /// public class GraphTraversalSource { + /// + /// Gets or sets the traversal strategies associated with this graph traversal source. + /// public ICollection TraversalStrategies { get; set; } + + /// + /// Gets or sets the associated with the current state of this graph traversal + /// source. + /// public Bytecode Bytecode { get; set; } - public GraphTraversalSource() + /// + /// Initializes a new instance of the class. + /// + public GraphTraversalSource() : this(new List(), new Bytecode()) { } + /// + /// Initializes a new instance of the class. + /// + /// The traversal strategies associated with this graph traversal source. + /// + /// The associated with the current state of this graph traversal + /// source. + /// public GraphTraversalSource(ICollection traversalStrategies, Bytecode bytecode) { TraversalStrategies = traversalStrategies; @@ -56,11 +78,21 @@ namespace Gremlin.Net.Process.Traversal return source; } <% } %> + [Obsolete("Use the Bindings class instead.", false)] public GraphTraversalSource WithBindings(object bindings) { return this; } + /// + /// Configures the as a "remote" to issue the + /// for execution elsewhere. + /// + /// + /// The instance to use to submit the + /// . + /// + /// A configured to use the provided . public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) { var source = new GraphTraversalSource(new List(TraversalStrategies), @@ -69,6 +101,10 @@ namespace Gremlin.Net.Process.Traversal return source; } + /// + /// Add a GraphComputer class used to execute the traversal. + /// This adds a to the strategies. + /// public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, string result = null, ITraversal vertices = null, ITraversal edges = null, Dictionary configuration = null) @@ -77,6 +113,10 @@ namespace Gremlin.Net.Process.Traversal } <% sourceSpawnMethods.each { method -> %> + /// + /// Spawns a off this graph traversal source and adds the <%= method.methodName %> step to that + /// traversal. + /// public GraphTraversal< <%= method.typeArguments.join(",") %> > <%= toCSharpMethodName.call(method.methodName) %>(params object[] args) { var traversal = new GraphTraversal< <%= method.typeArguments.join(",") %> >(TraversalStrategies, new Bytecode(Bytecode)); diff --git a/gremlin-dotnet/glv/NamingConversions.template b/gremlin-dotnet/glv/NamingConversions.template index b997dee1f53..201e74bd101 100644 --- a/gremlin-dotnet/glv/NamingConversions.template +++ b/gremlin-dotnet/glv/NamingConversions.template @@ -23,15 +23,13 @@ using System.Collections.Generic; +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// internal static class NamingConversions { /// - /// Gets the Java name equivalent for a given enum value + /// Gets the Java name equivalent for a given enum value /// internal static string GetEnumJavaName(string typeName, string value) { diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template index 5be695dc279..6a62414840d 100644 --- a/gremlin-dotnet/glv/P.template +++ b/gremlin-dotnet/glv/P.template @@ -21,10 +21,12 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// A is a predicate of the form Func<object, bool>. + /// That is, given some object, return true or false. /// public class P { diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs index 543fda61e96..aa4040a747f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Barrier { NormSack diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs index b35e8db6c4a..693d3318669 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs @@ -31,7 +31,7 @@ namespace Gremlin.Net.Process.Traversal /// /// Bytecode is simply a list of ordered instructions. /// Bytecode can be serialized between environments and machines by way of a GraphSON representation. - /// Thus, Gremlin-CSharp can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java. + /// Thus, Gremlin-DotNet can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java. /// public class Bytecode { diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs index b47dd32c89a..029638087ea 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Cardinality { List,Set,Single diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index 063c26e5eb5..15e248c3756 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Column { Keys,Values diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs index 2652df3a508..d9dfe10631f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs @@ -36,7 +36,7 @@ public abstract class DefaultTraversal : ITraversal private IEnumerator _traverserEnumerator; /// - /// Gets the representation of this traversal. + /// Gets the representation of this traversal. /// public Bytecode Bytecode { get; protected set; } diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs index 5f6717ef498..27d393494b5 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Direction { Both,In,Out diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs index c72ae8ec1ec..cc66fba0644 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum GraphSONVersion { V1_0,V2_0 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 5aaaef0bc0d..34f5bfb6aa1 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -24,18 +24,27 @@ 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 { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// Graph traversals are the primary way in which graphs are processed. /// public class GraphTraversal : DefaultTraversal { + /// + /// Initializes a new instance of the class. + /// public GraphTraversal() : this(new List(), new Bytecode()) { } + /// + /// Initializes a new instance of the class. + /// + /// The traversal strategies to be used by this graph traversal at evaluation time. + /// The associated with the construction of this graph traversal. public GraphTraversal(ICollection traversalStrategies, Bytecode bytecode) { TraversalStrategies = traversalStrategies; @@ -53,588 +62,882 @@ private static GraphTraversal Wrap(GraphTraversal traversa } + /// + /// Adds the V step to this . + /// public GraphTraversal< S , Vertex > V (params object[] args) { Bytecode.AddStep("V", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the addE step to this . + /// public GraphTraversal< S , Edge > AddE (params object[] args) { Bytecode.AddStep("addE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the addInE step to this . + /// public GraphTraversal< S , Edge > AddInE (params object[] args) { Bytecode.AddStep("addInE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the addOutE step to this . + /// public GraphTraversal< S , Edge > AddOutE (params object[] args) { Bytecode.AddStep("addOutE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the addV step to this . + /// public GraphTraversal< S , Vertex > AddV (params object[] args) { Bytecode.AddStep("addV", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the aggregate step to this . + /// public GraphTraversal< S , E > Aggregate (params object[] args) { Bytecode.AddStep("aggregate", args); return Wrap< S , E >(this); } + /// + /// Adds the and step to this . + /// public GraphTraversal< S , E > And (params object[] args) { Bytecode.AddStep("and", args); return Wrap< S , E >(this); } + /// + /// Adds the as step to this . + /// public GraphTraversal< S , E > As (params object[] args) { Bytecode.AddStep("as", args); return Wrap< S , E >(this); } + /// + /// Adds the barrier step to this . + /// public GraphTraversal< S , E > Barrier (params object[] args) { Bytecode.AddStep("barrier", args); return Wrap< S , E >(this); } + /// + /// Adds the both step to this . + /// public GraphTraversal< S , Vertex > Both (params object[] args) { Bytecode.AddStep("both", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the bothE step to this . + /// public GraphTraversal< S , Edge > BothE (params object[] args) { Bytecode.AddStep("bothE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the bothV step to this . + /// public GraphTraversal< S , Vertex > BothV (params object[] args) { Bytecode.AddStep("bothV", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the branch step to this . + /// public GraphTraversal< S , E2 > Branch (params object[] args) { Bytecode.AddStep("branch", args); return Wrap< S , E2 >(this); } + /// + /// Adds the by step to this . + /// public GraphTraversal< S , E > By (params object[] args) { Bytecode.AddStep("by", args); return Wrap< S , E >(this); } + /// + /// Adds the cap step to this . + /// public GraphTraversal< S , E2 > Cap (params object[] args) { Bytecode.AddStep("cap", args); return Wrap< S , E2 >(this); } + /// + /// Adds the choose step to this . + /// public GraphTraversal< S , E2 > Choose (params object[] args) { Bytecode.AddStep("choose", args); return Wrap< S , E2 >(this); } + /// + /// Adds the coalesce step to this . + /// public GraphTraversal< S , E2 > Coalesce (params object[] args) { Bytecode.AddStep("coalesce", args); return Wrap< S , E2 >(this); } + /// + /// Adds the coin step to this . + /// public GraphTraversal< S , E > Coin (params object[] args) { Bytecode.AddStep("coin", args); return Wrap< S , E >(this); } + /// + /// Adds the constant step to this . + /// public GraphTraversal< S , E2 > Constant (params object[] args) { Bytecode.AddStep("constant", args); return Wrap< S , E2 >(this); } + /// + /// Adds the count step to this . + /// public GraphTraversal< S , long > Count (params object[] args) { Bytecode.AddStep("count", args); return Wrap< S , long >(this); } + /// + /// Adds the cyclicPath step to this . + /// public GraphTraversal< S , E > CyclicPath (params object[] args) { Bytecode.AddStep("cyclicPath", args); return Wrap< S , E >(this); } + /// + /// Adds the dedup step to this . + /// public GraphTraversal< S , E > Dedup (params object[] args) { Bytecode.AddStep("dedup", args); return Wrap< S , E >(this); } + /// + /// Adds the drop step to this . + /// public GraphTraversal< S , E > Drop (params object[] args) { Bytecode.AddStep("drop", args); return Wrap< S , E >(this); } + /// + /// Adds the emit step to this . + /// public GraphTraversal< S , E > Emit (params object[] args) { Bytecode.AddStep("emit", args); return Wrap< S , E >(this); } + /// + /// Adds the filter step to this . + /// public GraphTraversal< S , E > Filter (params object[] args) { Bytecode.AddStep("filter", args); return Wrap< S , E >(this); } + /// + /// Adds the flatMap step to this . + /// public GraphTraversal< S , E2 > FlatMap (params object[] args) { Bytecode.AddStep("flatMap", args); return Wrap< S , E2 >(this); } + /// + /// Adds the fold step to this . + /// public GraphTraversal< S , E2 > Fold (params object[] args) { Bytecode.AddStep("fold", args); return Wrap< S , E2 >(this); } + /// + /// Adds the from step to this . + /// public GraphTraversal< S , E > From (params object[] args) { Bytecode.AddStep("from", args); return Wrap< S , E >(this); } + /// + /// Adds the group step to this . + /// public GraphTraversal< S , E > Group (params object[] args) { Bytecode.AddStep("group", args); return Wrap< S , E >(this); } + /// + /// Adds the groupCount step to this . + /// public GraphTraversal< S , E > GroupCount (params object[] args) { Bytecode.AddStep("groupCount", args); return Wrap< S , E >(this); } + /// + /// Adds the groupV3d0 step to this . + /// public GraphTraversal< S , E > GroupV3d0 (params object[] args) { Bytecode.AddStep("groupV3d0", args); return Wrap< S , E >(this); } + /// + /// Adds the has step to this . + /// public GraphTraversal< S , E > Has (params object[] args) { Bytecode.AddStep("has", args); return Wrap< S , E >(this); } + /// + /// Adds the hasId step to this . + /// public GraphTraversal< S , E > HasId (params object[] args) { Bytecode.AddStep("hasId", args); return Wrap< S , E >(this); } + /// + /// Adds the hasKey step to this . + /// public GraphTraversal< S , E > HasKey (params object[] args) { Bytecode.AddStep("hasKey", args); return Wrap< S , E >(this); } + /// + /// Adds the hasLabel step to this . + /// public GraphTraversal< S , E > HasLabel (params object[] args) { Bytecode.AddStep("hasLabel", args); return Wrap< S , E >(this); } + /// + /// Adds the hasNot step to this . + /// public GraphTraversal< S , E > HasNot (params object[] args) { Bytecode.AddStep("hasNot", args); return Wrap< S , E >(this); } + /// + /// Adds the hasValue step to this . + /// public GraphTraversal< S , E > HasValue (params object[] args) { Bytecode.AddStep("hasValue", args); return Wrap< S , E >(this); } + /// + /// Adds the id step to this . + /// public GraphTraversal< S , object > Id (params object[] args) { Bytecode.AddStep("id", args); return Wrap< S , object >(this); } + /// + /// Adds the identity step to this . + /// public GraphTraversal< S , E > Identity (params object[] args) { Bytecode.AddStep("identity", args); return Wrap< S , E >(this); } + /// + /// Adds the in step to this . + /// public GraphTraversal< S , Vertex > In (params object[] args) { Bytecode.AddStep("in", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the inE step to this . + /// public GraphTraversal< S , Edge > InE (params object[] args) { Bytecode.AddStep("inE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the inV step to this . + /// public GraphTraversal< S , Vertex > InV (params object[] args) { Bytecode.AddStep("inV", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the inject step to this . + /// public GraphTraversal< S , E > Inject (params object[] args) { Bytecode.AddStep("inject", args); return Wrap< S , E >(this); } + /// + /// Adds the is step to this . + /// public GraphTraversal< S , E > Is (params object[] args) { Bytecode.AddStep("is", args); return Wrap< S , E >(this); } + /// + /// Adds the key step to this . + /// public GraphTraversal< S , string > Key (params object[] args) { Bytecode.AddStep("key", args); return Wrap< S , string >(this); } + /// + /// Adds the label step to this . + /// public GraphTraversal< S , string > Label (params object[] args) { Bytecode.AddStep("label", args); return Wrap< S , string >(this); } + /// + /// Adds the limit step to this . + /// public GraphTraversal< S , E2 > Limit (params object[] args) { Bytecode.AddStep("limit", args); return Wrap< S , E2 >(this); } + /// + /// Adds the local step to this . + /// public GraphTraversal< S , E2 > Local (params object[] args) { Bytecode.AddStep("local", args); return Wrap< S , E2 >(this); } + /// + /// Adds the loops step to this . + /// public GraphTraversal< S , int > Loops (params object[] args) { Bytecode.AddStep("loops", args); return Wrap< S , int >(this); } + /// + /// Adds the map step to this . + /// public GraphTraversal< S , E2 > Map (params object[] args) { Bytecode.AddStep("map", args); return Wrap< S , E2 >(this); } + /// + /// Adds the mapKeys step to this . + /// public GraphTraversal< S , E2 > MapKeys (params object[] args) { Bytecode.AddStep("mapKeys", args); return Wrap< S , E2 >(this); } + /// + /// Adds the mapValues step to this . + /// public GraphTraversal< S , E2 > MapValues (params object[] args) { Bytecode.AddStep("mapValues", args); return Wrap< S , E2 >(this); } + /// + /// Adds the match step to this . + /// public GraphTraversal< S , IDictionary > Match (params object[] args) { Bytecode.AddStep("match", args); return Wrap< S , IDictionary >(this); } + /// + /// Adds the max step to this . + /// public GraphTraversal< S , E2 > Max (params object[] args) { Bytecode.AddStep("max", args); return Wrap< S , E2 >(this); } + /// + /// Adds the mean step to this . + /// public GraphTraversal< S , E2 > Mean (params object[] args) { Bytecode.AddStep("mean", args); return Wrap< S , E2 >(this); } + /// + /// Adds the min step to this . + /// public GraphTraversal< S , E2 > Min (params object[] args) { Bytecode.AddStep("min", args); return Wrap< S , E2 >(this); } + /// + /// Adds the not step to this . + /// public GraphTraversal< S , E > Not (params object[] args) { Bytecode.AddStep("not", args); return Wrap< S , E >(this); } + /// + /// Adds the option step to this . + /// public GraphTraversal< S , E > Option (params object[] args) { Bytecode.AddStep("option", args); return Wrap< S , E >(this); } + /// + /// Adds the optional step to this . + /// public GraphTraversal< S , E2 > Optional (params object[] args) { Bytecode.AddStep("optional", args); return Wrap< S , E2 >(this); } + /// + /// Adds the or step to this . + /// public GraphTraversal< S , E > Or (params object[] args) { Bytecode.AddStep("or", args); return Wrap< S , E >(this); } + /// + /// Adds the order step to this . + /// public GraphTraversal< S , E > Order (params object[] args) { Bytecode.AddStep("order", args); return Wrap< S , E >(this); } + /// + /// Adds the otherV step to this . + /// public GraphTraversal< S , Vertex > OtherV (params object[] args) { Bytecode.AddStep("otherV", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the out step to this . + /// public GraphTraversal< S , Vertex > Out (params object[] args) { Bytecode.AddStep("out", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the outE step to this . + /// public GraphTraversal< S , Edge > OutE (params object[] args) { Bytecode.AddStep("outE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the outV step to this . + /// public GraphTraversal< S , Vertex > OutV (params object[] args) { Bytecode.AddStep("outV", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the pageRank step to this . + /// public GraphTraversal< S , E > PageRank (params object[] args) { Bytecode.AddStep("pageRank", args); return Wrap< S , E >(this); } + /// + /// Adds the path step to this . + /// public GraphTraversal< S , Path > Path (params object[] args) { Bytecode.AddStep("path", args); return Wrap< S , Path >(this); } + /// + /// Adds the peerPressure step to this . + /// public GraphTraversal< S , E > PeerPressure (params object[] args) { Bytecode.AddStep("peerPressure", args); return Wrap< S , E >(this); } + /// + /// Adds the profile step to this . + /// public GraphTraversal< S , E > Profile (params object[] args) { Bytecode.AddStep("profile", args); return Wrap< S , E >(this); } + /// + /// Adds the program step to this . + /// public GraphTraversal< S , E > Program (params object[] args) { Bytecode.AddStep("program", args); return Wrap< S , E >(this); } + /// + /// Adds the project step to this . + /// public GraphTraversal< S , IDictionary > Project (params object[] args) { Bytecode.AddStep("project", args); return Wrap< S , IDictionary >(this); } + /// + /// Adds the properties step to this . + /// public GraphTraversal< S , E2 > Properties (params object[] args) { Bytecode.AddStep("properties", args); return Wrap< S , E2 >(this); } + /// + /// Adds the property step to this . + /// public GraphTraversal< S , E > Property (params object[] args) { Bytecode.AddStep("property", args); return Wrap< S , E >(this); } + /// + /// Adds the propertyMap step to this . + /// public GraphTraversal< S , IDictionary > PropertyMap (params object[] args) { Bytecode.AddStep("propertyMap", args); return Wrap< S , IDictionary >(this); } + /// + /// Adds the range step to this . + /// public GraphTraversal< S , E2 > Range (params object[] args) { Bytecode.AddStep("range", args); return Wrap< S , E2 >(this); } + /// + /// Adds the repeat step to this . + /// public GraphTraversal< S , E > Repeat (params object[] args) { Bytecode.AddStep("repeat", args); return Wrap< S , E >(this); } + /// + /// Adds the sack step to this . + /// public GraphTraversal< S , E > Sack (params object[] args) { Bytecode.AddStep("sack", args); return Wrap< S , E >(this); } + /// + /// Adds the sample step to this . + /// public GraphTraversal< S , E > Sample (params object[] args) { Bytecode.AddStep("sample", args); return Wrap< S , E >(this); } + /// + /// Adds the select step to this . + /// public GraphTraversal< S , IDictionary > Select (params object[] args) { Bytecode.AddStep("select", args); return Wrap< S , IDictionary >(this); } + /// + /// Adds the sideEffect step to this . + /// public GraphTraversal< S , E > SideEffect (params object[] args) { Bytecode.AddStep("sideEffect", args); return Wrap< S , E >(this); } + /// + /// Adds the simplePath step to this . + /// public GraphTraversal< S , E > SimplePath (params object[] args) { Bytecode.AddStep("simplePath", args); return Wrap< S , E >(this); } + /// + /// Adds the store step to this . + /// public GraphTraversal< S , E > Store (params object[] args) { Bytecode.AddStep("store", args); return Wrap< S , E >(this); } + /// + /// Adds the subgraph step to this . + /// public GraphTraversal< S , Edge > Subgraph (params object[] args) { Bytecode.AddStep("subgraph", args); return Wrap< S , Edge >(this); } + /// + /// Adds the sum step to this . + /// public GraphTraversal< S , E2 > Sum (params object[] args) { Bytecode.AddStep("sum", args); return Wrap< S , E2 >(this); } + /// + /// Adds the tail step to this . + /// public GraphTraversal< S , E2 > Tail (params object[] args) { Bytecode.AddStep("tail", args); return Wrap< S , E2 >(this); } + /// + /// Adds the timeLimit step to this . + /// public GraphTraversal< S , E > TimeLimit (params object[] args) { Bytecode.AddStep("timeLimit", args); return Wrap< S , E >(this); } + /// + /// Adds the times step to this . + /// public GraphTraversal< S , E > Times (params object[] args) { Bytecode.AddStep("times", args); return Wrap< S , E >(this); } + /// + /// Adds the to step to this . + /// public GraphTraversal< S , Vertex > To (params object[] args) { Bytecode.AddStep("to", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the toE step to this . + /// public GraphTraversal< S , Edge > ToE (params object[] args) { Bytecode.AddStep("toE", args); return Wrap< S , Edge >(this); } + /// + /// Adds the toV step to this . + /// public GraphTraversal< S , Vertex > ToV (params object[] args) { Bytecode.AddStep("toV", args); return Wrap< S , Vertex >(this); } + /// + /// Adds the tree step to this . + /// public GraphTraversal< S , E > Tree (params object[] args) { Bytecode.AddStep("tree", args); return Wrap< S , E >(this); } + /// + /// Adds the unfold step to this . + /// public GraphTraversal< S , E2 > Unfold (params object[] args) { Bytecode.AddStep("unfold", args); return Wrap< S , E2 >(this); } + /// + /// Adds the union step to this . + /// public GraphTraversal< S , E2 > Union (params object[] args) { Bytecode.AddStep("union", args); return Wrap< S , E2 >(this); } + /// + /// Adds the until step to this . + /// public GraphTraversal< S , E > Until (params object[] args) { Bytecode.AddStep("until", args); return Wrap< S , E >(this); } + /// + /// Adds the value step to this . + /// public GraphTraversal< S , E2 > Value (params object[] args) { Bytecode.AddStep("value", args); return Wrap< S , E2 >(this); } + /// + /// Adds the valueMap step to this . + /// public GraphTraversal< S , IDictionary > ValueMap (params object[] args) { Bytecode.AddStep("valueMap", args); return Wrap< S , IDictionary >(this); } + /// + /// Adds the values step to this . + /// public GraphTraversal< S , E2 > Values (params object[] args) { Bytecode.AddStep("values", args); return Wrap< S , E2 >(this); } + /// + /// Adds the where step to this . + /// public GraphTraversal< S , E > Where (params object[] args) { Bytecode.AddStep("where", args); diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs index 1380be789c6..317afadc15a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -21,26 +21,48 @@ #endregion +using System; using System.Collections.Generic; 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 { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// A is the primary DSL of the Gremlin traversal machine. + /// It provides access to all the configurations and steps for Turing complete graph computing. /// public class GraphTraversalSource { + /// + /// Gets or sets the traversal strategies associated with this graph traversal source. + /// public ICollection TraversalStrategies { get; set; } + + /// + /// Gets or sets the associated with the current state of this graph traversal + /// source. + /// public Bytecode Bytecode { get; set; } - public GraphTraversalSource() + /// + /// Initializes a new instance of the class. + /// + public GraphTraversalSource() : this(new List(), new Bytecode()) { } + /// + /// Initializes a new instance of the class. + /// + /// The traversal strategies associated with this graph traversal source. + /// + /// The associated with the current state of this graph traversal + /// source. + /// public GraphTraversalSource(ICollection traversalStrategies, Bytecode bytecode) { TraversalStrategies = traversalStrategies; @@ -96,11 +118,21 @@ public GraphTraversalSource WithoutStrategies(params object[] args) return source; } + [Obsolete("Use the Bindings class instead.", false)] public GraphTraversalSource WithBindings(object bindings) { return this; } + /// + /// Configures the as a "remote" to issue the + /// for execution elsewhere. + /// + /// + /// The instance to use to submit the + /// . + /// + /// A configured to use the provided . public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) { var source = new GraphTraversalSource(new List(TraversalStrategies), @@ -109,6 +141,10 @@ public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) return source; } + /// + /// Add a GraphComputer class used to execute the traversal. + /// This adds a to the strategies. + /// public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, string result = null, ITraversal vertices = null, ITraversal edges = null, Dictionary configuration = null) @@ -117,6 +153,10 @@ public GraphTraversalSource WithComputer(string graphComputer = null, int? worke } + /// + /// Spawns a off this graph traversal source and adds the E step to that + /// traversal. + /// public GraphTraversal< Edge,Edge > E(params object[] args) { var traversal = new GraphTraversal< Edge,Edge >(TraversalStrategies, new Bytecode(Bytecode)); @@ -124,6 +164,10 @@ public GraphTraversal< Edge,Edge > E(params object[] args) return traversal; } + /// + /// Spawns a off this graph traversal source and adds the V step to that + /// traversal. + /// public GraphTraversal< Vertex,Vertex > V(params object[] args) { var traversal = new GraphTraversal< Vertex,Vertex >(TraversalStrategies, new Bytecode(Bytecode)); @@ -131,6 +175,10 @@ public GraphTraversal< Vertex,Vertex > V(params object[] args) return traversal; } + /// + /// Spawns a off this graph traversal source and adds the addV step to that + /// traversal. + /// public GraphTraversal< Vertex,Vertex > AddV(params object[] args) { var traversal = new GraphTraversal< Vertex,Vertex >(TraversalStrategies, new Bytecode(Bytecode)); diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs index c271a9ff3be..76a263dee76 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum GryoVersion { V1_0 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs index bfee0dae5d1..aecdc570dc7 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs @@ -23,15 +23,13 @@ using System.Collections.Generic; +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// internal static class NamingConversions { /// - /// Gets the Java name equivalent for a given enum value + /// Gets the Java name equivalent for a given enum value /// internal static string GetEnumJavaName(string typeName, string value) { diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index a7a01eed2d6..d98d9bab890 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Operator { AddAll,And,Assign,Div,Max,Min,Minus,Mult,Or,Sum,SumLong diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index a59daf5dd2a..2e0c4ea60fa 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Order { Decr,Incr,KeyDecr,KeyIncr,Shuffle,ValueDecr,ValueIncr diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs index ee184e6e1c4..e0174023415 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs @@ -21,10 +21,12 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// A is a predicate of the form Func<object, bool>. + /// That is, given some object, return true or false. /// public class P { diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs index 2306cc05ba6..2231cdaf125 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Pick { Any,None diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs index 72ea8d992fe..01c6e1a616b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Pop { All,First,Last diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs index b19d709ecab..e443252786c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum Scope { Global,Local diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index ccd02421330..f914916b33d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -21,11 +21,9 @@ #endregion +// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { - /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml - /// public enum T { Id,Key,Label,Value diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index aaf61aa2f56..fd7a901bb72 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -24,468 +24,745 @@ 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 { /// - /// THIS IS A GENERATED CLASS - DO NOT MODIFY THIS CLASS DIRECTLY - see pom.xml + /// An anonymous . /// public static class __ { + /// + /// Starts an empty . + /// public static GraphTraversal Start() { return new GraphTraversal(); } + /// + /// Spawns a and adds the V step to that traversal. + /// public static GraphTraversal V(params object[] args) { return new GraphTraversal().V(args); } + /// + /// Spawns a and adds the addE step to that traversal. + /// public static GraphTraversal AddE(params object[] args) { return new GraphTraversal().AddE(args); } + /// + /// Spawns a and adds the addInE step to that traversal. + /// public static GraphTraversal AddInE(params object[] args) { return new GraphTraversal().AddInE(args); } + /// + /// Spawns a and adds the addOutE step to that traversal. + /// public static GraphTraversal AddOutE(params object[] args) { return new GraphTraversal().AddOutE(args); } + /// + /// Spawns a and adds the addV step to that traversal. + /// public static GraphTraversal AddV(params object[] args) { return new GraphTraversal().AddV(args); } + /// + /// Spawns a and adds the aggregate step to that traversal. + /// public static GraphTraversal Aggregate(params object[] args) { return new GraphTraversal().Aggregate(args); } + /// + /// Spawns a and adds the and step to that traversal. + /// public static GraphTraversal And(params object[] args) { return new GraphTraversal().And(args); } + /// + /// Spawns a and adds the as step to that traversal. + /// public static GraphTraversal As(params object[] args) { return new GraphTraversal().As(args); } + /// + /// Spawns a and adds the barrier step to that traversal. + /// public static GraphTraversal Barrier(params object[] args) { return new GraphTraversal().Barrier(args); } + /// + /// Spawns a and adds the both step to that traversal. + /// public static GraphTraversal Both(params object[] args) { return new GraphTraversal().Both(args); } + /// + /// Spawns a and adds the bothE step to that traversal. + /// public static GraphTraversal BothE(params object[] args) { return new GraphTraversal().BothE(args); } + /// + /// Spawns a and adds the bothV step to that traversal. + /// public static GraphTraversal BothV(params object[] args) { return new GraphTraversal().BothV(args); } + /// + /// Spawns a and adds the branch step to that traversal. + /// public static GraphTraversal Branch(params object[] args) { return new GraphTraversal().Branch(args); } + /// + /// Spawns a and adds the cap step to that traversal. + /// public static GraphTraversal Cap(params object[] args) { return new GraphTraversal().Cap(args); } + /// + /// Spawns a and adds the choose step to that traversal. + /// public static GraphTraversal Choose(params object[] args) { return new GraphTraversal().Choose(args); } + /// + /// Spawns a and adds the coalesce step to that traversal. + /// public static GraphTraversal Coalesce(params object[] args) { return new GraphTraversal().Coalesce(args); } + /// + /// Spawns a and adds the coin step to that traversal. + /// public static GraphTraversal Coin(params object[] args) { return new GraphTraversal().Coin(args); } + /// + /// Spawns a and adds the constant step to that traversal. + /// public static GraphTraversal Constant(params object[] args) { return new GraphTraversal().Constant(args); } + /// + /// Spawns a and adds the count step to that traversal. + /// public static GraphTraversal Count(params object[] args) { return new GraphTraversal().Count(args); } + /// + /// Spawns a and adds the cyclicPath step to that traversal. + /// public static GraphTraversal CyclicPath(params object[] args) { return new GraphTraversal().CyclicPath(args); } + /// + /// Spawns a and adds the dedup step to that traversal. + /// public static GraphTraversal Dedup(params object[] args) { return new GraphTraversal().Dedup(args); } + /// + /// Spawns a and adds the drop step to that traversal. + /// public static GraphTraversal Drop(params object[] args) { return new GraphTraversal().Drop(args); } + /// + /// Spawns a and adds the emit step to that traversal. + /// public static GraphTraversal Emit(params object[] args) { return new GraphTraversal().Emit(args); } + /// + /// Spawns a and adds the filter step to that traversal. + /// public static GraphTraversal Filter(params object[] args) { return new GraphTraversal().Filter(args); } + /// + /// Spawns a and adds the flatMap step to that traversal. + /// public static GraphTraversal FlatMap(params object[] args) { return new GraphTraversal().FlatMap(args); } + /// + /// Spawns a and adds the fold step to that traversal. + /// public static GraphTraversal Fold(params object[] args) { return new GraphTraversal().Fold(args); } + /// + /// Spawns a and adds the group step to that traversal. + /// public static GraphTraversal Group(params object[] args) { return new GraphTraversal().Group(args); } + /// + /// Spawns a and adds the groupCount step to that traversal. + /// public static GraphTraversal GroupCount(params object[] args) { return new GraphTraversal().GroupCount(args); } + /// + /// Spawns a and adds the groupV3d0 step to that traversal. + /// public static GraphTraversal GroupV3d0(params object[] args) { return new GraphTraversal().GroupV3d0(args); } + /// + /// Spawns a and adds the has step to that traversal. + /// public static GraphTraversal Has(params object[] args) { return new GraphTraversal().Has(args); } + /// + /// Spawns a and adds the hasId step to that traversal. + /// public static GraphTraversal HasId(params object[] args) { return new GraphTraversal().HasId(args); } + /// + /// Spawns a and adds the hasKey step to that traversal. + /// public static GraphTraversal HasKey(params object[] args) { return new GraphTraversal().HasKey(args); } + /// + /// Spawns a and adds the hasLabel step to that traversal. + /// public static GraphTraversal HasLabel(params object[] args) { return new GraphTraversal().HasLabel(args); } + /// + /// Spawns a and adds the hasNot step to that traversal. + /// public static GraphTraversal HasNot(params object[] args) { return new GraphTraversal().HasNot(args); } + /// + /// Spawns a and adds the hasValue step to that traversal. + /// public static GraphTraversal HasValue(params object[] args) { return new GraphTraversal().HasValue(args); } + /// + /// Spawns a and adds the id step to that traversal. + /// public static GraphTraversal Id(params object[] args) { return new GraphTraversal().Id(args); } + /// + /// Spawns a and adds the identity step to that traversal. + /// public static GraphTraversal Identity(params object[] args) { return new GraphTraversal().Identity(args); } + /// + /// Spawns a and adds the in step to that traversal. + /// public static GraphTraversal In(params object[] args) { return new GraphTraversal().In(args); } + /// + /// Spawns a and adds the inE step to that traversal. + /// public static GraphTraversal InE(params object[] args) { return new GraphTraversal().InE(args); } + /// + /// Spawns a and adds the inV step to that traversal. + /// public static GraphTraversal InV(params object[] args) { return new GraphTraversal().InV(args); } + /// + /// Spawns a and adds the inject step to that traversal. + /// public static GraphTraversal Inject(params object[] args) { return new GraphTraversal().Inject(args); } + /// + /// Spawns a and adds the is step to that traversal. + /// public static GraphTraversal Is(params object[] args) { return new GraphTraversal().Is(args); } + /// + /// Spawns a and adds the key step to that traversal. + /// public static GraphTraversal Key(params object[] args) { return new GraphTraversal().Key(args); } + /// + /// Spawns a and adds the label step to that traversal. + /// public static GraphTraversal Label(params object[] args) { return new GraphTraversal().Label(args); } + /// + /// Spawns a and adds the limit step to that traversal. + /// public static GraphTraversal Limit(params object[] args) { return new GraphTraversal().Limit(args); } + /// + /// Spawns a and adds the local step to that traversal. + /// public static GraphTraversal Local(params object[] args) { return new GraphTraversal().Local(args); } + /// + /// Spawns a and adds the loops step to that traversal. + /// public static GraphTraversal Loops(params object[] args) { return new GraphTraversal().Loops(args); } + /// + /// Spawns a and adds the map step to that traversal. + /// public static GraphTraversal Map(params object[] args) { return new GraphTraversal().Map(args); } + /// + /// Spawns a and adds the mapKeys step to that traversal. + /// public static GraphTraversal MapKeys(params object[] args) { return new GraphTraversal().MapKeys(args); } + /// + /// Spawns a and adds the mapValues step to that traversal. + /// public static GraphTraversal MapValues(params object[] args) { return new GraphTraversal().MapValues(args); } + /// + /// Spawns a and adds the match step to that traversal. + /// public static GraphTraversal> Match(params object[] args) { return new GraphTraversal().Match(args); } + /// + /// Spawns a and adds the max step to that traversal. + /// public static GraphTraversal Max(params object[] args) { return new GraphTraversal().Max(args); } + /// + /// Spawns a and adds the mean step to that traversal. + /// public static GraphTraversal Mean(params object[] args) { return new GraphTraversal().Mean(args); } + /// + /// Spawns a and adds the min step to that traversal. + /// public static GraphTraversal Min(params object[] args) { return new GraphTraversal().Min(args); } + /// + /// Spawns a and adds the not step to that traversal. + /// public static GraphTraversal Not(params object[] args) { return new GraphTraversal().Not(args); } + /// + /// Spawns a and adds the optional step to that traversal. + /// public static GraphTraversal Optional(params object[] args) { return new GraphTraversal().Optional(args); } + /// + /// Spawns a and adds the or step to that traversal. + /// public static GraphTraversal Or(params object[] args) { return new GraphTraversal().Or(args); } + /// + /// Spawns a and adds the order step to that traversal. + /// public static GraphTraversal Order(params object[] args) { return new GraphTraversal().Order(args); } + /// + /// Spawns a and adds the otherV step to that traversal. + /// public static GraphTraversal OtherV(params object[] args) { return new GraphTraversal().OtherV(args); } + /// + /// Spawns a and adds the out step to that traversal. + /// public static GraphTraversal Out(params object[] args) { return new GraphTraversal().Out(args); } + /// + /// Spawns a and adds the outE step to that traversal. + /// public static GraphTraversal OutE(params object[] args) { return new GraphTraversal().OutE(args); } + /// + /// Spawns a and adds the outV step to that traversal. + /// public static GraphTraversal OutV(params object[] args) { return new GraphTraversal().OutV(args); } + /// + /// Spawns a and adds the path step to that traversal. + /// public static GraphTraversal Path(params object[] args) { return new GraphTraversal().Path(args); } + /// + /// Spawns a and adds the project step to that traversal. + /// public static GraphTraversal> Project(params object[] args) { return new GraphTraversal().Project(args); } + /// + /// Spawns a and adds the properties step to that traversal. + /// public static GraphTraversal Properties(params object[] args) { return new GraphTraversal().Properties(args); } + /// + /// Spawns a and adds the property step to that traversal. + /// public static GraphTraversal Property(params object[] args) { return new GraphTraversal().Property(args); } + /// + /// Spawns a and adds the propertyMap step to that traversal. + /// public static GraphTraversal> PropertyMap(params object[] args) { return new GraphTraversal().PropertyMap(args); } + /// + /// Spawns a and adds the range step to that traversal. + /// public static GraphTraversal Range(params object[] args) { return new GraphTraversal().Range(args); } + /// + /// Spawns a and adds the repeat step to that traversal. + /// public static GraphTraversal Repeat(params object[] args) { return new GraphTraversal().Repeat(args); } + /// + /// Spawns a and adds the sack step to that traversal. + /// public static GraphTraversal Sack(params object[] args) { return new GraphTraversal().Sack(args); } + /// + /// Spawns a and adds the sample step to that traversal. + /// public static GraphTraversal Sample(params object[] args) { return new GraphTraversal().Sample(args); } + /// + /// Spawns a and adds the select step to that traversal. + /// public static GraphTraversal> Select(params object[] args) { return new GraphTraversal().Select(args); } + /// + /// Spawns a and adds the sideEffect step to that traversal. + /// public static GraphTraversal SideEffect(params object[] args) { return new GraphTraversal().SideEffect(args); } + /// + /// Spawns a and adds the simplePath step to that traversal. + /// public static GraphTraversal SimplePath(params object[] args) { return new GraphTraversal().SimplePath(args); } + /// + /// Spawns a and adds the store step to that traversal. + /// public static GraphTraversal Store(params object[] args) { return new GraphTraversal().Store(args); } + /// + /// Spawns a and adds the subgraph step to that traversal. + /// public static GraphTraversal Subgraph(params object[] args) { return new GraphTraversal().Subgraph(args); } + /// + /// Spawns a and adds the sum step to that traversal. + /// public static GraphTraversal Sum(params object[] args) { return new GraphTraversal().Sum(args); } + /// + /// Spawns a and adds the tail step to that traversal. + /// public static GraphTraversal Tail(params object[] args) { return new GraphTraversal().Tail(args); } + /// + /// Spawns a and adds the timeLimit step to that traversal. + /// public static GraphTraversal TimeLimit(params object[] args) { return new GraphTraversal().TimeLimit(args); } + /// + /// Spawns a and adds the times step to that traversal. + /// public static GraphTraversal Times(params object[] args) { return new GraphTraversal().Times(args); } + /// + /// Spawns a and adds the to step to that traversal. + /// public static GraphTraversal To(params object[] args) { return new GraphTraversal().To(args); } + /// + /// Spawns a and adds the toE step to that traversal. + /// public static GraphTraversal ToE(params object[] args) { return new GraphTraversal().ToE(args); } + /// + /// Spawns a and adds the toV step to that traversal. + /// public static GraphTraversal ToV(params object[] args) { return new GraphTraversal().ToV(args); } + /// + /// Spawns a and adds the tree step to that traversal. + /// public static GraphTraversal Tree(params object[] args) { return new GraphTraversal().Tree(args); } + /// + /// Spawns a and adds the unfold step to that traversal. + /// public static GraphTraversal Unfold(params object[] args) { return new GraphTraversal().Unfold(args); } + /// + /// Spawns a and adds the union step to that traversal. + /// public static GraphTraversal Union(params object[] args) { return new GraphTraversal().Union(args); } + /// + /// Spawns a and adds the until step to that traversal. + /// public static GraphTraversal Until(params object[] args) { return new GraphTraversal().Until(args); } + /// + /// Spawns a and adds the value step to that traversal. + /// public static GraphTraversal Value(params object[] args) { return new GraphTraversal().Value(args); } + /// + /// Spawns a and adds the valueMap step to that traversal. + /// public static GraphTraversal> ValueMap(params object[] args) { return new GraphTraversal().ValueMap(args); } + /// + /// Spawns a and adds the values step to that traversal. + /// public static GraphTraversal Values(params object[] args) { return new GraphTraversal().Values(args); } + /// + /// Spawns a and adds the where step to that traversal. + /// public static GraphTraversal Where(params object[] args) { return new GraphTraversal().Where(args); diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs index 0a077637025..10b2549a328 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Graph.cs @@ -25,8 +25,16 @@ namespace Gremlin.Net.Structure { + /// + /// A is a container object for a collection of , , + /// , and objects. + /// public class Graph { + /// + /// Generates a reusable instance. + /// + /// A graph traversal source. public GraphTraversalSource Traversal() { return new GraphTraversalSource(); From 73690217a04d6aa4fdb31e48ea209c626c229c80 Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Thu, 15 Jun 2017 18:25:56 +0200 Subject: [PATCH 15/28] Clean-up Gremlin-DotNet project files This removes some obsolete configuration options and improves the package meta information. Especially the description was extended to reflect the current state of Gremlin-DotNet. This explanation can be removed as soon as the old Gremlin.Net driver is obsolete (probably when a first release version of Gremlin-DotNet is released). The version is now 3.2.5-beta1. --- .../src/Gremlin.Net/Gremlin.Net.csproj | 44 +++++++------------ .../Gremlin.Net/Properties/AssemblyInfo.cs | 44 ------------------- .../Gremlin.Net.IntegrationTest.csproj | 4 -- .../Properties/AssemblyInfo.cs | 44 ------------------- .../Gremlin.Net.UnitTest.csproj | 6 --- .../Properties/AssemblyInfo.cs | 44 ------------------- 6 files changed, 17 insertions(+), 169 deletions(-) delete mode 100644 gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs delete mode 100644 gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs delete mode 100644 gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index a1fc9ef7d7b..124bb963a6a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -1,41 +1,31 @@  - - - Gremlin.Net is a cross-platform Gremlin Server driver for .NET that is written in C#. It uses WebSockets to communicate with Gremlin Server. - Gremlin.Net - Apache TinkerPop + + netstandard1.3 - 3.2.5-SNAPSHOT - Gremlin.Net + true + + + + 3.2.5-beta1 + Gremlin-DotNet + Apache TinkerPop + + Apache TinkerPop’s Gremlin-DotNet implements Gremlin within the C# language. + +Gremlin-DotNet is an extended version of the Gremlin.Net driver (versions <= 0.X). It includes an implementation of Gremlin in C#. This extended version is now part of the Apache TinkerPop project. +The 'old' Gremlin.Net driver is however still supported. Head to https://github.com/FlorianHockmann/Gremlin.Net for more information. + Gremlin.Net - gremlin-dotnet;gremlin;tinkerpop;tinkerpop3 + gremlin;tinkerpop;tinkerpop3 http://tinkerpop.apache.org https://github.com/apache/tinkerpop/blob/master/LICENSE https://github.com/apache/tinkerpop - false - false - false - False - - - - - - - - - - - - - - + - diff --git a/gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs b/gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs deleted file mode 100644 index 433db198c4a..00000000000 --- a/gremlin-dotnet/src/Gremlin.Net/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,44 +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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Gremlin.Net")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("6c1dd34d-e30f-4e37-aacc-beb8ad2320d8")] \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj index c5f29da98bc..fed1c49ce14 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj @@ -5,11 +5,7 @@ portable Gremlin.Net.IntegrationTest Gremlin.Net.IntegrationTest - true 1.0.4 - false - false - false diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 5dea6f08894..00000000000 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,44 +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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Gremlin.Net.IntegrationTest")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("cc54abe3-13d2-491c-81e2-4d0355abfa93")] \ No newline at end of file diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj index 6cf88ac9396..db36085da50 100644 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj @@ -5,11 +5,7 @@ portable Gremlin.Net.UnitTest Gremlin.Net.UnitTest - true 1.0.4 - false - false - false @@ -19,8 +15,6 @@ - - diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs deleted file mode 100644 index f339aa098d5..00000000000 --- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,44 +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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Gremlin.Net.UnitTest")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("1fab781b-b857-4ad2-bec8-e20c214d9e21")] \ No newline at end of file From 8468f4211a16674decac2ad7fe15a3a3985a9b9f Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Thu, 15 Jun 2017 19:00:38 +0200 Subject: [PATCH 16/28] Let Gremlin-DotNet include the documentation comments Every build now generates an XML document containing the documentation comments which will be displayed to the user with IntelliSense. The warning about missing comments had to be disabled for some files as we currently just don't have comments for those. --- gremlin-dotnet/glv/AnonymousTraversal.template | 4 ++++ gremlin-dotnet/glv/Enum.template | 4 ++++ gremlin-dotnet/glv/GraphTraversal.template | 4 ++++ gremlin-dotnet/glv/GraphTraversalSource.template | 4 ++++ gremlin-dotnet/glv/P.template | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj | 1 + gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs | 4 ++++ .../src/Gremlin.Net/Process/Traversal/Cardinality.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs | 4 ++++ .../src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs | 4 ++++ .../src/Gremlin.Net/Process/Traversal/GraphTraversal.cs | 4 ++++ .../src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs | 4 ++++ .../src/Gremlin.Net/Process/Traversal/GryoVersion.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs | 4 ++++ .../Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs | 2 ++ .../Traversal/Strategy/Decoration/VertexProgramStrategy.cs | 2 ++ .../Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs | 2 ++ .../Traversal/Strategy/Optimization/GraphFilterStrategy.cs | 2 ++ .../Traversal/Strategy/Optimization/OrderLimitStrategy.cs | 2 ++ .../Traversal/Strategy/Optimization/PathRetractionStrategy.cs | 2 ++ .../Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs | 2 ++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs | 4 ++++ gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs | 4 ++++ 29 files changed, 99 insertions(+) diff --git a/gremlin-dotnet/glv/AnonymousTraversal.template b/gremlin-dotnet/glv/AnonymousTraversal.template index 9bc72576b33..216b6d4502f 100644 --- a/gremlin-dotnet/glv/AnonymousTraversal.template +++ b/gremlin-dotnet/glv/AnonymousTraversal.template @@ -27,6 +27,8 @@ 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 + /// /// An anonymous . /// @@ -48,5 +50,7 @@ namespace Gremlin.Net.Process.Traversal return new GraphTraversal().<%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(args); } <% } %> + +#pragma warning restore 1591 } } \ No newline at end of file diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template index 25537f4720b..1fddab109db 100644 --- a/gremlin-dotnet/glv/Enum.template +++ b/gremlin-dotnet/glv/Enum.template @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum <%= enumClass.simpleName %> { <%= constants %> } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversal.template b/gremlin-dotnet/glv/GraphTraversal.template index d514e163ca9..ab96a17f35e 100644 --- a/gremlin-dotnet/glv/GraphTraversal.template +++ b/gremlin-dotnet/glv/GraphTraversal.template @@ -27,6 +27,8 @@ 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 + /// /// Graph traversals are the primary way in which graphs are processed. /// @@ -73,4 +75,6 @@ namespace Gremlin.Net.Process.Traversal <% } %> } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversalSource.template b/gremlin-dotnet/glv/GraphTraversalSource.template index 7a945f8604e..0d98433101a 100644 --- a/gremlin-dotnet/glv/GraphTraversalSource.template +++ b/gremlin-dotnet/glv/GraphTraversalSource.template @@ -30,6 +30,8 @@ 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 + /// /// A is the primary DSL of the Gremlin traversal machine. /// It provides access to all the configurations and steps for Turing complete graph computing. @@ -125,4 +127,6 @@ namespace Gremlin.Net.Process.Traversal } <% } %> } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template index 6a62414840d..f187cbb27b0 100644 --- a/gremlin-dotnet/glv/P.template +++ b/gremlin-dotnet/glv/P.template @@ -24,6 +24,8 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + /// /// A is a predicate of the form Func<object, bool>. /// That is, given some object, return true or false. @@ -38,4 +40,6 @@ namespace Gremlin.Net.Process.Traversal } <% } %> } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index 124bb963a6a..93f135c3288 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -3,6 +3,7 @@ netstandard1.3 true + true diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs index aa4040a747f..555d372589d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Barrier { NormSack } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs index 029638087ea..c31a142654b 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Cardinality { List,Set,Single } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index 15e248c3756..adcf738cef2 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Column { Keys,Values } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs index 27d393494b5..d3792633ac4 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Direction { Both,In,Out } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs index cc66fba0644..6869ba5a4dd 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum GraphSONVersion { V1_0,V2_0 } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 34f5bfb6aa1..4390c795c28 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -27,6 +27,8 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + /// /// Graph traversals are the primary way in which graphs are processed. /// @@ -946,4 +948,6 @@ public GraphTraversal< S , E > Where (params object[] args) } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs index 317afadc15a..e0cd25ae7ff 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -30,6 +30,8 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + /// /// A is the primary DSL of the Gremlin traversal machine. /// It provides access to all the configurations and steps for Turing complete graph computing. @@ -187,4 +189,6 @@ public GraphTraversal< Vertex,Vertex > AddV(params object[] args) } } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs index 76a263dee76..5ee735882be 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum GryoVersion { V1_0 } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index d98d9bab890..1ebc581433e 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Operator { AddAll,And,Assign,Div,Max,Min,Minus,Mult,Or,Sum,SumLong } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index 2e0c4ea60fa..0fdbbf9b04e 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Order { Decr,Incr,KeyDecr,KeyIncr,Shuffle,ValueDecr,ValueIncr } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs index e0174023415..89bdc29fe7c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs @@ -24,6 +24,8 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + /// /// A is a predicate of the form Func<object, bool>. /// That is, given some object, return true or false. @@ -110,4 +112,6 @@ public static TraversalPredicate Without(params object[] args) } } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs index 2231cdaf125..1f8c2d91263 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Pick { Any,None } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs index 01c6e1a616b..f0975d224e1 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Pop { All,First,Last } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs index e443252786c..67fa9707e8d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum Scope { Global,Local } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs index 98f949cda00..688ef92a1be 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs @@ -23,6 +23,7 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Decoration { +#pragma warning disable 1591 public class HaltedTraverserStrategy : AbstractTraversalStrategy { public HaltedTraverserStrategy(string haltedTraverserFactoryName = null) @@ -31,4 +32,5 @@ public HaltedTraverserStrategy(string haltedTraverserFactoryName = null) Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName; } } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs index 1c5b5f2cf27..61df1c1bee2 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs @@ -26,6 +26,7 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Decoration { +#pragma warning disable 1591 public class VertexProgramStrategy : AbstractTraversalStrategy { public VertexProgramStrategy(string graphComputer = null, int? workers = null, string persist = null, @@ -47,4 +48,5 @@ public VertexProgramStrategy(string graphComputer = null, int? workers = null, s configuration?.ToList().ForEach(x => Configuration[x.Key] = x.Value); } } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs index 11a9e2c52b6..d066c8a4319 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs @@ -23,6 +23,7 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Finalization { +#pragma warning disable 1591 public class MatchAlgorithmStrategy : AbstractTraversalStrategy { public MatchAlgorithmStrategy(string matchAlgorithm = null) @@ -31,4 +32,5 @@ public MatchAlgorithmStrategy(string matchAlgorithm = null) Configuration["matchAlgorithm"] = matchAlgorithm; } } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs index aaaee2c617e..7d29b0d719c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/GraphFilterStrategy.cs @@ -23,7 +23,9 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Optimization { +#pragma warning disable 1591 public class GraphFilterStrategy : AbstractTraversalStrategy { } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs index 82a8df9e8a4..c8b4ec4bcac 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/OrderLimitStrategy.cs @@ -23,7 +23,9 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Optimization { +#pragma warning disable 1591 public class OrderLimitStrategy : AbstractTraversalStrategy { } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs index e54fbb5a978..03978e7efdb 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/PathRetractionStrategy.cs @@ -23,7 +23,9 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Optimization { +#pragma warning disable 1591 public class PathRetractionStrategy : AbstractTraversalStrategy { } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs index 6cac454dd36..b9e3fc2802e 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Optimization/RepeatUnrollStrategy.cs @@ -23,7 +23,9 @@ namespace Gremlin.Net.Process.Traversal.Strategy.Optimization { +#pragma warning disable 1591 public class RepeatUnrollStrategy : AbstractTraversalStrategy { } +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index f914916b33d..b580aabeaab 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -24,8 +24,12 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + public enum T { Id,Key,Label,Value } + +#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index fd7a901bb72..0574d244371 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -27,6 +27,8 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { +#pragma warning disable 1591 + /// /// An anonymous . /// @@ -768,5 +770,7 @@ public static GraphTraversal Where(params object[] args) return new GraphTraversal().Where(args); } + +#pragma warning restore 1591 } } \ No newline at end of file From 3c0abd00ef1182b38db11f826b51b2d62a98d3ff Mon Sep 17 00:00:00 2001 From: Florian Hockmann Date: Fri, 16 Jun 2017 16:49:12 +0200 Subject: [PATCH 17/28] Re-enable warnings where they were disabled unnecessarily --- gremlin-dotnet/glv/AnonymousTraversal.template | 4 ---- gremlin-dotnet/glv/GraphTraversal.template | 5 ----- .../src/Gremlin.Net/Process/Traversal/GraphTraversal.cs | 5 ----- gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs | 4 ---- 4 files changed, 18 deletions(-) diff --git a/gremlin-dotnet/glv/AnonymousTraversal.template b/gremlin-dotnet/glv/AnonymousTraversal.template index 216b6d4502f..9bc72576b33 100644 --- a/gremlin-dotnet/glv/AnonymousTraversal.template +++ b/gremlin-dotnet/glv/AnonymousTraversal.template @@ -27,8 +27,6 @@ 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 - /// /// An anonymous . /// @@ -50,7 +48,5 @@ namespace Gremlin.Net.Process.Traversal return new GraphTraversal().<%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(args); } <% } %> - -#pragma warning restore 1591 } } \ No newline at end of file diff --git a/gremlin-dotnet/glv/GraphTraversal.template b/gremlin-dotnet/glv/GraphTraversal.template index ab96a17f35e..5c3e03e34be 100644 --- a/gremlin-dotnet/glv/GraphTraversal.template +++ b/gremlin-dotnet/glv/GraphTraversal.template @@ -27,8 +27,6 @@ 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 - /// /// Graph traversals are the primary way in which graphs are processed. /// @@ -73,8 +71,5 @@ namespace Gremlin.Net.Process.Traversal return Wrap< <%= method.t1 %> , <%= method.t2 %> >(this); } <% } %> - } - -#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index 4390c795c28..24938649090 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -27,8 +27,6 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { -#pragma warning disable 1591 - /// /// Graph traversals are the primary way in which graphs are processed. /// @@ -946,8 +944,5 @@ public GraphTraversal< S , E > Where (params object[] args) return Wrap< S , E >(this); } - } - -#pragma warning restore 1591 } \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index 0574d244371..fd7a901bb72 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -27,8 +27,6 @@ // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml namespace Gremlin.Net.Process.Traversal { -#pragma warning disable 1591 - /// /// An anonymous . /// @@ -770,7 +768,5 @@ public static GraphTraversal Where(params object[] args) return new GraphTraversal().Where(args); } - -#pragma warning restore 1591 } } \ No newline at end of file From a02c78b2fce3d6871c5390d8a379f1f0efedc2fe Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 21 Jun 2017 09:12:17 -0400 Subject: [PATCH 18/28] TINKERPOP-1552 Minor change to dev docs as project structure changed --- docs/src/dev/developer/development-environment.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc index 2e48b8711b8..ddba0a0a303 100644 --- a/docs/src/dev/developer/development-environment.asciidoc +++ b/docs/src/dev/developer/development-environment.asciidoc @@ -109,7 +109,7 @@ The build optionally requires link:https://www.microsoft.com/net/core[.NET Core `gremlin-dotnet` module. If .NET Core SDK is not installed, TinkerPop will still build with Maven, but .NET projects will be skipped. -`gremlin-dotnet` which also includes Gremlin-Csharp can be build and tested from the command line with: +`gremlin-dotnet` can be build and tested from the command line with: [source,text] mvn clean install -Pgremlin-dotnet From 227448287c911d596ddc7a2b5929c1c6d8d243a8 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Fri, 23 Jun 2017 13:07:45 -0400 Subject: [PATCH 19/28] TINKERPOP-1552 Bump to 3.2.6 in gremlin-dotnet --- gremlin-dotnet/pom.xml | 2 +- gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj | 2 +- gremlin-dotnet/src/pom.xml | 2 +- gremlin-dotnet/test/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 4bdf1e39746..3360bbc3d45 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -21,7 +21,7 @@ limitations under the License. org.apache.tinkerpop tinkerpop - 3.2.5-SNAPSHOT + 3.2.6-SNAPSHOT gremlin-dotnet Apache TinkerPop :: Gremlin-DotNet diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index 93f135c3288..0ff4537dc79 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -7,7 +7,7 @@ - 3.2.5-beta1 + 3.2.6-beta1 Gremlin-DotNet Apache TinkerPop diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index dd43b1f628e..50d4d56f80b 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -21,7 +21,7 @@ limitations under the License. org.apache.tinkerpop gremlin-dotnet - 3.2.5-SNAPSHOT + 3.2.6-SNAPSHOT gremlin-dotnet-source Apache TinkerPop :: Gremlin-DotNet - Source diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index 8cdffa9ec97..2cf2785ffcd 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -21,7 +21,7 @@ limitations under the License. org.apache.tinkerpop gremlin-dotnet - 3.2.5-SNAPSHOT + 3.2.6-SNAPSHOT gremlin-dotnet-tests Apache TinkerPop :: Gremlin-DotNet - Tests From 703e6f2461f176319227e2244c4cd9be2155bafe Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Fri, 23 Jun 2017 15:43:40 -0400 Subject: [PATCH 20/28] TINKERPOP-1552 Added basic deployment options for nuget Can't use the dotnet maven plugin on linux. it makes direct calls to nuget, which on linux requires mono. Used antrun plugin instead which is what was used with gremlin-python and works fine. Accomplished a basic push to the nuget staging environment. Still some bumps to sort out before this is good. --- .../development-environment.asciidoc | 6 +- docs/src/dev/developer/release.asciidoc | 1 + gremlin-dotnet/pom.xml | 10 +++ .../src/Gremlin.Net/Gremlin.Net.csproj | 25 ++++-- gremlin-dotnet/src/pom.xml | 86 ++++++++++++++++++- gremlin-dotnet/test/pom.xml | 10 +++ 6 files changed, 130 insertions(+), 8 deletions(-) diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc index ddba0a0a303..f56bcaef953 100644 --- a/docs/src/dev/developer/development-environment.asciidoc +++ b/docs/src/dev/developer/development-environment.asciidoc @@ -117,7 +117,11 @@ mvn clean install -Pgremlin-dotnet which enables the "gremlin-dotnet" Maven profile or in a more automated fashion simply add a `.glv` file to the `src` and `test` directories of the `gremlin-dotnet` module  which will signify to Maven that the environment is .NET-ready. The `.glv` file need not have any contents and is ignored by Git. A standard `mvn clean install` will then build -`gremlin-dotnet` in full. +`gremlin-dotnet` in full. + +For those who will release TinkerPop, it is also necessary to install link:http://www.mono-project.com/[Mono]. The +release process is known to work with 5.0.1, so it is best to probably install that version if possible. See release +documentation for more information on configuration for release. [[release-environment]] Release Environment diff --git a/docs/src/dev/developer/release.asciidoc b/docs/src/dev/developer/release.asciidoc index 121bbb6faef..48e11327bbf 100644 --- a/docs/src/dev/developer/release.asciidoc +++ b/docs/src/dev/developer/release.asciidoc @@ -220,6 +220,7 @@ Release & Promote .. This build will likely occur from the tag for the release, so be sure to checkout the tag first before executing this step. .. `mvn clean install -DskipTests` .. `mvn deploy -pl gremlin-python -DskipTests -Dpypi` +.. `mvn deploy -pl :gremlin-dotnet-source -DskipTests -Dnuget` . `svn co --depth empty https://dist.apache.org/repos/dist/dev/tinkerpop dev; svn up dev/xx.yy.zz` . `svn co --depth empty https://dist.apache.org/repos/dist/release/tinkerpop release; mkdir release/xx.yy.zz` . Copy release files from `dev/xx.yy.zz` to `release/xx.yy.zz`. diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 3360bbc3d45..6cd7da3b270 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -267,6 +267,16 @@ namingConversionsFile.newWriter().withWriter{ it << namingConversionsTemplate } + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + \ No newline at end of file diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index 0ff4537dc79..7ac6f8de05d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -8,16 +8,29 @@ 3.2.6-beta1 - Gremlin-DotNet + Gremlin.Net Apache TinkerPop - Apache TinkerPop’s Gremlin-DotNet implements Gremlin within the C# language. - -Gremlin-DotNet is an extended version of the Gremlin.Net driver (versions <= 0.X). It includes an implementation of Gremlin in C#. This extended version is now part of the Apache TinkerPop project. -The 'old' Gremlin.Net driver is however still supported. Head to https://github.com/FlorianHockmann/Gremlin.Net for more information. + 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-DotNet. Moreover, there are a few added constructs to Gremlin-DotNet that make traversals a bit more succinct. + + Please see the reference documentation at Apache TinkerPop for more information on usage. + + NOTE: Gremlin.Net is an extension of the Gremlin.Net driver by Florian Hockmann (versions <= 0.X) and is now + included as part of the Apache TinkerPop project. The 'old' Gremlin.Net driver is however still supported. + Head to https://github.com/FlorianHockmann/Gremlin.Net for more information. + Gremlin.Net - gremlin;tinkerpop;tinkerpop3 + gremlin;tinkerpop;apache http://tinkerpop.apache.org https://github.com/apache/tinkerpop/blob/master/LICENSE https://github.com/apache/tinkerpop diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 50d4d56f80b..645921f7461 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -40,6 +40,16 @@ limitations under the License. + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + @@ -74,11 +84,85 @@ limitations under the License. dotnet-maven-plugin true - ${project.parent.basedir}/target/nuget + true + false + false + + + glv-dotnet-deploy + + false + + nuget + + + + dotnet-library + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + deploy-nuget + deploy + + run + + + + + + + + nuget.exe already downloaded and at Gremlin.Net/bin/nuget.exe. + + + + + + + + + + + + + + + + + + + ant-contrib + ant-contrib + 20020829 + + + + + + \ No newline at end of file diff --git a/gremlin-dotnet/test/pom.xml b/gremlin-dotnet/test/pom.xml index 2cf2785ffcd..7fa75fa1ee8 100644 --- a/gremlin-dotnet/test/pom.xml +++ b/gremlin-dotnet/test/pom.xml @@ -47,6 +47,16 @@ limitations under the License. + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + From 25fd472e0af744c979a681d62d4413b12e44bec7 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Fri, 23 Jun 2017 16:05:35 -0400 Subject: [PATCH 21/28] TINKERPOP-1552 More consistent use of Gremlin.Net --- gremlin-dotnet/pom.xml | 2 +- gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj | 2 +- gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs | 2 +- gremlin-dotnet/src/pom.xml | 4 ++-- gremlin-dotnet/test/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 6cd7da3b270..58ac2d6beab 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -24,7 +24,7 @@ limitations under the License. 3.2.6-SNAPSHOT gremlin-dotnet - Apache TinkerPop :: Gremlin-DotNet + Apache TinkerPop :: Gremlin.Net pom diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index 7ac6f8de05d..361ce9e1c6a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -21,7 +21,7 @@ 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-DotNet. Moreover, there are a few added constructs to Gremlin-DotNet that make traversals a bit more succinct. + Gremlin.Net. Moreover, there are a few added constructs to Gremlin.Net that make traversals a bit more succinct. Please see the reference documentation at Apache TinkerPop for more information on usage. diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs index 693d3318669..b76f39545be 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs @@ -31,7 +31,7 @@ namespace Gremlin.Net.Process.Traversal /// /// Bytecode is simply a list of ordered instructions. /// Bytecode can be serialized between environments and machines by way of a GraphSON representation. - /// Thus, Gremlin-DotNet can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java. + /// Thus, Gremlin.Net can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java. /// public class Bytecode { diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 645921f7461..8f9007efca9 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -24,7 +24,7 @@ limitations under the License. 3.2.6-SNAPSHOT gremlin-dotnet-source - Apache TinkerPop :: Gremlin-DotNet - Source + Apache TinkerPop :: Gremlin.Net - Source ${packaging.type} @@ -93,7 +93,7 @@ limitations under the License. From 6457bb95581d937ff8b2e6404bbd3ad961f88e8b Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 28 Jun 2017 11:45:17 -0400 Subject: [PATCH 22/28] TINKERPOP-1552 Polish up nuget deploy to work with NuGet.Config --- .gitignore | 2 ++ .../developer/development-environment.asciidoc | 17 +++++++++++++++-- gremlin-dotnet/src/pom.xml | 7 ++++++- pom.xml | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fe469b048ea..0109f8214ca 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ tools/ .vscode/ .vs/ *nupkg +NuGet.Config +nuget.exe diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc index f56bcaef953..240d901e13c 100644 --- a/docs/src/dev/developer/development-environment.asciidoc +++ b/docs/src/dev/developer/development-environment.asciidoc @@ -120,8 +120,21 @@ The `.glv` file need not have any contents and is ignored by Git. A standard  `gremlin-dotnet` in full. For those who will release TinkerPop, it is also necessary to install link:http://www.mono-project.com/[Mono]. The -release process is known to work with 5.0.1, so it is best to probably install that version if possible. See release -documentation for more information on configuration for release. +release process is known to work with 5.0.1, so it is best to probably install that version. Release managers should +probably also do an install of link:https://dist.nuget.org/win-x86-commandline/v3.4.4/nuget.exe[nuget 3.4.4] as it +will help with environmental setup. To get an environment ready to deploy to NuGet, it is necessary to have a +NuGet API key (PMC members who have NuGet accounts can help with that). The API key should be added to `NuGet.Config` +with the following: + +[source,text] +---- +mono nuget.exe setApiKey [your-api-key] +---- + +This should update `~/.config/NuGet/NuGet.Config` a file with an entry containing the encrypted API key. On +`mvn deploy`, this file will be referenced on the automated `nuget push`. + +See release documentation for more information on configuration for release. [[release-environment]] Release Environment diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 8f9007efca9..86a56afbe14 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -146,8 +146,13 @@ limitations under the License. + + - + diff --git a/pom.xml b/pom.xml index 36d8d320c2d..327a0dbec6c 100644 --- a/pom.xml +++ b/pom.xml @@ -319,6 +319,7 @@ limitations under the License. **/*.user **/*.csproj **/.vs/** + **/NuGet.Config From 6135a00208a55b8317085531291c9ef98e481ce2 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 28 Jun 2017 12:42:09 -0400 Subject: [PATCH 23/28] TINKERPOP-1552 Make csproj version match maven pom versions --- .../src/Gremlin.Net/Gremlin.Net.csproj | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj index 361ce9e1c6a..30e15a74e6d 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj +++ b/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj @@ -1,4 +1,22 @@ - + + + + netstandard1.3 @@ -7,7 +25,7 @@ - 3.2.6-beta1 + 3.2.6-SNAPSHOT Gremlin.Net Apache TinkerPop From 554595f2e4adf60de1c890b090490c5aa62997b3 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 28 Jun 2017 13:22:08 -0400 Subject: [PATCH 24/28] TINKERPOP-1552 Nuget publishing of SNAPSHOTs working now. It's a bit hokey, but it works. There are some problems in the toolchain that makes this less nice that the gremlin-python setup. I almost wonder if we shouldn't copy the whole gremlin-dot-net source to target and operate on it in isolation so that we dont' have to muck with the source controlled csproj file. I suppose what I have here will work for now. As long as the documentation I wrote is followed I don't see any problems popping up, but we'll see. --- docs/src/dev/developer/release.asciidoc | 17 ++++- .../glv/Gremlin.Net.csproj.template | 64 +++++++++++++++++++ gremlin-dotnet/pom.xml | 14 ++++ gremlin-dotnet/src/pom.xml | 48 +++++++++++++- 4 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 gremlin-dotnet/glv/Gremlin.Net.csproj.template diff --git a/docs/src/dev/developer/release.asciidoc b/docs/src/dev/developer/release.asciidoc index 48e11327bbf..22a1f015ae8 100644 --- a/docs/src/dev/developer/release.asciidoc +++ b/docs/src/dev/developer/release.asciidoc @@ -60,7 +60,7 @@ development artifacts must be generated and deployed separately with additional mvn clean install -Pglv-python mvn deploy -pl gremlin-python -Dpypi -Python does not use the snapshot model that the JVM does, however, the build is smart in that it will dynamically +Python does not use the snapshot model the JVM does, however, the build is smart in that it will dynamically generate a development version number for the Python artifacts when "-SNAPSHOT" is in the `pom.xml`. The previous command will push the development version to link:https://pypi.python.org/pypi/gremlinpython/[pypi] for distribution. Use the `testpypi` test environment by updating the `gremlin-python/pom.xml` to verify the `mvn deploy` command works. @@ -69,6 +69,19 @@ IMPORTANT: The `clean` in the above commands is more important to the pypi deplo anything found in the `target/python-packaged/dist` directory. Since the names of the artifacts are based on timestamps, they will not overwrite one another and multiple artifacts will get uploaded. +For .NET and NuGet, development artifacts can be created as follows: + +[source,text] +mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-source -Dnuget +mvn deploy -pl :gremlin-dotnet-source -Dnuget + +As with PyPi, NuGet does not support a snapshot model as Java does. The commands above will dynamically generate a +version number when "-SNAPSHOT" is in the `pom.xml`. Use the `staging.nuget.org` environment by updating the +`gremlin-dot-source/pom.xml` to ensure the `mvn deploy` command works. + +IMPORTANT: These commands will dynamically edit the `gremlin-dotnet-source/Gremlin.Net.csproj`. Take care to commit +or not commit changes related to that as necessary. + Release Manager Requirements ---------------------------- @@ -218,7 +231,7 @@ Release & Promote . Login to link:https://repository.apache.org/[Apache Nexus] and release the previously closed repository. . Deploy to link:https://pypi.python.org/pypi[pypi] .. This build will likely occur from the tag for the release, so be sure to checkout the tag first before executing this step. -.. `mvn clean install -DskipTests` +.. `mvn clean install -DskipTests -Dnuget` .. `mvn deploy -pl gremlin-python -DskipTests -Dpypi` .. `mvn deploy -pl :gremlin-dotnet-source -DskipTests -Dnuget` . `svn co --depth empty https://dist.apache.org/repos/dist/dev/tinkerpop dev; svn up dev/xx.yy.zz` diff --git a/gremlin-dotnet/glv/Gremlin.Net.csproj.template b/gremlin-dotnet/glv/Gremlin.Net.csproj.template new file mode 100644 index 00000000000..b55eecb67c2 --- /dev/null +++ b/gremlin-dotnet/glv/Gremlin.Net.csproj.template @@ -0,0 +1,64 @@ + + + + + + + netstandard1.3 + true + true + + + + ${projectVersion} + Gremlin.Net + Apache TinkerPop + + 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. + + Please see the reference documentation at Apache TinkerPop for more information on usage. + + NOTE: Gremlin.Net is an extension of the Gremlin.Net driver by Florian Hockmann (versions <= 0.X) and is now + included as part of the Apache TinkerPop project. The 'old' Gremlin.Net driver is however still supported. + Head to https://github.com/FlorianHockmann/Gremlin.Net for more information. + + Gremlin.Net + gremlin;tinkerpop;apache + http://tinkerpop.apache.org + https://github.com/apache/tinkerpop/blob/master/LICENSE + https://github.com/apache/tinkerpop + + + + + + + + + + diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 58ac2d6beab..20db3d8ebb1 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -260,6 +260,20 @@ def namingConversionsTemplate = engine.createTemplate(new File('${project.basedi def namingConversionsFile = new File('${project.basedir}/src/Gremlin.Net/Process/Traversal/NamingConversions.cs') namingConversionsFile.newWriter().withWriter{ it << namingConversionsTemplate } +def determineVersion = { + def env = System.getenv() + def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("DOTNET_RELEASE_VERSION") : '${project.version}' + + // 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('${project.basedir}/glv/Gremlin.Net.csproj.template')).make(["projectVersion":versionToUse]) +def csprojFile = new File('${project.basedir}/src/Gremlin.Net/Gremlin.Net.csproj') +csprojFile.newWriter().withWriter{ it << csprojTemplate } ]]> diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml index 86a56afbe14..d19170d2e0c 100644 --- a/gremlin-dotnet/src/pom.xml +++ b/gremlin-dotnet/src/pom.xml @@ -152,7 +152,7 @@ limitations under the License. the "ConfigFile" option to nuget. --> - + @@ -166,6 +166,52 @@ limitations under the License. + + org.codehaus.gmavenplus + gmavenplus-plugin + + + org.apache.tinkerpop + gremlin-core + ${project.version} + runtime + + + org.codehaus.groovy + groovy-all + ${groovy.version} + runtime + + + log4j + log4j + 1.2.17 + runtime + + + + + generate-dsl + deploy + + execute + + + + + + + + + From eebc95d49d6bab9cdd9e51dfbb1317dfe1a3b72e Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 29 Jun 2017 07:03:03 -0400 Subject: [PATCH 25/28] TINKERPOP-1552 Updated changelog --- CHANGELOG.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index b438248903a..1c14ca6e905 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -28,6 +28,7 @@ TinkerPop 3.2.6 (Release Date: NOT OFFICIALLY RELEASED YET) This release also includes changes from <>. +* Added Gremlin.Net. * Deprecated the `useMapperFromGraph` configuration option for Gremlin Server serializers. * Added annotations to the traversal metrics pretty print. * `EdgeVertexStep` is no longer final and can be extended by providers. From 79e37fb912ee7a8c15cddfedad57b961198c8963 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 29 Jun 2017 07:08:24 -0400 Subject: [PATCH 26/28] TINKERPOP-1552 Added a warning to docs about Gremlin.Net --- docs/src/reference/gremlin-variants.asciidoc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc index 763ab4aa179..7f4441e4eb8 100644 --- a/docs/src/reference/gremlin-variants.asciidoc +++ b/docs/src/reference/gremlin-variants.asciidoc @@ -357,8 +357,12 @@ connection = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g', ---- [[gremlin-DotNet]] -Gremlin-DotNet --------------- +Gremlin.Net +----------- + +WARNING: Gremlin.Net does not yet have an official release. It is for developers who want to experiment with TinkerPop +in the .NET ecosystem. + Apache TinkerPop's Gremlin-DotNet implements Gremlin within the C# language. It targets .NET Standard and can therefore be used on different operating systems and with different .NET frameworks, such as .NET Framework and link:https://www.microsoft.com/net/core[.NET Core]. Since the C# syntax is very similar to that of Java, it should be very easy to switch between From cc522be287fc70eecc5dbcfadefaf30d98d1c659 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 5 Jul 2017 11:51:01 -0400 Subject: [PATCH 27/28] TINKERPOP-1552 Bumped to dotnet-dev-1.0.4 --- .travis.yml | 2 +- docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31a98a539e4..f0c88db6df5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_install: - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 - sudo apt-get update - - sudo apt-get install dotnet-dev-1.0.1 + - sudo apt-get install dotnet-dev-1.0.4 script: - "mvn clean install -Dci" #notifications: diff --git a/docker/Dockerfile b/docker/Dockerfile index 932536c77b1..3e7ca42ccb2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -26,7 +26,7 @@ RUN apt-get update \ && sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' \ && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 \ && apt-get update \ - && apt-get install -y oracle-java8-installer curl gawk git maven openssh-server dotnet-dev-1.0.1 \ + && apt-get install -y oracle-java8-installer curl gawk git maven openssh-server dotnet-dev-1.0.4 \ && rm -rf /var/lib/apt/lists/* /var/cache/oracle-jdk8-installer RUN sed -i 's@PermitRootLogin without-password@PermitRootLogin yes@' /etc/ssh/sshd_config From 426d141fda6f70f11e806b857111bb6d8c8e41a0 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 5 Jul 2017 12:09:52 -0400 Subject: [PATCH 28/28] TINKERPOP-1552 Put enums on separate lines for Gremlin.Net --- gremlin-dotnet/pom.xml | 2 +- .../src/Gremlin.Net/Process/Traversal/Cardinality.cs | 4 +++- .../src/Gremlin.Net/Process/Traversal/Column.cs | 3 ++- .../src/Gremlin.Net/Process/Traversal/Direction.cs | 4 +++- .../Gremlin.Net/Process/Traversal/GraphSONVersion.cs | 3 ++- .../src/Gremlin.Net/Process/Traversal/Operator.cs | 12 +++++++++++- .../src/Gremlin.Net/Process/Traversal/Order.cs | 8 +++++++- .../src/Gremlin.Net/Process/Traversal/Pick.cs | 3 ++- .../src/Gremlin.Net/Process/Traversal/Pop.cs | 4 +++- .../src/Gremlin.Net/Process/Traversal/Scope.cs | 3 ++- .../src/Gremlin.Net/Process/Traversal/T.cs | 5 ++++- 11 files changed, 40 insertions(+), 11 deletions(-) diff --git a/gremlin-dotnet/pom.xml b/gremlin-dotnet/pom.xml index 20db3d8ebb1..aba4315c153 100644 --- a/gremlin-dotnet/pom.xml +++ b/gremlin-dotnet/pom.xml @@ -237,7 +237,7 @@ def createEnum = { enumClass, csharpToJava -> def csharpName = toCSharpName(enumClass, value.name()) csharpToJava.put(enumClass.simpleName + "." + csharpName, value.name()) return csharpName - }.join(",")] + }.join(",\n\t\t")] def enumTemplate = engine.createTemplate(new File('${project.basedir}/glv/Enum.template')).make(b) def enumFile = new File('${project.basedir}/src/Gremlin.Net/Process/Traversal/' + enumClass.getSimpleName() + '.cs') diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs index c31a142654b..5a07258cd97 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -28,7 +28,9 @@ namespace Gremlin.Net.Process.Traversal public enum Cardinality { - List,Set,Single + List, + Set, + Single } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index adcf738cef2..432323f1ec4 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -28,7 +28,8 @@ namespace Gremlin.Net.Process.Traversal public enum Column { - Keys,Values + Keys, + Values } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs index d3792633ac4..6f197483807 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -28,7 +28,9 @@ namespace Gremlin.Net.Process.Traversal public enum Direction { - Both,In,Out + Both, + In, + Out } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs index 6869ba5a4dd..e978bc6b19a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs @@ -28,7 +28,8 @@ namespace Gremlin.Net.Process.Traversal public enum GraphSONVersion { - V1_0,V2_0 + V1_0, + V2_0 } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index 1ebc581433e..72b00486cbd 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -28,7 +28,17 @@ namespace Gremlin.Net.Process.Traversal public enum Operator { - AddAll,And,Assign,Div,Max,Min,Minus,Mult,Or,Sum,SumLong + AddAll, + And, + Assign, + Div, + Max, + Min, + Minus, + Mult, + Or, + Sum, + SumLong } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index 0fdbbf9b04e..1f12710942e 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -28,7 +28,13 @@ namespace Gremlin.Net.Process.Traversal public enum Order { - Decr,Incr,KeyDecr,KeyIncr,Shuffle,ValueDecr,ValueIncr + Decr, + Incr, + KeyDecr, + KeyIncr, + Shuffle, + ValueDecr, + ValueIncr } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs index 1f8c2d91263..e6394aebc22 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -28,7 +28,8 @@ namespace Gremlin.Net.Process.Traversal public enum Pick { - Any,None + Any, + None } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs index f0975d224e1..a7a8403802c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -28,7 +28,9 @@ namespace Gremlin.Net.Process.Traversal public enum Pop { - All,First,Last + All, + First, + Last } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs index 67fa9707e8d..d5af93ac804 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -28,7 +28,8 @@ namespace Gremlin.Net.Process.Traversal public enum Scope { - Global,Local + Global, + Local } #pragma warning restore 1591 diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index b580aabeaab..c21b50ac84a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -28,7 +28,10 @@ namespace Gremlin.Net.Process.Traversal public enum T { - Id,Key,Label,Value + Id, + Key, + Label, + Value } #pragma warning restore 1591