Пример #1
0
 public static IConfigurableGremlinQuerySource WithExecutor(this IConfigurableGremlinQuerySource source, IGremlinQueryExecutor executor)
 {
     return(source.ConfigureExecutionPipeline(pipeline => pipeline
                                              .UseSerializer(GremlinQuerySerializer.Groovy)
                                              .UseExecutor(executor)
                                              .UseDeserializer(GremlinQueryExecutionResultDeserializer.Graphson)));
 }
Пример #2
0
        protected QueryDeserializationTest(IConfigurableGremlinQuerySource g, ITestOutputHelper testOutputHelper, [CallerFilePath] string callerFilePath = "") : base(
                g
                .ConfigureEnvironment(env => env
                                      .UseExecutor(GremlinQueryExecutor.Create((_, _) =>
        {
            var context = XunitContext.Context;

            var prefix = context.ClassName.Substring(0, context.ClassName.Length - "DeserializationTests".Length);

            try
            {
                var jArray = JsonConvert.DeserializeObject <JArray>(
                    File.ReadAllText(System.IO.Path.Combine(context.SourceDirectory, prefix + "IntegrationTests." + XunitContext.Context.MethodName + ".verified.txt")));

                return(jArray
                       .Select(x => (object)x)
                       .ToAsyncEnumerable());
            }
            catch (IOException)
            {
                return(AsyncEnumerable.Empty <object>());
            }
        }))),
                testOutputHelper,
                callerFilePath)
        {
        }
Пример #3
0
 public static IConfigurableGremlinQuerySource WithExecutor(this IConfigurableGremlinQuerySource source, IGremlinQueryExecutor <GroovySerializedGremlinQuery, JToken> executor)
 {
     return(source.UseExecutionPipeline(conf => conf
                                        .UseGroovySerialization()
                                        .UseExecutor(executor)
                                        .UseGraphsonDeserialization()));
 }
Пример #4
0
 public static IConfigurableGremlinQuerySource UseCosmosDb(this IConfigurableGremlinQuerySource source, string hostname, string database, string graphName, string authKey, int port = 443)
 {
     return(source
            .ConfigureExecutionPipeline(pipeline => pipeline
                                        .UseCosmosDbSerializer()
                                        .UseCosmosDbExecutor(hostname, database, graphName, authKey, source.Logger, port)
                                        .UseCosmosDbDeserializer()));
 }
 public static IConfigurableGremlinQuerySource WithCosmosDbRemote(this IConfigurableGremlinQuerySource source, string hostname, string database, string graphName, string authKey, int port = 443)
 {
     return source.WithExecutor(
         new WebSocketGremlinQueryExecutor<CosmosDbGroovyGremlinQueryElementVisitor>(
             new CosmosDbGremlinClient(
                 new CosmosDbGremlinServer(hostname, database, graphName, authKey, port)),
             new CosmosDbGraphsonSerializerFactory(),
             source.Logger));
 }
Пример #6
0
 public static IConfigurableGremlinQuerySource WithRemote(this IConfigurableGremlinQuerySource source, GremlinServer server, GraphsonVersion graphsonVersion)
 {
     return(source.WithExecutor(
                new WebSocketGremlinQueryExecutor <GroovyGremlinQueryElementVisitor>(
                    new GremlinClientEx(
                        server,
                        graphsonVersion),
                    new DefaultGraphsonSerializerFactory(),
                    source.Logger)));
 }
