You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/05/26 12:58:52 UTC

[01/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Extracted logic for DefaultTraversal generation for DSLs [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1489 ded97822f -> 74bffea00 (forced update)


TINKERPOP-786 Extracted logic for DefaultTraversal generation for DSLs


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6efaca00
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6efaca00
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6efaca00

Branch: refs/heads/TINKERPOP-1489
Commit: 6efaca0017e64d0c108ccae9065458b94b3d2dea
Parents: 21b92b8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 27 15:19:46 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../traversal/dsl/GremlinDslProcessor.java      | 96 ++++++++++----------
 1 file changed, 50 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6efaca00/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 5a1a6bd..f9d5a40 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -95,52 +95,9 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 // GremlinDsl annotation on it
                 generateTraversalInterface(ctx);
 
-                // START write of the "DefaultTraversal" class
-                final TypeSpec.Builder defaultTraversalClass = TypeSpec.classBuilder(ctx.defaultTraversalClazz)
-                        .addModifiers(Modifier.PUBLIC)
-                        .addTypeVariables(Arrays.asList(TypeVariableName.get("S"), TypeVariableName.get("E")))
-                        .superclass(TypeName.get(elementUtils.getTypeElement(DefaultTraversal.class.getCanonicalName()).asType()))
-                        .addSuperinterface(ParameterizedTypeName.get(ctx.traversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")));
-
-                // add the required constructors for instantiation
-                defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
-                        .addModifiers(Modifier.PUBLIC)
-                        .addStatement("super()")
-                        .build());
-                defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
-                        .addModifiers(Modifier.PUBLIC)
-                        .addParameter(Graph.class, "graph")
-                        .addStatement("super($N)", "graph")
-                        .build());
-                defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
-                        .addModifiers(Modifier.PUBLIC)
-                        .addParameter(ctx.traversalSourceClassName, "traversalSource")
-                        .addStatement("super($N)", "traversalSource")
-                        .build());
-
-                // add the override
-                defaultTraversalClass.addMethod(MethodSpec.methodBuilder("iterate")
-                        .addModifiers(Modifier.PUBLIC)
-                        .addAnnotation(Override.class)
-                        .addStatement("return ($T) super.iterate()", ctx.traversalClassName)
-                        .returns(ParameterizedTypeName.get(ctx.traversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
-                        .build());
-                defaultTraversalClass.addMethod(MethodSpec.methodBuilder("asAdmin")
-                        .addModifiers(Modifier.PUBLIC)
-                        .addAnnotation(Override.class)
-                        .addStatement("return ($T) super.asAdmin()", GraphTraversal.Admin.class)
-                        .returns(ParameterizedTypeName.get(ctx.graphTraversalAdminClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
-                        .build());
-                defaultTraversalClass.addMethod(MethodSpec.methodBuilder("clone")
-                        .addModifiers(Modifier.PUBLIC)
-                        .addAnnotation(Override.class)
-                        .addStatement("return ($T) super.clone()", ctx.defaultTraversalClassName)
-                        .returns(ParameterizedTypeName.get(ctx.defaultTraversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
-                        .build());
-
-                final JavaFile defaultTraversalJavaFile = JavaFile.builder(ctx.packageName, defaultTraversalClass.build()).build();
-                defaultTraversalJavaFile.writeTo(filer);
-                // END write of the "DefaultTraversal" class
+                // create the "DefaultTraversal" class which implements the above generated "Traversal" and can then
+                // be used by the "TraversalSource" generated below to spawn new traversal instances
+                generateDefaultTraversal(ctx);
 
                 // START write "TraversalSource" class
                 final TypeElement graphTraversalSourceElement = elementUtils.getTypeElement(GraphTraversalSource.class.getCanonicalName());
@@ -225,6 +182,53 @@ public class GremlinDslProcessor extends AbstractProcessor {
         return true;
     }
 
+    private void generateDefaultTraversal(final Context ctx) throws IOException {
+        final TypeSpec.Builder defaultTraversalClass = TypeSpec.classBuilder(ctx.defaultTraversalClazz)
+                .addModifiers(Modifier.PUBLIC)
+                .addTypeVariables(Arrays.asList(TypeVariableName.get("S"), TypeVariableName.get("E")))
+                .superclass(TypeName.get(elementUtils.getTypeElement(DefaultTraversal.class.getCanonicalName()).asType()))
+                .addSuperinterface(ParameterizedTypeName.get(ctx.traversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")));
+
+        // add the required constructors for instantiation
+        defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
+                .addModifiers(Modifier.PUBLIC)
+                .addStatement("super()")
+                .build());
+        defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
+                .addModifiers(Modifier.PUBLIC)
+                .addParameter(Graph.class, "graph")
+                .addStatement("super($N)", "graph")
+                .build());
+        defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
+                .addModifiers(Modifier.PUBLIC)
+                .addParameter(ctx.traversalSourceClassName, "traversalSource")
+                .addStatement("super($N)", "traversalSource")
+                .build());
+
+        // add the override
+        defaultTraversalClass.addMethod(MethodSpec.methodBuilder("iterate")
+                .addModifiers(Modifier.PUBLIC)
+                .addAnnotation(Override.class)
+                .addStatement("return ($T) super.iterate()", ctx.traversalClassName)
+                .returns(ParameterizedTypeName.get(ctx.traversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
+                .build());
+        defaultTraversalClass.addMethod(MethodSpec.methodBuilder("asAdmin")
+                .addModifiers(Modifier.PUBLIC)
+                .addAnnotation(Override.class)
+                .addStatement("return ($T) super.asAdmin()", GraphTraversal.Admin.class)
+                .returns(ParameterizedTypeName.get(ctx.graphTraversalAdminClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
+                .build());
+        defaultTraversalClass.addMethod(MethodSpec.methodBuilder("clone")
+                .addModifiers(Modifier.PUBLIC)
+                .addAnnotation(Override.class)
+                .addStatement("return ($T) super.clone()", ctx.defaultTraversalClassName)
+                .returns(ParameterizedTypeName.get(ctx.defaultTraversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
+                .build());
+
+        final JavaFile defaultTraversalJavaFile = JavaFile.builder(ctx.packageName, defaultTraversalClass.build()).build();
+        defaultTraversalJavaFile.writeTo(filer);
+    }
+
     private void generateTraversalInterface(final Context ctx) throws IOException {
         final TypeSpec.Builder traversalInterface = TypeSpec.interfaceBuilder(ctx.traversalClazz)
                 .addModifiers(Modifier.PUBLIC)


[10/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Bumped to 0.10 of google compile-test

Posted by sp...@apache.org.
TINKERPOP-786 Bumped to 0.10 of google compile-test


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ef359dda
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ef359dda
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ef359dda

Branch: refs/heads/TINKERPOP-1489
Commit: ef359ddabaf673e26bc5a4d099c6106abb4d44d9
Parents: 7790716
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Apr 29 06:53:15 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 gremlin-core/pom.xml                            |  6 ++-
 .../traversal/dsl/GremlinDslProcessorTest.java  | 41 ++++++++++----------
 2 files changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ef359dda/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index 989bf83..0efadfa 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -104,21 +104,23 @@ limitations under the License.
         <dependency>
             <groupId>com.google.testing.compile</groupId>
             <artifactId>compile-testing</artifactId>
-            <version>0.8</version>
+            <version>0.10</version>
             <scope>test</scope>
         </dependency>
+        <!--
         <dependency>
             <groupId>com.google.truth</groupId>
             <artifactId>truth</artifactId>
             <version>0.25</version>
             <exclusions>
-                <!-- truth comes in through compile-testing and has a self-conflict - produces further conflict with hadoop-gremlin -->
+                truth comes in through compile-testing and has a self-conflict - produces further conflict with hadoop-gremlin
                 <exclusion>
                     <groupId>com.google.guava</groupId>
                     <artifactId>guava</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
+-->
     </dependencies>
     <build>
         <directory>${basedir}/target</directory>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ef359dda/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
index 982ec5b..5df010d 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
@@ -18,13 +18,14 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.dsl;
 
+import com.google.testing.compile.Compilation;
 import com.google.testing.compile.JavaFileObjects;
 import org.junit.Test;
 
 import javax.tools.StandardLocation;
 
-import static com.google.common.truth.Truth.ASSERT;
-import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource;
+import static com.google.testing.compile.CompilationSubject.assertThat;
+import static com.google.testing.compile.Compiler.javac;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -33,35 +34,35 @@ public class GremlinDslProcessorTest {
 
     @Test
     public void shouldCompileToDefaultPackage() {
-        ASSERT.about(javaSource())
-                .that(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialTraversalDsl.java")))
-                .processedWith(new GremlinDslProcessor())
-                .compilesWithoutError();
+        Compilation compilation = javac()
+                .withProcessors(new GremlinDslProcessor())
+                .compile(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialTraversalDsl.java")));
+        assertThat(compilation).succeededWithoutWarnings();
     }
 
     @Test
     public void shouldCompileAndMovePackage() {
-        ASSERT.about(javaSource())
-                .that(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialMoveTraversalDsl.java")))
-                .processedWith(new GremlinDslProcessor())
-                .compilesWithoutError()
-                .and()
-                .generatesFileNamed(StandardLocation.SOURCE_OUTPUT, "org.apache.tinkerpop.gremlin.process.traversal.dsl.social", "SocialMoveTraversal.java");
+        Compilation compilation = javac()
+                .withProcessors(new GremlinDslProcessor())
+                .compile(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialMoveTraversalDsl.java")));
+        assertThat(compilation).succeededWithoutWarnings();
+        assertThat(compilation)
+                .generatedFile(StandardLocation.SOURCE_OUTPUT, "org.apache.tinkerpop.gremlin.process.traversal.dsl.social", "SocialMoveTraversal.java");
     }
 
     @Test
     public void shouldCompileTraversalAndTraversalSourceToDefaultPackage() {
-        ASSERT.about(javaSource())
-                .that(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialPackageTraversalDsl.java")))
-                .processedWith(new GremlinDslProcessor())
-                .compilesWithoutError();
+        Compilation compilation = javac()
+                .withProcessors(new GremlinDslProcessor())
+                .compile(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialPackageTraversalDsl.java")));
+        assertThat(compilation).succeededWithoutWarnings();
     }
 
     @Test
     public void shouldCompileWithNoDefaultMethods() {
-        ASSERT.about(javaSource())
-                .that(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialNoDefaultMethodsTraversalDsl.java")))
-                .processedWith(new GremlinDslProcessor())
-                .compilesWithoutError();
+        Compilation compilation = javac()
+                .withProcessors(new GremlinDslProcessor())
+                .compile(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialNoDefaultMethodsTraversalDsl.java")));
+        assertThat(compilation).succeededWithoutWarnings();
     }
 }


[21/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Added support for anonymous traversal generation

Posted by sp...@apache.org.
TINKERPOP-786 Added support for anonymous traversal generation


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e0505d12
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e0505d12
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e0505d12

Branch: refs/heads/TINKERPOP-1489
Commit: e0505d1243f31789514ebc315ee19ee3568470a8
Parents: 5c7f0cb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 16:43:00 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc       |   1 +
 .../src/main/java/SocialTraversalDsl.java       |  10 ++
 .../src/test/java/SocialDslTest.java            |   6 +
 .../process/traversal/dsl/GremlinDsl.java       |   1 +
 .../traversal/dsl/GremlinDslProcessor.java      | 133 ++++++++++++++++++-
 5 files changed, 147 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0505d12/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 1be365d..7da4015 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -3027,6 +3027,7 @@ The annotation processor will generate several classes for the DSL:
 interfaces (such as `GraphTraversal`) to instead return a `SocialTraversal`
 * `DefaultSocialTraversal` - A default implementation of `SocialTraversal` (typically not used directly by the user)
 * `SocialTraversalSource` - Spawns `DefaultSocialTraversal` instances.
+* `__` - Spawns anonymous `DefaultSocialTraversal` instances.
 
 Using the DSL then just involves telling the `Graph` to use it:
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0505d12/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
index af1f039..b7e4f07 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 
 /**
  * This Social DSL is meant to be used with the TinkerPop "modern" toy graph.
@@ -54,4 +55,13 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
     public default <E2 extends Number> GraphTraversal<S, E2> youngestFriendsAge() {
         return out("knows").hasLabel("person").values("age").min();
     }
+
+    /**
+     * Designed to be used as a filter for "person" vertices based on the number of "created" edges encountered.
+     *
+     * @param number the minimum number of projects a person created
+     */
+    public default GraphTraversal<S,Long> createdAtLeast(int number) {
+        return outE("created").count().is(P.gte(number));
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0505d12/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
index 5967244..7f76558 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
@@ -51,4 +51,10 @@ public class SocialDslTest {
         SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
         assertEquals(4, social.persons().count().next().intValue());
     }
+
+    @Test
+    public void shouldFindAllPersonsWithTwoOrMoreProjects() {
+        SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
+        assertEquals(1, social.persons().filter(__.createdAtLeast(2)).count().next().intValue());
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0505d12/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
index df96007..d3a807f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
@@ -38,6 +38,7 @@ import java.lang.annotation.Target;
  *     <li>{@code SocialTraversal} - an interface that is an extension to {@code SocialTraversalDsl}</li>
  *     <li>{@code DefaultSocialTraversal} - an implementation of the {@code SocialTraversal}</li>
  *     <li>{@code SocialTraversalSource} - an extension of {@link GraphTraversalSource} which spawns {@code DefaultSocialTraversal} instances</li>
+ *     <li>{@code __} - which spawns anonymous {@code DefaultSocialTraversal} instances</li>
  * </ul>
  *
  * Together these generated classes provide all the infrastructure required to properly Gremlin traversals enhanced

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0505d12/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index e246765..04e59b4 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -29,6 +29,7 @@ import com.squareup.javapoet.TypeVariableName;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
@@ -53,6 +54,7 @@ import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeVariable;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
 import javax.tools.Diagnostic;
@@ -104,6 +106,9 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 // create the "TraversalSource" class which is used to spawn traversals from a Graph instance. It will
                 // spawn instances of the "DefaultTraversal" generated above.
                 generateTraversalSource(ctx);
+
+                // create anonymous traversal for DSL
+                generateAnonymousTraversal(ctx);
             }
         } catch (Exception ex) {
             messager.printMessage(Diagnostic.Kind.ERROR, ex.getMessage());
@@ -112,6 +117,126 @@ public class GremlinDslProcessor extends AbstractProcessor {
         return true;
     }
 
+    private void generateAnonymousTraversal(final Context ctx) throws IOException {
+        final TypeSpec.Builder anonymousClass = TypeSpec.classBuilder("__")
+                .addModifiers(Modifier.PUBLIC, Modifier.FINAL);
+
+        // this class is just static methods - it should not be instantiated
+        anonymousClass.addMethod(MethodSpec.constructorBuilder()
+                .addModifiers(Modifier.PRIVATE)
+                .build());
+
+        // add start() method
+        anonymousClass.addMethod(MethodSpec.methodBuilder("start")
+                .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
+                .addTypeVariable(TypeVariableName.get("A"))
+                .addStatement("return new $N<>()", ctx.defaultTraversalClazz)
+                .returns(ParameterizedTypeName.get(ctx.traversalClassName, TypeVariableName.get("A"), TypeVariableName.get("A")))
+                .build());
+
+        // process the methods of the GremlinDsl annotated class
+        for (Element element : ctx.annotatedDslType.getEnclosedElements()) {
+            if (element.getKind() != ElementKind.METHOD) continue;
+
+            final ExecutableElement templateMethod = (ExecutableElement) element;
+            final String methodName = templateMethod.getSimpleName().toString();
+
+            final TypeName returnType = getReturnTypeDefinition(ctx.traversalClassName, templateMethod);
+            final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(methodName)
+                    .addModifiers(Modifier.STATIC, Modifier.PUBLIC)
+                    .addExceptions(templateMethod.getThrownTypes().stream().map(TypeName::get).collect(Collectors.toList()))
+                    .returns(returnType);
+
+            templateMethod.getTypeParameters().forEach(tp -> methodToAdd.addTypeVariable(TypeVariableName.get(tp)));
+
+            // might have to deal with an "S" (in __ it's usually an "A") - how to make this less bound to that convention?
+            final DeclaredType returnTypeMirror = (DeclaredType) templateMethod.getReturnType();
+            final List<? extends TypeMirror> returnTypeArguments = returnTypeMirror.getTypeArguments();
+            returnTypeArguments.stream().filter(rtm -> rtm instanceof TypeVariable).forEach(rtm -> {
+                if (((TypeVariable) rtm).asElement().getSimpleName().contentEquals("S"))
+                    methodToAdd.addTypeVariable(TypeVariableName.get(((TypeVariable) rtm).asElement().getSimpleName().toString()));
+            });
+
+            boolean added = false;
+            final List<? extends VariableElement> parameters = templateMethod.getParameters();
+            String body = "return __.<S>start().$L(";
+            for (VariableElement param : parameters) {
+                methodToAdd.addParameter(ParameterSpec.get(param));
+
+                body = body + param.getSimpleName() + ",";
+                added = true;
+            }
+
+            // treat a final array as a varargs param
+            if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
+                methodToAdd.varargs(true);
+
+            if (added) body = body.substring(0, body.length() - 1);
+
+            body = body + ")";
+
+            methodToAdd.addStatement(body, methodName);
+
+            anonymousClass.addMethod(methodToAdd.build());
+        }
+
+        // use methods from __ to template them into the DSL __
+        final Element anonymousTraversal = elementUtils.getTypeElement(__.class.getCanonicalName());
+        for (Element element : anonymousTraversal.getEnclosedElements()) {
+            if (element.getKind() != ElementKind.METHOD) continue;
+
+            final ExecutableElement templateMethod = (ExecutableElement) element;
+            final String methodName = templateMethod.getSimpleName().toString();
+
+            // ignore start() from __ - that's not proxied
+            if (methodName.equals("start")) continue;
+
+            final TypeName returnType = getReturnTypeDefinition(ctx.traversalClassName, templateMethod);
+            final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(methodName)
+                    .addModifiers(Modifier.STATIC, Modifier.PUBLIC)
+                    .addExceptions(templateMethod.getThrownTypes().stream().map(TypeName::get).collect(Collectors.toList()))
+                    .returns(returnType);
+
+            templateMethod.getTypeParameters().forEach(tp -> methodToAdd.addTypeVariable(TypeVariableName.get(tp)));
+
+            boolean added = false;
+            final List<? extends VariableElement> parameters = templateMethod.getParameters();
+            String body;
+            if (methodName.equals("__")) {
+                for (VariableElement param : parameters) {
+                    methodToAdd.addParameter(ParameterSpec.get(param));
+                }
+
+                methodToAdd.varargs(true);
+
+                body = "return inject(starts)";
+            } else {
+                body = "return __.<A>start().$L(";
+                for (VariableElement param : parameters) {
+                    methodToAdd.addParameter(ParameterSpec.get(param));
+
+                    body = body + param.getSimpleName() + ",";
+                    added = true;
+                }
+
+                // treat a final array as a varargs param
+                if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
+                    methodToAdd.varargs(true);
+
+                if (added) body = body.substring(0, body.length() - 1);
+
+                body = body + ")";
+            }
+
+            methodToAdd.addStatement(body, methodName);
+
+            anonymousClass.addMethod(methodToAdd.build());
+        }
+
+        final JavaFile traversalSourceJavaFile = JavaFile.builder(ctx.packageName, anonymousClass.build()).build();
+        traversalSourceJavaFile.writeTo(filer);
+    }
+
     private void generateTraversalSource(final Context ctx) throws IOException {
         final TypeElement graphTraversalSourceElement = ctx.traversalSourceDslType;
         final TypeSpec.Builder traversalSourceClass = TypeSpec.classBuilder(ctx.traversalSourceClazz)
@@ -132,7 +257,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .build());
 
         // override methods to return a the DSL TraversalSource. find GraphTraversalSource class somewhere in the hierarchy
-        final Element tinkerPopsGraphTraversalSource = findTinkerPopsGraphTraversalSource(graphTraversalSourceElement);
+        final Element tinkerPopsGraphTraversalSource = findClassAsElement(graphTraversalSourceElement, GraphTraversalSource.class);
         for (Element elementOfGraphTraversalSource : tinkerPopsGraphTraversalSource.getEnclosedElements()) {
             // first copy/override methods that return a GraphTraversalSource so that we can instead return
             // the DSL TraversalSource class.
@@ -226,13 +351,13 @@ public class GremlinDslProcessor extends AbstractProcessor {
         traversalSourceJavaFile.writeTo(filer);
     }
 
-    private Element findTinkerPopsGraphTraversalSource(final Element element) {
-        if (element.getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())) {
+    private Element findClassAsElement(final Element element, final Class<?> clazz) {
+        if (element.getSimpleName().contentEquals(clazz.getSimpleName())) {
             return element;
         }
 
         final List<? extends TypeMirror> supertypes = typeUtils.directSupertypes(element.asType());
-        return findTinkerPopsGraphTraversalSource(typeUtils.asElement(supertypes.get(0)));
+        return findClassAsElement(typeUtils.asElement(supertypes.get(0)), clazz);
     }
 
     private void generateDefaultTraversal(final Context ctx) throws IOException {


[29/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Refactored processor

Posted by sp...@apache.org.
TINKERPOP-786 Refactored processor

Removed some more duplicate code and streamlined a bit further.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7963dc24
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7963dc24
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7963dc24

Branch: refs/heads/TINKERPOP-1489
Commit: 7963dc24a0cc87f3c2a68aef9ff887e04b18596d
Parents: fbf8f0d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 12 09:02:08 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 .../traversal/dsl/GremlinDslProcessor.java      | 48 +++++++++-----------
 1 file changed, 21 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7963dc24/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 1717053..3358143 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -61,7 +61,6 @@ import javax.tools.Diagnostic;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Optional;
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
@@ -135,7 +134,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .build());
 
         // process the methods of the GremlinDsl annotated class
-        for (ExecutableElement templateMethod : findMethodsOfElement(ctx.annotatedDslType)) {
+        for (ExecutableElement templateMethod : findMethodsOfElement(ctx.annotatedDslType, null)) {
             final String methodName = templateMethod.getSimpleName().toString();
 
             final TypeName returnType = getReturnTypeDefinition(ctx.traversalClassName, templateMethod);
@@ -178,12 +177,10 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         // use methods from __ to template them into the DSL __
         final Element anonymousTraversal = elementUtils.getTypeElement(__.class.getCanonicalName());
-        for (ExecutableElement templateMethod : findMethodsOfElement(anonymousTraversal)) {
+        final Predicate<ExecutableElement> ignore = ee -> ee.getSimpleName().contentEquals("start");
+        for (ExecutableElement templateMethod : findMethodsOfElement(anonymousTraversal, ignore)) {
             final String methodName = templateMethod.getSimpleName().toString();
 
-            // ignore start() from __ - that's not proxied
-            if (methodName.equals("start")) continue;
-
             final TypeName returnType = getReturnTypeDefinition(ctx.traversalClassName, templateMethod);
             final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(methodName)
                     .addModifiers(Modifier.STATIC, Modifier.PUBLIC)
@@ -251,18 +248,16 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         // override methods to return a the DSL TraversalSource. find GraphTraversalSource class somewhere in the hierarchy
         final Element tinkerPopsGraphTraversalSource = findClassAsElement(graphTraversalSourceElement, GraphTraversalSource.class);
-        for (ExecutableElement elementOfGraphTraversalSource : findMethodsOfElement(tinkerPopsGraphTraversalSource)) {
+        final Predicate<ExecutableElement> ignore = e -> !(e.getReturnType().getKind() == TypeKind.DECLARED && ((DeclaredType) e.getReturnType()).asElement().getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName()));
+        for (ExecutableElement elementOfGraphTraversalSource : findMethodsOfElement(tinkerPopsGraphTraversalSource, ignore)) {
             // first copy/override methods that return a GraphTraversalSource so that we can instead return
             // the DSL TraversalSource class.
-            tryConstructMethod(elementOfGraphTraversalSource, ctx.traversalSourceClassName, "",
-                    e -> !(e.getReturnType().getKind() == TypeKind.DECLARED && ((DeclaredType) e.getReturnType()).asElement().getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())),
-                    Modifier.PUBLIC)
-                    .ifPresent(traversalSourceClass::addMethod);
+            traversalSourceClass.addMethod(constructMethod(elementOfGraphTraversalSource, ctx.traversalSourceClassName, "",Modifier.PUBLIC));
         }
 
         // override methods that return GraphTraversal that come from the user defined extension of GraphTraversal
         if (!graphTraversalSourceElement.getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())) {
-            for (ExecutableElement templateMethod : findMethodsOfElement(graphTraversalSourceElement)) {
+            for (ExecutableElement templateMethod : findMethodsOfElement(graphTraversalSourceElement, null)) {
                 final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(templateMethod.getSimpleName().toString())
                         .addModifiers(Modifier.PUBLIC)
                         .addAnnotation(Override.class);
@@ -410,18 +405,17 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addSuperinterface(TypeName.get(ctx.annotatedDslType.asType()));
 
         // process the methods of the GremlinDsl annotated class
-        for (ExecutableElement templateMethod : findMethodsOfElement(ctx.annotatedDslType)) {
-            tryConstructMethod(templateMethod, ctx.traversalClassName, ctx.dslName, null,
-                    Modifier.PUBLIC, Modifier.DEFAULT).ifPresent(traversalInterface::addMethod);
+        for (ExecutableElement templateMethod : findMethodsOfElement(ctx.annotatedDslType, null)) {
+            traversalInterface.addMethod(constructMethod(templateMethod, ctx.traversalClassName, ctx.dslName,
+                    Modifier.PUBLIC, Modifier.DEFAULT));
         }
 
         // process the methods of GraphTraversal
         final TypeElement graphTraversalElement = elementUtils.getTypeElement(GraphTraversal.class.getCanonicalName());
-        for (ExecutableElement templateMethod : findMethodsOfElement(graphTraversalElement)) {
-            tryConstructMethod(templateMethod, ctx.traversalClassName, ctx.dslName,
-                    e -> e.getSimpleName().contentEquals("asAdmin") || e.getSimpleName().contentEquals("iterate"),
-                    Modifier.PUBLIC, Modifier.DEFAULT)
-                    .ifPresent(traversalInterface::addMethod);
+        final Predicate<ExecutableElement> ignore = e -> e.getSimpleName().contentEquals("asAdmin") || e.getSimpleName().contentEquals("iterate");
+        for (ExecutableElement templateMethod : findMethodsOfElement(graphTraversalElement, ignore)) {
+            traversalInterface.addMethod(constructMethod(templateMethod, ctx.traversalClassName, ctx.dslName,
+                    Modifier.PUBLIC, Modifier.DEFAULT));
         }
 
         // there are weird things with generics that require this method to be implemented if it isn't already present
@@ -438,13 +432,11 @@ public class GremlinDslProcessor extends AbstractProcessor {
         traversalJavaFile.writeTo(filer);
     }
 
-    private Optional<MethodSpec> tryConstructMethod(final Element element, final ClassName returnClazz, final String parent,
-                                                    final Predicate<ExecutableElement> ignore, final Modifier... modifiers) {
+    private MethodSpec constructMethod(final Element element, final ClassName returnClazz, final String parent,
+                                       final Modifier... modifiers) {
         final ExecutableElement templateMethod = (ExecutableElement) element;
         final String methodName = templateMethod.getSimpleName().toString();
 
-        if (ignore != null && ignore.test(templateMethod)) return Optional.empty();
-
         final TypeName returnType = getReturnTypeDefinition(returnClazz, templateMethod);
         final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(methodName)
                 .addModifiers(modifiers)
@@ -474,7 +466,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
         body = body + ")";
         methodToAdd.addStatement(body, returnClazz, methodName);
 
-        return Optional.of(methodToAdd.build());
+        return methodToAdd.build();
     }
 
     private TypeName getReturnTypeDefinition(final ClassName returnClazz, final ExecutableElement templateMethod) {
@@ -495,10 +487,12 @@ public class GremlinDslProcessor extends AbstractProcessor {
             throw new ProcessorException(dslElement, "The interface %s is not public.", typeElement.getQualifiedName());
     }
 
-    private List<ExecutableElement> findMethodsOfElement(final Element element) {
+    private List<ExecutableElement> findMethodsOfElement(final Element element, final Predicate<ExecutableElement> ignore) {
+        final Predicate<ExecutableElement> test = null == ignore ? ee -> false : ignore;
         return element.getEnclosedElements().stream()
                 .filter(ee -> ee.getKind() == ElementKind.METHOD)
-                .map(ee -> (ExecutableElement) ee).collect(Collectors.toList());
+                .map(ee -> (ExecutableElement) ee)
+                .filter(ee -> !test.test(ee)).collect(Collectors.toList());
     }
 
     private List<? extends TypeMirror> getTypeArguments(final ExecutableElement templateMethod) {


[48/50] [abbrv] tinkerpop git commit: Javascript GLV

Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
new file mode 100644
index 0000000..d9803ba
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -0,0 +1,2025 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphTraversalModule() {
+  "use strict";
+
+  var t = loadModule.call(this, './traversal.js');
+  var remote = loadModule.call(this, '../driver/remote-connection.js');
+  var Bytecode = t.Bytecode;
+  var inherits = t.inherits;
+  var parseArgs = t.parseArgs;
+
+  /**
+   *
+   * @param {Graph} graph
+   * @param {TraversalStrategies} traversalStrategies
+   * @param {Bytecode} [bytecode]
+   * @constructor
+   */
+  function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode || new Bytecode();
+  }
+
+  /**
+   * @param remoteConnection
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+  };
+
+  /**
+   * Returns the string representation of the GraphTraversalSource.
+   * @returns {string}
+   */
+  GraphTraversalSource.prototype.toString = function () {
+    return 'graphtraversalsource[' + this._graph.toString() + ']';
+  };
+
+  /**
+   * withBulk GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withBulk = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withComputer GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withComputer = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withPath GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withPath = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withSack GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withSack = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withSideEffect GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withSideEffect = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withStrategies GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withStrategies = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withoutStrategies GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withoutStrategies = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * E GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.E = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('E', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * V GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.V = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('V', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * addV GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.addV = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('addV', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * inject GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.inject = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('inject', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * Represents a graph traversal.
+   * @constructor
+   */
+  function GraphTraversal(graph, traversalStrategies, bytecode) {
+    t.Traversal.call(this, graph, traversalStrategies, bytecode);
+  }
+
+  inherits(GraphTraversal, t.Traversal);
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.V = function (args) {
+    this._bytecode.addStep('V', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addE = function (args) {
+    this._bytecode.addStep('addE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addInE = function (args) {
+    this._bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addOutE = function (args) {
+    this._bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addV = function (args) {
+    this._bytecode.addStep('addV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.aggregate = function (args) {
+    this._bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.and = function (args) {
+    this._bytecode.addStep('and', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.as = function (args) {
+    this._bytecode.addStep('as', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.barrier = function (args) {
+    this._bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.both = function (args) {
+    this._bytecode.addStep('both', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.bothE = function (args) {
+    this._bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.bothV = function (args) {
+    this._bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.branch = function (args) {
+    this._bytecode.addStep('branch', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.by = function (args) {
+    this._bytecode.addStep('by', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.cap = function (args) {
+    this._bytecode.addStep('cap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.choose = function (args) {
+    this._bytecode.addStep('choose', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.coalesce = function (args) {
+    this._bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.coin = function (args) {
+    this._bytecode.addStep('coin', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.constant = function (args) {
+    this._bytecode.addStep('constant', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.count = function (args) {
+    this._bytecode.addStep('count', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.cyclicPath = function (args) {
+    this._bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.dedup = function (args) {
+    this._bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.drop = function (args) {
+    this._bytecode.addStep('drop', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.emit = function (args) {
+    this._bytecode.addStep('emit', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.filter = function (args) {
+    this._bytecode.addStep('filter', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.flatMap = function (args) {
+    this._bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.fold = function (args) {
+    this._bytecode.addStep('fold', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.from_ = function (args) {
+    this._bytecode.addStep('from', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.group = function (args) {
+    this._bytecode.addStep('group', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.groupCount = function (args) {
+    this._bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.groupV3d0 = function (args) {
+    this._bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.has = function (args) {
+    this._bytecode.addStep('has', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasId = function (args) {
+    this._bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasKey = function (args) {
+    this._bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasLabel = function (args) {
+    this._bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasNot = function (args) {
+    this._bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasValue = function (args) {
+    this._bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.id = function (args) {
+    this._bytecode.addStep('id', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.identity = function (args) {
+    this._bytecode.addStep('identity', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.inE = function (args) {
+    this._bytecode.addStep('inE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.inV = function (args) {
+    this._bytecode.addStep('inV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.in_ = function (args) {
+    this._bytecode.addStep('in', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.inject = function (args) {
+    this._bytecode.addStep('inject', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.is = function (args) {
+    this._bytecode.addStep('is', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.key = function (args) {
+    this._bytecode.addStep('key', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.label = function (args) {
+    this._bytecode.addStep('label', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.limit = function (args) {
+    this._bytecode.addStep('limit', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.local = function (args) {
+    this._bytecode.addStep('local', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.loops = function (args) {
+    this._bytecode.addStep('loops', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.map = function (args) {
+    this._bytecode.addStep('map', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.mapKeys = function (args) {
+    this._bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.mapValues = function (args) {
+    this._bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.match = function (args) {
+    this._bytecode.addStep('match', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.max = function (args) {
+    this._bytecode.addStep('max', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.mean = function (args) {
+    this._bytecode.addStep('mean', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.min = function (args) {
+    this._bytecode.addStep('min', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.not = function (args) {
+    this._bytecode.addStep('not', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.option = function (args) {
+    this._bytecode.addStep('option', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.optional = function (args) {
+    this._bytecode.addStep('optional', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.or = function (args) {
+    this._bytecode.addStep('or', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.order = function (args) {
+    this._bytecode.addStep('order', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.otherV = function (args) {
+    this._bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.out = function (args) {
+    this._bytecode.addStep('out', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.outE = function (args) {
+    this._bytecode.addStep('outE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.outV = function (args) {
+    this._bytecode.addStep('outV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.pageRank = function (args) {
+    this._bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.path = function (args) {
+    this._bytecode.addStep('path', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.peerPressure = function (args) {
+    this._bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.profile = function (args) {
+    this._bytecode.addStep('profile', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.program = function (args) {
+    this._bytecode.addStep('program', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.project = function (args) {
+    this._bytecode.addStep('project', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.properties = function (args) {
+    this._bytecode.addStep('properties', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.property = function (args) {
+    this._bytecode.addStep('property', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.propertyMap = function (args) {
+    this._bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.range = function (args) {
+    this._bytecode.addStep('range', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.repeat = function (args) {
+    this._bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sack = function (args) {
+    this._bytecode.addStep('sack', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sample = function (args) {
+    this._bytecode.addStep('sample', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.select = function (args) {
+    this._bytecode.addStep('select', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sideEffect = function (args) {
+    this._bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.simplePath = function (args) {
+    this._bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.store = function (args) {
+    this._bytecode.addStep('store', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.subgraph = function (args) {
+    this._bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sum = function (args) {
+    this._bytecode.addStep('sum', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.tail = function (args) {
+    this._bytecode.addStep('tail', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.timeLimit = function (args) {
+    this._bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.times = function (args) {
+    this._bytecode.addStep('times', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.to = function (args) {
+    this._bytecode.addStep('to', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.toE = function (args) {
+    this._bytecode.addStep('toE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.toV = function (args) {
+    this._bytecode.addStep('toV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.tree = function (args) {
+    this._bytecode.addStep('tree', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.unfold = function (args) {
+    this._bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.union = function (args) {
+    this._bytecode.addStep('union', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.until = function (args) {
+    this._bytecode.addStep('until', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.value = function (args) {
+    this._bytecode.addStep('value', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.valueMap = function (args) {
+    this._bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.values = function (args) {
+    this._bytecode.addStep('values', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.where = function (args) {
+    this._bytecode.addStep('where', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * Contains the static method definitions
+   * @type {Object}
+   */
+  var statics = {};
+
+  /**
+   * V() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.V = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.V.apply(g, arguments);
+  };
+
+  /**
+   * __() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.__ = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.__.apply(g, arguments);
+  };
+
+  /**
+   * addE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addE.apply(g, arguments);
+  };
+
+  /**
+   * addInE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addInE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addInE.apply(g, arguments);
+  };
+
+  /**
+   * addOutE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addOutE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addOutE.apply(g, arguments);
+  };
+
+  /**
+   * addV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addV.apply(g, arguments);
+  };
+
+  /**
+   * aggregate() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.aggregate = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.aggregate.apply(g, arguments);
+  };
+
+  /**
+   * and() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.and = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.and.apply(g, arguments);
+  };
+
+  /**
+   * as() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.as = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.as.apply(g, arguments);
+  };
+
+  /**
+   * barrier() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.barrier = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.barrier.apply(g, arguments);
+  };
+
+  /**
+   * both() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.both = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.both.apply(g, arguments);
+  };
+
+  /**
+   * bothE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.bothE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.bothE.apply(g, arguments);
+  };
+
+  /**
+   * bothV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.bothV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.bothV.apply(g, arguments);
+  };
+
+  /**
+   * branch() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.branch = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.branch.apply(g, arguments);
+  };
+
+  /**
+   * cap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.cap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.cap.apply(g, arguments);
+  };
+
+  /**
+   * choose() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.choose = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.choose.apply(g, arguments);
+  };
+
+  /**
+   * coalesce() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.coalesce = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.coalesce.apply(g, arguments);
+  };
+
+  /**
+   * coin() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.coin = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.coin.apply(g, arguments);
+  };
+
+  /**
+   * constant() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.constant = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.constant.apply(g, arguments);
+  };
+
+  /**
+   * count() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.count = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.count.apply(g, arguments);
+  };
+
+  /**
+   * cyclicPath() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.cyclicPath = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.cyclicPath.apply(g, arguments);
+  };
+
+  /**
+   * dedup() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.dedup = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.dedup.apply(g, arguments);
+  };
+
+  /**
+   * drop() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.drop = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.drop.apply(g, arguments);
+  };
+
+  /**
+   * emit() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.emit = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.emit.apply(g, arguments);
+  };
+
+  /**
+   * filter() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.filter = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.filter.apply(g, arguments);
+  };
+
+  /**
+   * flatMap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.flatMap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.flatMap.apply(g, arguments);
+  };
+
+  /**
+   * fold() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.fold = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.fold.apply(g, arguments);
+  };
+
+  /**
+   * group() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.group = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.group.apply(g, arguments);
+  };
+
+  /**
+   * groupCount() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.groupCount = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.groupCount.apply(g, arguments);
+  };
+
+  /**
+   * groupV3d0() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.groupV3d0 = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.groupV3d0.apply(g, arguments);
+  };
+
+  /**
+   * has() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.has = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.has.apply(g, arguments);
+  };
+
+  /**
+   * hasId() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasId = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasId.apply(g, arguments);
+  };
+
+  /**
+   * hasKey() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasKey = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasKey.apply(g, arguments);
+  };
+
+  /**
+   * hasLabel() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasLabel = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasLabel.apply(g, arguments);
+  };
+
+  /**
+   * hasNot() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasNot = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasNot.apply(g, arguments);
+  };
+
+  /**
+   * hasValue() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasValue = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasValue.apply(g, arguments);
+  };
+
+  /**
+   * id() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.id = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.id.apply(g, arguments);
+  };
+
+  /**
+   * identity() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.identity = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.identity.apply(g, arguments);
+  };
+
+  /**
+   * inE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.inE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.inE.apply(g, arguments);
+  };
+
+  /**
+   * inV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.inV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.inV.apply(g, arguments);
+  };
+
+  /**
+   * in_() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.in_ = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.in_.apply(g, arguments);
+  };
+
+  /**
+   * inject() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.inject = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.inject.apply(g, arguments);
+  };
+
+  /**
+   * is() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.is = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.is.apply(g, arguments);
+  };
+
+  /**
+   * key() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.key = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.key.apply(g, arguments);
+  };
+
+  /**
+   * label() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.label = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.label.apply(g, arguments);
+  };
+
+  /**
+   * limit() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.limit = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.limit.apply(g, arguments);
+  };
+
+  /**
+   * local() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.local = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.local.apply(g, arguments);
+  };
+
+  /**
+   * loops() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.loops = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.loops.apply(g, arguments);
+  };
+
+  /**
+   * map() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.map = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.map.apply(g, arguments);
+  };
+
+  /**
+   * mapKeys() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.mapKeys = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.mapKeys.apply(g, arguments);
+  };
+
+  /**
+   * mapValues() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.mapValues = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.mapValues.apply(g, arguments);
+  };
+
+  /**
+   * match() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.match = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.match.apply(g, arguments);
+  };
+
+  /**
+   * max() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.max = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.max.apply(g, arguments);
+  };
+
+  /**
+   * mean() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.mean = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.mean.apply(g, arguments);
+  };
+
+  /**
+   * min() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.min = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.min.apply(g, arguments);
+  };
+
+  /**
+   * not() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.not = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.not.apply(g, arguments);
+  };
+
+  /**
+   * optional() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.optional = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.optional.apply(g, arguments);
+  };
+
+  /**
+   * or() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.or = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.or.apply(g, arguments);
+  };
+
+  /**
+   * order() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.order = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.order.apply(g, arguments);
+  };
+
+  /**
+   * otherV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.otherV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.otherV.apply(g, arguments);
+  };
+
+  /**
+   * out() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.out = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.out.apply(g, arguments);
+  };
+
+  /**
+   * outE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.outE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.outE.apply(g, arguments);
+  };
+
+  /**
+   * outV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.outV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.outV.apply(g, arguments);
+  };
+
+  /**
+   * path() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.path = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.path.apply(g, arguments);
+  };
+
+  /**
+   * project() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.project = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.project.apply(g, arguments);
+  };
+
+  /**
+   * properties() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.properties = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.properties.apply(g, arguments);
+  };
+
+  /**
+   * property() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.property = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.property.apply(g, arguments);
+  };
+
+  /**
+   * propertyMap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.propertyMap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.propertyMap.apply(g, arguments);
+  };
+
+  /**
+   * range() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.range = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.range.apply(g, arguments);
+  };
+
+  /**
+   * repeat() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.repeat = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.repeat.apply(g, arguments);
+  };
+
+  /**
+   * sack() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sack = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sack.apply(g, arguments);
+  };
+
+  /**
+   * sample() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sample = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sample.apply(g, arguments);
+  };
+
+  /**
+   * select() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.select = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.select.apply(g, arguments);
+  };
+
+  /**
+   * sideEffect() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sideEffect = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sideEffect.apply(g, arguments);
+  };
+
+  /**
+   * simplePath() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.simplePath = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.simplePath.apply(g, arguments);
+  };
+
+  /**
+   * start() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.start = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.start.apply(g, arguments);
+  };
+
+  /**
+   * store() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.store = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.store.apply(g, arguments);
+  };
+
+  /**
+   * subgraph() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.subgraph = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.subgraph.apply(g, arguments);
+  };
+
+  /**
+   * sum() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sum = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sum.apply(g, arguments);
+  };
+
+  /**
+   * tail() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.tail = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.tail.apply(g, arguments);
+  };
+
+  /**
+   * timeLimit() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.timeLimit = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.timeLimit.apply(g, arguments);
+  };
+
+  /**
+   * times() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.times = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.times.apply(g, arguments);
+  };
+
+  /**
+   * to() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.to = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.to.apply(g, arguments);
+  };
+
+  /**
+   * toE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.toE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.toE.apply(g, arguments);
+  };
+
+  /**
+   * toV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.toV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.toV.apply(g, arguments);
+  };
+
+  /**
+   * tree() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.tree = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.tree.apply(g, arguments);
+  };
+
+  /**
+   * unfold() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.unfold = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.unfold.apply(g, arguments);
+  };
+
+  /**
+   * union() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.union = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.union.apply(g, arguments);
+  };
+
+  /**
+   * until() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.until = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.until.apply(g, arguments);
+  };
+
+  /**
+   * value() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.value = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.value.apply(g, arguments);
+  };
+
+  /**
+   * valueMap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.valueMap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.valueMap.apply(g, arguments);
+  };
+
+  /**
+   * values() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.values = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.values.apply(g, arguments);
+  };
+
+  /**
+   * where() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.where = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.where.apply(g, arguments);
+  };
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    GraphTraversal: GraphTraversal,
+    GraphTraversalSource: GraphTraversalSource,
+    statics: statics
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
new file mode 100644
index 0000000..5c9bf6c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -0,0 +1,395 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTraversalModule() {
+  "use strict";
+
+  function Traversal(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode;
+    this.traversers = null;
+    this.sideEffects = null;
+  }
+
+  /** @returns {Bytecode} */
+  Traversal.prototype.getBytecode = function () {
+    return this._bytecode;
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.list = function (callback) {
+    var self = this;
+    this._traversalStrategies.applyStrategies(this, function (err) {
+      if (err) {
+        return callback(err);
+      }
+      callback(err, self.traversers);
+    });
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.one = function (callback) {
+    this.list(function (err, result) {
+      callback(err, result ? result[0] : null);
+    });
+  };
+
+  /**
+   * Returns the Bytecode JSON representation of the traversal
+   * @returns {String}
+   */
+  Traversal.prototype.toString = function () {
+    return this._bytecode.toString();
+  };
+  
+  /**
+   * Represents an operation.
+   * @constructor
+   */
+  function P(operator, value, other) {
+    this.operator = operator;
+    this.value = value;
+    this.other = other;
+  }
+
+  /**
+   * Returns the string representation of the instance.
+   * @returns {string}
+   */
+  P.prototype.toString = function () {
+    if (this.other === undefined) {
+      return this.operator + '(' + this.value + ')';
+    }
+    return this.operator + '(' + this.value + ', ' + this.other + ')';
+  };
+
+  function createP(operator, args) {
+    args.unshift(null, operator);
+    return new (Function.prototype.bind.apply(P, args));
+  }
+
+  /** @param {...Object} args */
+  P.between = function (args) {
+    return createP('between', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.eq = function (args) {
+    return createP('eq', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.gt = function (args) {
+    return createP('gt', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.gte = function (args) {
+    return createP('gte', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.inside = function (args) {
+    return createP('inside', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.lt = function (args) {
+    return createP('lt', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.lte = function (args) {
+    return createP('lte', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.neq = function (args) {
+    return createP('neq', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.not = function (args) {
+    return createP('not', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.outside = function (args) {
+    return createP('outside', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.test = function (args) {
+    return createP('test', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.within = function (args) {
+    return createP('within', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.without = function (args) {
+    return createP('without', parseArgs.apply(null, arguments));
+  };
+
+  P.prototype.and = function (arg) {
+    return new P('and', this, arg);
+  };
+
+  P.prototype.or = function (arg) {
+    return new P('or', this, arg);
+  };
+
+  function Traverser(object, bulk) {
+    this.object = object;
+    this.bulk = bulk == undefined ? 1 : bulk;
+  }
+
+  function TraversalSideEffects() {
+
+  }
+
+  /**
+   * Creates a new instance of TraversalStrategies.
+   * @param {TraversalStrategies} [traversalStrategies]
+   * @constructor
+   */
+  function TraversalStrategies(traversalStrategies) {
+    /** @type {Array<TraversalStrategy>} */
+    this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
+  }
+
+  /** @param {TraversalStrategy} strategy */
+  TraversalStrategies.prototype.addStrategy = function (strategy) {
+    this.strategies.push(strategy);
+  };
+
+  /** @param {Traversal} traversal */
+  TraversalStrategies.prototype.applyStrategies = function (traversal) {
+    this.strategies.forEach(function eachStrategy(s) {
+      s.apply(traversal);
+    });
+  };
+
+  /**
+   * @abstract
+   * @constructor
+   */
+  function TraversalStrategy() {
+
+  }
+
+  /**
+   * @abstract
+   * @param {Traversal} traversal
+   */
+  TraversalStrategy.prototype.apply = function (traversal) {
+
+  };
+
+  /**
+   * Creates a new instance of Bytecode
+   * @param {Bytecode} [toClone]
+   * @constructor
+   */
+  function Bytecode(toClone) {
+    this._bindings = {};
+    if (!toClone) {
+      this.sourceInstructions = [];
+      this.stepInstructions = [];
+    }
+    else {
+      this.sourceInstructions = toClone.sourceInstructions.slice(0);
+      this.stepInstructions = toClone.sourceInstructions.slice(0);
+    }
+  }
+
+  /**
+   * Adds a new source instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addSource = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    this.sourceInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  /**
+   * Adds a new step instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addStep = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    this.stepInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  Bytecode.prototype._generateInstruction = function (name, values) {
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    return instruction;
+  };
+
+  /**
+   * Returns the JSON representation of the source and step instructions
+   * @returns {String}
+   */
+  Bytecode.prototype.toString = function () {
+    return (
+      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
+    );
+  };
+
+  Bytecode.prototype._convertToArgument = function (value) {
+    return value;
+  };
+
+  function toEnum(typeName, keys) {
+    var result = {};
+    keys.split(' ').forEach(function (k) {
+      if (k === k.toUpperCase()) {
+        k = k.toLowerCase();
+      }
+      result[k] = new EnumValue(typeName, k);
+    });
+    return result;
+  }
+
+  function EnumValue(typeName, elementName) {
+    this.typeName = typeName;
+    this.elementName = elementName;
+  }
+
+  /**
+   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
+   */
+  var enums = {};
+  enums.barrier = toEnum('Barrier', 'normSack');
+  enums.cardinality = toEnum('Cardinality', 'list set single');
+  enums.column = toEnum('Column', 'keys values');
+  enums.direction = toEnum('Direction', 'BOTH IN OUT');
+  enums.operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
+  enums.order = toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr');
+  enums.pop = toEnum('Pop', 'all first last');
+  enums.scope = toEnum('Scope', 'global local');
+  enums.t = toEnum('T', 'id key label value');
+
+  // Utility functions
+  /** @returns {Array} */
+  function parseArgs() {
+    return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+  }
+
+  /**
+   * @param {Array} arr
+   * @param {Function} fn
+   * @param {Function} [callback]
+   */
+  function eachSeries(arr, fn, callback) {
+    if (!Array.isArray(arr)) {
+      throw new TypeError('First parameter is not an Array');
+    }
+    callback = callback || noop;
+    var length = arr.length;
+    if (length === 0) {
+      return callback();
+    }
+    var sync;
+    var index = 1;
+    fn(arr[0], next);
+    if (sync === undefined) {
+      sync = false;
+    }
+
+    function next(err) {
+      if (err) {
+        return callback(err);
+      }
+      if (index >= length) {
+        return callback();
+      }
+      if (sync === undefined) {
+        sync = true;
+      }
+      if (sync) {
+        return process.nextTick(function () {
+          fn(arr[index++], next);
+        });
+      }
+      fn(arr[index++], next);
+    }
+  }
+
+  function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor;
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  }
+
+  var toExport = {
+    Bytecode: Bytecode,
+    EnumValue: EnumValue,
+    inherits: inherits,
+    P: P,
+    parseArgs: parseArgs,
+    Traversal: Traversal,
+    TraversalSideEffects: TraversalSideEffects,
+    TraversalStrategies: TraversalStrategies,
+    TraversalStrategy: TraversalStrategy,
+    Traverser: Traverser
+  };
+  Object.keys(enums).forEach(function (k) {
+    toExport[k] = enums[k];
+  });
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
new file mode 100644
index 0000000..7c48819
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -0,0 +1,146 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphModule() {
+  "use strict";
+
+  var gt = loadModule.call(this, '../process/graph-traversal.js');
+  var t = loadModule.call(this, '../process/traversal.js');
+  var inherits = t.inherits;
+
+  function Graph() {
+
+  }
+
+  /**
+   * Returns the graph traversal source.
+   * @returns {GraphTraversalSource}
+   */
+  Graph.prototype.traversal = function () {
+    return new gt.GraphTraversalSource(this, new t.TraversalStrategies());
+  };
+
+  Graph.prototype.toString = function () {
+    return 'graph[empty]';
+  };
+
+  function Element(id, label) {
+    this.id = id;
+    this.label = label;
+  }
+
+  /**
+   * Compares this instance to another and determines if they can be considered as equal.
+   * @param {Element} other
+   * @returns {boolean}
+   */
+  Element.prototype.equals = function (other) {
+    return (other instanceof Element) && this.id === other.id;
+  };
+
+  function Vertex(id, label, properties) {
+    Element.call(this, id, label);
+    this.properties = properties;
+  }
+
+  Vertex.prototype.toString = function () {
+    return 'v[' + this.id + ']';
+  };
+
+  inherits(Vertex, Element);
+
+  function Edge(id, outV, label, inV) {
+    Element.call(this, id, label);
+    this.outV = outV;
+    this.inV = inV;
+  }
+
+  inherits(Edge, Element);
+
+  Edge.prototype.toString = function () {
+    return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+  };
+
+  function VertexProperty(id, label, value) {
+    Element.call(this, id, label);
+    this.value = value;
+    this.key = this.label;
+  }
+
+  inherits(VertexProperty, Element);
+
+  VertexProperty.prototype.toString = function () {
+    return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+  };
+
+  function Property(key, value) {
+    this.key = key;
+    this.value = value;
+  }
+
+  Property.prototype.toString = function () {
+    return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+  };
+
+  Property.prototype.equals = function (other) {
+    return (other instanceof Property) && this.key === other.key && this.value === other.value;
+  };
+
+  /**
+   * Represents a walk through a graph as defined by a traversal.
+   * @param {Array} labels
+   * @param {Array} objects
+   * @constructor
+   */
+  function Path(labels, objects) {
+    this.labels = labels;
+    this.objects = objects;
+  }
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    Edge: Edge,
+    Graph: Graph,
+    Path: Path,
+    Property: Property,
+    Vertex: Vertex,
+    VertexProperty: VertexProperty
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
new file mode 100644
index 0000000..2dde340
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -0,0 +1,406 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function graphSerializerModule() {
+  "use strict";
+
+  var t = loadModule.call(this, '../../process/traversal.js');
+  var g = loadModule.call(this, '../graph.js');
+
+  /**
+   * A type serializer
+   * @typedef {Object} Serializer
+   * @property {Function} serialize
+   * @property {Function} deserialize
+   * @property {Function} [canBeUsedFor]
+   */
+
+  /**
+   * @const
+   * @private
+   */
+  var valueKey = '@value';
+
+  /**
+   * @const
+   * @private
+   */
+  var typeKey = '@type';
+
+  var deserializers = {
+    'g:Traverser': TraverserSerializer,
+    'g:Int32':  NumberSerializer,
+    'g:Int64':  NumberSerializer,
+    'g:Float':  NumberSerializer,
+    'g:Double': NumberSerializer,
+    'g:Vertex': VertexSerializer,
+    'g:Edge': EdgeSerializer,
+    'g:VertexProperty': VertexPropertySerializer,
+    'g:Property': PropertySerializer,
+    'g:Path': PathSerializer
+  };
+
+  var serializers = [
+    NumberSerializer,
+    BytecodeSerializer,
+    TraverserSerializer,
+    PSerializer,
+    LambdaSerializer,
+    EnumSerializer
+  ];
+
+  /**
+   * GraphSON Writer
+   * @param {Object} [options]
+   * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+   * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+   * @constructor
+   */
+  function GraphSONWriter(options) {
+    this._options = options || {};
+    // Create instance of the default serializers
+    this._serializers = serializers.map(function (serializerConstructor) {
+      var s = new serializerConstructor();
+      s.writer = this;
+      return s;
+    }, this);
+    var customSerializers = this._options.serializers || {};
+    Object.keys(customSerializers).forEach(function (key) {
+      var s = customSerializers[key];
+      if (!s.serialize) {
+        return;
+      }
+      s.writer = this;
+      // Insert custom serializers first
+      this._serializers.unshift(s);
+    }, this);
+  }
+
+  GraphSONWriter.prototype.adaptObject = function (value) {
+    var s;
+    if (Array.isArray(value)) {
+      return value.map(function (item) {
+        return this.adaptObject(item);
+      }, this);
+    }
+    for (var i = 0; i < this._serializers.length; i++) {
+      var currentSerializer = this._serializers[i];
+      if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+        s = currentSerializer;
+        break;
+      }
+    }
+    if (s) {
+      return s.serialize(value);
+    }
+    // Default (strings / objects / ...)
+    return value;
+  };
+
+  /**
+   * Returns the GraphSON representation of the provided object instance.
+   * @param {Object} obj
+   * @returns {String}
+   */
+  GraphSONWriter.prototype.write = function (obj) {
+    return JSON.stringify(this.adaptObject(obj));
+  };
+
+  /**
+   * GraphSON Reader
+   * @param {Object} [options]
+   * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+   * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+   * @constructor
+   */
+  function GraphSONReader(options) {
+    this._options = options || {};
+    this._deserializers = {};
+    Object.keys(deserializers).forEach(function (typeName) {
+      var serializerConstructor = deserializers[typeName];
+      var s = new serializerConstructor();
+      s.reader = this;
+      this._deserializers[typeName] = s;
+    }, this);
+    if (this._options.serializers) {
+      var customSerializers = this._options.serializers || {};
+      Object.keys(customSerializers).forEach(function (key) {
+        var s = customSerializers[key];
+        if (!s.deserialize) {
+          return;
+        }
+        s.reader = this;
+        this._deserializers[key] = s;
+      }, this);
+    }
+  }
+
+  GraphSONReader.prototype.read = function (obj) {
+    if (Array.isArray(obj)) {
+      return obj.map(function mapEach(item) {
+        return this.read(item);
+      }, this);
+    }
+    var type = obj[typeKey];
+    if (type) {
+      var d = this._deserializers[type];
+      if (d) {
+        // Use type serializer
+        return d.deserialize(obj);
+      }
+      return obj[valueKey];
+    }
+    if (obj && typeof obj === 'object' && obj.constructor === Object) {
+      return this._deserializeObject(obj);
+    }
+    // Default (for boolean, number and other scalars)
+    return obj;
+  };
+
+  GraphSONReader.prototype._deserializeObject = function (obj) {
+    var keys = Object.keys(obj);
+    var result = {};
+    for (var i = 0; i < keys.length; i++) {
+      result[keys[i]] = this.read(obj[keys[i]]);
+    }
+    return result;
+  };
+
+  function NumberSerializer() {
+
+  }
+
+  NumberSerializer.prototype.serialize = function (item) {
+    return item;
+  };
+
+  NumberSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return parseFloat(value);
+  };
+
+  NumberSerializer.prototype.canBeUsedFor = function (value) {
+    return (typeof value === 'number');
+  };
+
+  function BytecodeSerializer() {
+
+  }
+
+  BytecodeSerializer.prototype.serialize = function (item) {
+    var bytecode = item;
+    if (item instanceof t.Traversal) {
+      bytecode = item.getBytecode();
+    }
+    var result = {};
+    result[typeKey] = 'g:Bytecode';
+    var resultValue = result[valueKey] = {};
+    var sources = this._serializeInstructions(bytecode.sourceInstructions);
+    if (sources) {
+      resultValue['source'] = sources;
+    }
+    var steps = this._serializeInstructions(bytecode.stepInstructions);
+    if (steps) {
+      resultValue['step'] = steps;
+    }
+    return result;
+  };
+
+  BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
+    if (instructions.length === 0) {
+      return null;
+    }
+    var result = new Array(instructions.length);
+    result[0] = instructions[0];
+    for (var i = 1; i < instructions.length; i++) {
+      result[i] = this.writer.adaptObject(instructions[i]);
+    }
+    return result;
+  };
+
+  BytecodeSerializer.prototype.canBeUsedFor = function (value) {
+    return (value instanceof t.Bytecode) || (value instanceof t.Traversal);
+  };
+
+  function PSerializer() {
+
+  }
+
+  /** @param {P} item */
+  PSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:P';
+    var resultValue = result[valueKey] = {
+      'predicate': item.operator
+    };
+    if (item.other == undefined) {
+      resultValue['value'] = this.writer.adaptObject(item.value);
+    }
+    else {
+      resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+    }
+    return result;
+  };
+
+  PSerializer.prototype.canBeUsedFor = function (value) {
+    return (value instanceof t.P);
+  };
+
+  function LambdaSerializer() {
+
+  }
+
+  /** @param {Function} item */
+  LambdaSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:Lambda';
+    result[valueKey] = {
+      'arguments': item.length,
+      'language': 'gremlin-javascript',
+      'script': item.toString()
+    };
+    return result;
+  };
+
+  LambdaSerializer.prototype.canBeUsedFor = function (value) {
+    return (typeof value === 'function');
+  };
+
+  function EnumSerializer() {
+
+  }
+
+  /** @param {EnumValue} item */
+  EnumSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:' + item.typeName;
+    result[valueKey] = item.elementName;
+    return result;
+  };
+
+  EnumSerializer.prototype.canBeUsedFor = function (value) {
+    return value && value.typeName && value instanceof t.EnumValue;
+  };
+
+  function TraverserSerializer() {
+
+  }
+
+  /** @param {Traverser} item */
+  TraverserSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:Traverser';
+    result[valueKey] = {
+      'value': this.writer.adaptObject(item.object),
+      'bulk': this.writer.adaptObject(item.bulk)
+    };
+    return result;
+  };
+
+  TraverserSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+  };
+
+  TraverserSerializer.prototype.canBeUsedFor = function (value) {
+    return (value instanceof t.Traverser);
+  };
+
+  function VertexSerializer() {
+
+  }
+
+  VertexSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+  };
+
+  function VertexPropertySerializer() {
+
+  }
+
+  VertexPropertySerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+  };
+
+  function PropertySerializer() {
+
+  }
+
+  PropertySerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.Property(
+      value['key'],
+      this.reader.read(value['value']));
+  };
+
+  function EdgeSerializer() {
+
+  }
+
+  EdgeSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.Edge(
+      this.reader.read(value['id']),
+      this.reader.read(value['outV']),
+      value['label'],
+      this.reader.read(value['inV'])
+    );
+  };
+
+  function PathSerializer() {
+
+  }
+
+  PathSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    var objects = value['objects'].map(function objectMapItem(o) {
+      return this.reader.read(o);
+    }, this);
+    return new g.Path(this.reader.read(value['labels']), objects);
+  };
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    GraphSONWriter: GraphSONWriter,
+    GraphSONReader: GraphSONReader
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
new file mode 100644
index 0000000..858ed06
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
@@ -0,0 +1,84 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineHelperModule() {
+  "use strict";
+
+  var assert = {
+    ok: function (condition, message) {
+      if (!condition) {
+        throw new AssertError(message || (condition + ' == true'));
+      }
+    },
+    strictEqual: function (val1, val2, message) {
+      if (val1 !== val2) {
+        throw new AssertError(message || (val1 + ' === ' + val2));
+      }
+    }
+  };
+
+  function loadLibModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      moduleName = '../lib/' + moduleName;
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined' && typeof java !== 'undefined') {
+      moduleName = __DIR__ + '../../../main/javascript/gremlin-javascript/' + moduleName;
+      var path = new java.io.File(moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  function AssertError(message) {
+    Error.call(this, message);
+    this.stack = (new Error(message)).stack;
+    if (typeof print !== 'undefined') {
+      print(this.stack);
+    }
+  }
+
+  inherits(AssertError, Error);
+
+  function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor;
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  }
+  var toExport = {
+    assert: assert,
+    loadLibModule: loadLibModule
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
new file mode 100644
index 0000000..6edb323
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+  "use strict";
+
+  var helper = loadModule.call(this, './helper.js');
+  var assert = helper.assert;
+  var glvModule = helper.loadLibModule.call(this, './index.js');
+
+  [
+    function testExports() {
+      assert.ok(glvModule);
+
+      assert.ok(glvModule.process);
+      assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
+      assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
+      assert.strictEqual(typeof glvModule.process.inherits, 'function');
+      assert.strictEqual(typeof glvModule.process.P, 'function');
+      assert.strictEqual(typeof glvModule.process.parseArgs, 'function');
+      assert.strictEqual(typeof glvModule.process.Traversal, 'function');
+      assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
+      assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
+      assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
+      assert.strictEqual(typeof glvModule.process.Traverser, 'function');
+      assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
+      assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+      assert.ok(glvModule.process.statics);
+
+      assert.ok(glvModule.structure);
+      assert.ok(glvModule.structure.io);
+      assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
+      assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
+      assert.strictEqual(typeof glvModule.structure.Edge, 'function');
+      assert.strictEqual(typeof glvModule.structure.Graph, 'function');
+      assert.strictEqual(typeof glvModule.structure.Path, 'function');
+      assert.strictEqual(typeof glvModule.structure.Property, 'function');
+      assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
+      assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
+
+      assert.ok(glvModule.driver);
+      assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
+      assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
+      assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
+    }
+  ].forEach(function (testCase) {
+    testCase.call(null);
+  });
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      return load(__DIR__ + moduleName);
+    }
+    throw new Error('No module loader was found');
+  }
+}).call(this)
\ No newline at end of file


[11/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Add option for no default method generation on GremlinDsl

Posted by sp...@apache.org.
TINKERPOP-786 Add option for no default method generation on GremlinDsl


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7790716a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7790716a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7790716a

Branch: refs/heads/TINKERPOP-1489
Commit: 7790716acac24d8c7d274c5a0b53f5440887be17
Parents: f437275
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Apr 29 06:40:59 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../process/traversal/dsl/GremlinDsl.java       | 13 +++
 .../traversal/dsl/GremlinDslProcessor.java      | 88 ++++++++++----------
 .../traversal/dsl/GremlinDslProcessorTest.java  |  8 ++
 .../dsl/SocialNoDefaultMethodsTraversalDsl.java | 37 ++++++++
 4 files changed, 104 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7790716a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
index 15b93d6..df96007 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
@@ -60,4 +60,17 @@ public @interface GremlinDsl {
      * this value is not supplied the generated "source" will simply extend from {@link GraphTraversalSource}.
      */
     public String traversalSource() default "org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource";
+
+    /**
+     * When set to {@code true}, which is the default, the following methods will be generated to the DSL
+     * implementation of the {@link GraphTraversalSource}:
+     *
+     * <ul>
+     *   <li>{@link GraphTraversalSource#addV()}</li>
+     *   <li>{@link GraphTraversalSource#addV(String)}</li>
+     *   <li>{@link GraphTraversalSource#V(Object...)}</li>
+     *   <li>{@link GraphTraversalSource#E(Object...)}</li>
+     * </ul>
+     */
+    public boolean generateDefaultMethods() default true;
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7790716a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 9e23410..f8a3266 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -177,48 +177,50 @@ public class GremlinDslProcessor extends AbstractProcessor {
             }
         }
 
-        // override methods that return GraphTraversal
-        traversalSourceClass.addMethod(MethodSpec.methodBuilder("addV")
-                .addModifiers(Modifier.PUBLIC)
-                .addAnnotation(Override.class)
-                .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.getBytecode().addStep($T.addV)", GraphTraversal.Symbols.class)
-                .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
-                .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, null))", ctx.traversalClassName, AddVertexStartStep.class)
-                .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
-                .build());
-        traversalSourceClass.addMethod(MethodSpec.methodBuilder("addV")
-                .addModifiers(Modifier.PUBLIC)
-                .addAnnotation(Override.class)
-                .addParameter(String.class, "label")
-                .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.getBytecode().addStep($T.addV, label)", GraphTraversal.Symbols.class)
-                .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
-                .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, label))", ctx.traversalClassName, AddVertexStartStep.class)
-                .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
-                .build());
-        traversalSourceClass.addMethod(MethodSpec.methodBuilder("V")
-                .addModifiers(Modifier.PUBLIC)
-                .addAnnotation(Override.class)
-                .addParameter(Object[].class, "vertexIds")
-                .varargs(true)
-                .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.getBytecode().addStep($T.V, vertexIds)", GraphTraversal.Symbols.class)
-                .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
-                .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, $T.class, true, vertexIds))", ctx.traversalClassName, GraphStep.class, Vertex.class)
-                .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
-                .build());
-        traversalSourceClass.addMethod(MethodSpec.methodBuilder("E")
-                .addModifiers(Modifier.PUBLIC)
-                .addAnnotation(Override.class)
-                .addParameter(Object[].class, "edgeIds")
-                .varargs(true)
-                .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.getBytecode().addStep($T.E, edgeIds)", GraphTraversal.Symbols.class)
-                .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
-                .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, $T.class, true, edgeIds))", ctx.traversalClassName, GraphStep.class, Edge.class)
-                .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Edge.class), ClassName.get(Edge.class)))
-                .build());
+        if (ctx.generateDefaultMethods) {
+            // override methods that return GraphTraversal
+            traversalSourceClass.addMethod(MethodSpec.methodBuilder("addV")
+                    .addModifiers(Modifier.PUBLIC)
+                    .addAnnotation(Override.class)
+                    .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
+                    .addStatement("clone.getBytecode().addStep($T.addV)", GraphTraversal.Symbols.class)
+                    .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
+                    .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, null))", ctx.traversalClassName, AddVertexStartStep.class)
+                    .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
+                    .build());
+            traversalSourceClass.addMethod(MethodSpec.methodBuilder("addV")
+                    .addModifiers(Modifier.PUBLIC)
+                    .addAnnotation(Override.class)
+                    .addParameter(String.class, "label")
+                    .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
+                    .addStatement("clone.getBytecode().addStep($T.addV, label)", GraphTraversal.Symbols.class)
+                    .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
+                    .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, label))", ctx.traversalClassName, AddVertexStartStep.class)
+                    .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
+                    .build());
+            traversalSourceClass.addMethod(MethodSpec.methodBuilder("V")
+                    .addModifiers(Modifier.PUBLIC)
+                    .addAnnotation(Override.class)
+                    .addParameter(Object[].class, "vertexIds")
+                    .varargs(true)
+                    .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
+                    .addStatement("clone.getBytecode().addStep($T.V, vertexIds)", GraphTraversal.Symbols.class)
+                    .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
+                    .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, $T.class, true, vertexIds))", ctx.traversalClassName, GraphStep.class, Vertex.class)
+                    .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
+                    .build());
+            traversalSourceClass.addMethod(MethodSpec.methodBuilder("E")
+                    .addModifiers(Modifier.PUBLIC)
+                    .addAnnotation(Override.class)
+                    .addParameter(Object[].class, "edgeIds")
+                    .varargs(true)
+                    .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
+                    .addStatement("clone.getBytecode().addStep($T.E, edgeIds)", GraphTraversal.Symbols.class)
+                    .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
+                    .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, $T.class, true, edgeIds))", ctx.traversalClassName, GraphStep.class, Edge.class)
+                    .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Edge.class), ClassName.get(Edge.class)))
+                    .build());
+        }
 
         final JavaFile traversalSourceJavaFile = JavaFile.builder(ctx.packageName, traversalSourceClass.build()).build();
         traversalSourceJavaFile.writeTo(filer);
@@ -393,12 +395,14 @@ public class GremlinDslProcessor extends AbstractProcessor {
         private final ClassName defaultTraversalClassName;
         private final ClassName graphTraversalAdminClassName;
         private final TypeElement traversalSourceDslType;
+        private final boolean generateDefaultMethods;
 
         public Context(final TypeElement dslElement) {
             annotatedDslType = dslElement;
 
             // gets the annotation on the dsl class/interface
             GremlinDsl gremlinDslAnnotation = dslElement.getAnnotation(GremlinDsl.class);
+            generateDefaultMethods = gremlinDslAnnotation.generateDefaultMethods();
 
             traversalSourceDslType = elementUtils.getTypeElement(gremlinDslAnnotation.traversalSource());
             packageName = getPackageName(dslElement, gremlinDslAnnotation);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7790716a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
index d0d7d6f..982ec5b 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
@@ -56,4 +56,12 @@ public class GremlinDslProcessorTest {
                 .processedWith(new GremlinDslProcessor())
                 .compilesWithoutError();
     }
+
+    @Test
+    public void shouldCompileWithNoDefaultMethods() {
+        ASSERT.about(javaSource())
+                .that(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialNoDefaultMethodsTraversalDsl.java")))
+                .processedWith(new GremlinDslProcessor())
+                .compilesWithoutError();
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7790716a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialNoDefaultMethodsTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialNoDefaultMethodsTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialNoDefaultMethodsTraversalDsl.java
new file mode 100644
index 0000000..4eb15bd
--- /dev/null
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialNoDefaultMethodsTraversalDsl.java
@@ -0,0 +1,37 @@
+/*
+ * 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.process.traversal.dsl;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@GremlinDsl(generateDefaultMethods = false)
+public interface SocialNoDefaultMethodsTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
+    public default GraphTraversal<S, Vertex> knows(final String personName) {
+        return out("knows").hasLabel("person").has("name", personName);
+    }
+
+    public default <E2 extends Number> GraphTraversal<S, E2> meanAgeOfFriends() {
+        return out("knows").hasLabel("person").values("age").mean();
+    }
+}


[45/50] [abbrv] tinkerpop git commit: Filter out __() static method

Posted by sp...@apache.org.
Filter out __() static method


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/aed528cb
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/aed528cb
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/aed528cb

Branch: refs/heads/TINKERPOP-1489
Commit: aed528cb5139e1eaa1b26697efa1e5543cd1e635
Parents: ae93524
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Oct 19 16:03:45 2016 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 .../javascript/GraphTraversalSourceGenerator.groovy       |  1 +
 .../gremlin-javascript/process/graph-traversal.js         | 10 ----------
 2 files changed, 1 insertion(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aed528cb/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index a8217e2..0ae6079 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -195,6 +195,7 @@ class GraphTraversalSourceGenerator {
         __.class.getMethods().
                 findAll { GraphTraversal.class.equals(it.returnType) }.
                 findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { !it.name.equals("__") }.
                 collect { SymbolHelper.toJs(it.name) }.
                 unique().
                 sort { a, b -> a <=> b }.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aed528cb/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index 663a24d..7f36e59 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -1080,16 +1080,6 @@
   };
 
   /**
-   * __() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.__ = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.__.apply(g, arguments);
-  };
-
-  /**
    * addE() static method
    * @param {...Object} args
    * @returns {GraphTraversal}


[15/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Improved TraversalSource for testing purposes

Posted by sp...@apache.org.
TINKERPOP-786 Improved TraversalSource for testing purposes


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e661359a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e661359a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e661359a

Branch: refs/heads/TINKERPOP-1489
Commit: e661359a9a760bb398b590c9c1bffa8268463f78
Parents: b47b25c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 13:52:42 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:51 2017 -0400

----------------------------------------------------------------------
 .../dsl/SocialPackageTraversalSourceDsl.java         | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e661359a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
index 143a5c9..64859eb 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
@@ -44,11 +44,16 @@ public class SocialPackageTraversalSourceDsl extends GraphTraversalSource {
         super(graph);
     }
 
-    public GraphTraversal<Vertex, Vertex> persons() {
-        final GraphTraversalSource clone = this.clone();
+    public GraphTraversal<Vertex, Vertex> persons(String... names) {
+        GraphTraversalSource clone = this.clone();
+
         clone.getBytecode().addStep(GraphTraversal.Symbols.V);
-        clone.getBytecode().addStep(GraphTraversal.Symbols.hasLabel, "person");
-        final GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
-        return TraversalHelper.addHasContainer(traversal.addStep(new GraphStep<>(traversal, Vertex.class, true)), new HasContainer(T.label.getAccessor(), P.eq("person")));
+        GraphTraversal<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
+        traversal.asAdmin().addStep(new GraphStep<>(traversal.asAdmin(), Vertex.class, true));
+
+        traversal = traversal.hasLabel("person");
+        if (names.length > 0) traversal = traversal.has("name", P.within(names));
+
+        return traversal;
     }
 }


[24/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Made python DSL example like the java example

Posted by sp...@apache.org.
TINKERPOP-786 Made python DSL example like the java example


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5e09caf1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5e09caf1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5e09caf1

Branch: refs/heads/TINKERPOP-1489
Commit: 5e09caf175e8c89695718a4987bff8fd241f8147
Parents: a3d42d5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 11 08:55:51 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 gremlin-python/src/main/jython/tests/process/test_dsl.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5e09caf1/gremlin-python/src/main/jython/tests/process/test_dsl.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_dsl.py b/gremlin-python/src/main/jython/tests/process/test_dsl.py
index 92196fe..04313ab 100644
--- a/gremlin-python/src/main/jython/tests/process/test_dsl.py
+++ b/gremlin-python/src/main/jython/tests/process/test_dsl.py
@@ -57,16 +57,21 @@ class SocialTraversalSource(GraphTraversalSource):
         super(SocialTraversalSource, self).__init__(*args, **kwargs)
         self.graph_traversal = SocialTraversal
 
-    def persons(self):
+    def persons(self, *args):
         traversal = self.get_graph_traversal()
         traversal.bytecode.add_step("V")
         traversal.bytecode.add_step("hasLabel", "person")
+
+        if len(args) > 0:
+            traversal.bytecode.add_step("has", "name", P.within(args))
+
         return traversal
 
 
 def test_dsl(remote_connection):
     social = Graph().traversal(SocialTraversalSource).withRemote(remote_connection)
-    assert social.V().has("name", "marko").knows("josh").next()
-    assert social.V().has("name", "marko").youngestFriendsAge().next() == 27
+    assert social.persons("marko").knows("josh").next()
+    assert social.persons("marko").youngestFriendsAge().next() == 27
     assert social.persons().count().next() == 4
+    assert social.persons("marko", "josh").count().next() == 2
     assert social.persons().filter(___.createdAtLeast(2)).count().next() == 1


[28/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Refactored the processor a bit.

Posted by sp...@apache.org.
TINKERPOP-786 Refactored the processor a bit.

Trying to get this guy more organized. Lots of duplicate code to remove still.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/fbf8f0df
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fbf8f0df
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fbf8f0df

Branch: refs/heads/TINKERPOP-1489
Commit: fbf8f0dffbbc332ff15171d1fced011d4a66e805
Parents: 404ee8c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 12 08:16:33 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 .../traversal/dsl/GremlinDslProcessor.java      | 48 ++++++++++----------
 1 file changed, 23 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fbf8f0df/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 04e59b4..1717053 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -135,10 +135,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .build());
 
         // process the methods of the GremlinDsl annotated class
-        for (Element element : ctx.annotatedDslType.getEnclosedElements()) {
-            if (element.getKind() != ElementKind.METHOD) continue;
-
-            final ExecutableElement templateMethod = (ExecutableElement) element;
+        for (ExecutableElement templateMethod : findMethodsOfElement(ctx.annotatedDslType)) {
             final String methodName = templateMethod.getSimpleName().toString();
 
             final TypeName returnType = getReturnTypeDefinition(ctx.traversalClassName, templateMethod);
@@ -150,8 +147,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
             templateMethod.getTypeParameters().forEach(tp -> methodToAdd.addTypeVariable(TypeVariableName.get(tp)));
 
             // might have to deal with an "S" (in __ it's usually an "A") - how to make this less bound to that convention?
-            final DeclaredType returnTypeMirror = (DeclaredType) templateMethod.getReturnType();
-            final List<? extends TypeMirror> returnTypeArguments = returnTypeMirror.getTypeArguments();
+            final List<? extends TypeMirror> returnTypeArguments = getTypeArguments(templateMethod);
             returnTypeArguments.stream().filter(rtm -> rtm instanceof TypeVariable).forEach(rtm -> {
                 if (((TypeVariable) rtm).asElement().getSimpleName().contentEquals("S"))
                     methodToAdd.addTypeVariable(TypeVariableName.get(((TypeVariable) rtm).asElement().getSimpleName().toString()));
@@ -182,10 +178,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         // use methods from __ to template them into the DSL __
         final Element anonymousTraversal = elementUtils.getTypeElement(__.class.getCanonicalName());
-        for (Element element : anonymousTraversal.getEnclosedElements()) {
-            if (element.getKind() != ElementKind.METHOD) continue;
-
-            final ExecutableElement templateMethod = (ExecutableElement) element;
+        for (ExecutableElement templateMethod : findMethodsOfElement(anonymousTraversal)) {
             final String methodName = templateMethod.getSimpleName().toString();
 
             // ignore start() from __ - that's not proxied
@@ -258,7 +251,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         // override methods to return a the DSL TraversalSource. find GraphTraversalSource class somewhere in the hierarchy
         final Element tinkerPopsGraphTraversalSource = findClassAsElement(graphTraversalSourceElement, GraphTraversalSource.class);
-        for (Element elementOfGraphTraversalSource : tinkerPopsGraphTraversalSource.getEnclosedElements()) {
+        for (ExecutableElement elementOfGraphTraversalSource : findMethodsOfElement(tinkerPopsGraphTraversalSource)) {
             // first copy/override methods that return a GraphTraversalSource so that we can instead return
             // the DSL TraversalSource class.
             tryConstructMethod(elementOfGraphTraversalSource, ctx.traversalSourceClassName, "",
@@ -269,11 +262,8 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         // override methods that return GraphTraversal that come from the user defined extension of GraphTraversal
         if (!graphTraversalSourceElement.getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())) {
-            for (Element elementOfGraphTraversalSource : graphTraversalSourceElement.getEnclosedElements()) {
-                if (elementOfGraphTraversalSource.getKind() != ElementKind.METHOD) continue;
-
-                final ExecutableElement templateMethod = (ExecutableElement) elementOfGraphTraversalSource;
-                final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(elementOfGraphTraversalSource.getSimpleName().toString())
+            for (ExecutableElement templateMethod : findMethodsOfElement(graphTraversalSourceElement)) {
+                final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(templateMethod.getSimpleName().toString())
                         .addModifiers(Modifier.PUBLIC)
                         .addAnnotation(Override.class);
 
@@ -295,7 +285,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
                 body = body + ").asAdmin())";
                 methodToAdd.addStatement("$T clone = this.clone()", ctx.traversalSourceClassName)
-                        .addStatement(body, ctx.defaultTraversalClassName, elementOfGraphTraversalSource.getSimpleName())
+                        .addStatement(body, ctx.defaultTraversalClassName, templateMethod.getSimpleName())
                         .returns(getReturnTypeDefinition(ctx.traversalClassName, templateMethod));
 
                 traversalSourceClass.addMethod(methodToAdd.build());
@@ -420,15 +410,15 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addSuperinterface(TypeName.get(ctx.annotatedDslType.asType()));
 
         // process the methods of the GremlinDsl annotated class
-        for (Element elementOfDsl : ctx.annotatedDslType.getEnclosedElements()) {
-            tryConstructMethod(elementOfDsl, ctx.traversalClassName, ctx.dslName, null,
+        for (ExecutableElement templateMethod : findMethodsOfElement(ctx.annotatedDslType)) {
+            tryConstructMethod(templateMethod, ctx.traversalClassName, ctx.dslName, null,
                     Modifier.PUBLIC, Modifier.DEFAULT).ifPresent(traversalInterface::addMethod);
         }
 
         // process the methods of GraphTraversal
         final TypeElement graphTraversalElement = elementUtils.getTypeElement(GraphTraversal.class.getCanonicalName());
-        for (Element elementOfGraphTraversal : graphTraversalElement.getEnclosedElements()) {
-            tryConstructMethod(elementOfGraphTraversal, ctx.traversalClassName, ctx.dslName,
+        for (ExecutableElement templateMethod : findMethodsOfElement(graphTraversalElement)) {
+            tryConstructMethod(templateMethod, ctx.traversalClassName, ctx.dslName,
                     e -> e.getSimpleName().contentEquals("asAdmin") || e.getSimpleName().contentEquals("iterate"),
                     Modifier.PUBLIC, Modifier.DEFAULT)
                     .ifPresent(traversalInterface::addMethod);
@@ -450,8 +440,6 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
     private Optional<MethodSpec> tryConstructMethod(final Element element, final ClassName returnClazz, final String parent,
                                                     final Predicate<ExecutableElement> ignore, final Modifier... modifiers) {
-        if (element.getKind() != ElementKind.METHOD) return Optional.empty();
-
         final ExecutableElement templateMethod = (ExecutableElement) element;
         final String methodName = templateMethod.getSimpleName().toString();
 
@@ -490,8 +478,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
     }
 
     private TypeName getReturnTypeDefinition(final ClassName returnClazz, final ExecutableElement templateMethod) {
-        final DeclaredType returnTypeMirror = (DeclaredType) templateMethod.getReturnType();
-        final List<? extends TypeMirror> returnTypeArguments = returnTypeMirror.getTypeArguments();
+        final List<? extends TypeMirror> returnTypeArguments = getTypeArguments(templateMethod);
 
         // build a return type with appropriate generic declarations (if such declarations are present)
         return returnTypeArguments.isEmpty() ?
@@ -508,6 +495,17 @@ public class GremlinDslProcessor extends AbstractProcessor {
             throw new ProcessorException(dslElement, "The interface %s is not public.", typeElement.getQualifiedName());
     }
 
+    private List<ExecutableElement> findMethodsOfElement(final Element element) {
+        return element.getEnclosedElements().stream()
+                .filter(ee -> ee.getKind() == ElementKind.METHOD)
+                .map(ee -> (ExecutableElement) ee).collect(Collectors.toList());
+    }
+
+    private List<? extends TypeMirror> getTypeArguments(final ExecutableElement templateMethod) {
+        final DeclaredType returnTypeMirror = (DeclaredType) templateMethod.getReturnType();
+        return returnTypeMirror.getTypeArguments();
+    }
+
     private class Context {
         private final TypeElement annotatedDslType;
         private final String packageName;


[39/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Improved flexbility of handling __ for DSLs in java

Posted by sp...@apache.org.
TINKERPOP-786 Improved flexbility of handling __ for DSLs in java


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d6b0122b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d6b0122b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d6b0122b

Branch: refs/heads/TINKERPOP-1489
Commit: d6b0122b55ebaf4fc91c3c0a0139ca72984a1834
Parents: 651c1c6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 26 07:26:30 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 07:26:30 2017 -0400

----------------------------------------------------------------------
 .../gremlin/process/traversal/dsl/GremlinDslProcessor.java    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d6b0122b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 5088d21..470dd4b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -178,7 +178,12 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 methodToAdd.varargs(true);
                 methodToAdd.addStatement("return inject(starts)", methodName);
             } else {
-                addMethodBody(methodToAdd, templateMethod, "return __.<A>start().$L(", ")", methodName);
+                if (templateMethod.getTypeParameters().isEmpty()) {
+                    final List<? extends TypeMirror> types = getTypeArguments(templateMethod);
+                    addMethodBody(methodToAdd, templateMethod, "return __.<$T>start().$L(", ")", types.get(0), methodName);
+                } else {
+                    addMethodBody(methodToAdd, templateMethod, "return __.<A>start().$L(", ")", methodName);
+                }
             }
 
             anonymousClass.addMethod(methodToAdd.build());


[44/50] [abbrv] tinkerpop git commit: Graph, traversalStrategies and graph as Traversal properties

Posted by sp...@apache.org.
Graph, traversalStrategies and graph as Traversal properties

Expose those properties as in the Python GLV and the Java implementation. Previously, those properties where exposed using the private notation (ie: _graph).


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ae93524a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ae93524a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ae93524a

Branch: refs/heads/TINKERPOP-1489
Commit: ae93524a9ec82ac3b9b5c8cdf5bc40aa2f78ebb5
Parents: b0454c3
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Oct 18 16:22:23 2016 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 .../GraphTraversalSourceGenerator.groovy        |  23 +-
 .../javascript/TraversalSourceGenerator.groovy  |  12 +-
 .../process/graph-traversal.js                  | 253 ++++++++++---------
 .../gremlin-javascript/process/traversal.js     |  12 +-
 4 files changed, 151 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae93524a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index b569292..a8217e2 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -80,9 +80,9 @@ class GraphTraversalSourceGenerator {
    * @constructor
    */
   function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode || new Bytecode();
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode || new Bytecode();
   }
 
   /**
@@ -90,9 +90,9 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
   };
 
   /**
@@ -100,7 +100,7 @@ class GraphTraversalSourceGenerator {
    * @returns {string}
    */
   GraphTraversalSource.prototype.toString = function () {
-    return 'graphtraversalsource[' + this._graph.toString() + ']';
+    return 'graphtraversalsource[' + this.graph.toString() + ']';
   };
 """)
         GraphTraversalSource.getMethods(). // SOURCE STEPS
@@ -122,8 +122,8 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.${method} = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 """)
                 }
@@ -141,8 +141,8 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.${method} = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 """)
                 }
@@ -153,6 +153,7 @@ class GraphTraversalSourceGenerator {
                 """
   /**
    * Represents a graph traversal.
+   * @extends Traversal
    * @constructor
    */
   function GraphTraversal(graph, traversalStrategies, bytecode) {
@@ -175,7 +176,7 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.${method} = function (args) {
-    this._bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
     return this;
   };
 """)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae93524a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index 5b07a32..46f65a4 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -61,22 +61,22 @@ class TraversalSourceGenerator {
   "use strict";
 
   function Traversal(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode;
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode;
     this.traversers = null;
     this.sideEffects = null;
   }
 
   /** @returns {Bytecode} */
   Traversal.prototype.getBytecode = function () {
-    return this._bytecode;
+    return this.bytecode;
   };
 
   /** @param {Function} callback */
   Traversal.prototype.list = function (callback) {
     var self = this;
-    this._traversalStrategies.applyStrategies(this, function (err) {
+    this.traversalStrategies.applyStrategies(this, function (err) {
       if (err) {
         return callback(err);
       }
@@ -96,7 +96,7 @@ class TraversalSourceGenerator {
    * @returns {String}
    */
   Traversal.prototype.toString = function () {
-    return this._bytecode.toString();
+    return this.bytecode.toString();
   };
   """);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae93524a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index 1a6356b..663a24d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -37,9 +37,9 @@
    * @constructor
    */
   function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode || new Bytecode();
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode || new Bytecode();
   }
 
   /**
@@ -47,9 +47,9 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
   };
 
   /**
@@ -57,7 +57,7 @@
    * @returns {string}
    */
   GraphTraversalSource.prototype.toString = function () {
-    return 'graphtraversalsource[' + this._graph.toString() + ']';
+    return 'graphtraversalsource[' + this.graph.toString() + ']';
   };
 
   /**
@@ -66,8 +66,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withBulk = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -76,8 +76,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withComputer = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -86,8 +86,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withPath = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withPath', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -96,8 +96,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withSack = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withSack', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -106,8 +106,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withSideEffect = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -116,8 +116,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withStrategies = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -126,8 +126,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withoutStrategies = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -136,8 +136,8 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.E = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('E', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -146,8 +146,8 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.V = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('V', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -156,8 +156,8 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.addV = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('addV', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -166,12 +166,13 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.inject = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('inject', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
    * Represents a graph traversal.
+   * @extends Traversal
    * @constructor
    */
   function GraphTraversal(graph, traversalStrategies, bytecode) {
@@ -185,7 +186,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.V = function (args) {
-    this._bytecode.addStep('V', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('V', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -194,7 +195,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addE = function (args) {
-    this._bytecode.addStep('addE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -203,7 +204,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addInE = function (args) {
-    this._bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -212,7 +213,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addOutE = function (args) {
-    this._bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -221,7 +222,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addV = function (args) {
-    this._bytecode.addStep('addV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -230,7 +231,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.aggregate = function (args) {
-    this._bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -239,7 +240,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.and = function (args) {
-    this._bytecode.addStep('and', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('and', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -248,7 +249,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.as = function (args) {
-    this._bytecode.addStep('as', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('as', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -257,7 +258,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.barrier = function (args) {
-    this._bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -266,7 +267,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.both = function (args) {
-    this._bytecode.addStep('both', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('both', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -275,7 +276,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.bothE = function (args) {
-    this._bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -284,7 +285,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.bothV = function (args) {
-    this._bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -293,7 +294,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.branch = function (args) {
-    this._bytecode.addStep('branch', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -302,7 +303,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.by = function (args) {
-    this._bytecode.addStep('by', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('by', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -311,7 +312,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.cap = function (args) {
-    this._bytecode.addStep('cap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -320,7 +321,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.choose = function (args) {
-    this._bytecode.addStep('choose', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -329,7 +330,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.coalesce = function (args) {
-    this._bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -338,7 +339,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.coin = function (args) {
-    this._bytecode.addStep('coin', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -347,7 +348,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.constant = function (args) {
-    this._bytecode.addStep('constant', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -356,7 +357,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.count = function (args) {
-    this._bytecode.addStep('count', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('count', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -365,7 +366,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.cyclicPath = function (args) {
-    this._bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -374,7 +375,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.dedup = function (args) {
-    this._bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -383,7 +384,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.drop = function (args) {
-    this._bytecode.addStep('drop', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -392,7 +393,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.emit = function (args) {
-    this._bytecode.addStep('emit', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -401,7 +402,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.filter = function (args) {
-    this._bytecode.addStep('filter', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -410,7 +411,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.flatMap = function (args) {
-    this._bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -419,7 +420,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.fold = function (args) {
-    this._bytecode.addStep('fold', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -428,7 +429,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.from_ = function (args) {
-    this._bytecode.addStep('from', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('from', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -437,7 +438,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.group = function (args) {
-    this._bytecode.addStep('group', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('group', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -446,7 +447,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.groupCount = function (args) {
-    this._bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -455,7 +456,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.groupV3d0 = function (args) {
-    this._bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -464,7 +465,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.has = function (args) {
-    this._bytecode.addStep('has', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('has', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -473,7 +474,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasId = function (args) {
-    this._bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -482,7 +483,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasKey = function (args) {
-    this._bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -491,7 +492,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasLabel = function (args) {
-    this._bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -500,7 +501,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasNot = function (args) {
-    this._bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -509,7 +510,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasValue = function (args) {
-    this._bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -518,7 +519,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.id = function (args) {
-    this._bytecode.addStep('id', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('id', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -527,7 +528,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.identity = function (args) {
-    this._bytecode.addStep('identity', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -536,7 +537,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.inE = function (args) {
-    this._bytecode.addStep('inE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -545,7 +546,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.inV = function (args) {
-    this._bytecode.addStep('inV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -554,7 +555,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.in_ = function (args) {
-    this._bytecode.addStep('in', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('in', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -563,7 +564,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.inject = function (args) {
-    this._bytecode.addStep('inject', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -572,7 +573,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.is = function (args) {
-    this._bytecode.addStep('is', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('is', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -581,7 +582,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.key = function (args) {
-    this._bytecode.addStep('key', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('key', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -590,7 +591,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.label = function (args) {
-    this._bytecode.addStep('label', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('label', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -599,7 +600,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.limit = function (args) {
-    this._bytecode.addStep('limit', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -608,7 +609,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.local = function (args) {
-    this._bytecode.addStep('local', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('local', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -617,7 +618,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.loops = function (args) {
-    this._bytecode.addStep('loops', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -626,7 +627,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.map = function (args) {
-    this._bytecode.addStep('map', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('map', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -635,7 +636,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.mapKeys = function (args) {
-    this._bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -644,7 +645,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.mapValues = function (args) {
-    this._bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -653,7 +654,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.match = function (args) {
-    this._bytecode.addStep('match', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('match', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -662,7 +663,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.max = function (args) {
-    this._bytecode.addStep('max', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('max', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -671,7 +672,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.mean = function (args) {
-    this._bytecode.addStep('mean', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -680,7 +681,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.min = function (args) {
-    this._bytecode.addStep('min', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('min', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -689,7 +690,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.not = function (args) {
-    this._bytecode.addStep('not', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('not', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -698,7 +699,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.option = function (args) {
-    this._bytecode.addStep('option', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('option', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -707,7 +708,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.optional = function (args) {
-    this._bytecode.addStep('optional', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -716,7 +717,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.or = function (args) {
-    this._bytecode.addStep('or', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('or', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -725,7 +726,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.order = function (args) {
-    this._bytecode.addStep('order', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('order', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -734,7 +735,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.otherV = function (args) {
-    this._bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -743,7 +744,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.out = function (args) {
-    this._bytecode.addStep('out', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('out', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -752,7 +753,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.outE = function (args) {
-    this._bytecode.addStep('outE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -761,7 +762,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.outV = function (args) {
-    this._bytecode.addStep('outV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -770,7 +771,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.pageRank = function (args) {
-    this._bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -779,7 +780,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.path = function (args) {
-    this._bytecode.addStep('path', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('path', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -788,7 +789,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.peerPressure = function (args) {
-    this._bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -797,7 +798,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.profile = function (args) {
-    this._bytecode.addStep('profile', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -806,7 +807,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.program = function (args) {
-    this._bytecode.addStep('program', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('program', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -815,7 +816,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.project = function (args) {
-    this._bytecode.addStep('project', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('project', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -824,7 +825,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.properties = function (args) {
-    this._bytecode.addStep('properties', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -833,7 +834,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.property = function (args) {
-    this._bytecode.addStep('property', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('property', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -842,7 +843,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.propertyMap = function (args) {
-    this._bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -851,7 +852,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.range = function (args) {
-    this._bytecode.addStep('range', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('range', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -860,7 +861,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.repeat = function (args) {
-    this._bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -869,7 +870,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sack = function (args) {
-    this._bytecode.addStep('sack', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -878,7 +879,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sample = function (args) {
-    this._bytecode.addStep('sample', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -887,7 +888,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.select = function (args) {
-    this._bytecode.addStep('select', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('select', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -896,7 +897,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sideEffect = function (args) {
-    this._bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -905,7 +906,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.simplePath = function (args) {
-    this._bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -914,7 +915,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.store = function (args) {
-    this._bytecode.addStep('store', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('store', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -923,7 +924,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.subgraph = function (args) {
-    this._bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -932,7 +933,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sum = function (args) {
-    this._bytecode.addStep('sum', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -941,7 +942,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.tail = function (args) {
-    this._bytecode.addStep('tail', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -950,7 +951,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.timeLimit = function (args) {
-    this._bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -959,7 +960,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.times = function (args) {
-    this._bytecode.addStep('times', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('times', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -968,7 +969,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.to = function (args) {
-    this._bytecode.addStep('to', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('to', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -977,7 +978,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.toE = function (args) {
-    this._bytecode.addStep('toE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -986,7 +987,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.toV = function (args) {
-    this._bytecode.addStep('toV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -995,7 +996,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.tree = function (args) {
-    this._bytecode.addStep('tree', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1004,7 +1005,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.unfold = function (args) {
-    this._bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1013,7 +1014,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.union = function (args) {
-    this._bytecode.addStep('union', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('union', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1022,7 +1023,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.until = function (args) {
-    this._bytecode.addStep('until', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('until', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1031,7 +1032,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.value = function (args) {
-    this._bytecode.addStep('value', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('value', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1040,7 +1041,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.valueMap = function (args) {
-    this._bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1049,7 +1050,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.values = function (args) {
-    this._bytecode.addStep('values', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('values', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1058,7 +1059,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.where = function (args) {
-    this._bytecode.addStep('where', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('where', parseArgs.apply(null, arguments));
     return this;
   };
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae93524a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index ff2927e..a7a9bb7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -24,22 +24,22 @@
   "use strict";
 
   function Traversal(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode;
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode;
     this.traversers = null;
     this.sideEffects = null;
   }
 
   /** @returns {Bytecode} */
   Traversal.prototype.getBytecode = function () {
-    return this._bytecode;
+    return this.bytecode;
   };
 
   /** @param {Function} callback */
   Traversal.prototype.list = function (callback) {
     var self = this;
-    this._traversalStrategies.applyStrategies(this, function (err) {
+    this.traversalStrategies.applyStrategies(this, function (err) {
       if (err) {
         return callback(err);
       }
@@ -59,7 +59,7 @@
    * @returns {String}
    */
   Traversal.prototype.toString = function () {
-    return this._bytecode.toString();
+    return this.bytecode.toString();
   };
   
   /**


[02/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Made override of iterate() automatic

Posted by sp...@apache.org.
TINKERPOP-786 Made override of iterate() automatic


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/21b92b8f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/21b92b8f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/21b92b8f

Branch: refs/heads/TINKERPOP-1489
Commit: 21b92b8faec44eb07b7abebc2a47d9d61f8e890d
Parents: 06d6d13
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 27 15:16:16 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../src/main/java/SocialTraversalDsl.java       |  6 --
 .../traversal/dsl/GremlinDslProcessor.java      | 69 ++++++++++++--------
 .../traversal/dsl/SocialMoveTraversalDsl.java   |  6 --
 .../traversal/dsl/SocialTraversalDsl.java       |  6 --
 4 files changed, 43 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21b92b8f/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
index 546a328..fb2a3f6 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
@@ -32,10 +32,4 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
     public default <E2 extends Number> GraphTraversal<S, E2> youngestFriendsAge() {
         return out("knows").hasLabel("person").values("age").min();
     }
-
-    @Override
-    public default GraphTraversal<S, E> iterate() {
-        GraphTraversal.Admin.super.iterate();
-        return this;
-    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21b92b8f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index d96ae01..5a1a6bd 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -56,6 +56,7 @@ import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
 import javax.tools.Diagnostic;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
@@ -88,33 +89,11 @@ public class GremlinDslProcessor extends AbstractProcessor {
         try {
             for (Element dslElement : roundEnv.getElementsAnnotatedWith(GremlinDsl.class)) {
                 validateDSL(dslElement);
-                final TypeElement annotatedDslType = (TypeElement) dslElement;
-                final Context ctx = new Context(annotatedDslType);
+                final Context ctx = new Context((TypeElement) dslElement);
 
-                // START write "Traversal" class
-                final TypeSpec.Builder traversalInterface = TypeSpec.interfaceBuilder(ctx.traversalClazz)
-                        .addModifiers(Modifier.PUBLIC)
-                        .addTypeVariables(Arrays.asList(TypeVariableName.get("S"), TypeVariableName.get("E")))
-                        .addSuperinterface(TypeName.get(dslElement.asType()));
-
-                // process the methods of the GremlinDsl annotated class
-                for (Element elementOfDsl : annotatedDslType.getEnclosedElements()) {
-                    tryConstructMethod(elementOfDsl, ctx.traversalClassName, ctx.dslName, null,
-                            Modifier.PUBLIC, Modifier.DEFAULT).ifPresent(traversalInterface::addMethod);
-                }
-
-                // process the methods of GraphTraversal
-                final TypeElement graphTraversalElement = elementUtils.getTypeElement(GraphTraversal.class.getCanonicalName());
-                for (Element elementOfGraphTraversal : graphTraversalElement.getEnclosedElements()) {
-                    tryConstructMethod(elementOfGraphTraversal, ctx.traversalClassName, ctx.dslName,
-                            e -> e.getSimpleName().contentEquals("asAdmin") || e.getSimpleName().contentEquals("iterate"),
-                            Modifier.PUBLIC, Modifier.DEFAULT)
-                            .ifPresent(traversalInterface::addMethod);
-                }
-
-                final JavaFile traversalJavaFile = JavaFile.builder(ctx.packageName, traversalInterface.build()).build();
-                traversalJavaFile.writeTo(filer);
-                // END write "Traversal" class
+                // creates the "Traversal" interface using an extension of the GraphTraversal class that has the
+                // GremlinDsl annotation on it
+                generateTraversalInterface(ctx);
 
                 // START write of the "DefaultTraversal" class
                 final TypeSpec.Builder defaultTraversalClass = TypeSpec.classBuilder(ctx.defaultTraversalClazz)
@@ -246,6 +225,41 @@ public class GremlinDslProcessor extends AbstractProcessor {
         return true;
     }
 
+    private void generateTraversalInterface(final Context ctx) throws IOException {
+        final TypeSpec.Builder traversalInterface = TypeSpec.interfaceBuilder(ctx.traversalClazz)
+                .addModifiers(Modifier.PUBLIC)
+                .addTypeVariables(Arrays.asList(TypeVariableName.get("S"), TypeVariableName.get("E")))
+                .addSuperinterface(TypeName.get(ctx.annotatedDslType.asType()));
+
+        // process the methods of the GremlinDsl annotated class
+        for (Element elementOfDsl : ctx.annotatedDslType.getEnclosedElements()) {
+            tryConstructMethod(elementOfDsl, ctx.traversalClassName, ctx.dslName, null,
+                    Modifier.PUBLIC, Modifier.DEFAULT).ifPresent(traversalInterface::addMethod);
+        }
+
+        // process the methods of GraphTraversal
+        final TypeElement graphTraversalElement = elementUtils.getTypeElement(GraphTraversal.class.getCanonicalName());
+        for (Element elementOfGraphTraversal : graphTraversalElement.getEnclosedElements()) {
+            tryConstructMethod(elementOfGraphTraversal, ctx.traversalClassName, ctx.dslName,
+                    e -> e.getSimpleName().contentEquals("asAdmin") || e.getSimpleName().contentEquals("iterate"),
+                    Modifier.PUBLIC, Modifier.DEFAULT)
+                    .ifPresent(traversalInterface::addMethod);
+        }
+
+        // there are weird things with generics that require this method to be implemented if it isn't already present
+        // in the GremlinDsl annotated class extending from GraphTraversal
+        traversalInterface.addMethod(MethodSpec.methodBuilder("iterate")
+                .addModifiers(Modifier.PUBLIC, Modifier.DEFAULT)
+                .addAnnotation(Override.class)
+                .addStatement("$T.super.iterate()", ClassName.get(ctx.annotatedDslType))
+                .addStatement("return this")
+                .returns(ParameterizedTypeName.get(ctx.traversalClassName, TypeVariableName.get("S"), TypeVariableName.get("E")))
+                .build());
+
+        final JavaFile traversalJavaFile = JavaFile.builder(ctx.packageName, traversalInterface.build()).build();
+        traversalJavaFile.writeTo(filer);
+    }
+
     private Optional<MethodSpec> tryConstructMethod(final Element element, final ClassName returnClazz, final String parent,
                                                     final Predicate<ExecutableElement> ignore, final Modifier... modifiers) {
         if (element.getKind() != ElementKind.METHOD) return Optional.empty();
@@ -303,6 +317,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
     }
 
     private class Context {
+        private final TypeElement annotatedDslType;
         private final String packageName;
         private final String dslName;
         private final String traversalClazz;
@@ -314,6 +329,8 @@ public class GremlinDslProcessor extends AbstractProcessor {
         private final ClassName graphTraversalAdminClassName;
 
         public Context(final TypeElement dslElement) {
+            annotatedDslType = dslElement;
+
             // gets the annotation on the dsl class/interface
             GremlinDsl gremlinDslAnnotation = dslElement.getAnnotation(GremlinDsl.class);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21b92b8f/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
index 1392e30..1db1dff 100644
--- a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
@@ -34,10 +34,4 @@ public interface SocialMoveTraversalDsl<S, E> extends GraphTraversal.Admin<S, E>
     public default <E2 extends Number> GraphTraversal<S, E2> meanAgeOfFriends() {
         return out("knows").hasLabel("person").properties("age").mean();
     }
-
-    @Override
-    public default GraphTraversal<S, E> iterate() {
-        GraphTraversal.Admin.super.iterate();
-        return this;
-    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21b92b8f/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
index af53dd2..fc4921f 100644
--- a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
@@ -34,10 +34,4 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
     public default <E2 extends Number> GraphTraversal<S, E2> meanAgeOfFriends() {
         return out("knows").hasLabel("person").properties("age").mean();
     }
-
-    @Override
-    public default GraphTraversal<S, E> iterate() {
-        GraphTraversal.Admin.super.iterate();
-        return this;
-    }
 }


[36/50] [abbrv] tinkerpop git commit: Improved error messaging in addV() CTR

Posted by sp...@apache.org.
Improved error messaging in addV() CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1ee5b375
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1ee5b375
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1ee5b375

Branch: refs/heads/TINKERPOP-1489
Commit: 1ee5b37535467cf60c7d4671ab3728af18d3e057
Parents: 7bf6883
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 25 08:19:36 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 25 08:19:36 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                               | 1 +
 .../process/traversal/dsl/graph/GraphTraversalSource.java        | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1ee5b375/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index be8059d..31a4064 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Improved error messaging on the `g.addV(Object...)` when passing an invalid arguments.
 * Reduced memory usage for TinkerGraph deserialization in GraphSON by streaming vertices and edges.
 * Now using Groovy `[...]` map notation in `GroovyTranslator` instead of `new LinkedHashMap(){{ }}`.
 * Maintained type information on `Traversal.promise()`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1ee5b375/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index af78add..1b6a218 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -41,6 +41,7 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 import java.util.ArrayList;
@@ -263,16 +264,15 @@ public class GraphTraversalSource implements TraversalSource {
      */
     @Deprecated
     public GraphTraversal<Vertex, Vertex> addV(final Object... keyValues) {
+        ElementHelper.legalPropertyKeyValueArray(keyValues);
         if (keyValues.length != 0 && keyValues[0].equals(T.label)) {
             final GraphTraversal<Vertex, Vertex> traversal = this.addV(keyValues[1].toString());
-            this.addV(keyValues[1].toString());
             for (int i = 2; i < keyValues.length; i = i + 2) {
                 traversal.property(keyValues[i], keyValues[i + 1]);
             }
             return traversal;
         } else {
             final GraphTraversal<Vertex, Vertex> traversal = this.addV();
-            this.addV(keyValues[1].toString());
             for (int i = 0; i < keyValues.length; i = i + 2) {
                 traversal.property(keyValues[i], keyValues[i + 1]);
             }


[37/50] [abbrv] tinkerpop git commit: Merge branch 'pr-609' into tp32

Posted by sp...@apache.org.
Merge branch 'pr-609' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8812f85a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8812f85a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8812f85a

Branch: refs/heads/TINKERPOP-1489
Commit: 8812f85a022a9de0592bae5de8a0dd5503a9c86b
Parents: 1ee5b37 6813e9e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 25 09:53:20 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 25 09:53:20 2017 -0400

----------------------------------------------------------------------
 .../remote/traversal/step/map/RemoteStep.java    | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[09/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Removed some commented out config in the pom.xml

Posted by sp...@apache.org.
TINKERPOP-786 Removed some commented out config in the pom.xml


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/62cfbc95
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/62cfbc95
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/62cfbc95

Branch: refs/heads/TINKERPOP-1489
Commit: 62cfbc952e427a1a0babd124f2c2fcec6ace7fea
Parents: ef359dd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Apr 29 06:57:46 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 gremlin-core/pom.xml | 14 --------------
 1 file changed, 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/62cfbc95/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index 0efadfa..f3bff75 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -107,20 +107,6 @@ limitations under the License.
             <version>0.10</version>
             <scope>test</scope>
         </dependency>
-        <!--
-        <dependency>
-            <groupId>com.google.truth</groupId>
-            <artifactId>truth</artifactId>
-            <version>0.25</version>
-            <exclusions>
-                truth comes in through compile-testing and has a self-conflict - produces further conflict with hadoop-gremlin
-                <exclusion>
-                    <groupId>com.google.guava</groupId>
-                    <artifactId>guava</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
--->
     </dependencies>
     <build>
         <directory>${basedir}/target</directory>


[31/50] [abbrv] tinkerpop git commit: Merge branch 'tp31' into tp32

Posted by sp...@apache.org.
Merge branch 'tp31' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/afa3432e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/afa3432e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/afa3432e

Branch: refs/heads/TINKERPOP-1489
Commit: afa3432e4046a0c450ac5c71106ab056c3131926
Parents: abe23d4 07bca45
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon May 22 09:50:54 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 22 09:50:54 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/the-graph.asciidoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/afa3432e/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------


[46/50] [abbrv] tinkerpop git commit: TINKERPOP-1489 Regenerated traversal.js

Posted by sp...@apache.org.
TINKERPOP-1489 Regenerated traversal.js

which added Pick.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/74bffea0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/74bffea0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/74bffea0

Branch: refs/heads/TINKERPOP-1489
Commit: 74bffea00a5e2bf09cc7df1da39868d5bfb99fbb
Parents: 94e2db4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 18 12:48:27 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 .../src/main/javascript/gremlin-javascript/process/traversal.js     | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/74bffea0/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index f585161..9709a4f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -377,6 +377,7 @@
     direction: toEnum('Direction', 'BOTH IN OUT'),
     operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
     order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+    pick: toEnum('Pick', 'any none'),
     pop: toEnum('Pop', 'all first last'),
     scope: toEnum('Scope', 'global local'),
     t: toEnum('T', 'id key label value')


[41/50] [abbrv] tinkerpop git commit: Export enums and fix TraversalStrategies#applyStrategies()

Posted by sp...@apache.org.
Export enums and fix TraversalStrategies#applyStrategies()


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b0454c3d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b0454c3d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b0454c3d

Branch: refs/heads/TINKERPOP-1489
Commit: b0454c3d0c53c4094ab29f36c8a08b2fe4556a03
Parents: fe8da7c
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Fri Oct 7 12:01:30 2016 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 .../GraphTraversalSourceGenerator.groovy        |  4 +-
 .../javascript/TraversalSourceGenerator.groovy  | 52 +++++++++-----------
 .../driver/remote-connection.js                 |  2 +-
 .../main/javascript/gremlin-javascript/index.js | 11 ++++-
 .../process/graph-traversal.js                  |  4 +-
 .../gremlin-javascript/process/traversal.js     | 44 ++++++++---------
 .../gremlin-javascript/test-exports.js          | 15 ++++--
 .../gremlin-javascript/test-graphson.js         |  2 +-
 .../gremlin-javascript/test-traversal.js        | 17 ++++++-
 9 files changed, 87 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index 81c38dc..b569292 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -87,12 +87,12 @@ class GraphTraversalSourceGenerator {
 
   /**
    * @param remoteConnection
-   * @returns {GraphTraversal}
+   * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
     var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
   };
 
   /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index efcb826..5b07a32 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -177,11 +177,14 @@ class TraversalSourceGenerator {
     this.strategies.push(strategy);
   };
 
-  /** @param {Traversal} traversal */
-  TraversalStrategies.prototype.applyStrategies = function (traversal) {
-    this.strategies.forEach(function eachStrategy(s) {
-      s.apply(traversal);
-    });
+  /**
+   * @param {Traversal} traversal
+   * @param {Function} callback
+   */
+  TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
+    eachSeries(this.strategies, function eachStrategy(s, next) {
+      s.apply(traversal, next);
+    }, callback);
   };
 
   /**
@@ -195,8 +198,9 @@ class TraversalSourceGenerator {
   /**
    * @abstract
    * @param {Traversal} traversal
+   * @param {Function} callback
    */
-  TraversalStrategy.prototype.apply = function (traversal) {
+  TraversalStrategy.prototype.apply = function (traversal, callback) {
 
   };
 
@@ -290,24 +294,6 @@ class TraversalSourceGenerator {
     this.elementName = elementName;
   }
 
-  /**
-   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
-   */
-  var enums = {};\n""")
-
-        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
-                .findAll { Enum.class.isAssignableFrom(it) }
-                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
-                .collect()) {
-            moduleOutput.append("  enums.${SymbolHelper.decapitalize(enumClass.getSimpleName())} = " +
-                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
-            enumClass.getEnumConstants()
-                    .sort { a, b -> a.name() <=> b.name() }
-                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
-            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("');\n")
-        }
-
-        moduleOutput.append("""
   // Utility functions
   /** @returns {Array} */
   function parseArgs() {
@@ -376,11 +362,21 @@ class TraversalSourceGenerator {
     TraversalSideEffects: TraversalSideEffects,
     TraversalStrategies: TraversalStrategies,
     TraversalStrategy: TraversalStrategy,
-    Traverser: Traverser
+    Traverser: Traverser""")
+        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
+                .findAll { Enum.class.isAssignableFrom(it) }
+                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
+                .collect()) {
+            moduleOutput.append(",\n    ${SymbolHelper.decapitalize(enumClass.getSimpleName())}: " +
+                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
+            enumClass.getEnumConstants()
+                    .sort { a, b -> a.name() <=> b.name() }
+                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
+            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("')")
+        }
+
+        moduleOutput.append("""
   };
-  Object.keys(enums).forEach(function (k) {
-    toExport[k] = enums[k];
-  });
   if (typeof module !== 'undefined') {
     // CommonJS
     module.exports = toExport;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
index 99b177f..e19b537 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
@@ -68,7 +68,7 @@
   /** @override */
   RemoteStrategy.prototype.apply = function (traversal, callback) {
     if (traversal.traversers) {
-      return;
+      return callback();
     }
     this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
       if (err) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index cda8200..ddcdac2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -49,14 +49,21 @@
     process: {
       Bytecode: t.Bytecode,
       EnumValue: t.EnumValue,
-      inherits: t.inherits,
       P: t.P,
-      parseArgs: t.parseArgs,
       Traversal: t.Traversal,
       TraversalSideEffects: t.TraversalSideEffects,
       TraversalStrategies: t.TraversalStrategies,
       TraversalStrategy: t.TraversalStrategy,
       Traverser: t.Traverser,
+      barrier: t.barrier,
+      cardinality: t.cardinality,
+      column: t.column,
+      direction: t.direction,
+      operator: t.operator,
+      order: t.order,
+      pop: t.pop,
+      scope: t.scope,
+      t: t.t,
       GraphTraversal: gt.GraphTraversal,
       GraphTraversalSource: gt.GraphTraversalSource,
       statics: gt.statics

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index d9803ba..1a6356b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -44,12 +44,12 @@
 
   /**
    * @param remoteConnection
-   * @returns {GraphTraversal}
+   * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
     var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
   };
 
   /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index 5c9bf6c..ff2927e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -185,11 +185,14 @@
     this.strategies.push(strategy);
   };
 
-  /** @param {Traversal} traversal */
-  TraversalStrategies.prototype.applyStrategies = function (traversal) {
-    this.strategies.forEach(function eachStrategy(s) {
-      s.apply(traversal);
-    });
+  /**
+   * @param {Traversal} traversal
+   * @param {Function} callback
+   */
+  TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
+    eachSeries(this.strategies, function eachStrategy(s, next) {
+      s.apply(traversal, next);
+    }, callback);
   };
 
   /**
@@ -203,8 +206,9 @@
   /**
    * @abstract
    * @param {Traversal} traversal
+   * @param {Function} callback
    */
-  TraversalStrategy.prototype.apply = function (traversal) {
+  TraversalStrategy.prototype.apply = function (traversal, callback) {
 
   };
 
@@ -298,20 +302,6 @@
     this.elementName = elementName;
   }
 
-  /**
-   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
-   */
-  var enums = {};
-  enums.barrier = toEnum('Barrier', 'normSack');
-  enums.cardinality = toEnum('Cardinality', 'list set single');
-  enums.column = toEnum('Column', 'keys values');
-  enums.direction = toEnum('Direction', 'BOTH IN OUT');
-  enums.operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
-  enums.order = toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr');
-  enums.pop = toEnum('Pop', 'all first last');
-  enums.scope = toEnum('Scope', 'global local');
-  enums.t = toEnum('T', 'id key label value');
-
   // Utility functions
   /** @returns {Array} */
   function parseArgs() {
@@ -380,11 +370,17 @@
     TraversalSideEffects: TraversalSideEffects,
     TraversalStrategies: TraversalStrategies,
     TraversalStrategy: TraversalStrategy,
-    Traverser: Traverser
+    Traverser: Traverser,
+    barrier: toEnum('Barrier', 'normSack'),
+    cardinality: toEnum('Cardinality', 'list set single'),
+    column: toEnum('Column', 'keys values'),
+    direction: toEnum('Direction', 'BOTH IN OUT'),
+    operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
+    order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+    pop: toEnum('Pop', 'all first last'),
+    scope: toEnum('Scope', 'global local'),
+    t: toEnum('T', 'id key label value')
   };
-  Object.keys(enums).forEach(function (k) {
-    toExport[k] = enums[k];
-  });
   if (typeof module !== 'undefined') {
     // CommonJS
     module.exports = toExport;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
index 6edb323..b9265c7 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
@@ -34,9 +34,7 @@
       assert.ok(glvModule.process);
       assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
       assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
-      assert.strictEqual(typeof glvModule.process.inherits, 'function');
       assert.strictEqual(typeof glvModule.process.P, 'function');
-      assert.strictEqual(typeof glvModule.process.parseArgs, 'function');
       assert.strictEqual(typeof glvModule.process.Traversal, 'function');
       assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
       assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
@@ -44,6 +42,17 @@
       assert.strictEqual(typeof glvModule.process.Traverser, 'function');
       assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
       assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+      assert.strictEqual(typeof glvModule.process.barrier, 'object');
+      assert.strictEqual(typeof glvModule.process.cardinality, 'object');
+      assert.strictEqual(typeof glvModule.process.column, 'object');
+      assert.strictEqual(typeof glvModule.process.direction, 'object');
+      assert.strictEqual(typeof glvModule.process.operator, 'object');
+      assert.strictEqual(typeof glvModule.process.order, 'object');
+      assert.strictEqual(typeof glvModule.process.pop, 'object');
+      assert.strictEqual(typeof glvModule.process.scope, 'object');
+      assert.strictEqual(typeof glvModule.process.t, 'object');
+
+
       assert.ok(glvModule.process.statics);
 
       assert.ok(glvModule.structure);
@@ -75,4 +84,4 @@
     }
     throw new Error('No module loader was found');
   }
-}).call(this)
\ No newline at end of file
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
index e44ef90..418a9dd 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
@@ -87,7 +87,7 @@
       assert.strictEqual(writer.write(true), 'true');
       assert.strictEqual(writer.write(false), 'false');
     },
-    function testWriteNumber() {
+    function testWriteP() {
       var writer = new GraphSONWriter();
       var expected = JSON.stringify({"@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.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0454c3d/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
index 477df91..1ec4253 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
@@ -26,9 +26,10 @@
   var helper = loadModule.call(this, './helper.js');
   var assert = helper.assert;
   var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+  var t = helper.loadLibModule.call(this, 'process/traversal.js');
 
   [
-    function testBytecode() {
+    function testBytecode1() {
       var g = new graph.Graph().traversal();
       var bytecode = g.V().out('created').getBytecode();
       assert.ok(bytecode);
@@ -37,6 +38,20 @@
       assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
       assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
       assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+    },
+    function testBytecode2() {
+      var g = new graph.Graph().traversal();
+      var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+      assert.ok(bytecode);
+      assert.strictEqual(bytecode.sourceInstructions.length, 0);
+      assert.strictEqual(bytecode.stepInstructions.length, 3);
+      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+      assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
+      assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
+      assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
+      assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
+      assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
+      assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
     }
   ].forEach(function (testCase) {
     testCase.call(null);


[27/50] [abbrv] tinkerpop git commit: updated pattern for defining anonymous dsl traversals

Posted by sp...@apache.org.
updated pattern for defining anonymous dsl traversals


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/404ee8ce
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/404ee8ce
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/404ee8ce

Branch: refs/heads/TINKERPOP-1489
Commit: 404ee8ced4165d188799f6904ff5aed7ca7adee3
Parents: a96544f
Author: davebshow <da...@gmail.com>
Authored: Thu May 11 12:02:45 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 .../python/GraphTraversalSourceGenerator.groovy |  15 +-
 .../gremlin_python/process/graph_traversal.py   | 555 ++++++++++---------
 .../src/main/jython/tests/process/test_dsl.py   |  23 +-
 3 files changed, 299 insertions(+), 294 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/404ee8ce/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
index c2e733f..086b8ea 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
@@ -162,11 +162,12 @@ under the License.
 ////////////////////////
         pythonClass.append(
                 """class __(object):
-  @staticmethod
-  def start():
+  graph_traversal = GraphTraversal
+  @classmethod
+  def start(cls):
     return GraphTraversal(None, None, Bytecode())
-  @staticmethod
-  def __(*args):
+  @classmethod
+  def __(cls, *args):
     return __.inject(*args)
 """)
         __.class.getMethods().
@@ -178,9 +179,9 @@ under the License.
                 sort { a, b -> a <=> b }.
                 forEach { method ->
                     pythonClass.append(
-                            """  @staticmethod
-  def ${method}(*args):
-    return GraphTraversal(None, None, Bytecode()).${method}(*args)
+                            """  @classmethod
+  def ${method}(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).${method}(*args)
 """)
                 };
         pythonClass.append("\n\n")

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/404ee8ce/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
index ef49443..1c940aa 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
@@ -396,285 +396,286 @@ class GraphTraversal(Traversal):
 
 
 class __(object):
-  @staticmethod
-  def start():
+  graph_traversal = GraphTraversal
+  @classmethod
+  def start(cls):
     return GraphTraversal(None, None, Bytecode())
-  @staticmethod
-  def __(*args):
+  @classmethod
+  def __(cls, *args):
     return __.inject(*args)
-  @staticmethod
-  def V(*args):
-    return GraphTraversal(None, None, Bytecode()).V(*args)
-  @staticmethod
-  def addE(*args):
-    return GraphTraversal(None, None, Bytecode()).addE(*args)
-  @staticmethod
-  def addInE(*args):
-    return GraphTraversal(None, None, Bytecode()).addInE(*args)
-  @staticmethod
-  def addOutE(*args):
-    return GraphTraversal(None, None, Bytecode()).addOutE(*args)
-  @staticmethod
-  def addV(*args):
-    return GraphTraversal(None, None, Bytecode()).addV(*args)
-  @staticmethod
-  def aggregate(*args):
-    return GraphTraversal(None, None, Bytecode()).aggregate(*args)
-  @staticmethod
-  def and_(*args):
-    return GraphTraversal(None, None, Bytecode()).and_(*args)
-  @staticmethod
-  def as_(*args):
-    return GraphTraversal(None, None, Bytecode()).as_(*args)
-  @staticmethod
-  def barrier(*args):
-    return GraphTraversal(None, None, Bytecode()).barrier(*args)
-  @staticmethod
-  def both(*args):
-    return GraphTraversal(None, None, Bytecode()).both(*args)
-  @staticmethod
-  def bothE(*args):
-    return GraphTraversal(None, None, Bytecode()).bothE(*args)
-  @staticmethod
-  def bothV(*args):
-    return GraphTraversal(None, None, Bytecode()).bothV(*args)
-  @staticmethod
-  def branch(*args):
-    return GraphTraversal(None, None, Bytecode()).branch(*args)
-  @staticmethod
-  def cap(*args):
-    return GraphTraversal(None, None, Bytecode()).cap(*args)
-  @staticmethod
-  def choose(*args):
-    return GraphTraversal(None, None, Bytecode()).choose(*args)
-  @staticmethod
-  def coalesce(*args):
-    return GraphTraversal(None, None, Bytecode()).coalesce(*args)
-  @staticmethod
-  def coin(*args):
-    return GraphTraversal(None, None, Bytecode()).coin(*args)
-  @staticmethod
-  def constant(*args):
-    return GraphTraversal(None, None, Bytecode()).constant(*args)
-  @staticmethod
-  def count(*args):
-    return GraphTraversal(None, None, Bytecode()).count(*args)
-  @staticmethod
-  def cyclicPath(*args):
-    return GraphTraversal(None, None, Bytecode()).cyclicPath(*args)
-  @staticmethod
-  def dedup(*args):
-    return GraphTraversal(None, None, Bytecode()).dedup(*args)
-  @staticmethod
-  def drop(*args):
-    return GraphTraversal(None, None, Bytecode()).drop(*args)
-  @staticmethod
-  def emit(*args):
-    return GraphTraversal(None, None, Bytecode()).emit(*args)
-  @staticmethod
-  def filter(*args):
-    return GraphTraversal(None, None, Bytecode()).filter(*args)
-  @staticmethod
-  def flatMap(*args):
-    return GraphTraversal(None, None, Bytecode()).flatMap(*args)
-  @staticmethod
-  def fold(*args):
-    return GraphTraversal(None, None, Bytecode()).fold(*args)
-  @staticmethod
-  def group(*args):
-    return GraphTraversal(None, None, Bytecode()).group(*args)
-  @staticmethod
-  def groupCount(*args):
-    return GraphTraversal(None, None, Bytecode()).groupCount(*args)
-  @staticmethod
-  def groupV3d0(*args):
-    return GraphTraversal(None, None, Bytecode()).groupV3d0(*args)
-  @staticmethod
-  def has(*args):
-    return GraphTraversal(None, None, Bytecode()).has(*args)
-  @staticmethod
-  def hasId(*args):
-    return GraphTraversal(None, None, Bytecode()).hasId(*args)
-  @staticmethod
-  def hasKey(*args):
-    return GraphTraversal(None, None, Bytecode()).hasKey(*args)
-  @staticmethod
-  def hasLabel(*args):
-    return GraphTraversal(None, None, Bytecode()).hasLabel(*args)
-  @staticmethod
-  def hasNot(*args):
-    return GraphTraversal(None, None, Bytecode()).hasNot(*args)
-  @staticmethod
-  def hasValue(*args):
-    return GraphTraversal(None, None, Bytecode()).hasValue(*args)
-  @staticmethod
-  def id(*args):
-    return GraphTraversal(None, None, Bytecode()).id(*args)
-  @staticmethod
-  def identity(*args):
-    return GraphTraversal(None, None, Bytecode()).identity(*args)
-  @staticmethod
-  def inE(*args):
-    return GraphTraversal(None, None, Bytecode()).inE(*args)
-  @staticmethod
-  def inV(*args):
-    return GraphTraversal(None, None, Bytecode()).inV(*args)
-  @staticmethod
-  def in_(*args):
-    return GraphTraversal(None, None, Bytecode()).in_(*args)
-  @staticmethod
-  def inject(*args):
-    return GraphTraversal(None, None, Bytecode()).inject(*args)
-  @staticmethod
-  def is_(*args):
-    return GraphTraversal(None, None, Bytecode()).is_(*args)
-  @staticmethod
-  def key(*args):
-    return GraphTraversal(None, None, Bytecode()).key(*args)
-  @staticmethod
-  def label(*args):
-    return GraphTraversal(None, None, Bytecode()).label(*args)
-  @staticmethod
-  def limit(*args):
-    return GraphTraversal(None, None, Bytecode()).limit(*args)
-  @staticmethod
-  def local(*args):
-    return GraphTraversal(None, None, Bytecode()).local(*args)
-  @staticmethod
-  def loops(*args):
-    return GraphTraversal(None, None, Bytecode()).loops(*args)
-  @staticmethod
-  def map(*args):
-    return GraphTraversal(None, None, Bytecode()).map(*args)
-  @staticmethod
-  def mapKeys(*args):
-    return GraphTraversal(None, None, Bytecode()).mapKeys(*args)
-  @staticmethod
-  def mapValues(*args):
-    return GraphTraversal(None, None, Bytecode()).mapValues(*args)
-  @staticmethod
-  def match(*args):
-    return GraphTraversal(None, None, Bytecode()).match(*args)
-  @staticmethod
-  def max(*args):
-    return GraphTraversal(None, None, Bytecode()).max(*args)
-  @staticmethod
-  def mean(*args):
-    return GraphTraversal(None, None, Bytecode()).mean(*args)
-  @staticmethod
-  def min(*args):
-    return GraphTraversal(None, None, Bytecode()).min(*args)
-  @staticmethod
-  def not_(*args):
-    return GraphTraversal(None, None, Bytecode()).not_(*args)
-  @staticmethod
-  def optional(*args):
-    return GraphTraversal(None, None, Bytecode()).optional(*args)
-  @staticmethod
-  def or_(*args):
-    return GraphTraversal(None, None, Bytecode()).or_(*args)
-  @staticmethod
-  def order(*args):
-    return GraphTraversal(None, None, Bytecode()).order(*args)
-  @staticmethod
-  def otherV(*args):
-    return GraphTraversal(None, None, Bytecode()).otherV(*args)
-  @staticmethod
-  def out(*args):
-    return GraphTraversal(None, None, Bytecode()).out(*args)
-  @staticmethod
-  def outE(*args):
-    return GraphTraversal(None, None, Bytecode()).outE(*args)
-  @staticmethod
-  def outV(*args):
-    return GraphTraversal(None, None, Bytecode()).outV(*args)
-  @staticmethod
-  def path(*args):
-    return GraphTraversal(None, None, Bytecode()).path(*args)
-  @staticmethod
-  def project(*args):
-    return GraphTraversal(None, None, Bytecode()).project(*args)
-  @staticmethod
-  def properties(*args):
-    return GraphTraversal(None, None, Bytecode()).properties(*args)
-  @staticmethod
-  def property(*args):
-    return GraphTraversal(None, None, Bytecode()).property(*args)
-  @staticmethod
-  def propertyMap(*args):
-    return GraphTraversal(None, None, Bytecode()).propertyMap(*args)
-  @staticmethod
-  def range(*args):
-    return GraphTraversal(None, None, Bytecode()).range(*args)
-  @staticmethod
-  def repeat(*args):
-    return GraphTraversal(None, None, Bytecode()).repeat(*args)
-  @staticmethod
-  def sack(*args):
-    return GraphTraversal(None, None, Bytecode()).sack(*args)
-  @staticmethod
-  def sample(*args):
-    return GraphTraversal(None, None, Bytecode()).sample(*args)
-  @staticmethod
-  def select(*args):
-    return GraphTraversal(None, None, Bytecode()).select(*args)
-  @staticmethod
-  def sideEffect(*args):
-    return GraphTraversal(None, None, Bytecode()).sideEffect(*args)
-  @staticmethod
-  def simplePath(*args):
-    return GraphTraversal(None, None, Bytecode()).simplePath(*args)
-  @staticmethod
-  def store(*args):
-    return GraphTraversal(None, None, Bytecode()).store(*args)
-  @staticmethod
-  def subgraph(*args):
-    return GraphTraversal(None, None, Bytecode()).subgraph(*args)
-  @staticmethod
-  def sum(*args):
-    return GraphTraversal(None, None, Bytecode()).sum(*args)
-  @staticmethod
-  def tail(*args):
-    return GraphTraversal(None, None, Bytecode()).tail(*args)
-  @staticmethod
-  def timeLimit(*args):
-    return GraphTraversal(None, None, Bytecode()).timeLimit(*args)
-  @staticmethod
-  def times(*args):
-    return GraphTraversal(None, None, Bytecode()).times(*args)
-  @staticmethod
-  def to(*args):
-    return GraphTraversal(None, None, Bytecode()).to(*args)
-  @staticmethod
-  def toE(*args):
-    return GraphTraversal(None, None, Bytecode()).toE(*args)
-  @staticmethod
-  def toV(*args):
-    return GraphTraversal(None, None, Bytecode()).toV(*args)
-  @staticmethod
-  def tree(*args):
-    return GraphTraversal(None, None, Bytecode()).tree(*args)
-  @staticmethod
-  def unfold(*args):
-    return GraphTraversal(None, None, Bytecode()).unfold(*args)
-  @staticmethod
-  def union(*args):
-    return GraphTraversal(None, None, Bytecode()).union(*args)
-  @staticmethod
-  def until(*args):
-    return GraphTraversal(None, None, Bytecode()).until(*args)
-  @staticmethod
-  def value(*args):
-    return GraphTraversal(None, None, Bytecode()).value(*args)
-  @staticmethod
-  def valueMap(*args):
-    return GraphTraversal(None, None, Bytecode()).valueMap(*args)
-  @staticmethod
-  def values(*args):
-    return GraphTraversal(None, None, Bytecode()).values(*args)
-  @staticmethod
-  def where(*args):
-    return GraphTraversal(None, None, Bytecode()).where(*args)
+  @classmethod
+  def V(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).V(*args)
+  @classmethod
+  def addE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).addE(*args)
+  @classmethod
+  def addInE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).addInE(*args)
+  @classmethod
+  def addOutE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).addOutE(*args)
+  @classmethod
+  def addV(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).addV(*args)
+  @classmethod
+  def aggregate(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).aggregate(*args)
+  @classmethod
+  def and_(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).and_(*args)
+  @classmethod
+  def as_(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).as_(*args)
+  @classmethod
+  def barrier(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).barrier(*args)
+  @classmethod
+  def both(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).both(*args)
+  @classmethod
+  def bothE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).bothE(*args)
+  @classmethod
+  def bothV(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).bothV(*args)
+  @classmethod
+  def branch(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).branch(*args)
+  @classmethod
+  def cap(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).cap(*args)
+  @classmethod
+  def choose(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).choose(*args)
+  @classmethod
+  def coalesce(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).coalesce(*args)
+  @classmethod
+  def coin(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).coin(*args)
+  @classmethod
+  def constant(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).constant(*args)
+  @classmethod
+  def count(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).count(*args)
+  @classmethod
+  def cyclicPath(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).cyclicPath(*args)
+  @classmethod
+  def dedup(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).dedup(*args)
+  @classmethod
+  def drop(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).drop(*args)
+  @classmethod
+  def emit(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).emit(*args)
+  @classmethod
+  def filter(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).filter(*args)
+  @classmethod
+  def flatMap(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).flatMap(*args)
+  @classmethod
+  def fold(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).fold(*args)
+  @classmethod
+  def group(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).group(*args)
+  @classmethod
+  def groupCount(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).groupCount(*args)
+  @classmethod
+  def groupV3d0(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).groupV3d0(*args)
+  @classmethod
+  def has(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).has(*args)
+  @classmethod
+  def hasId(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).hasId(*args)
+  @classmethod
+  def hasKey(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).hasKey(*args)
+  @classmethod
+  def hasLabel(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).hasLabel(*args)
+  @classmethod
+  def hasNot(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).hasNot(*args)
+  @classmethod
+  def hasValue(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).hasValue(*args)
+  @classmethod
+  def id(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).id(*args)
+  @classmethod
+  def identity(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).identity(*args)
+  @classmethod
+  def inE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).inE(*args)
+  @classmethod
+  def inV(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).inV(*args)
+  @classmethod
+  def in_(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).in_(*args)
+  @classmethod
+  def inject(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).inject(*args)
+  @classmethod
+  def is_(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).is_(*args)
+  @classmethod
+  def key(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).key(*args)
+  @classmethod
+  def label(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).label(*args)
+  @classmethod
+  def limit(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).limit(*args)
+  @classmethod
+  def local(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).local(*args)
+  @classmethod
+  def loops(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).loops(*args)
+  @classmethod
+  def map(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).map(*args)
+  @classmethod
+  def mapKeys(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).mapKeys(*args)
+  @classmethod
+  def mapValues(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).mapValues(*args)
+  @classmethod
+  def match(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).match(*args)
+  @classmethod
+  def max(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).max(*args)
+  @classmethod
+  def mean(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).mean(*args)
+  @classmethod
+  def min(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).min(*args)
+  @classmethod
+  def not_(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).not_(*args)
+  @classmethod
+  def optional(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).optional(*args)
+  @classmethod
+  def or_(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).or_(*args)
+  @classmethod
+  def order(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).order(*args)
+  @classmethod
+  def otherV(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).otherV(*args)
+  @classmethod
+  def out(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).out(*args)
+  @classmethod
+  def outE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).outE(*args)
+  @classmethod
+  def outV(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).outV(*args)
+  @classmethod
+  def path(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).path(*args)
+  @classmethod
+  def project(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).project(*args)
+  @classmethod
+  def properties(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).properties(*args)
+  @classmethod
+  def property(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).property(*args)
+  @classmethod
+  def propertyMap(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).propertyMap(*args)
+  @classmethod
+  def range(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).range(*args)
+  @classmethod
+  def repeat(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).repeat(*args)
+  @classmethod
+  def sack(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).sack(*args)
+  @classmethod
+  def sample(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).sample(*args)
+  @classmethod
+  def select(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).select(*args)
+  @classmethod
+  def sideEffect(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).sideEffect(*args)
+  @classmethod
+  def simplePath(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).simplePath(*args)
+  @classmethod
+  def store(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).store(*args)
+  @classmethod
+  def subgraph(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).subgraph(*args)
+  @classmethod
+  def sum(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).sum(*args)
+  @classmethod
+  def tail(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).tail(*args)
+  @classmethod
+  def timeLimit(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).timeLimit(*args)
+  @classmethod
+  def times(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).times(*args)
+  @classmethod
+  def to(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).to(*args)
+  @classmethod
+  def toE(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).toE(*args)
+  @classmethod
+  def toV(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).toV(*args)
+  @classmethod
+  def tree(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).tree(*args)
+  @classmethod
+  def unfold(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).unfold(*args)
+  @classmethod
+  def union(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).union(*args)
+  @classmethod
+  def until(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).until(*args)
+  @classmethod
+  def value(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).value(*args)
+  @classmethod
+  def valueMap(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).valueMap(*args)
+  @classmethod
+  def values(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).values(*args)
+  @classmethod
+  def where(cls, *args):
+    return cls.graph_traversal(None, None, Bytecode()).where(*args)
 
 
 def V(*args):

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/404ee8ce/gremlin-python/src/main/jython/tests/process/test_dsl.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_dsl.py b/gremlin-python/src/main/jython/tests/process/test_dsl.py
index 0652cbb..5ec79ca 100644
--- a/gremlin-python/src/main/jython/tests/process/test_dsl.py
+++ b/gremlin-python/src/main/jython/tests/process/test_dsl.py
@@ -18,7 +18,7 @@ under the License.
 '''
 import pytest
 
-from gremlin_python.process.traversal import (Bytecode, P)
+from gremlin_python.process.traversal import Bytecode, P
 from gremlin_python.process.graph_traversal import (
     GraphTraversalSource, GraphTraversal)
 from gremlin_python.process.graph_traversal import __ as AnonymousTraversal
@@ -39,17 +39,20 @@ class SocialTraversal(GraphTraversal):
         return self.outE("created").count().is_(P.gte(number))
 
 class __(AnonymousTraversal):
-    @staticmethod
-    def knows(*args):
-        return SocialTraversal(None, None, Bytecode()).knows(*args)
 
-    @staticmethod
-    def youngestFriendsAge(*args):
-        return SocialTraversal(None, None, Bytecode()).youngestFriendsAge(*args)
+    graph_traversal = SocialTraversal
 
-    @staticmethod
-    def createdAtLeast(*args):
-        return SocialTraversal(None, None, Bytecode()).createdAtLeast(*args)
+    @classmethod
+    def knows(cls, *args):
+        return cls.graph_traversal(None, None, Bytecode()).knows(*args)
+
+    @classmethod
+    def youngestFriendsAge(cls, *args):
+        return cls.graph_traversal(None, None, Bytecode()).youngestFriendsAge(*args)
+
+    @classmethod
+    def createdAtLeast(cls, *args):
+        return cls.graph_traversal(None, None, Bytecode()).createdAtLeast(*args)
 
 
 class SocialTraversalSource(GraphTraversalSource):


[22/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Added a note to docs about generic naming

Posted by sp...@apache.org.
TINKERPOP-786 Added a note to docs about generic naming


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/911d17fe
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/911d17fe
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/911d17fe

Branch: refs/heads/TINKERPOP-1489
Commit: 911d17fe09aa16304c386b8e031ec9a677751be7
Parents: e0505d1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 10 15:27:56 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/911d17fe/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 7da4015..ec0bed9 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -3008,6 +3008,9 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
 }
 ----
 
+IMPORTANT: Follow the TinkerPop convention of using `<S,E>` in naming generics as those conventions are taken into
+account when generating the anonymous traversal class.
+
 The `@GremlinDsl` annotation is used by the link:https://docs.oracle.com/javase/8/docs/api/index.html?javax/annotation/processing/Processor.html[Java Annotation Processor]
 to generate the boilerplate class structure required to properly use the DSL within the TinkerPop framework. These
 classes can be generated and maintained by hand, but it would be time consuming, monotonous and error-prone to do so.


[19/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Updated reference docs for dsl archetype

Posted by sp...@apache.org.
TINKERPOP-786 Updated reference docs for dsl archetype


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a96544f0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a96544f0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a96544f0

Branch: refs/heads/TINKERPOP-1489
Commit: a96544f08ebc44dcfb14971682c7ef1a39d878a8
Parents: 3142aee
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 11 11:43:17 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/gremlin-applications.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a96544f0/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index 7e25585..e62ce86 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -2129,6 +2129,7 @@ Gremlin Archetypes
 TinkerPop has a number of link:https://maven.apache.org/guides/introduction/introduction-to-archetypes.html[Maven archetypes],
 which provide example project templates to quickly get started with TinkerPop. The available archetypes are as follows:
 
+* `gremlin-archetype-dsl` - An example project that demonstrates how to build Domain Specific Languages with Gremlin in Java.
 * `gremlin-archetype-server` - An example project that demonstrates the basic structure of a
 <<gremlin-server,Gremlin Server>> project, how to connect with the Gremlin Driver, and how to embed Gremlin Server in
 a testing framework.


[25/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Refactoring the DSL processor

Posted by sp...@apache.org.
TINKERPOP-786 Refactoring the DSL processor

Abstracted some duplicate code to a single method to clean up a bit more.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/db9343f0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/db9343f0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/db9343f0

Branch: refs/heads/TINKERPOP-1489
Commit: db9343f09bff33d4d8f178afc4f3ddc2a9cdbf51
Parents: 7963dc2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 12 10:31:39 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 .../traversal/dsl/GremlinDslProcessor.java      | 103 +++++--------------
 1 file changed, 27 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/db9343f0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 3358143..5088d21 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -152,26 +152,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                     methodToAdd.addTypeVariable(TypeVariableName.get(((TypeVariable) rtm).asElement().getSimpleName().toString()));
             });
 
-            boolean added = false;
-            final List<? extends VariableElement> parameters = templateMethod.getParameters();
-            String body = "return __.<S>start().$L(";
-            for (VariableElement param : parameters) {
-                methodToAdd.addParameter(ParameterSpec.get(param));
-
-                body = body + param.getSimpleName() + ",";
-                added = true;
-            }
-
-            // treat a final array as a varargs param
-            if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
-                methodToAdd.varargs(true);
-
-            if (added) body = body.substring(0, body.length() - 1);
-
-            body = body + ")";
-
-            methodToAdd.addStatement(body, methodName);
-
+            addMethodBody(methodToAdd, templateMethod, "return __.<S>start().$L(", ")", methodName);
             anonymousClass.addMethod(methodToAdd.build());
         }
 
@@ -189,37 +170,17 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
             templateMethod.getTypeParameters().forEach(tp -> methodToAdd.addTypeVariable(TypeVariableName.get(tp)));
 
-            boolean added = false;
-            final List<? extends VariableElement> parameters = templateMethod.getParameters();
-            String body;
             if (methodName.equals("__")) {
-                for (VariableElement param : parameters) {
+                for (VariableElement param : templateMethod.getParameters()) {
                     methodToAdd.addParameter(ParameterSpec.get(param));
                 }
 
                 methodToAdd.varargs(true);
-
-                body = "return inject(starts)";
+                methodToAdd.addStatement("return inject(starts)", methodName);
             } else {
-                body = "return __.<A>start().$L(";
-                for (VariableElement param : parameters) {
-                    methodToAdd.addParameter(ParameterSpec.get(param));
-
-                    body = body + param.getSimpleName() + ",";
-                    added = true;
-                }
-
-                // treat a final array as a varargs param
-                if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
-                    methodToAdd.varargs(true);
-
-                if (added) body = body.substring(0, body.length() - 1);
-
-                body = body + ")";
+                addMethodBody(methodToAdd, templateMethod, "return __.<A>start().$L(", ")", methodName);
             }
 
-            methodToAdd.addStatement(body, methodName);
-
             anonymousClass.addMethod(methodToAdd.build());
         }
 
@@ -262,26 +223,10 @@ public class GremlinDslProcessor extends AbstractProcessor {
                         .addModifiers(Modifier.PUBLIC)
                         .addAnnotation(Override.class);
 
-                boolean added = false;
-                final List<? extends VariableElement> parameters = templateMethod.getParameters();
-                String body = "return new $T (clone, super.$L(";
-                for (VariableElement param : parameters) {
-                    methodToAdd.addParameter(ParameterSpec.get(param));
-
-                    body = body + param.getSimpleName() + ",";
-                    added = true;
-                }
-
-                // treat a final array as a varargs param
-                if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
-                    methodToAdd.varargs(true);
-
-                if (added) body = body.substring(0, body.length() - 1);
-
-                body = body + ").asAdmin())";
-                methodToAdd.addStatement("$T clone = this.clone()", ctx.traversalSourceClassName)
-                        .addStatement(body, ctx.defaultTraversalClassName, templateMethod.getSimpleName())
-                        .returns(getReturnTypeDefinition(ctx.traversalClassName, templateMethod));
+                methodToAdd.addStatement("$T clone = this.clone()", ctx.traversalSourceClassName);
+                addMethodBody(methodToAdd, templateMethod, "return new $T (clone, super.$L(", ").asAdmin())",
+                        ctx.defaultTraversalClassName, templateMethod.getSimpleName());
+                methodToAdd.returns(getReturnTypeDefinition(ctx.traversalClassName, templateMethod));
 
                 traversalSourceClass.addMethod(methodToAdd.build());
             }
@@ -446,27 +391,33 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         templateMethod.getTypeParameters().forEach(tp -> methodToAdd.addTypeVariable(TypeVariableName.get(tp)));
 
-        boolean added = false;
-        final List<? extends VariableElement> parameters = templateMethod.getParameters();
         final String parentCall = parent.isEmpty() ? "" : parent + ".";
-        String body = "return ($T) " + parentCall + "super.$L(";
-        for (VariableElement param : parameters) {
-            methodToAdd.addParameter(ParameterSpec.get(param));
+        final String body = "return ($T) " + parentCall + "super.$L(";
+        addMethodBody(methodToAdd, templateMethod, body, ")", returnClazz, methodName);
+
+        return methodToAdd.build();
+    }
+
+    private void addMethodBody(final MethodSpec.Builder methodToAdd, final ExecutableElement templateMethod,
+                               final String startBody, final String endBody, final Object... statementArgs) {
+        final List<? extends VariableElement> parameters = templateMethod.getParameters();
+        String body = startBody;
 
-            body = body + param.getSimpleName() + ",";
-            added = true;
+        final int numberOfParams = parameters.size();
+        for (int ix = 0; ix < numberOfParams; ix++) {
+            final VariableElement param = parameters.get(ix);
+            methodToAdd.addParameter(ParameterSpec.get(param));
+            body = body + param.getSimpleName();
+            if (ix < numberOfParams - 1) body = body + ",";
         }
 
+        body = body + endBody;
+
         // treat a final array as a varargs param
         if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
             methodToAdd.varargs(true);
 
-        if (added) body = body.substring(0, body.length() - 1);
-
-        body = body + ")";
-        methodToAdd.addStatement(body, returnClazz, methodName);
-
-        return methodToAdd.build();
+        methodToAdd.addStatement(body, statementArgs);
     }
 
     private TypeName getReturnTypeDefinition(final ClassName returnClazz, final ExecutableElement templateMethod) {


[32/50] [abbrv] tinkerpop git commit: TINKERPOP-1675 Throw underlying unchecked exception in processNextStart

Posted by sp...@apache.org.
TINKERPOP-1675 Throw underlying unchecked exception in processNextStart

For consistency with previous behavior, if an unchecked exception is
set on the returned future throw that instead of the wrapped
CompletionException.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6813e9ef
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6813e9ef
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6813e9ef

Branch: refs/heads/TINKERPOP-1489
Commit: 6813e9efd86a4d032d3106000fb5e805deb26454
Parents: afa3432
Author: Andrew Tolbert <an...@datastax.com>
Authored: Mon May 22 12:14:15 2017 -0500
Committer: Andrew Tolbert <an...@datastax.com>
Committed: Mon May 22 12:20:27 2017 -0500

----------------------------------------------------------------------
 .../remote/traversal/step/map/RemoteStep.java    | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6813e9ef/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
index 3e19097..8f7d12b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
@@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 import java.util.NoSuchElementException;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -57,7 +58,23 @@ public final class RemoteStep<S, E> extends AbstractStep<S, E> {
 
     @Override
     protected Traverser.Admin<E> processNextStart() throws NoSuchElementException {
-        if (null == this.remoteTraversal) promise().join();
+        if (null == this.remoteTraversal) {
+            try {
+                promise().join();
+            } catch (CompletionException e) {
+                Throwable cause = e.getCause();
+                // If the underlying future failed, join() will throw a CompletionException, for consistency
+                // with previous behavior:
+                // - Throw underlying exception if it was unchecked (RuntimeException or Error).
+                // - Wrap in IllegalStateException otherwise.
+                if (cause instanceof RuntimeException) {
+                    throw (RuntimeException) cause;
+                } else if (cause instanceof Error) {
+                    throw (Error) cause;
+                }
+                throw new IllegalStateException(cause);
+            }
+        }
         return this.remoteTraversal.nextTraverser();
     }
 


[12/50] [abbrv] tinkerpop git commit: added basic pattern for gremlin-python dsl development

Posted by sp...@apache.org.
added basic pattern for gremlin-python dsl development


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e0dc97d0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e0dc97d0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e0dc97d0

Branch: refs/heads/TINKERPOP-1489
Commit: e0dc97d0d8337f8808807b1dbf218202e2b0cced
Parents: 2d574fb
Author: davebshow <da...@gmail.com>
Authored: Mon May 8 17:47:37 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../python/GraphTraversalSourceGenerator.groovy | 13 +++--
 .../gremlin_python/process/graph_traversal.py   | 29 ++++++-----
 .../jython/gremlin_python/structure/graph.py    |  6 ++-
 .../src/main/jython/tests/process/test_dsl.py   | 54 ++++++++++++++++++++
 4 files changed, 84 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0dc97d0/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
index 1c66c35..c2e733f 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
@@ -75,8 +75,13 @@ under the License.
     if bytecode is None:
       bytecode = Bytecode()
     self.bytecode = bytecode
+    self.graph_traversal = GraphTraversal
   def __repr__(self):
     return "graphtraversalsource[" + str(self.graph) + "]"
+  def get_graph_traversal_source(self):
+    return self.__class__(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+  def get_graph_traversal(self):
+    return self.graph_traversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
 """)
         GraphTraversalSource.getMethods(). // SOURCE STEPS
                 findAll { GraphTraversalSource.class.equals(it.returnType) }.
@@ -92,14 +97,14 @@ under the License.
                 forEach { method ->
                     pythonClass.append(
                             """  def ${method}(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("${SymbolHelper.toJava(method)}", *args)
     return source
 """)
                 }
         pythonClass.append(
                 """  def withRemote(self, remote_connection):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
     return source
   def withComputer(self,graph_computer=None, workers=None, result=None, persist=None, vertices=None, edges=None, configuration=None):
@@ -113,7 +118,7 @@ under the License.
                 forEach { method ->
                     pythonClass.append(
                             """  def ${method}(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal = self.get_graph_traversal()
     traversal.bytecode.add_step("${SymbolHelper.toJava(method)}", *args)
     return traversal
 """)
@@ -126,7 +131,7 @@ under the License.
         pythonClass.append(
                 """class GraphTraversal(Traversal):
   def __init__(self, graph, traversal_strategies, bytecode):
-    Traversal.__init__(self, graph, traversal_strategies, bytecode)
+    super(GraphTraversal, self).__init__(graph, traversal_strategies, bytecode)
   def __getitem__(self, index):
     if isinstance(index, int):
         return self.range(long(index), long(index + 1))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0dc97d0/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
index e722215..ef49443 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
@@ -32,59 +32,64 @@ class GraphTraversalSource(object):
     if bytecode is None:
       bytecode = Bytecode()
     self.bytecode = bytecode
+    self.graph_traversal = GraphTraversal
   def __repr__(self):
     return "graphtraversalsource[" + str(self.graph) + "]"
+  def get_graph_traversal_source(self):
+    return self.__class__(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+  def get_graph_traversal(self):
+    return self.graph_traversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
   def withBulk(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("withBulk", *args)
     return source
   def withPath(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("withPath", *args)
     return source
   def withSack(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("withSack", *args)
     return source
   def withSideEffect(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("withSideEffect", *args)
     return source
   def withStrategies(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("withStrategies", *args)
     return source
   def withoutStrategies(self, *args):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.bytecode.add_source("withoutStrategies", *args)
     return source
   def withRemote(self, remote_connection):
-    source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
+    source = self.get_graph_traversal_source()
     source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
     return source
   def withComputer(self,graph_computer=None, workers=None, result=None, persist=None, vertices=None, edges=None, configuration=None):
     return self.withStrategies(VertexProgramStrategy(graph_computer,workers,result,persist,vertices,edges,configuration))
   def E(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal = self.get_graph_traversal()
     traversal.bytecode.add_step("E", *args)
     return traversal
   def V(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal = self.get_graph_traversal()
     traversal.bytecode.add_step("V", *args)
     return traversal
   def addV(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal = self.get_graph_traversal()
     traversal.bytecode.add_step("addV", *args)
     return traversal
   def inject(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal = self.get_graph_traversal()
     traversal.bytecode.add_step("inject", *args)
     return traversal
 
 
 class GraphTraversal(Traversal):
   def __init__(self, graph, traversal_strategies, bytecode):
-    Traversal.__init__(self, graph, traversal_strategies, bytecode)
+    super(GraphTraversal, self).__init__(graph, traversal_strategies, bytecode)
   def __getitem__(self, index):
     if isinstance(index, int):
         return self.range(long(index), long(index + 1))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0dc97d0/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/graph.py b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
index d77cde1..7089dad 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
@@ -28,8 +28,10 @@ class Graph(object):
         if self.__class__ not in TraversalStrategies.global_cache:
             TraversalStrategies.global_cache[self.__class__] = TraversalStrategies()
 
-    def traversal(self):
-        return GraphTraversalSource(self, TraversalStrategies.global_cache[self.__class__])
+    def traversal(self, traversal_source_class=None):
+        if not traversal_source_class:
+            traversal_source_class = GraphTraversalSource
+        return traversal_source_class(self, TraversalStrategies.global_cache[self.__class__])
 
     def __repr__(self):
         return "graph[empty]"

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0dc97d0/gremlin-python/src/main/jython/tests/process/test_dsl.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_dsl.py b/gremlin-python/src/main/jython/tests/process/test_dsl.py
new file mode 100644
index 0000000..ece81dc
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/process/test_dsl.py
@@ -0,0 +1,54 @@
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+'''
+import pytest
+
+from gremlin_python.process.graph_traversal import (
+    GraphTraversalSource, GraphTraversal)
+from gremlin_python.structure.graph import Graph
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class SocialTraversalDsl(GraphTraversal):
+
+    def knows(self, person_name):
+        return self.out("knows").hasLabel("person").has("name", person_name)
+
+    def youngestFriendsAge(self):
+        return self.out("knows").hasLabel("person").values("age").min()
+
+
+class SocialTraversalSourceDsl(GraphTraversalSource):
+
+    def __init__(self, *args, **kwargs):
+        super(SocialTraversalSourceDsl, self).__init__(*args, **kwargs)
+        self.graph_traversal = SocialTraversalDsl
+
+    def persons(self):
+        traversal = self.get_graph_traversal()
+        traversal.bytecode.add_step("V")
+        traversal.bytecode.add_step("hasLabel", "person")
+        return traversal
+
+
+def test_dsl(remote_connection):
+    social = Graph().traversal(SocialTraversalSourceDsl).withRemote(remote_connection)
+    assert social.V().has("name", "marko").knows("josh").next()
+    assert social.V().has("name", "marko").youngestFriendsAge().next() == 27
+    assert social.persons().count().next() == 4


[03/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Improved social DSL example a bit.

Posted by sp...@apache.org.
TINKERPOP-786 Improved social DSL example a bit.

Made persons() take a varargs of names to filter with so that you can do: g.persons('marko')


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7e0d6d4a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7e0d6d4a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7e0d6d4a

Branch: refs/heads/TINKERPOP-1489
Commit: 7e0d6d4a79e1310243638fdeb502b0813e01c9d5
Parents: e0dc97d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 10:24:55 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../src/main/java/SocialTraversalDsl.java          |  2 +-
 .../src/main/java/SocialTraversalSourceDsl.java    | 17 +++++++++++++----
 .../src/test/java/SocialDslTest.java               |  2 ++
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e0d6d4a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
index add44aa..e8a2ded 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
@@ -25,7 +25,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 
 @GremlinDsl(traversalSource = "${package}.SocialTraversalSourceDsl")
 public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
-    public default GraphTraversal<S, Vertex> knows(final String personName) {
+    public default GraphTraversal<S, Vertex> knows(String personName) {
         return out("knows").hasLabel("person").has("name", personName);
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e0d6d4a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
index 0117914..9b5b136 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
@@ -41,11 +41,20 @@ public class SocialTraversalSourceDsl extends GraphTraversalSource {
         super(graph);
     }
 
-    public GraphTraversal<Vertex, Vertex> persons() {
-        final GraphTraversalSource clone = this.clone();
+    public GraphTraversal<Vertex, Vertex> persons(String... names) {
+        GraphTraversalSource clone = this.clone();
         clone.getBytecode().addStep(GraphTraversal.Symbols.V);
         clone.getBytecode().addStep(GraphTraversal.Symbols.hasLabel, "person");
-        final GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
-        return TraversalHelper.addHasContainer(traversal.addStep(new GraphStep<>(traversal, Vertex.class, true)), new HasContainer(T.label.getAccessor(), P.eq("person")));
+
+        GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
+        traversal.addStep(new GraphStep<>(traversal, Vertex.class, true));
+        TraversalHelper.addHasContainer(traversal, new HasContainer(T.label.getAccessor(), P.eq("person")));
+
+        if (names.length > 0) {
+            clone.getBytecode().addStep(GraphTraversal.Symbols.has, P.within(names));
+            TraversalHelper.addHasContainer(traversal, new HasContainer("name", P.within(names)));
+        }
+
+        return traversal;
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e0d6d4a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
index be73500..5967244 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
@@ -36,12 +36,14 @@ public class SocialDslTest {
     public void shouldValidateThatMarkoKnowsJosh() {
         SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
         assertTrue(social.V().has("name","marko").knows("josh").hasNext());
+        assertTrue(social.persons("marko").knows("josh").hasNext());
     }
 
     @Test
     public void shouldGetAgeOfYoungestFriendOfMarko() {
         SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
         assertEquals(27, social.V().has("name","marko").youngestFriendsAge().next().intValue());
+        assertEquals(27, social.persons("marko").youngestFriendsAge().next().intValue());
     }
 
     @Test


[20/50] [abbrv] tinkerpop git commit: TINKERPOP-786 WIP for anonymous traversals in python DSLs

Posted by sp...@apache.org.
TINKERPOP-786 WIP for anonymous traversals in python DSLs

Not sure if this will be the right way to do this, but it works and tests pass. We'll see what happens once this gets review.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a3d42d5f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a3d42d5f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a3d42d5f

Branch: refs/heads/TINKERPOP-1489
Commit: a3d42d5f37ff90d758947f19b9568cd2a3d92f1b
Parents: 911d17f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 10 16:47:27 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/tests/process/test_dsl.py   | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a3d42d5f/gremlin-python/src/main/jython/tests/process/test_dsl.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_dsl.py b/gremlin-python/src/main/jython/tests/process/test_dsl.py
index ece81dc..92196fe 100644
--- a/gremlin-python/src/main/jython/tests/process/test_dsl.py
+++ b/gremlin-python/src/main/jython/tests/process/test_dsl.py
@@ -18,14 +18,15 @@ under the License.
 '''
 import pytest
 
+from gremlin_python.process.traversal import (Bytecode, P)
 from gremlin_python.process.graph_traversal import (
-    GraphTraversalSource, GraphTraversal)
+    GraphTraversalSource, GraphTraversal, __)
 from gremlin_python.structure.graph import Graph
 
 __author__ = 'David M. Brown (davebshow@gmail.com)'
 
 
-class SocialTraversalDsl(GraphTraversal):
+class SocialTraversal(GraphTraversal):
 
     def knows(self, person_name):
         return self.out("knows").hasLabel("person").has("name", person_name)
@@ -33,12 +34,28 @@ class SocialTraversalDsl(GraphTraversal):
     def youngestFriendsAge(self):
         return self.out("knows").hasLabel("person").values("age").min()
 
+    def createdAtLeast(self, number):
+        return self.outE("created").count().is_(P.gte(number))
 
-class SocialTraversalSourceDsl(GraphTraversalSource):
+class ___(__):
+    @staticmethod
+    def knows(*args):
+        return SocialTraversal(None, None, Bytecode()).knows(*args)
+
+    @staticmethod
+    def youngestFriendsAge(*args):
+        return SocialTraversal(None, None, Bytecode()).youngestFriendsAge(*args)
+
+    @staticmethod
+    def createdAtLeast(*args):
+        return SocialTraversal(None, None, Bytecode()).createdAtLeast(*args)
+
+
+class SocialTraversalSource(GraphTraversalSource):
 
     def __init__(self, *args, **kwargs):
-        super(SocialTraversalSourceDsl, self).__init__(*args, **kwargs)
-        self.graph_traversal = SocialTraversalDsl
+        super(SocialTraversalSource, self).__init__(*args, **kwargs)
+        self.graph_traversal = SocialTraversal
 
     def persons(self):
         traversal = self.get_graph_traversal()
@@ -48,7 +65,8 @@ class SocialTraversalSourceDsl(GraphTraversalSource):
 
 
 def test_dsl(remote_connection):
-    social = Graph().traversal(SocialTraversalSourceDsl).withRemote(remote_connection)
+    social = Graph().traversal(SocialTraversalSource).withRemote(remote_connection)
     assert social.V().has("name", "marko").knows("josh").next()
     assert social.V().has("name", "marko").youngestFriendsAge().next() == 27
     assert social.persons().count().next() == 4
+    assert social.persons().filter(___.createdAtLeast(2)).count().next() == 1


[49/50] [abbrv] tinkerpop git commit: Javascript GLV

Posted by sp...@apache.org.
Javascript GLV


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/fe8da7cf
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fe8da7cf
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fe8da7cf

Branch: refs/heads/TINKERPOP-1489
Commit: fe8da7cf0ff8ba7fe258df9514d35b1b117919da
Parents: 1d97c3d
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Oct 5 16:14:46 2016 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 gremlin-javascript/pom.xml                      |  132 ++
 .../GraphTraversalSourceGenerator.groovy        |  247 +++
 .../javascript/TraversalSourceGenerator.groovy  |  398 ++++
 .../javascript/GenerateGremlinJavascript.java   |   32 +
 .../gremlin/javascript/jsr223/SymbolHelper.java |   59 +
 .../driver/remote-connection.js                 |  107 +
 .../main/javascript/gremlin-javascript/index.js |   85 +
 .../process/graph-traversal.js                  | 2025 ++++++++++++++++++
 .../gremlin-javascript/process/traversal.js     |  395 ++++
 .../gremlin-javascript/structure/graph.js       |  146 ++
 .../structure/io/graph-serializer.js            |  406 ++++
 .../javascript/gremlin-javascript/helper.js     |   84 +
 .../gremlin-javascript/test-exports.js          |   78 +
 .../gremlin-javascript/test-graphson.js         |  108 +
 .../gremlin-javascript/test-traversal.js        |   54 +
 pom.xml                                         |    1 +
 16 files changed, 4357 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
new file mode 100644
index 0000000..387e628
--- /dev/null
+++ b/gremlin-javascript/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tinkerpop</groupId>
+        <artifactId>tinkerpop</artifactId>
+        <version>3.2.3-SNAPSHOT</version>
+    </parent>
+    <artifactId>gremlin-javascript</artifactId>
+    <name>Apache TinkerPop :: Gremlin Javascript</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>tinkergraph-gremlin</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-test</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-server</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${slf4j.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <properties>
+        <!-- provides a way to convert maven.test.skip value to skipTests for use in skipping python tests -->
+        <maven.test.skip>false</maven.test.skip>
+        <skipTests>${maven.test.skip}</skipTests>
+        <gremlin.server.dir>${project.parent.basedir}/gremlin-server</gremlin.server.dir>
+    </properties>
+    <build>
+        <directory>${basedir}/target</directory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <id>generate-javascript</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>java</goal>
+                        </goals>
+                        <configuration>
+                            <mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
+                            <arguments>
+                                <argument>${basedir}/src/main/javascript/gremlin-javascript/process/traversal.js</argument>
+                                <argument>${basedir}/src/main/javascript/gremlin-javascript/process/graph-traversal.js</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>js-tests</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>jjs</executable>
+                            <arguments>
+                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-exports.js</argument>
+                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-graphson.js</argument>
+                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-traversal.js</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.gmavenplus</groupId>
+                <artifactId>gmavenplus-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>3.0.0</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>clean</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
new file mode 100644
index 0000000..81c38dc
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -0,0 +1,247 @@
+/*
+ *  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.javascript
+
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+
+import java.lang.reflect.Modifier
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class GraphTraversalSourceGenerator {
+
+    public static void create(final String graphTraversalSourceFile) {
+
+        final StringBuilder moduleOutput = new StringBuilder()
+
+        moduleOutput.append("""/*
+ *  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.
+ */
+ """)
+
+//////////////////////////
+// GraphTraversalSource //
+//////////////////////////
+        moduleOutput.append("""
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphTraversalModule() {
+  "use strict";
+
+  var t = loadModule.call(this, './traversal.js');
+  var remote = loadModule.call(this, '../driver/remote-connection.js');
+  var Bytecode = t.Bytecode;
+  var inherits = t.inherits;
+  var parseArgs = t.parseArgs;
+
+  /**
+   *
+   * @param {Graph} graph
+   * @param {TraversalStrategies} traversalStrategies
+   * @param {Bytecode} [bytecode]
+   * @constructor
+   */
+  function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode || new Bytecode();
+  }
+
+  /**
+   * @param remoteConnection
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+  };
+
+  /**
+   * Returns the string representation of the GraphTraversalSource.
+   * @returns {string}
+   */
+  GraphTraversalSource.prototype.toString = function () {
+    return 'graphtraversalsource[' + this._graph.toString() + ']';
+  };
+""")
+        GraphTraversalSource.getMethods(). // SOURCE STEPS
+                findAll { GraphTraversalSource.class.equals(it.returnType) }.
+                findAll {
+                    !it.name.equals("clone") &&
+                            !it.name.equals(TraversalSource.Symbols.withBindings) &&
+                            !it.name.equals(TraversalSource.Symbols.withRemote)
+                }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * ${method} GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.${method} = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+""")
+                }
+        GraphTraversalSource.getMethods(). // SPAWN STEPS
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * ${method} GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.${method} = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+""")
+                }
+////////////////////
+// GraphTraversal //
+////////////////////
+        moduleOutput.append(
+                """
+  /**
+   * Represents a graph traversal.
+   * @constructor
+   */
+  function GraphTraversal(graph, traversalStrategies, bytecode) {
+    t.Traversal.call(this, graph, traversalStrategies, bytecode);
+  }
+
+  inherits(GraphTraversal, t.Traversal);
+""")
+        GraphTraversal.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.${method} = function (args) {
+    this._bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return this;
+  };
+""")
+                };
+
+////////////////////////
+// AnonymousTraversal //
+////////////////////////
+        moduleOutput.append("""
+  /**
+   * Contains the static method definitions
+   * @type {Object}
+   */
+  var statics = {};
+""");
+        __.class.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * ${method}() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.${method} = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.${method}.apply(g, arguments);
+  };
+""")
+                };
+
+        moduleOutput.append("""
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    GraphTraversal: GraphTraversal,
+    GraphTraversalSource: GraphTraversalSource,
+    statics: statics
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);""")
+
+        // save to file
+        final File file = new File(graphTraversalSourceFile);
+        file.delete()
+        moduleOutput.eachLine { file.append(it + "\n") }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
new file mode 100644
index 0000000..efcb826
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -0,0 +1,398 @@
+/*
+ *  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.javascript
+
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.util.CoreImports
+import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+
+import java.lang.reflect.Modifier
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class TraversalSourceGenerator {
+
+    public static void create(final String traversalSourceFile) {
+
+        final StringBuilder moduleOutput = new StringBuilder()
+
+        moduleOutput.append("""/*
+ *  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.
+ */
+""")
+        moduleOutput.append("""
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTraversalModule() {
+  "use strict";
+
+  function Traversal(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode;
+    this.traversers = null;
+    this.sideEffects = null;
+  }
+
+  /** @returns {Bytecode} */
+  Traversal.prototype.getBytecode = function () {
+    return this._bytecode;
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.list = function (callback) {
+    var self = this;
+    this._traversalStrategies.applyStrategies(this, function (err) {
+      if (err) {
+        return callback(err);
+      }
+      callback(err, self.traversers);
+    });
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.one = function (callback) {
+    this.list(function (err, result) {
+      callback(err, result ? result[0] : null);
+    });
+  };
+
+  /**
+   * Returns the Bytecode JSON representation of the traversal
+   * @returns {String}
+   */
+  Traversal.prototype.toString = function () {
+    return this._bytecode.toString();
+  };
+  """);
+
+        moduleOutput.append("""
+  /**
+   * Represents an operation.
+   * @constructor
+   */
+  function P(operator, value, other) {
+    this.operator = operator;
+    this.value = value;
+    this.other = other;
+  }
+
+  /**
+   * Returns the string representation of the instance.
+   * @returns {string}
+   */
+  P.prototype.toString = function () {
+    if (this.other === undefined) {
+      return this.operator + '(' + this.value + ')';
+    }
+    return this.operator + '(' + this.value + ', ' + this.other + ')';
+  };
+
+  function createP(operator, args) {
+    args.unshift(null, operator);
+    return new (Function.prototype.bind.apply(P, args));
+  }
+""")
+        P.class.getMethods().
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { P.class.isAssignableFrom(it.returnType) }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                each { method ->
+                    moduleOutput.append(
+                            """
+  /** @param {...Object} args */
+  P.${method} = function (args) {
+    return createP('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+  };
+""")
+                };
+        moduleOutput.append("""
+  P.prototype.and = function (arg) {
+    return new P('and', this, arg);
+  };
+
+  P.prototype.or = function (arg) {
+    return new P('or', this, arg);
+  };
+""")
+
+        moduleOutput.append("""
+  function Traverser(object, bulk) {
+    this.object = object;
+    this.bulk = bulk == undefined ? 1 : bulk;
+  }
+
+  function TraversalSideEffects() {
+
+  }
+
+  /**
+   * Creates a new instance of TraversalStrategies.
+   * @param {TraversalStrategies} [traversalStrategies]
+   * @constructor
+   */
+  function TraversalStrategies(traversalStrategies) {
+    /** @type {Array<TraversalStrategy>} */
+    this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
+  }
+
+  /** @param {TraversalStrategy} strategy */
+  TraversalStrategies.prototype.addStrategy = function (strategy) {
+    this.strategies.push(strategy);
+  };
+
+  /** @param {Traversal} traversal */
+  TraversalStrategies.prototype.applyStrategies = function (traversal) {
+    this.strategies.forEach(function eachStrategy(s) {
+      s.apply(traversal);
+    });
+  };
+
+  /**
+   * @abstract
+   * @constructor
+   */
+  function TraversalStrategy() {
+
+  }
+
+  /**
+   * @abstract
+   * @param {Traversal} traversal
+   */
+  TraversalStrategy.prototype.apply = function (traversal) {
+
+  };
+
+  /**
+   * Creates a new instance of Bytecode
+   * @param {Bytecode} [toClone]
+   * @constructor
+   */
+  function Bytecode(toClone) {
+    this._bindings = {};
+    if (!toClone) {
+      this.sourceInstructions = [];
+      this.stepInstructions = [];
+    }
+    else {
+      this.sourceInstructions = toClone.sourceInstructions.slice(0);
+      this.stepInstructions = toClone.sourceInstructions.slice(0);
+    }
+  }
+
+  /**
+   * Adds a new source instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addSource = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    this.sourceInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  /**
+   * Adds a new step instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addStep = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    this.stepInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  Bytecode.prototype._generateInstruction = function (name, values) {
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    return instruction;
+  };
+
+  /**
+   * Returns the JSON representation of the source and step instructions
+   * @returns {String}
+   */
+  Bytecode.prototype.toString = function () {
+    return (
+      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
+    );
+  };
+
+  Bytecode.prototype._convertToArgument = function (value) {
+    return value;
+  };
+
+  function toEnum(typeName, keys) {
+    var result = {};
+    keys.split(' ').forEach(function (k) {
+      if (k === k.toUpperCase()) {
+        k = k.toLowerCase();
+      }
+      result[k] = new EnumValue(typeName, k);
+    });
+    return result;
+  }
+
+  function EnumValue(typeName, elementName) {
+    this.typeName = typeName;
+    this.elementName = elementName;
+  }
+
+  /**
+   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
+   */
+  var enums = {};\n""")
+
+        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
+                .findAll { Enum.class.isAssignableFrom(it) }
+                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
+                .collect()) {
+            moduleOutput.append("  enums.${SymbolHelper.decapitalize(enumClass.getSimpleName())} = " +
+                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
+            enumClass.getEnumConstants()
+                    .sort { a, b -> a.name() <=> b.name() }
+                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
+            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("');\n")
+        }
+
+        moduleOutput.append("""
+  // Utility functions
+  /** @returns {Array} */
+  function parseArgs() {
+    return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+  }
+
+  /**
+   * @param {Array} arr
+   * @param {Function} fn
+   * @param {Function} [callback]
+   */
+  function eachSeries(arr, fn, callback) {
+    if (!Array.isArray(arr)) {
+      throw new TypeError('First parameter is not an Array');
+    }
+    callback = callback || noop;
+    var length = arr.length;
+    if (length === 0) {
+      return callback();
+    }
+    var sync;
+    var index = 1;
+    fn(arr[0], next);
+    if (sync === undefined) {
+      sync = false;
+    }
+
+    function next(err) {
+      if (err) {
+        return callback(err);
+      }
+      if (index >= length) {
+        return callback();
+      }
+      if (sync === undefined) {
+        sync = true;
+      }
+      if (sync) {
+        return process.nextTick(function () {
+          fn(arr[index++], next);
+        });
+      }
+      fn(arr[index++], next);
+    }
+  }
+
+  function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor;
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  }
+
+  var toExport = {
+    Bytecode: Bytecode,
+    EnumValue: EnumValue,
+    inherits: inherits,
+    P: P,
+    parseArgs: parseArgs,
+    Traversal: Traversal,
+    TraversalSideEffects: TraversalSideEffects,
+    TraversalStrategies: TraversalStrategies,
+    TraversalStrategy: TraversalStrategy,
+    Traverser: Traverser
+  };
+  Object.keys(enums).forEach(function (k) {
+    toExport[k] = enums[k];
+  });
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);""")
+
+        // save to a file
+        final File file = new File(traversalSourceFile);
+        file.delete()
+        moduleOutput.eachLine { file.append(it + "\n") }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
new file mode 100644
index 0000000..1656db4
--- /dev/null
+++ b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
@@ -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.javascript;
+
+public class GenerateGremlinJavascript {
+
+    private GenerateGremlinJavascript() {
+        // just need the main method
+    }
+
+    public static void main(String[] args) {
+        TraversalSourceGenerator.create(args[0]);
+        GraphTraversalSourceGenerator.create(args[1]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
new file mode 100644
index 0000000..535de44
--- /dev/null
+++ b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
@@ -0,0 +1,59 @@
+/*
+ *  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.javascript.jsr223;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Jorge Bay Gondra
+ */
+public final class SymbolHelper {
+
+    private final static Map<String, String> TO_JS_MAP = new HashMap<>();
+    private final static Map<String, String> FROM_JS_MAP = new HashMap<>();
+
+    static {
+        TO_JS_MAP.put("in", "in_");
+        TO_JS_MAP.put("from", "from_");
+        TO_JS_MAP.forEach((k, v) -> FROM_JS_MAP.put(v, k));
+    }
+
+    private SymbolHelper() {
+        // static methods only, do not instantiate
+    }
+
+    public static String toJs(final String symbol) {
+        return TO_JS_MAP.getOrDefault(symbol, symbol);
+    }
+
+    public static String toJava(final String symbol) {
+        return FROM_JS_MAP.getOrDefault(symbol, symbol);
+    }
+
+    public static String decapitalize(String string) {
+        if (string == null || string.length() == 0) {
+            return string;
+        }
+        char c[] = string.toCharArray();
+        c[0] = Character.toLowerCase(c[0]);
+        return new String(c);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
new file mode 100644
index 0000000..99b177f
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineRemoteConnectionModule() {
+  "use strict";
+
+  var t = loadModule.call(this, '../process/traversal.js');
+  var inherits = t.inherits;
+
+  function RemoteConnection(url, traversalSource) {
+    this.url = url;
+    this.traversalSource = traversalSource;
+  }
+
+  /**
+   * @abstract
+   * @param {Bytecode} bytecode
+   * @param {Function} callback
+   */
+  RemoteConnection.prototype.submit = function (bytecode, callback) {
+    throw new Error('submit() needs to be implemented');
+  };
+
+  /**
+   * @extends {Traversal}
+   * @constructor
+   */
+  function RemoteTraversal(traversers, sideEffects) {
+    t.Traversal.call(this, null, null, null);
+    this.traversers = traversers;
+    this.sideEffects = sideEffects;
+  }
+
+  inherits(RemoteTraversal, t.Traversal);
+
+  /**
+   *
+   * @param {RemoteConnection} connection
+   * @extends {TraversalStrategy}
+   * @constructor
+   */
+  function RemoteStrategy(connection) {
+    t.TraversalStrategy.call(this);
+    this.connection = connection;
+  }
+
+  inherits(RemoteStrategy, t.TraversalStrategy);
+
+  /** @override */
+  RemoteStrategy.prototype.apply = function (traversal, callback) {
+    if (traversal.traversers) {
+      return;
+    }
+    this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
+      if (err) {
+        return callback(err);
+      }
+      traversal.sideEffects = remoteTraversal.sideEffects;
+      traversal.traversers = remoteTraversal.traversers;
+      callback();
+    });
+  };
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    RemoteConnection: RemoteConnection,
+    RemoteStrategy: RemoteStrategy,
+    RemoteTraversal: RemoteTraversal
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
new file mode 100644
index 0000000..cda8200
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function exportModule() {
+  "use strict";
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var t = loadModule.call(this, './process/traversal.js');
+  var gt = loadModule.call(this, './process/graph-traversal.js');
+  var graph = loadModule.call(this, './structure/graph.js');
+  var gs = loadModule.call(this, './structure/io/graph-serializer.js');
+  var rc = loadModule.call(this, './driver/remote-connection.js');
+  var toExport = {
+    driver: {
+      RemoteConnection: rc.RemoteConnection,
+      RemoteStrategy: rc.RemoteStrategy,
+      RemoteTraversal: rc.RemoteTraversal
+    },
+    process: {
+      Bytecode: t.Bytecode,
+      EnumValue: t.EnumValue,
+      inherits: t.inherits,
+      P: t.P,
+      parseArgs: t.parseArgs,
+      Traversal: t.Traversal,
+      TraversalSideEffects: t.TraversalSideEffects,
+      TraversalStrategies: t.TraversalStrategies,
+      TraversalStrategy: t.TraversalStrategy,
+      Traverser: t.Traverser,
+      GraphTraversal: gt.GraphTraversal,
+      GraphTraversalSource: gt.GraphTraversalSource,
+      statics: gt.statics
+    },
+    structure: {
+      io: {
+        GraphSONReader: gs.GraphSONReader,
+        GraphSONWriter: gs.GraphSONWriter
+      },
+      Edge: graph.Edge,
+      Graph: graph.Graph,
+      Path: graph.Path,
+      Property: graph.Property,
+      Vertex: graph.Vertex,
+      VertexProperty: graph.VertexProperty
+    }
+  };
+
+
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  return toExport;
+}).call(this);
\ No newline at end of file


[14/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Added some initial documentation for DSLs

Posted by sp...@apache.org.
TINKERPOP-786 Added some initial documentation for DSLs


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/50f2dac9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/50f2dac9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/50f2dac9

Branch: refs/heads/TINKERPOP-1489
Commit: 50f2dac9d897d5776a2cdd4ae3a7b56a4ed6339a
Parents: e661359
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 13:57:48 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:51 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc | 154 +++++++++++++++++++++++++
 1 file changed, 154 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/50f2dac9/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 2612309..1be365d 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -2939,3 +2939,157 @@ g.V().outE().inV().
     by().
     by('name')
 ----
+
+[[dsl]]
+Domain Specific Languages
+-------------------------
+
+Gremlin is a link:http://en.wikipedia.org/wiki/Domain-specific_language[domain specific language] (DSL) for traversing
+graphs. It operates in the language of vertices, edges and properties. Typically, applications built with Gremlin are
+not of the graph domain, but instead model their domain within a graph. For example, the "modern" toy graph models
+software and person domain objects with the relationships between them (i.e. a person "knows" another person and a
+person "created" software).
+
+image::tinkerpop-modern.png[width=350]
+
+An analyst who wanted to find all the people who "marko" knows could write the following Gremlin:
+
+[source,java]
+----
+g.V().hasLabel('person').has('name','marko').out('knows')
+----
+
+While this method achieves the desired answer, it requires the analyst to traverse the graph in the domain language
+of the graph rather than the domain language of the social network. A more natural way for the analyst to write this
+traversal might be:
+
+[source,java]
+----
+g.persons('marko').knows()
+----
+
+In the statement above, the traversal is written in the language of the domain, abstracting away the underlying
+graph structure from the query. The two traversal results are equivalent and, indeed, the "Social Network DSL" produces
+the same set of traversal steps as the "Graph DSL" thus producing equivalent strategy application and performance
+runtimes.
+
+The following sections explain how to develop application specific DSLs for different <<gremlin-variants,Gremlin Language Variants>>.
+
+[[gremlin-java-dsl]
+Gremlin-Java
+~~~~~~~~~~~~
+
+Creating a DSL in Java requires the `@GremlinDsl` Java annotation in `gremlin-core`. This annotation should be applied
+to a "DSL interface" that extends `GraphTraversal.Admin`.
+
+[source,java]
+----
+@GremlinDsl
+public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
+}
+----
+
+IMPORTANT: The name of the DSL interface should be suffixed with "TraversalDSL". All characters in the interface name
+before that become the "name" of the DSL.
+
+In this interface, define the methods that the DSL will be composed of:
+
+[source,java]
+----
+@GremlinDsl
+public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
+    public default GraphTraversal<S, Vertex> knows(String personName) {
+        return out("knows").hasLabel("person").has("name", personName);
+    }
+
+    public default <E2 extends Number> GraphTraversal<S, E2> youngestFriendsAge() {
+        return out("knows").hasLabel("person").values("age").min();
+    }
+}
+----
+
+The `@GremlinDsl` annotation is used by the link:https://docs.oracle.com/javase/8/docs/api/index.html?javax/annotation/processing/Processor.html[Java Annotation Processor]
+to generate the boilerplate class structure required to properly use the DSL within the TinkerPop framework. These
+classes can be generated and maintained by hand, but it would be time consuming, monotonous and error-prone to do so.
+Typically, the Java compilation process is automatically configured to detect annotation processors on the classpath
+and will automatically use them when found. If that does not happen, it may be necessary to make configuration changes
+to the build to allow for the compilation process to be aware of the following `javax.annotation.processing.Processor`
+implementation:
+
+[source,java]
+----
+org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDslProcessor
+----
+
+The annotation processor will generate several classes for the DSL:
+
+* `SocialTraversal` - A `Traversal` interface that extends the `SocialTraversalDsl` proxying methods to its underlying
+interfaces (such as `GraphTraversal`) to instead return a `SocialTraversal`
+* `DefaultSocialTraversal` - A default implementation of `SocialTraversal` (typically not used directly by the user)
+* `SocialTraversalSource` - Spawns `DefaultSocialTraversal` instances.
+
+Using the DSL then just involves telling the `Graph` to use it:
+
+[source,java]
+----
+SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
+social.V().has("name","marko").knows("josh");
+----
+
+The `SocialTraversalSource` can also be customized with DSL functions. As an additional step, include a class that
+extends from `GraphTraversalSource` and with a name that is suffixed with "TraversalSourceDsl". Include in this class,
+any custom methods required by the DSL:
+
+[source,java]
+----
+public class SocialTraversalSourceDsl extends GraphTraversalSource {
+
+    public SocialTraversalSourceDsl(final Graph graph, final TraversalStrategies traversalStrategies) {
+        super(graph, traversalStrategies);
+    }
+
+    public SocialTraversalSourceDsl(final Graph graph) {
+        super(graph);
+    }
+
+    public GraphTraversal<Vertex, Vertex> persons(String... names) {
+        GraphTraversalSource clone = this.clone();
+
+        // Manually add a "start" step for the traversal in this case the equivalent of V(). GraphStep is marked
+        // as a "start" step by passing "true" in the constructor.
+        clone.getBytecode().addStep(GraphTraversal.Symbols.V);
+        GraphTraversal<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
+        traversal.asAdmin().addStep(new GraphStep<>(traversal.asAdmin(), Vertex.class, true));
+
+        traversal = traversal.hasLabel("person");
+        if (names.length > 0) traversal = traversal.has("name", P.within(names));
+
+        return traversal;
+    }
+}
+----
+
+Then, back in the `SocialTraversal` interface, update the `GremlinDsl` annotation with the `traversalSource` argument
+to point to the fully qualified class name of the `SocialTraversalSourceDsl`:
+
+[source,java]
+----
+@GremlinDsl(traversalSource = "com.company.SocialTraversalSourceDsl")
+public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
+    ...
+}
+----
+
+It is then possible to use the `persons()` method to start traversals:
+
+[source,java]
+----
+SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
+social.persons().count();
+----
+
+NOTE: Using Maven, as shown in the `gremlin-archetype-dsl` module, makes developing DSLs with the annotation processor
+straightforward in that it sets up appropriate paths to the generated code automatically.
+
+Gremlin-Python
+~~~~~~~~~~~~~~


[50/50] [abbrv] tinkerpop git commit: Use null as empty result

Posted by sp...@apache.org.
Use null as empty result


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d2651910
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d2651910
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d2651910

Branch: refs/heads/TINKERPOP-1489
Commit: d2651910001de540399a752aaf07b1beca9fcd94
Parents: aed528c
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 3 14:34:28 2016 +0100
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy   | 2 +-
 .../src/main/javascript/gremlin-javascript/process/traversal.js    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d2651910/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index 46f65a4..d5899f0 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -87,7 +87,7 @@ class TraversalSourceGenerator {
   /** @param {Function} callback */
   Traversal.prototype.one = function (callback) {
     this.list(function (err, result) {
-      callback(err, result ? result[0] : null);
+      callback(err, result && result.length > 0 ? result[0] : null);
     });
   };
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d2651910/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index a7a9bb7..f585161 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -50,7 +50,7 @@
   /** @param {Function} callback */
   Traversal.prototype.one = function (callback) {
     this.list(function (err, result) {
-      callback(err, result ? result[0] : null);
+      callback(err, result && result.length > 0 ? result[0] : null);
     });
   };
 


[06/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Worked in custom GraphTraversalSource into DSL

Posted by sp...@apache.org.
TINKERPOP-786 Worked in custom GraphTraversalSource into DSL


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/cf53e13d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/cf53e13d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/cf53e13d

Branch: refs/heads/TINKERPOP-1489
Commit: cf53e13d66dbced6ab0695481473e8a5e8a5d5c0
Parents: fe702fe
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 28 14:58:52 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../src/main/java/SocialTraversalDsl.java       |  2 +-
 .../src/main/java/SocialTraversalSourceDsl.java | 51 ++++++++++++
 .../src/test/java/SocialDslTest.java            |  6 ++
 .../process/traversal/dsl/GremlinDsl.java       |  6 ++
 .../traversal/dsl/GremlinDslProcessor.java      | 87 ++++++++++++++++----
 .../traversal/util/DefaultTraversal.java        |  5 ++
 .../traversal/dsl/GremlinDslProcessorTest.java  |  8 ++
 .../dsl/SocialPackageTraversalSourceDsl.java    | 54 ++++++++++++
 .../traversal/dsl/SocialMoveTraversalDsl.java   |  2 +-
 .../dsl/SocialPackageTraversalDsl.java          | 37 +++++++++
 .../traversal/dsl/SocialTraversalDsl.java       |  2 +-
 11 files changed, 242 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
index fb2a3f6..add44aa 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
@@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
-@GremlinDsl
+@GremlinDsl(traversalSource = "${package}.SocialTraversalSourceDsl")
 public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
     public default GraphTraversal<S, Vertex> knows(final String personName) {
         return out("knows").hasLabel("person").has("name", personName);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
new file mode 100644
index 0000000..0117914
--- /dev/null
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
@@ -0,0 +1,51 @@
+/*
+ * 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 ${package};
+
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+public class SocialTraversalSourceDsl extends GraphTraversalSource {
+
+    public SocialTraversalSourceDsl(final Graph graph, final TraversalStrategies traversalStrategies) {
+        super(graph, traversalStrategies);
+    }
+
+    public SocialTraversalSourceDsl(final Graph graph) {
+        super(graph);
+    }
+
+    public GraphTraversal<Vertex, Vertex> persons() {
+        final GraphTraversalSource clone = this.clone();
+        clone.getBytecode().addStep(GraphTraversal.Symbols.V);
+        clone.getBytecode().addStep(GraphTraversal.Symbols.hasLabel, "person");
+        final GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
+        return TraversalHelper.addHasContainer(traversal.addStep(new GraphStep<>(traversal, Vertex.class, true)), new HasContainer(T.label.getAccessor(), P.eq("person")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
index ddd584c..be73500 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/test/java/SocialDslTest.java
@@ -43,4 +43,10 @@ public class SocialDslTest {
         SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
         assertEquals(27, social.V().has("name","marko").youngestFriendsAge().next().intValue());
     }
+
+    @Test
+    public void shouldFindAllPersons() {
+        SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
+        assertEquals(4, social.persons().count().next().intValue());
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
index cbeb5ba..d08736e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.process.traversal.dsl;
 
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -39,4 +40,9 @@ public @interface GremlinDsl {
      * it will default to the same package as the class or interface the annotation is on.
      */
     public String packageName() default "";
+
+    /**
+     * Defines the optional canonical name of the {@link GraphTraversalSource} that this DSL should extend from.
+     */
+    public String traversalSource() default "org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource";
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index c2c4fc7..6a09ef5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -111,7 +111,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
     }
 
     private void generateTraversalSource(final Context ctx) throws IOException {
-        final TypeElement graphTraversalSourceElement = elementUtils.getTypeElement(GraphTraversalSource.class.getCanonicalName());
+        final TypeElement graphTraversalSourceElement = ctx.traversalSourceDslType;
         final TypeSpec.Builder traversalSourceClass = TypeSpec.classBuilder(ctx.traversalSourceClazz)
                 .addModifiers(Modifier.PUBLIC)
                 .superclass(TypeName.get(graphTraversalSourceElement.asType()));
@@ -129,22 +129,58 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addStatement("super($N, $N)", "graph", "strategies")
                 .build());
 
-        // override methods to return a the DSL TraversalSource
-        for (Element elementOfGraphTraversal : graphTraversalSourceElement.getEnclosedElements()) {
+        // override methods to return a the DSL TraversalSource. find GraphTraversalSource class somewhere in the hierarchy
+        final Element tinkerPopsGraphTraversalSource = findTinkerPopsGraphTraversalSource(graphTraversalSourceElement);
+        for (Element elementOfGraphTraversalSource : tinkerPopsGraphTraversalSource.getEnclosedElements()) {
             // first copy/override methods that return a GraphTraversalSource so that we can instead return
             // the DSL TraversalSource class.
-            tryConstructMethod(elementOfGraphTraversal, ctx.traversalSourceClassName, "",
+            tryConstructMethod(elementOfGraphTraversalSource, ctx.traversalSourceClassName, "",
                     e -> !(e.getReturnType().getKind() == TypeKind.DECLARED && ((DeclaredType) e.getReturnType()).asElement().getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())),
                     Modifier.PUBLIC)
                     .ifPresent(traversalSourceClass::addMethod);
         }
 
+        // override methods that return GraphTraversal that come from the user defined extension of GraphTraversal
+        if (!graphTraversalSourceElement.getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())) {
+            for (Element elementOfGraphTraversalSource : graphTraversalSourceElement.getEnclosedElements()) {
+                if (elementOfGraphTraversalSource.getKind() != ElementKind.METHOD) continue;
+
+                final ExecutableElement templateMethod = (ExecutableElement) elementOfGraphTraversalSource;
+                final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(elementOfGraphTraversalSource.getSimpleName().toString())
+                        .addModifiers(Modifier.PUBLIC)
+                        .addAnnotation(Override.class);
+
+                boolean added = false;
+                final List<? extends VariableElement> parameters = templateMethod.getParameters();
+                String body = "return new " + ctx.defaultTraversalClassName + "(clone, super." + elementOfGraphTraversalSource.getSimpleName().toString() + "(";
+                for (VariableElement param : parameters) {
+                    methodToAdd.addParameter(ParameterSpec.get(param));
+
+                    body = body + param.getSimpleName() + ",";
+                    added = true;
+                }
+
+                // treat a final array as a varargs param
+                if (!parameters.isEmpty() && parameters.get(parameters.size() - 1).asType().getKind() == TypeKind.ARRAY)
+                    methodToAdd.varargs(true);
+
+                if (added) body = body.substring(0, body.length() - 1);
+
+                body = body + ").asAdmin())";
+                methodToAdd.addStatement("$T clone = this.clone()", ctx.traversalSourceClassName)
+                        .addStatement(body)
+                        .returns(getReturnTypeDefinition(ctx.traversalClassName, templateMethod));
+
+                traversalSourceClass.addMethod(methodToAdd.build());
+            }
+        }
+
         // override methods that return GraphTraversal
         traversalSourceClass.addMethod(MethodSpec.methodBuilder("addV")
                 .addModifiers(Modifier.PUBLIC)
                 .addAnnotation(Override.class)
                 .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.bytecode.addStep($T.addV)", GraphTraversal.Symbols.class)
+                .addStatement("clone.getBytecode().addStep($T.addV)", GraphTraversal.Symbols.class)
                 .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
                 .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, null))", ctx.traversalClassName, AddVertexStartStep.class)
                 .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
@@ -154,7 +190,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addAnnotation(Override.class)
                 .addParameter(String.class, "label")
                 .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.bytecode.addStep($T.addV, label)", GraphTraversal.Symbols.class)
+                .addStatement("clone.getBytecode().addStep($T.addV, label)", GraphTraversal.Symbols.class)
                 .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
                 .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, label))", ctx.traversalClassName, AddVertexStartStep.class)
                 .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
@@ -165,7 +201,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addParameter(Object[].class, "vertexIds")
                 .varargs(true)
                 .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.bytecode.addStep($T.V, vertexIds)", GraphTraversal.Symbols.class)
+                .addStatement("clone.getBytecode().addStep($T.V, vertexIds)", GraphTraversal.Symbols.class)
                 .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
                 .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, $T.class, true, vertexIds))", ctx.traversalClassName, GraphStep.class, Vertex.class)
                 .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Vertex.class), ClassName.get(Vertex.class)))
@@ -176,7 +212,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addParameter(Object[].class, "edgeIds")
                 .varargs(true)
                 .addStatement("$N clone = this.clone()", ctx.traversalSourceClazz)
-                .addStatement("clone.bytecode.addStep($T.E, edgeIds)", GraphTraversal.Symbols.class)
+                .addStatement("clone.getBytecode().addStep($T.E, edgeIds)", GraphTraversal.Symbols.class)
                 .addStatement("$N traversal = new $N(clone)", ctx.defaultTraversalClazz, ctx.defaultTraversalClazz)
                 .addStatement("return ($T) traversal.asAdmin().addStep(new $T(traversal, $T.class, true, edgeIds))", ctx.traversalClassName, GraphStep.class, Edge.class)
                 .returns(ParameterizedTypeName.get(ctx.traversalClassName, ClassName.get(Edge.class), ClassName.get(Edge.class)))
@@ -186,6 +222,15 @@ public class GremlinDslProcessor extends AbstractProcessor {
         traversalSourceJavaFile.writeTo(filer);
     }
 
+    private Element findTinkerPopsGraphTraversalSource(final Element element) {
+        if (element.getSimpleName().contentEquals(GraphTraversalSource.class.getSimpleName())) {
+            return element;
+        }
+
+        final List<? extends TypeMirror> supertypes = typeUtils.directSupertypes(element.asType());
+        return findTinkerPopsGraphTraversalSource(typeUtils.asElement(supertypes.get(0)));
+    }
+
     private void generateDefaultTraversal(final Context ctx) throws IOException {
         final TypeSpec.Builder defaultTraversalClass = TypeSpec.classBuilder(ctx.defaultTraversalClazz)
                 .addModifiers(Modifier.PUBLIC)
@@ -208,6 +253,12 @@ public class GremlinDslProcessor extends AbstractProcessor {
                 .addParameter(ctx.traversalSourceClassName, "traversalSource")
                 .addStatement("super($N)", "traversalSource")
                 .build());
+        defaultTraversalClass.addMethod(MethodSpec.constructorBuilder()
+                .addModifiers(Modifier.PUBLIC)
+                .addParameter(ctx.traversalSourceClassName, "traversalSource")
+                .addParameter(ctx.graphTraversalAdminClassName, "traversal")
+                .addStatement("super($N, $N.asAdmin())", "traversalSource", "traversal")
+                .build());
 
         // add the override
         defaultTraversalClass.addMethod(MethodSpec.methodBuilder("iterate")
@@ -277,13 +328,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
         if (ignore != null && ignore.test(templateMethod)) return Optional.empty();
 
-        final DeclaredType returnTypeMirror = (DeclaredType) templateMethod.getReturnType();
-        final List<? extends TypeMirror> returnTypeArguments = returnTypeMirror.getTypeArguments();
-
-        // build a return type with appropriate generic declarations (if such declarations are present)
-        final TypeName returnType = returnTypeArguments.isEmpty() ?
-                returnClazz :
-                ParameterizedTypeName.get(returnClazz, returnTypeArguments.stream().map(TypeName::get).collect(Collectors.toList()).toArray(new TypeName[returnTypeArguments.size()]));
+        final TypeName returnType = getReturnTypeDefinition(returnClazz, templateMethod);
         final MethodSpec.Builder methodToAdd = MethodSpec.methodBuilder(methodName)
                 .addModifiers(modifiers)
                 .addAnnotation(Override.class)
@@ -315,6 +360,16 @@ public class GremlinDslProcessor extends AbstractProcessor {
         return Optional.of(methodToAdd.build());
     }
 
+    private TypeName getReturnTypeDefinition(final ClassName returnClazz, final ExecutableElement templateMethod) {
+        final DeclaredType returnTypeMirror = (DeclaredType) templateMethod.getReturnType();
+        final List<? extends TypeMirror> returnTypeArguments = returnTypeMirror.getTypeArguments();
+
+        // build a return type with appropriate generic declarations (if such declarations are present)
+        return returnTypeArguments.isEmpty() ?
+                returnClazz :
+                ParameterizedTypeName.get(returnClazz, returnTypeArguments.stream().map(TypeName::get).collect(Collectors.toList()).toArray(new TypeName[returnTypeArguments.size()]));
+    }
+
     private void validateDSL(final Element dslElement) throws ProcessorException {
         if (dslElement.getKind() != ElementKind.INTERFACE)
             throw new ProcessorException(dslElement, "Only interfaces can be annotated with @%s", GremlinDsl.class.getSimpleName());
@@ -335,6 +390,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
         private final String defaultTraversalClazz;
         private final ClassName defaultTraversalClassName;
         private final ClassName graphTraversalAdminClassName;
+        private final TypeElement traversalSourceDslType;
 
         public Context(final TypeElement dslElement) {
             annotatedDslType = dslElement;
@@ -342,6 +398,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
             // gets the annotation on the dsl class/interface
             GremlinDsl gremlinDslAnnotation = dslElement.getAnnotation(GremlinDsl.class);
 
+            traversalSourceDslType = elementUtils.getTypeElement(gremlinDslAnnotation.traversalSource());
             packageName = getPackageName(dslElement, gremlinDslAnnotation);
 
             // create the Traversal implementation interface

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index c8f4b24..5a65006 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -79,6 +79,11 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
         this(traversalSource.getGraph(), traversalSource.getStrategies(), traversalSource.getBytecode());
     }
 
+    public DefaultTraversal(final TraversalSource traversalSource, final DefaultTraversal.Admin<S,E> traversal) {
+        this(traversalSource.getGraph(), traversalSource.getStrategies(), traversal.getBytecode());
+        steps.addAll(traversal.getSteps());
+    }
+
     // TODO: clean up unused or redundant constructors
 
     public DefaultTraversal() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
index d1e976d..d0d7d6f 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessorTest.java
@@ -48,4 +48,12 @@ public class GremlinDslProcessorTest {
                 .and()
                 .generatesFileNamed(StandardLocation.SOURCE_OUTPUT, "org.apache.tinkerpop.gremlin.process.traversal.dsl.social", "SocialMoveTraversal.java");
     }
+
+    @Test
+    public void shouldCompileTraversalAndTraversalSourceToDefaultPackage() {
+        ASSERT.about(javaSource())
+                .that(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialPackageTraversalDsl.java")))
+                .processedWith(new GremlinDslProcessor())
+                .compilesWithoutError();
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
new file mode 100644
index 0000000..143a5c9
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalSourceDsl.java
@@ -0,0 +1,54 @@
+/*
+ * 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.process.traversal.dsl;
+
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class SocialPackageTraversalSourceDsl extends GraphTraversalSource {
+
+    public SocialPackageTraversalSourceDsl(final Graph graph, final TraversalStrategies traversalStrategies) {
+        super(graph, traversalStrategies);
+    }
+
+    public SocialPackageTraversalSourceDsl(final Graph graph) {
+        super(graph);
+    }
+
+    public GraphTraversal<Vertex, Vertex> persons() {
+        final GraphTraversalSource clone = this.clone();
+        clone.getBytecode().addStep(GraphTraversal.Symbols.V);
+        clone.getBytecode().addStep(GraphTraversal.Symbols.hasLabel, "person");
+        final GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
+        return TraversalHelper.addHasContainer(traversal.addStep(new GraphStep<>(traversal, Vertex.class, true)), new HasContainer(T.label.getAccessor(), P.eq("person")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
index 1ef5ca8..bb27a9e 100644
--- a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.tinkerpop.gremlin.util.dsl;
+package org.apache.tinkerpop.gremlin.process.traversal.dsl;
 
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalDsl.java
new file mode 100644
index 0000000..f472932
--- /dev/null
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialPackageTraversalDsl.java
@@ -0,0 +1,37 @@
+/*
+ * 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.process.traversal.dsl;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@GremlinDsl(traversalSource = "org.apache.tinkerpop.gremlin.process.traversal.dsl.SocialPackageTraversalSourceDsl")
+public interface SocialPackageTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
+    public default GraphTraversal<S, Vertex> knows(final String personName) {
+        return out("knows").hasLabel("person").has("name", personName);
+    }
+
+    public default <E2 extends Number> GraphTraversal<S, E2> meanAgeOfFriends() {
+        return out("knows").hasLabel("person").values("age").mean();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf53e13d/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
index c3c40a3..4c31330 100644
--- a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.tinkerpop.gremlin.util.dsl;
+package org.apache.tinkerpop.gremlin.process.traversal.dsl;
 
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;


[40/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Changed name of DSL archetype

Posted by sp...@apache.org.
TINKERPOP-786 Changed name of DSL archetype


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1d97c3de
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1d97c3de
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1d97c3de

Branch: refs/heads/TINKERPOP-1489
Commit: 1d97c3de28ea14b1cda35c4e078b9dd76418120c
Parents: d6b0122
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 26 07:48:00 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 07:48:00 2017 -0400

----------------------------------------------------------------------
 gremlin-archetype/gremlin-archetype-dsl/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d97c3de/gremlin-archetype/gremlin-archetype-dsl/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/pom.xml b/gremlin-archetype/gremlin-archetype-dsl/pom.xml
index d4922f5..cecdc28 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/pom.xml
+++ b/gremlin-archetype/gremlin-archetype-dsl/pom.xml
@@ -10,7 +10,7 @@
     </parent>
 
     <artifactId>gremlin-archetype-dsl</artifactId>
-    <name>Apache TinkerPop :: Archetype - TinkerGraph</name>
+    <name>Apache TinkerPop :: Archetype - DSL</name>
     <packaging>jar</packaging>
 
     <build>


[08/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Added a bunch of javadoc

Posted by sp...@apache.org.
TINKERPOP-786 Added a bunch of javadoc


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ffe4c05d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ffe4c05d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ffe4c05d

Branch: refs/heads/TINKERPOP-1489
Commit: ffe4c05d47cf6e976c1b29a1528fd2498e718966
Parents: cf53e13
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 28 16:07:00 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../process/traversal/dsl/GremlinDsl.java        | 19 +++++++++++++++++--
 .../traversal/dsl/GremlinDslProcessor.java       |  2 ++
 .../traversal/dsl/ProcessorException.java        |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ffe4c05d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
index d08736e..15b93d6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDsl.java
@@ -27,7 +27,21 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * An annotation that specifies that an interface is meant to be used a DSL extension to a {@link GraphTraversal}.
+ * An annotation that specifies that an interface is meant to be used to produce Gremlin DSL. This annotation should
+ * be applied to an interface that extends {@link GraphTraversal}. This interface should be suffixed with
+ * {@code TraversalDsl}. The DSL classes will be generated to the package of the annotated class or the to the value
+ * specified in the {@link #packageName()} and will use the part of the interface name up to the suffix to generate
+ * the classes. Therefore, assuming an interface, annotated with {@code GremlinDsl}, called {@code SocialTraversalDsl},
+ * there will be three classes generated:
+ *
+ * <ul>
+ *     <li>{@code SocialTraversal} - an interface that is an extension to {@code SocialTraversalDsl}</li>
+ *     <li>{@code DefaultSocialTraversal} - an implementation of the {@code SocialTraversal}</li>
+ *     <li>{@code SocialTraversalSource} - an extension of {@link GraphTraversalSource} which spawns {@code DefaultSocialTraversal} instances</li>
+ * </ul>
+ *
+ * Together these generated classes provide all the infrastructure required to properly Gremlin traversals enhanced
+ * with domain specific steps.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -42,7 +56,8 @@ public @interface GremlinDsl {
     public String packageName() default "";
 
     /**
-     * Defines the optional canonical name of the {@link GraphTraversalSource} that this DSL should extend from.
+     * Defines the optional canonical name of the {@link GraphTraversalSource} that this DSL should extend from. If
+     * this value is not supplied the generated "source" will simply extend from {@link GraphTraversalSource}.
      */
     public String traversalSource() default "org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource";
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ffe4c05d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index 6a09ef5..9e23410 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -65,6 +65,8 @@ import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 /**
+ * A custom Java annotation processor for the {@link GremlinDsl} annotation that helps to generate DSLs classes.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 @SupportedAnnotationTypes("org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDsl")

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ffe4c05d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/ProcessorException.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/ProcessorException.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/ProcessorException.java
index c84278e..3051890 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/ProcessorException.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/ProcessorException.java
@@ -21,6 +21,8 @@ package org.apache.tinkerpop.gremlin.process.traversal.dsl;
 import javax.lang.model.element.Element;
 
 /**
+ * Exception thrown by the {@link GremlinDslProcessor}.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class ProcessorException extends Exception {


[47/50] [abbrv] tinkerpop git commit: Javascript GLV

Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
new file mode 100644
index 0000000..e44ef90
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+  "use strict";
+
+  var helper = loadModule.call(this, './helper.js');
+  var assert = helper.assert;
+  var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+  var t = helper.loadLibModule.call(this, 'process/traversal.js');
+  var gs = helper.loadLibModule.call(this, 'structure/io/graph-serializer.js');
+  var GraphSONReader = gs.GraphSONReader;
+  var GraphSONWriter = gs.GraphSONWriter;
+  var P = t.P;
+
+  [
+    function testReadNumbers() {
+      var reader = new GraphSONReader();
+      [
+        [{
+          "@type": "g:Int32",
+          "@value": 31
+        }, 31],
+        [{
+          "@type": "g:Float",
+          "@value": 31.3
+        }, 31.3],
+        [{
+          "@type": "g:Double",
+          "@value": 31.2
+        }, 31.2]
+      ].forEach(function (item) {
+        var result = reader.read(item[0]);
+        assert.strictEqual(result, item[1]);
+        assert.strictEqual(typeof result, 'number');
+      });
+    },
+    function testReadGraph() {
+      var obj = {"@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 = new GraphSONReader(obj);
+      var result = reader.read(obj);
+      assert.ok(result instanceof graph.Vertex);
+      assert.strictEqual(result.label, 'person');
+      assert.strictEqual(typeof result.id, 'number');
+    },
+    function testReadPath() {
+      var obj = {"@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 = new GraphSONReader(obj);
+      var result = reader.read(obj);
+      assert.ok(result);
+      assert.ok(result.objects);
+      assert.ok(result.labels);
+      assert.strictEqual(result.objects[2], 'lop');
+      assert.ok(result.objects[0] instanceof graph.Vertex);
+      assert.ok(result.objects[1] instanceof graph.Vertex);
+      assert.strictEqual(result.objects[0].label, 'person');
+      assert.strictEqual(result.objects[1].label, 'software');
+    },
+    function testWriteNumber() {
+      var writer = new GraphSONWriter();
+      assert.strictEqual(writer.write(2), '2');
+    },
+    function testWriteBoolean() {
+      var writer = new GraphSONWriter();
+      assert.strictEqual(writer.write(true), 'true');
+      assert.strictEqual(writer.write(false), 'false');
+    },
+    function testWriteNumber() {
+      var writer = new GraphSONWriter();
+      var expected = JSON.stringify({"@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.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
+    }
+  ].forEach(function (testCase) {
+    testCase.call(null);
+  });
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      return load(__DIR__ + moduleName);
+    }
+    throw new Error('No module loader was found');
+  }
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
new file mode 100644
index 0000000..477df91
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+  "use strict";
+
+  var helper = loadModule.call(this, './helper.js');
+  var assert = helper.assert;
+  var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+
+  [
+    function testBytecode() {
+      var g = new graph.Graph().traversal();
+      var bytecode = g.V().out('created').getBytecode();
+      assert.ok(bytecode);
+      assert.strictEqual(bytecode.sourceInstructions.length, 0);
+      assert.strictEqual(bytecode.stepInstructions.length, 2);
+      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+      assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
+      assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+    }
+  ].forEach(function (testCase) {
+    testCase.call(null);
+  });
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      return load(__DIR__ + moduleName);
+    }
+    throw new Error('No module loader was found');
+  }
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe8da7cf/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9d6192d..165f9db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,7 @@ limitations under the License.
         <module>gremlin-groovy</module>
         <module>gremlin-groovy-test</module>
         <module>tinkergraph-gremlin</module>
+        <module>gremlin-javascript</module>
         <module>gremlin-python</module>
         <module>hadoop-gremlin</module>
         <module>spark-gremlin</module>


[18/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Updated changelog for DSL work

Posted by sp...@apache.org.
TINKERPOP-786 Updated changelog for DSL work


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5c7f0cbd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5c7f0cbd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5c7f0cbd

Branch: refs/heads/TINKERPOP-1489
Commit: 5c7f0cbd1f8a294d0a98f257cd62a327cc4fd345
Parents: 50f2dac
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 13:58:05 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:30 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5c7f0cbd/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7057aac..dbfe181 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Added the `gremlin-archetype-dsl` to demonstrate how to structure a Maven project for a DSL.
+* Developed and documented patterns for Domain Specific Language implementations.
 * Now using Groovy `[...]` map notation in `GroovyTranslator` instead of `new LinkedHashMap(){{ }}`.
 * Maintained type information on `Traversal.promise()`.
 * Propagated exception to `Future` instead of calling thread in `RemoteConnection`.


[38/50] [abbrv] tinkerpop git commit: Merge branch 'TINKERPOP-786' into tp32

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-786' into tp32

Conflicts:
	CHANGELOG.asciidoc


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/651c1c66
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/651c1c66
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/651c1c66

Branch: refs/heads/TINKERPOP-1489
Commit: 651c1c66e6e7d919d71519c35be251259ff9a595
Parents: 8812f85 869ba9a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 26 06:35:42 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 06:35:42 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   2 +
 .../developer/development-environment.asciidoc  |  10 +
 .../src/reference/gremlin-applications.asciidoc |   1 +
 docs/src/reference/the-traversal.asciidoc       | 250 ++++++++
 .../upgrade/release-3.2.x-incubating.asciidoc   |  25 +-
 gremlin-archetype/gremlin-archetype-dsl/pom.xml |  44 ++
 .../META-INF/maven/archetype-metadata.xml       |  38 ++
 .../archetype-resources/README.asciidoc         |  35 ++
 .../main/resources/archetype-resources/pom.xml  |  63 ++
 .../src/main/java/SocialTraversalDsl.java       |  67 +++
 .../src/main/java/SocialTraversalSourceDsl.java |  67 +++
 .../src/test/java/SocialDslTest.java            |  60 ++
 .../projects/standard/archetype.properties      |  21 +
 .../test/resources/projects/standard/goal.txt   |   1 +
 gremlin-archetype/pom.xml                       |   1 +
 gremlin-core/pom.xml                            |  24 +
 .../process/traversal/dsl/GremlinDsl.java       |  77 +++
 .../traversal/dsl/GremlinDslProcessor.java      | 496 ++++++++++++++++
 .../traversal/dsl/ProcessorException.java       |  39 ++
 .../traversal/util/DefaultTraversal.java        |   5 +
 .../javax.annotation.processing.Processor       |   1 +
 .../traversal/dsl/GremlinDslProcessorTest.java  |  68 +++
 .../dsl/SocialPackageTraversalSourceDsl.java    |  59 ++
 .../traversal/dsl/SocialMoveTraversalDsl.java   |  37 ++
 .../dsl/SocialNoDefaultMethodsTraversalDsl.java |  37 ++
 .../dsl/SocialPackageTraversalDsl.java          |  37 ++
 .../traversal/dsl/SocialTraversalDsl.java       |  37 ++
 .../python/GraphTraversalSourceGenerator.groovy |  28 +-
 .../gremlin_python/process/graph_traversal.py   | 584 ++++++++++---------
 .../jython/gremlin_python/structure/graph.py    |   6 +-
 .../src/main/jython/tests/process/test_dsl.py   |  81 +++
 31 files changed, 1997 insertions(+), 304 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/651c1c66/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 31a4064,dbfe181..dd7616e
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,8 -26,8 +26,10 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
 +* Improved error messaging on the `g.addV(Object...)` when passing an invalid arguments.
 +* Reduced memory usage for TinkerGraph deserialization in GraphSON by streaming vertices and edges.
+ * Added the `gremlin-archetype-dsl` to demonstrate how to structure a Maven project for a DSL.
+ * Developed and documented patterns for Domain Specific Language implementations.
  * Now using Groovy `[...]` map notation in `GroovyTranslator` instead of `new LinkedHashMap(){{ }}`.
  * Maintained type information on `Traversal.promise()`.
  * Propagated exception to `Future` instead of calling thread in `RemoteConnection`.


[04/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Updated docs for intellij setup

Posted by sp...@apache.org.
TINKERPOP-786 Updated docs for intellij setup

Now that we have a annotation processor in gremlin-core there are some additional setup instructions required for Intellij to ensure tests can run through the debugger.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a98471c4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a98471c4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a98471c4

Branch: refs/heads/TINKERPOP-1489
Commit: a98471c4ee267afb1e362a93c28fb9dea221fb98
Parents: 62cfbc9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 4 10:27:27 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 docs/src/dev/developer/development-environment.asciidoc | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a98471c4/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc
index 4a7a3f0..98a89f7 100644
--- a/docs/src/dev/developer/development-environment.asciidoc
+++ b/docs/src/dev/developer/development-environment.asciidoc
@@ -223,3 +223,13 @@ This will ensure that tests will properly execute within the IDE.
 
 If Intellij complains about "duplicate sources" for the Groovy files when attempting to compile/run tests, then
 install the link:http://plugins.jetbrains.com/plugin/7442?pr=idea[GMavenPlus Intellij plugin].
+
+The `gremlin-core` module uses a Java annotation processor to help support DSLs. To support this capability be sure
+that:
+
+. `File | Settings | Compiler | Annotation Processors` has the checkbox with the "Enable annotation processing" checked.
+Intellij should be able to detect the processor automatically on build.
+. The `gremlin-core/target` directory should not be hidden and `target/classes`, `target/gneerated-sources` and
+`target/generated-test-sources should be marked as "Generated Sources Root". If they are not setup that way by
+Intellij by default then simply right-click on them use the "Mark Directory with" option to make the appropriate
+selections.


[33/50] [abbrv] tinkerpop git commit: Improved memory usage when deserializing TinkerGraph from GraphSON

Posted by sp...@apache.org.
Improved memory usage when deserializing TinkerGraph from GraphSON

Streamed vertices/edges rather than reading them all into memory at once. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7ea38751
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7ea38751
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7ea38751

Branch: refs/heads/TINKERPOP-1489
Commit: 7ea38751871f6eddd4c4bcfe8ac82300a08f5a7d
Parents: afa3432
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 23 11:01:55 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 23 11:01:55 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../structure/TinkerIoRegistryV2d0.java         | 40 +++++++++-----------
 2 files changed, 18 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7ea38751/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7057aac..be8059d 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Reduced memory usage for TinkerGraph deserialization in GraphSON by streaming vertices and edges.
 * Now using Groovy `[...]` map notation in `GroovyTranslator` instead of `new LinkedHashMap(){{ }}`.
 * Maintained type information on `Traversal.promise()`.
 * Propagated exception to `Future` instead of calling thread in `RemoteConnection`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7ea38751/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
index 727931c..394216b 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
@@ -26,7 +26,6 @@ import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.TinkerPopJacksonModule;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
@@ -37,12 +36,11 @@ import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
 import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
 import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
+import org.apache.tinkerpop.shaded.jackson.core.JsonToken;
 import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
 import org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider;
 import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
-import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
 import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdScalarSerializer;
-import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
 import org.apache.tinkerpop.shaded.kryo.Kryo;
 import org.apache.tinkerpop.shaded.kryo.Serializer;
 import org.apache.tinkerpop.shaded.kryo.io.Input;
@@ -53,7 +51,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -201,26 +198,23 @@ public final class TinkerIoRegistryV2d0 extends AbstractIoRegistry {
             conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
             final TinkerGraph graph = TinkerGraph.open(conf);
 
-            final List<? extends Edge> edges;
-            final List<? extends Vertex> vertices;
-
-            jsonParser.nextToken();
-            final Map<String, Object> graphData = deserializationContext.readValue(jsonParser, Map.class);
-            vertices = (List<DetachedVertex>) graphData.get(GraphSONTokens.VERTICES);
-            edges = (List<DetachedEdge>) graphData.get(GraphSONTokens.EDGES);
-
-
-            vertices.forEach(e -> {
-                if (e instanceof DetachedVertex) {
-                    ((DetachedVertex)e).attach(Attachable.Method.getOrCreate(graph));
+            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
+                if (jsonParser.getCurrentName().equals("vertices")) {
+                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+                        if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
+                            final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
+                            v.attach(Attachable.Method.getOrCreate(graph));
+                        }
+                    }
+                } else if (jsonParser.getCurrentName().equals("edges")) {
+                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+                        if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
+                            final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
+                            e.attach(Attachable.Method.getOrCreate(graph));
+                        }
+                    }
                 }
-            });
-
-            edges.forEach(e -> {
-                if (e instanceof DetachedEdge) {
-                    ((DetachedEdge) e).attach(Attachable.Method.getOrCreate(graph));
-                }
-            });
+            }
 
             return graph;
         }


[34/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Updated upgrade docs with DSL info

Posted by sp...@apache.org.
TINKERPOP-786 Updated upgrade docs with DSL info


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/869ba9a4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/869ba9a4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/869ba9a4

Branch: refs/heads/TINKERPOP-1489
Commit: 869ba9a45ee8ef897e40fa65d61ce1ac4598bea5
Parents: db9343f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 24 05:10:22 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 24 05:10:22 2017 -0400

----------------------------------------------------------------------
 .../upgrade/release-3.2.x-incubating.asciidoc   | 25 ++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/869ba9a4/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index a2045e4..eeb193e 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -32,6 +32,27 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.2.5/CHANGELOG.asc
 Upgrading for Users
 ~~~~~~~~~~~~~~~~~~~
 
+DSL Support
+^^^^^^^^^^^
+
+It has always been possible to construct Domain Specific Languages (DSLs) with Gremlin, but the approach has required
+a somewhat deep understanding of the TinkerPop code base and it is not something that has had a recommeded method
+for implementation. With this release, TinkerPop simplifies DSL development and provides the best practices for their
+implementation.
+
+[source,java]
+----
+// standard Gremlin
+g.V().hasLabel('person').
+  where(outE("created").count().is(P.gte(2))).count()
+
+// the same traversal as above written as a DSL
+social.persons().where(createdAtLeast(2)).count()
+----
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-786[TINKERPOP-786],
+link:http://tinkerpop.apache.org/docs/3.2.5/dev/reference/#dsl[Reference Documentation]
+
 Authentication Configuration
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -40,7 +61,7 @@ authentication handler and channelizer classes to use. This has been deprecated
 A class that extends `AbstractAuthenticationHandler` may also now be provided as `authentication.authenticationHandler`
 to be used in either of the provided channelizer classes to handle the provided authenticator
 
-See: https://issues.apache.org/jira/browse/TINKERPOP-1657[TINKERPOP-1657]
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1657[TINKERPOP-1657]
 
 Default Maximum Parameters
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -72,7 +93,7 @@ be helpful in understanding usage problems. As `GremlinScriptEngine` instances a
 are naturally exposed as part of the standard link:http://tinkerpop.apache.org/docs/current/reference/#_metrics[metrics]
 set. Note that metrics are captured for both sessionless requests as well as for each individual session that is opened.
 
-See: https://issues.apache.org/jira/browse/TINKERPOP-1644[TINKERPOP-1644]
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1644[TINKERPOP-1644]
 
 Additional Error Information
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^


[17/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Updated README for gremlin-archetype-dsl

Posted by sp...@apache.org.
TINKERPOP-786 Updated README for gremlin-archetype-dsl


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/df012d37
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/df012d37
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/df012d37

Branch: refs/heads/TINKERPOP-1489
Commit: df012d37ace790a4493831dfca6ffdaf3897b1fc
Parents: 94fe5f5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 11:21:45 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:51 2017 -0400

----------------------------------------------------------------------
 .../src/main/resources/archetype-resources/README.asciidoc   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/df012d37/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/README.asciidoc
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/README.asciidoc b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/README.asciidoc
index 1e131b1..b50bdc7 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/README.asciidoc
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/README.asciidoc
@@ -17,7 +17,10 @@ limitations under the License.
 Gremlin DSL
 ===========
 
-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+This is a starter project that demonstrates how a basic
+link:http://tinkerpop.apache.org/docs/${project.version}/reference/#dsl[Domain Specific Language] (DSL) project is
+structured with Java and Maven. The DSL is built to work with the TinkerPop "modern" toy graph. Please see the unit
+tests in `SocialDslTest` for actual DSL usage.
 
 Prerequisites
 -------------
@@ -29,5 +32,4 @@ Building and Running
 --------------------
 
 [source,text]
-mvn clean package
-mvn exec:java -Dexec.mainClass="${package}.App"
\ No newline at end of file
+mvn clean install
\ No newline at end of file


[07/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Fixed gremlin syntax in test DSL files

Posted by sp...@apache.org.
TINKERPOP-786 Fixed gremlin syntax in test DSL files


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/fe702fe7
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fe702fe7
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fe702fe7

Branch: refs/heads/TINKERPOP-1489
Commit: fe702fe7e8c01065adccde0271851a39e5af5a23
Parents: be3ed44
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 27 15:40:41 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java      | 2 +-
 .../gremlin/process/traversal/dsl/SocialTraversalDsl.java          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe702fe7/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
index 1db1dff..1ef5ca8 100644
--- a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialMoveTraversalDsl.java
@@ -32,6 +32,6 @@ public interface SocialMoveTraversalDsl<S, E> extends GraphTraversal.Admin<S, E>
     }
 
     public default <E2 extends Number> GraphTraversal<S, E2> meanAgeOfFriends() {
-        return out("knows").hasLabel("person").properties("age").mean();
+        return out("knows").hasLabel("person").values("age").mean();
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe702fe7/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
index fc4921f..c3c40a3 100644
--- a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/process/traversal/dsl/SocialTraversalDsl.java
@@ -32,6 +32,6 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
     }
 
     public default <E2 extends Number> GraphTraversal<S, E2> meanAgeOfFriends() {
-        return out("knows").hasLabel("person").properties("age").mean();
+        return out("knows").hasLabel("person").values("age").mean();
     }
 }


[26/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Added docs for gremlin-python based DSLs

Posted by sp...@apache.org.
TINKERPOP-786 Added docs for gremlin-python based DSLs


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3142aeee
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3142aeee
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3142aeee

Branch: refs/heads/TINKERPOP-1489
Commit: 3142aeeeef4a3494b6c698f5e8e57a1205973287
Parents: 628ef6e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 11 10:06:33 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc       | 110 +++++++++++++++++--
 .../src/main/java/SocialTraversalDsl.java       |   2 +-
 2 files changed, 102 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3142aeee/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index ec0bed9..443004c 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -2946,17 +2946,17 @@ Domain Specific Languages
 
 Gremlin is a link:http://en.wikipedia.org/wiki/Domain-specific_language[domain specific language] (DSL) for traversing
 graphs. It operates in the language of vertices, edges and properties. Typically, applications built with Gremlin are
-not of the graph domain, but instead model their domain within a graph. For example, the "modern" toy graph models
+not of the graph domain, but instead model their domain within a graph. For example, the
+link:http://tinkerpop.apache.org/docs/current/images/tinkerpop-modern.png["modern" toy graph] models
 software and person domain objects with the relationships between them (i.e. a person "knows" another person and a
 person "created" software).
 
-image::tinkerpop-modern.png[width=350]
-
-An analyst who wanted to find all the people who "marko" knows could write the following Gremlin:
+An analyst who wanted to find out if "marko" knows "josh" could write the following Gremlin:
 
 [source,java]
 ----
-g.V().hasLabel('person').has('name','marko').out('knows')
+g.V().hasLabel('person').has('name','marko').
+  out('knows').hasLabel('person').has('name','josh').hasNext()
 ----
 
 While this method achieves the desired answer, it requires the analyst to traverse the graph in the domain language
@@ -2965,15 +2965,35 @@ traversal might be:
 
 [source,java]
 ----
-g.persons('marko').knows()
+g.persons('marko').knows('josh').hasNext()
 ----
 
 In the statement above, the traversal is written in the language of the domain, abstracting away the underlying
-graph structure from the query. The two traversal results are equivalent and, indeed, the "Social Network DSL" produces
+graph structure from the query. The two traversal results are equivalent and, indeed, the "Social DSL" produces
 the same set of traversal steps as the "Graph DSL" thus producing equivalent strategy application and performance
 runtimes.
 
-The following sections explain how to develop application specific DSLs for different <<gremlin-variants,Gremlin Language Variants>>.
+To further the example of the Social DSL consider the following:
+
+[source,java]
+----
+// Graph DSL - find the number of persons who created at least 2 projects
+g.V().hasLabel('person').
+  where(outE("created").count().is(P.gte(2))).count()
+
+// Social DSL - find the number of persons who created at least 2 projects
+social.persons().where(createdAtLeast(2)).count()
+
+// Graph DSL - determine the age of the youngest friend "marko" has
+g.V().hasLabel('person').has('name','marko').
+  out("knows").hasLabel("person").values("age").min()
+
+// Social DSL - determine the age of the youngest friend "marko" has
+social.persons("marko").youngestFriendsAge()
+----
+
+The following sections explain how to develop application specific DSLs for different <<gremlin-variants,Gremlin Language Variants>>
+using the examples above of the Social DSL as the API for the implementation.
 
 [[gremlin-java-dsl]
 Gremlin-Java
@@ -3005,6 +3025,10 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
     public default <E2 extends Number> GraphTraversal<S, E2> youngestFriendsAge() {
         return out("knows").hasLabel("person").values("age").min();
     }
+
+    public default GraphTraversal<S, Long> createdAtLeast(int number) {
+        return outE("created").count().is(P.gte(number));
+    }
 }
 ----
 
@@ -3089,7 +3113,7 @@ It is then possible to use the `persons()` method to start traversals:
 [source,java]
 ----
 SocialTraversalSource social = graph.traversal(SocialTraversalSource.class);
-social.persons().count();
+social.persons("marko").knows("josh");
 ----
 
 NOTE: Using Maven, as shown in the `gremlin-archetype-dsl` module, makes developing DSLs with the annotation processor
@@ -3097,3 +3121,71 @@ straightforward in that it sets up appropriate paths to the generated code autom
 
 Gremlin-Python
 ~~~~~~~~~~~~~~
+
+Writing a Gremlin DSL in Python simply requires direct extension of several classes:
+
+* `GraphTraversal` - which exposes the various steps used in traversal writing
+* `__` - which spawns anonymous traversals from steps
+* `GraphTraversalSource` - which spawns `GraphTraversal` instances
+
+The Social DSL based on the link:http://tinkerpop.apache.org/docs/current/images/tinkerpop-modern.png["modern" toy graph]
+might look like this:
+
+[source,python]
+----
+class SocialTraversal(GraphTraversal):
+
+    def knows(self, person_name):
+        return self.out("knows").hasLabel("person").has("name", person_name)
+
+    def youngestFriendsAge(self):
+        return self.out("knows").hasLabel("person").values("age").min()
+
+    def createdAtLeast(self, number):
+        return self.outE("created").count().is_(P.gte(number))
+
+class __(AnonymousTraversal):
+    @staticmethod
+    def knows(*args):
+        return SocialTraversal(None, None, Bytecode()).knows(*args)
+
+    @staticmethod
+    def youngestFriendsAge(*args):
+        return SocialTraversal(None, None, Bytecode()).youngestFriendsAge(*args)
+
+    @staticmethod
+    def createdAtLeast(*args):
+        return SocialTraversal(None, None, Bytecode()).createdAtLeast(*args)
+
+
+class SocialTraversalSource(GraphTraversalSource):
+
+    def __init__(self, *args, **kwargs):
+        super(SocialTraversalSource, self).__init__(*args, **kwargs)
+        self.graph_traversal = SocialTraversal
+
+    def persons(self, *args):
+        traversal = self.get_graph_traversal()
+        traversal.bytecode.add_step("V")
+        traversal.bytecode.add_step("hasLabel", "person")
+
+        if len(args) > 0:
+            traversal.bytecode.add_step("has", "name", P.within(args))
+
+        return traversal
+----
+
+NOTE: The `AnonymousTraversal` class above is just an alias for `__` as in
+`from gremlin_python.process.graph_traversal import __ as AnonymousTraversal`
+
+Using the DSL is straightforward and just requires that the graph instance know the `SocialTraversalSource` should
+be used:
+
+[source,python]
+----
+social = Graph().traversal(SocialTraversalSource).withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
+social.persons("marko").knows("josh")
+social.persons("marko").youngestFriendsAge()
+social.persons().filter(__.createdAtLeast(2)).count()
+----
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3142aeee/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
index b7e4f07..7f83152 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalDsl.java
@@ -61,7 +61,7 @@ public interface SocialTraversalDsl<S, E> extends GraphTraversal.Admin<S, E> {
      *
      * @param number the minimum number of projects a person created
      */
-    public default GraphTraversal<S,Long> createdAtLeast(int number) {
+    public default GraphTraversal<S, Long> createdAtLeast(int number) {
         return outE("created").count().is(P.gte(number));
     }
 }


[43/50] [abbrv] tinkerpop git commit: TINKERPOP-1489 Cleaned up pom

Posted by sp...@apache.org.
TINKERPOP-1489 Cleaned up pom

Removed some weird characters in license and bumped version to 3.2.5-SNAPSHOT


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/94e2db45
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/94e2db45
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/94e2db45

Branch: refs/heads/TINKERPOP-1489
Commit: 94e2db450c9feeeaf153cb7068c3bb11bd1a3452
Parents: 9cdebd1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 18 12:47:48 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 gremlin-javascript/pom.xml | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/94e2db45/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 387e628..b9b78cc 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~  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.
-  -->
+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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -24,7 +21,7 @@
     <parent>
         <groupId>org.apache.tinkerpop</groupId>
         <artifactId>tinkerpop</artifactId>
-        <version>3.2.3-SNAPSHOT</version>
+        <version>3.2.5-SNAPSHOT</version>
     </parent>
     <artifactId>gremlin-javascript</artifactId>
     <name>Apache TinkerPop :: Gremlin Javascript</name>


[35/50] [abbrv] tinkerpop git commit: TINKERPOP-1653 Fixed multiple -e script execution in Console

Posted by sp...@apache.org.
TINKERPOP-1653 Fixed multiple -e script execution in Console

Added tests - not sure why these weren't there before.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7bf68835
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7bf68835
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7bf68835

Branch: refs/heads/TINKERPOP-1489
Commit: 7bf688350251f64247a71c39900fa015c59eb35b
Parents: 7ea3875
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 25 06:45:12 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 25 06:45:12 2017 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    |  6 ++---
 .../src/test/python/tests/test_console.py       | 25 ++++++++++++++++----
 .../src/test/python/x-printed.script            | 21 ++++++++++++++++
 gremlin-console/src/test/python/x.groovy        | 20 ----------------
 gremlin-console/src/test/python/x.script        | 20 ++++++++++++++++
 .../src/test/python/y-printed.script            | 21 ++++++++++++++++
 gremlin-console/src/test/python/y.groovy        | 20 ----------------
 gremlin-console/src/test/python/y.script        | 20 ++++++++++++++++
 .../src/test/python/z-printed.script            | 21 ++++++++++++++++
 gremlin-console/src/test/python/z.groovy        | 20 ----------------
 gremlin-console/src/test/python/z.script        | 20 ++++++++++++++++
 11 files changed, 147 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index 393f1f2..3bdc8a1 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -365,7 +365,7 @@ class Console {
     }
 
     private void executeInShell(final List<List<String>> scriptsAndArgs) {
-        scriptsAndArgs.each { scriptAndArgs ->
+        scriptsAndArgs.eachWithIndex { scriptAndArgs, idx ->
             final String scriptFile = scriptAndArgs[0]
             try {
                 // check if this script comes with arguments. if so then set them up in an "args" bundle
@@ -400,8 +400,6 @@ class Console {
 
                     }
                 }
-
-                if (!interactive) System.exit(0)
             } catch (FileNotFoundException ignored) {
                 io.err.println(Colorizer.render(Preferences.errorColor, "Gremlin file not found at [$scriptFile]."))
                 if (!interactive) System.exit(1)
@@ -410,6 +408,8 @@ class Console {
                 if (!interactive) System.exit(1)
             }
         }
+
+        if (!interactive) System.exit(0)
     }
 
     public static void main(final String[] args) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/tests/test_console.py
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/tests/test_console.py b/gremlin-console/src/test/python/tests/test_console.py
index f079291..407b563 100644
--- a/gremlin-console/src/test/python/tests/test_console.py
+++ b/gremlin-console/src/test/python/tests/test_console.py
@@ -34,7 +34,7 @@ class TestConsole(object):
         TestConsole._close(child)
 
     def test_just_dash_i(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i x.groovy")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i x.script")
         TestConsole._expect_gremlin_header(child)
         TestConsole._send(child, "x")
         child.expect("==>2\r\n")
@@ -42,7 +42,7 @@ class TestConsole(object):
         TestConsole._close(child)
 
     def test_dash_i_with_args(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.groovy 1 2 3")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.script 1 2 3")
         TestConsole._expect_gremlin_header(child)
         TestConsole._send(child, "y")
         child.expect("==>6\r\n")
@@ -50,7 +50,7 @@ class TestConsole(object):
         TestConsole._close(child)
 
     def test_dash_i_multiple_scripts(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.groovy 1 2 3 -i x.groovy -i \"z.groovy x -i --color -D\"")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.script 1 2 3 -i x.script -i \"z.script x -i --color -D\"")
         TestConsole._expect_gremlin_header(child)
         TestConsole._send(child, "y")
         child.expect("==>6\r\n")
@@ -63,8 +63,25 @@ class TestConsole(object):
         TestConsole._expect_prompt(child)
         TestConsole._close(child)
 
+    def test_just_dash_e(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e x-printed.script")
+        child.expect("2\r\n")
+        TestConsole._close(child)
+
+    def test_dash_e_with_args(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e y-printed.script 1 2 3")
+        child.expect("6\r\n")
+        TestConsole._close(child)
+
+    def test_dash_e_multiple_scripts(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e y-printed.script 1 2 3 -e x-printed.script -e \"z-printed.script x -e --color -D\"")
+        child.expect("6\r\n")
+        child.expect("2\r\n")
+        child.expect("argument=\[x, -e, --color, -D\]\r\n")
+        TestConsole._close(child)
+
     def test_no_mix_dash_i_and_dash_e(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.groovy 1 2 3 -i x.groovy -e \"z.groovy x -i --color -D\"")
+        child = pexpect.spawn(TestConsole.gremlinsh + "-i y.script 1 2 3 -i x.script -e \"z.script x -i --color -D\"")
         child.expect("-i and -e options are mutually exclusive - provide one or the other")
         child.expect(pexpect.EOF)
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/x-printed.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/x-printed.script b/gremlin-console/src/test/python/x-printed.script
new file mode 100644
index 0000000..9be57a5
--- /dev/null
+++ b/gremlin-console/src/test/python/x-printed.script
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+x = 1 + 1
+println x
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/x.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/x.groovy b/gremlin-console/src/test/python/x.groovy
deleted file mode 100644
index 31a9f19..0000000
--- a/gremlin-console/src/test/python/x.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-
-x = 1 + 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/x.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/x.script b/gremlin-console/src/test/python/x.script
new file mode 100644
index 0000000..31a9f19
--- /dev/null
+++ b/gremlin-console/src/test/python/x.script
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+x = 1 + 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/y-printed.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/y-printed.script b/gremlin-console/src/test/python/y-printed.script
new file mode 100644
index 0000000..e297186
--- /dev/null
+++ b/gremlin-console/src/test/python/y-printed.script
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+y = args.collect{Integer.parseInt(it)}.sum()
+println y
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/y.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/y.groovy b/gremlin-console/src/test/python/y.groovy
deleted file mode 100644
index 8b0adf6..0000000
--- a/gremlin-console/src/test/python/y.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-
-y = args.collect{Integer.parseInt(it)}.sum()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/y.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/y.script b/gremlin-console/src/test/python/y.script
new file mode 100644
index 0000000..8b0adf6
--- /dev/null
+++ b/gremlin-console/src/test/python/y.script
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+y = args.collect{Integer.parseInt(it)}.sum()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/z-printed.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/z-printed.script b/gremlin-console/src/test/python/z-printed.script
new file mode 100644
index 0000000..676542a
--- /dev/null
+++ b/gremlin-console/src/test/python/z-printed.script
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+z = "argument=" + args
+println z
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/z.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/z.groovy b/gremlin-console/src/test/python/z.groovy
deleted file mode 100644
index 3d7d101..0000000
--- a/gremlin-console/src/test/python/z.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-
-z = "argument=" + args
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7bf68835/gremlin-console/src/test/python/z.script
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/z.script b/gremlin-console/src/test/python/z.script
new file mode 100644
index 0000000..3d7d101
--- /dev/null
+++ b/gremlin-console/src/test/python/z.script
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+z = "argument=" + args
\ No newline at end of file


[13/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Used templating language instead of string concat

Posted by sp...@apache.org.
TINKERPOP-786 Used templating language instead of string concat


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2d574fbd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2d574fbd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2d574fbd

Branch: refs/heads/TINKERPOP-1489
Commit: 2d574fbddc8aefd671880427c421b610da0f3b4d
Parents: a98471c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 4 10:28:29 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../gremlin/process/traversal/dsl/GremlinDslProcessor.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d574fbd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
index f8a3266..e246765 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslProcessor.java
@@ -154,7 +154,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
                 boolean added = false;
                 final List<? extends VariableElement> parameters = templateMethod.getParameters();
-                String body = "return new " + ctx.defaultTraversalClassName + "(clone, super." + elementOfGraphTraversalSource.getSimpleName().toString() + "(";
+                String body = "return new $T (clone, super.$L(";
                 for (VariableElement param : parameters) {
                     methodToAdd.addParameter(ParameterSpec.get(param));
 
@@ -170,7 +170,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
 
                 body = body + ").asAdmin())";
                 methodToAdd.addStatement("$T clone = this.clone()", ctx.traversalSourceClassName)
-                        .addStatement(body)
+                        .addStatement(body, ctx.defaultTraversalClassName, elementOfGraphTraversalSource.getSimpleName())
                         .returns(getReturnTypeDefinition(ctx.traversalClassName, templateMethod));
 
                 traversalSourceClass.addMethod(methodToAdd.build());
@@ -344,7 +344,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
         boolean added = false;
         final List<? extends VariableElement> parameters = templateMethod.getParameters();
         final String parentCall = parent.isEmpty() ? "" : parent + ".";
-        String body = "return (" + returnClazz.simpleName() + ") " + parentCall + "super." + methodName + "(";
+        String body = "return ($T) " + parentCall + "super.$L(";
         for (VariableElement param : parameters) {
             methodToAdd.addParameter(ParameterSpec.get(param));
 
@@ -359,7 +359,7 @@ public class GremlinDslProcessor extends AbstractProcessor {
         if (added) body = body.substring(0, body.length() - 1);
 
         body = body + ")";
-        methodToAdd.addStatement(body);
+        methodToAdd.addStatement(body, returnClazz, methodName);
 
         return Optional.of(methodToAdd.build());
     }


[16/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Improved the TraversalSource definition in the archetype

Posted by sp...@apache.org.
TINKERPOP-786 Improved the TraversalSource definition in the archetype


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b47b25cd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b47b25cd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b47b25cd

Branch: refs/heads/TINKERPOP-1489
Commit: b47b25cda2ee3b38159c127e3f0218e7a9a55e37
Parents: df012d3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 9 13:47:31 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:51 2017 -0400

----------------------------------------------------------------------
 .../src/main/java/SocialTraversalSourceDsl.java     | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b47b25cd/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
index 3bd8297..d14b843 100644
--- a/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
+++ b/gremlin-archetype/gremlin-archetype-dsl/src/main/resources/archetype-resources/src/main/java/SocialTraversalSourceDsl.java
@@ -52,17 +52,15 @@ public class SocialTraversalSourceDsl extends GraphTraversalSource {
      */
     public GraphTraversal<Vertex, Vertex> persons(String... names) {
         GraphTraversalSource clone = this.clone();
-        clone.getBytecode().addStep(GraphTraversal.Symbols.V);
-        clone.getBytecode().addStep(GraphTraversal.Symbols.hasLabel, "person");
 
-        GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
-        traversal.addStep(new GraphStep<>(traversal, Vertex.class, true));
-        TraversalHelper.addHasContainer(traversal, new HasContainer(T.label.getAccessor(), P.eq("person")));
+        // Manually add a "start" step for the traversal in this case the equivalent of V(). GraphStep is marked
+        // as a "start" step by passing "true" in the constructor.
+        clone.getBytecode().addStep(GraphTraversal.Symbols.V);
+        GraphTraversal<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
+        traversal.asAdmin().addStep(new GraphStep<>(traversal.asAdmin(), Vertex.class, true));
 
-        if (names.length > 0) {
-            clone.getBytecode().addStep(GraphTraversal.Symbols.has, P.within(names));
-            TraversalHelper.addHasContainer(traversal, new HasContainer("name", P.within(names)));
-        }
+        traversal = traversal.hasLabel("person");
+        if (names.length > 0) traversal = traversal.has("name", P.within(names));
 
         return traversal;
     }


[30/50] [abbrv] tinkerpop git commit: Fixed bad sample code in docs

Posted by sp...@apache.org.
Fixed bad sample code in docs

vertexIdKey was removed a long long time ago. Can't even find where it was last in the API going back to 3.0.x - that's been bad a long time...dah CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/07bca450
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/07bca450
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/07bca450

Branch: refs/heads/TINKERPOP-1489
Commit: 07bca45002ca2392bd1e8ada1eed6ff29528c88d
Parents: 0e5725b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon May 22 09:48:05 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 22 09:48:05 2017 -0400

----------------------------------------------------------------------
 docs/src/reference/the-graph.asciidoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/07bca450/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-graph.asciidoc b/docs/src/reference/the-graph.asciidoc
index 09c11fa..9515cf5 100644
--- a/docs/src/reference/the-graph.asciidoc
+++ b/docs/src/reference/the-graph.asciidoc
@@ -440,7 +440,7 @@ try (final OutputStream os = new FileOutputStream("tinkerpop-modern.xml")) {
 
 final Graph newGraph = TinkerGraph.open();
 try (final InputStream stream = new FileInputStream("tinkerpop-modern.xml")) {
-    newGraph.io(IoCore.graphml()).reader().vertexIdKey("name").create().readGraph(stream, newGraph);
+    newGraph.io(IoCore.graphml()).reader().create().readGraph(stream, newGraph);
 }
 ----
 
@@ -507,7 +507,7 @@ try (final OutputStream os = new FileOutputStream("tinkerpop-modern.json")) {
 
 final Graph newGraph = TinkerGraph.open();
 try (final InputStream stream = new FileInputStream("tinkerpop-modern.json")) {
-    newGraph.io(IoCore.graphson()).reader().vertexIdKey("name").create().readGraph(stream, newGraph);
+    newGraph.io(IoCore.graphson()).reader().create().readGraph(stream, newGraph);
 }
 ----
 
@@ -719,7 +719,7 @@ try (final OutputStream os = new FileOutputStream("tinkerpop-modern.kryo")) {
 
 final Graph newGraph = TinkerGraph.open();
 try (final InputStream stream = new FileInputStream("tinkerpop-modern.kryo")) {
-    newGraph.io(IoCore.gryo()).reader().vertexIdKey("name").create().readGraph(stream, newGraph);
+    newGraph.io(IoCore.gryo()).reader().create().readGraph(stream, newGraph);
 }
 ----
 


[05/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Deleted an unused interface

Posted by sp...@apache.org.
TINKERPOP-786 Deleted an unused interface


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f437275e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f437275e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f437275e

Branch: refs/heads/TINKERPOP-1489
Commit: f437275e6b21aecddf150fe2fca70de5cd3fb837
Parents: ffe4c05
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 28 16:07:52 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:01:50 2017 -0400

----------------------------------------------------------------------
 .../dsl/GremlinDslAnnotatedInterface.java       | 32 --------------------
 1 file changed, 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f437275e/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslAnnotatedInterface.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslAnnotatedInterface.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslAnnotatedInterface.java
deleted file mode 100644
index 2f6db74..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/GremlinDslAnnotatedInterface.java
+++ /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.process.traversal.dsl;
-
-import javax.lang.model.element.TypeElement;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-class GremlinDslAnnotatedInterface {
-    private final TypeElement annotatedInterfaceElement;
-
-    public GremlinDslAnnotatedInterface(final TypeElement interfaceElement) {
-        annotatedInterfaceElement = interfaceElement;
-    }
-}


[42/50] [abbrv] tinkerpop git commit: Parse Edge and VertexProperty properties

Posted by sp...@apache.org.
Parse Edge and VertexProperty properties

To follow the decision around TINKERPOP-1474 for the GLV to parse properties.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9cdebd15
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9cdebd15
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9cdebd15

Branch: refs/heads/TINKERPOP-1489
Commit: 9cdebd15509d6430c921a6ae3bcf8b0b9c2a55bd
Parents: d265191
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 16 13:41:46 2016 +0100
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 26 08:58:26 2017 -0400

----------------------------------------------------------------------
 .../javascript/gremlin-javascript/structure/graph.js | 15 +++++++++++++--
 .../structure/io/graph-serializer.js                 | 13 +++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9cdebd15/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
index 7c48819..cd408ae 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -68,10 +68,20 @@
 
   inherits(Vertex, Element);
 
-  function Edge(id, outV, label, inV) {
+  function Edge(id, outV, label, inV, properties) {
     Element.call(this, id, label);
     this.outV = outV;
     this.inV = inV;
+    this.properties = {};
+    (function adaptProperties(self) {
+      if (properties) {
+        var keys = Object.keys(properties);
+        for (var i = 0; i < keys.length; i++) {
+          var k = keys[i];
+          self.properties[k] = properties[k].value;
+        }
+      }
+    })(this);
   }
 
   inherits(Edge, Element);
@@ -80,10 +90,11 @@
     return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
   };
 
-  function VertexProperty(id, label, value) {
+  function VertexProperty(id, label, value, properties) {
     Element.call(this, id, label);
     this.value = value;
     this.key = this.label;
+    this.properties = properties;
   }
 
   inherits(VertexProperty, Element);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9cdebd15/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
index 2dde340..31652da 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -155,6 +155,9 @@
   }
 
   GraphSONReader.prototype.read = function (obj) {
+    if (obj === undefined) {
+      return undefined;
+    }
     if (Array.isArray(obj)) {
       return obj.map(function mapEach(item) {
         return this.read(item);
@@ -340,7 +343,12 @@
 
   VertexPropertySerializer.prototype.deserialize = function (obj) {
     var value = obj[valueKey];
-    return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+    return new g.VertexProperty(
+      this.reader.read(value['id']),
+      value['label'],
+      this.reader.read(value['value']),
+      this.reader.read(value['properties'])
+    );
   };
 
   function PropertySerializer() {
@@ -364,7 +372,8 @@
       this.reader.read(value['id']),
       this.reader.read(value['outV']),
       value['label'],
-      this.reader.read(value['inV'])
+      this.reader.read(value['inV']),
+      this.reader.read(value['properties'])
     );
   };
 


[23/50] [abbrv] tinkerpop git commit: TINKERPOP-786 Minor change to imports for python DSL example

Posted by sp...@apache.org.
TINKERPOP-786 Minor change to imports for python DSL example


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/628ef6e0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/628ef6e0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/628ef6e0

Branch: refs/heads/TINKERPOP-1489
Commit: 628ef6e02c59adc213335083324792ac2d571b0e
Parents: 5e09caf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 11 10:06:17 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 gremlin-python/src/main/jython/tests/process/test_dsl.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/628ef6e0/gremlin-python/src/main/jython/tests/process/test_dsl.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_dsl.py b/gremlin-python/src/main/jython/tests/process/test_dsl.py
index 04313ab..0652cbb 100644
--- a/gremlin-python/src/main/jython/tests/process/test_dsl.py
+++ b/gremlin-python/src/main/jython/tests/process/test_dsl.py
@@ -20,7 +20,8 @@ import pytest
 
 from gremlin_python.process.traversal import (Bytecode, P)
 from gremlin_python.process.graph_traversal import (
-    GraphTraversalSource, GraphTraversal, __)
+    GraphTraversalSource, GraphTraversal)
+from gremlin_python.process.graph_traversal import __ as AnonymousTraversal
 from gremlin_python.structure.graph import Graph
 
 __author__ = 'David M. Brown (davebshow@gmail.com)'
@@ -37,7 +38,7 @@ class SocialTraversal(GraphTraversal):
     def createdAtLeast(self, number):
         return self.outE("created").count().is_(P.gte(number))
 
-class ___(__):
+class __(AnonymousTraversal):
     @staticmethod
     def knows(*args):
         return SocialTraversal(None, None, Bytecode()).knows(*args)
@@ -74,4 +75,4 @@ def test_dsl(remote_connection):
     assert social.persons("marko").youngestFriendsAge().next() == 27
     assert social.persons().count().next() == 4
     assert social.persons("marko", "josh").count().next() == 2
-    assert social.persons().filter(___.createdAtLeast(2)).count().next() == 1
+    assert social.persons().filter(__.createdAtLeast(2)).count().next() == 1