Пример #7
0
 public static IGremlinQuerySource UseGremlinServer(this IConfigurableGremlinQuerySource source, Func <IGremlinServerConfigurator, IGremlinQuerySourceTransformation> configuratorTransformation)
 {
     return(source
            .UseWebSocket(configurator => configuratorTransformation(new GremlinServerConfigurator(configurator)))
            .ConfigureEnvironment(environment => environment
                                  .ConfigureFeatureSet(featureSet => featureSet
                                                       .ConfigureGraphFeatures(graphFeatures => graphFeatures & ~(GraphFeatures.Transactions | GraphFeatures.ThreadedTransactions | GraphFeatures.ConcurrentAccess))
                                                       .ConfigureVertexFeatures(vertexFeatures => vertexFeatures & ~(VertexFeatures.Upsert | VertexFeatures.CustomIds))
                                                       .ConfigureVertexPropertyFeatures(vPropertiesFeatures => vPropertiesFeatures & ~(VertexPropertyFeatures.CustomIds))
                                                       .ConfigureEdgeFeatures(edgeProperties => edgeProperties & ~(EdgeFeatures.Upsert | EdgeFeatures.CustomIds)))));
 }
 public static IGremlinQuerySource UseJanusGraph(this IConfigurableGremlinQuerySource environment, Func <IJanusGraphConfigurator, IGremlinQuerySourceTransformation> transformation)
 {
     return(environment
            .UseWebSocket(builder => transformation(new JanusGraphConfigurator(builder)))
            .ConfigureEnvironment(environment => environment
                                  .ConfigureFeatureSet(featureSet => featureSet
                                                       .ConfigureGraphFeatures(_ => GraphFeatures.Computer | GraphFeatures.Transactions | GraphFeatures.ThreadedTransactions | GraphFeatures.Persistence)
                                                       .ConfigureVariableFeatures(_ => VariableFeatures.MapValues)
                                                       .ConfigureVertexFeatures(_ => VertexFeatures.AddVertices | VertexFeatures.RemoveVertices | VertexFeatures.MultiProperties | VertexFeatures.AddProperty | VertexFeatures.RemoveProperty | VertexFeatures.StringIds)
                                                       .ConfigureVertexPropertyFeatures(_ => VertexPropertyFeatures.RemoveProperty | VertexPropertyFeatures.NumericIds | VertexPropertyFeatures.StringIds | VertexPropertyFeatures.Properties | VertexPropertyFeatures.BooleanValues | VertexPropertyFeatures.ByteValues | VertexPropertyFeatures.DoubleValues | VertexPropertyFeatures.FloatValues | VertexPropertyFeatures.IntegerValues | VertexPropertyFeatures.LongValues | VertexPropertyFeatures.StringValues)
                                                       .ConfigureEdgeFeatures(_ => EdgeFeatures.AddEdges | EdgeFeatures.RemoveEdges | EdgeFeatures.AddProperty | EdgeFeatures.RemoveProperty | EdgeFeatures.NumericIds | EdgeFeatures.StringIds | EdgeFeatures.UuidIds | EdgeFeatures.CustomIds | EdgeFeatures.AnyIds)
                                                       .ConfigureEdgePropertyFeatures(_ => EdgePropertyFeatures.Properties | EdgePropertyFeatures.BooleanValues | EdgePropertyFeatures.ByteValues | EdgePropertyFeatures.DoubleValues | EdgePropertyFeatures.FloatValues | EdgePropertyFeatures.IntegerValues | EdgePropertyFeatures.LongValues | EdgePropertyFeatures.StringValues))
                                  .StoreByteArraysAsBase64String()));
 }
Пример #9
0
 public static IConfigurableGremlinQuerySource UseWebSocket(
     this IConfigurableGremlinQuerySource source,
     string hostname,
     GraphsonVersion graphsonVersion,
     int port        = 8182,
     bool enableSsl  = false,
     string username = null,
     string password = null,
     IReadOnlyDictionary <Type, IGraphSONSerializer> additionalGraphsonSerializers       = null,
     IReadOnlyDictionary <string, IGraphSONDeserializer> additionalGraphsonDeserializers = null)
 {
     return(source.ConfigureExecutionPipeline(conf => conf
                                              .UseSerializer(GremlinQuerySerializer.Groovy)
                                              .UseWebSocketExecutor(hostname, port, enableSsl, username, password, graphsonVersion, additionalGraphsonSerializers, additionalGraphsonDeserializers, source.Logger)
                                              .UseDeserializer(GremlinQueryExecutionResultDeserializer.Graphson)));
 }
Пример #10
0
 public static IConfigurableGremlinQuerySource UseCosmosDb(this IConfigurableGremlinQuerySource source, string hostname, string database, string graphName, string authKey, int port = 443)
 {
     return(source
            .UseExecutionPipeline(builder => builder
                                  .UseSerializer(GremlinQuerySerializer <GroovySerializedGremlinQuery>
                                                 .FromVisitor <CosmosDbGroovyGremlinQueryElementVisitor>())
                                  .AddWebSocketExecutor(
                                      hostname,
                                      port,
                                      true,
                                      $"/dbs/{database}/colls/{graphName}",
                                      authKey,
                                      GraphsonVersion.V2, new Dictionary <Type, IGraphSONSerializer>
     {
         { typeof(TimeSpan), new TimeSpanSerializer() }
     },
 public static IGremlinQuerySource UseNeptune(this IConfigurableGremlinQuerySource source, Func <INeptuneConfigurator, IGremlinQuerySourceTransformation> transformation)
 {
     return(source
            .UseWebSocket(configurator => transformation(new NeptuneConfigurator(configurator)))
            .ConfigureEnvironment(environment => environment
                                  .ConfigureSerializer(serializer => serializer
                                                       .ConfigureFragmentSerializer(fragmentSerializer => fragmentSerializer
                                                                                    .Override <PropertyStep.ByKeyStep>((step, env, overridden, recurse) => overridden(Cardinality.List.Equals(step.Cardinality) ? new PropertyStep.ByKeyStep(step.Key, step.Value, step.MetaProperties, Cardinality.Set) : step, env, recurse))))
                                  .StoreTimeSpansAsNumbers()
                                  .StoreByteArraysAsBase64String()
                                  .ConfigureFeatureSet(featureSet => featureSet
                                                       .ConfigureGraphFeatures(_ => GraphFeatures.Transactions | GraphFeatures.Persistence | GraphFeatures.ConcurrentAccess)
                                                       .ConfigureVariableFeatures(_ => VariableFeatures.None)
                                                       .ConfigureVertexFeatures(_ => VertexFeatures.AddVertices | VertexFeatures.RemoveVertices | VertexFeatures.MultiProperties | VertexFeatures.UserSuppliedIds | VertexFeatures.AddProperty | VertexFeatures.RemoveProperty | VertexFeatures.StringIds)
                                                       .ConfigureVertexPropertyFeatures(_ => VertexPropertyFeatures.RemoveProperty | VertexPropertyFeatures.NumericIds | VertexPropertyFeatures.StringIds | VertexPropertyFeatures.Properties | VertexPropertyFeatures.BooleanValues | VertexPropertyFeatures.ByteValues | VertexPropertyFeatures.DoubleValues | VertexPropertyFeatures.FloatValues | VertexPropertyFeatures.IntegerValues | VertexPropertyFeatures.LongValues | VertexPropertyFeatures.StringValues)
                                                       .ConfigureEdgeFeatures(_ => EdgeFeatures.AddEdges | EdgeFeatures.RemoveEdges | EdgeFeatures.UserSuppliedIds | EdgeFeatures.AddProperty | EdgeFeatures.RemoveProperty | EdgeFeatures.NumericIds | EdgeFeatures.StringIds | EdgeFeatures.UuidIds | EdgeFeatures.CustomIds | EdgeFeatures.AnyIds)
                                                       .ConfigureEdgePropertyFeatures(_ => EdgePropertyFeatures.Properties | EdgePropertyFeatures.BooleanValues | EdgePropertyFeatures.ByteValues | EdgePropertyFeatures.DoubleValues | EdgePropertyFeatures.FloatValues | EdgePropertyFeatures.IntegerValues | EdgePropertyFeatures.LongValues | EdgePropertyFeatures.StringValues))));
 }
        public static IGremlinQuerySource UseWebSocket(
            this IConfigurableGremlinQuerySource source,
            Func <IWebSocketConfigurator, IGremlinQuerySourceTransformation> configuratorTransformation)
        {
            var configurator = new WebSocketConfigurator(
                new GremlinServer(),
                GremlinClientFactory.Default,
                "g");

            return(configuratorTransformation(configurator)
                   .Transform(source
                              .ConfigureEnvironment(_ => _))
                   .ConfigureEnvironment(environment => environment
                                         .ConfigureExecutor(executor => executor
                                                            .Log())
                                         .ConfigureDeserializer(d => d
                                                                .ConfigureFragmentDeserializer(f => f
                                                                                               .AddNewtonsoftJson()))));
        }
Пример #13
0
        public Program()
        {
            _g = g
                 //Since the Vertex and Edge classes contained in this sample implement IVertex resp. IEdge,
                 //setting a model is actually not required as long as these classes are discoverable (i.e. they reside
                 //in a currently loaded assembly). We explicitly set a model here anyway.
                 .UseModel(GraphModel.FromBaseTypes <Vertex, Edge>())

                 //Configure Gremlinq to work on a locally running instance of Gremlin server.
                 .UseWebSocket("localhost", GraphsonVersion.V3)

                 //For Gremlin Server >= 3.4.0, we need to remove all ReferenceElementStrategies
                 //from the traversals, or else we don't get any vertex properties in the returned
                 //json-payloads and we end up with NullReferenceExceptions. Uncomment below
                 //when running on Gremlin Server >= 3.4.0.
                 .RemoveStrategies("ReferenceElementStrategy");

            //Uncomment below, comment above and enter appropriate data to configure Gremlinq to work on CosmosDB!
            //.UseCosmosDb(hostname, database, graphName, authKey);
        }
Пример #14
0
 public JsonSupportTest()
 {
     _g = g
          .UseModel(GraphModel.FromBaseTypes <Vertex, Edge>());
 }
Пример #15
0
 protected IntegrationTests(IConfigurableGremlinQuerySource g)
 {
     _g = g;
 }
Пример #16
0
 public static IConfigurableGremlinQuerySource WithRemote(this IConfigurableGremlinQuerySource source, string hostname, GraphsonVersion graphsonVersion, int port = 8182, bool enableSsl = false, string username = null, string password = null)
 {
     return(source.WithRemote(
                new GremlinServer(hostname, port, enableSsl, username, password),
                graphsonVersion));
 }