Skip to content
Browse files

added Gremlin-Scala.

  • Loading branch information...
1 parent b1ade0b commit 5e8c4b90ce65ef248302faffbb30081557dc6973 @okram okram committed
Showing with 1,919 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +13 −0 gremlin-scala/gremlin-scala.bat
  3. +3 −0 gremlin-scala/gremlin-scala.sh
  4. +188 −0 gremlin-scala/pom.xml
  5. +34 −0 gremlin-scala/src/assembly/distribution.xml
  6. +32 −0 gremlin-scala/src/assembly/standalone.xml
  7. +77 −0 gremlin-scala/src/main/bin/gremlin-scala.bat
  8. +29 −0 gremlin-scala/src/main/bin/gremlin-scala.sh
  9. +9 −0 gremlin-scala/src/main/java/com/tinkerpop/gremlin/scala/Dummy.java
  10. +1 −0 gremlin-scala/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
  11. +30 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/package.scala
  12. +18 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/Gremlin.scala
  13. +358 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/GremlinScalaPipeline.scala
  14. +25 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaEdge.scala
  15. +17 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaElement.scala
  16. +40 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaGraph.scala
  17. +16 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaLoopBundle.scala
  18. +53 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaVertex.scala
  19. +105 −0 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/console/Console.scala
  20. +19 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/FunctionStepTest.scala
  21. +21 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/GremlinTest.scala
  22. +35 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/UtilitiesTest.scala
  23. +25 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/branch/IfThenElseStepTest.scala
  24. +39 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/branch/LoopStepTest.scala
  25. +32 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/branch/SplitMergeStepsTest.scala
  26. +40 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/BackStepTest.scala
  27. +28 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/DedupStepTest.scala
  28. +38 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/ExceptStepTest.scala
  29. +40 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/FilterStepTest.scala
  30. +35 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/HasNotStepTest.scala
  31. +39 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/HasStepTest.scala
  32. +22 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/RangeStepTest.scala
  33. +32 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/RetainStepTest.scala
  34. +35 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/AggregateStepTest.scala
  35. +25 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/GroupByStepTest.scala
  36. +44 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/GroupCountStepTest.scala
  37. +39 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/SideEffectStepTest.scala
  38. +28 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/StoreStepTest.scala
  39. +33 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/TableStepTest.scala
  40. +25 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/TreeStepTest.scala
  41. +22 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/MapStepTest.scala
  42. +28 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/PathStepTest.scala
  43. +36 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/SelectStepTest.scala
  44. +26 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/TransformStepTest.scala
  45. +81 −0 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/TraversalStepsTest.scala
View
4 .gitignore
@@ -0,0 +1,4 @@
+*.log
+target/
+.idea/
+*.iml
View
13 gremlin-scala/gremlin-scala.bat
@@ -0,0 +1,13 @@
+:: Windows launcher script for Gremlin
+@echo off
+
+cd %CD%\target\
+
+set TARGET=
+
+for /f "tokens=*" %%a in ('dir /b /ad') do (
+if exist "%%a\bin\gremlin-scala.bat" set TARGET=%%a
+)
+
+cd %TARGET%\bin\
+call gremlin-scala.bat %*
View
3 gremlin-scala/gremlin-scala.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+`dirname $0`/target/gremlin-scala-*-standalone/bin/gremlin-scala.sh $@
View
188 gremlin-scala/pom.xml
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.tinkerpop.gremlin</groupId>
+ <artifactId>gremlin</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </parent>
+ <artifactId>gremlin-scala</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Gremlin-Scala: Gremlin for the Scala Language</name>
+ <developers>
+ <developer>
+ <name>Zach Cox</name>
+ <email>zcox522@gmail.com</email>
+ <url>http://theza.ch</url>
+ </developer>
+ </developers>
+ <mailingLists>
+ <mailingList>
+ <name>Gremlin Users</name>
+ <subscribe>http://groups.google.com/group/gremlin-users</subscribe>
+ <unsubscribe>http://groups.google.com/group/gremlin-users</unsubscribe>
+ <archive>http://groups.google.com/group/gremlin-users/topics</archive>
+ </mailingList>
+ </mailingLists>
+ <inceptionYear>2011</inceptionYear>
+ <dependencies>
+ <dependency>
+ <groupId>com.tinkerpop.gremlin</groupId>
+ <artifactId>gremlin-java</artifactId>
+ <version>${gremlin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop</groupId>
+ <artifactId>pipes</artifactId>
+ <version>${pipes.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <!-- CONSOLE -->
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-compiler</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>jline</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <!-- Blueprints impls for repl -->
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-graph-jung</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-graph-sail</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-neo4j-graph</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-neo4jbatch-graph</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-orient-graph</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-dex-graph</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-sail-graph</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.blueprints</groupId>
+ <artifactId>blueprints-rexster-graph</artifactId>
+ <version>${blueprints.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tinkerpop.gremlin</groupId>
+ <artifactId>gremlin-test</artifactId>
+ <version>${gremlin.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>scala-tools.org</id>
+ <name>Scala-tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </repository>
+ </repositories>
+ <build>
+ <directory>${basedir}/target</directory>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources
+ </directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>assembly</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/standalone.xml</descriptor>
+ <descriptor>src/assembly/distribution.xml</descriptor>
+ </descriptors>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <outputDirectory>target</outputDirectory>
+ <workDirectory>target/assembly/work</workDirectory>
+ <tarLongFileMode>warn</tarLongFileMode>
+ <archive>
+ <manifest>
+ <mainClass>com.tinkerpop.gremlin.scala.console.Console</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <!-- <version>2.15.3-SNAPSHOT</version> --> <!-- 2.15.3 includes JLine in scala:console, but has issues after exit -->
+ <version>2.15.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
34 gremlin-scala/src/assembly/distribution.xml
@@ -0,0 +1,34 @@
+<assembly>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <fileMode>0775</fileMode>
+ <includes>
+ <include>gremlin-scala.sh</include>
+ <include>gremlin-scala.bat</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src</directory>
+ </fileSet>
+ <fileSet>
+ <directory>data</directory>
+ </fileSet>
+ <fileSet>
+ <directory>target/apidocs</directory>
+ </fileSet>
+ <fileSet>
+ <directory>target/site</directory>
+ </fileSet>
+ <fileSet>
+ <directory>target/${project.artifactId}-${project.version}-standalone</directory>
+ </fileSet>
+ </fileSets>
+</assembly>
View
32 gremlin-scala/src/assembly/standalone.xml
@@ -0,0 +1,32 @@
+<assembly>
+ <id>standalone</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>src/main/bin</directory>
+ <outputDirectory>/bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>target/*.jar</directory>
+ <outputDirectory>/lib</outputDirectory>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <unpack>false</unpack>
+ <scope>compile</scope>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <unpack>false</unpack>
+ <scope>provided</scope>
+ </dependencySet>
+ </dependencySets>
+</assembly>
View
77 gremlin-scala/src/main/bin/gremlin-scala.bat
@@ -0,0 +1,77 @@
+:: Windows launcher script for Gremlin Scala
+
+@echo off
+
+
+::cd ..\lib
+
+::set LIBDIR=%CD%
+
+
+set LIBDIR=..\lib
+
+
+set OLD_CLASSPATH=%CLASSPATH%
+set CP=
+
+
+for %%i in (%LIBDIR%\*.jar) do call :concatsep %%i
+
+:: cd ..\..\..\
+
+
+set JAVA_OPTIONS=-Xms32m -Xmx512m
+
+
+:: Launch the application
+
+if "%1" == "" goto console
+
+if "%1" == "-v" goto version
+
+
+
+:console
+
+set CLASSPATH=%CP%;%OLD_CLASSPATH%
+java %JAVA_OPTIONS% %JAVA_ARGS% com.tinkerpop.gremlin.scala.console.Console
+set CLASSPATH=%OLD_CLASSPATH%
+
+set CLASSPATH=%OLD_CLASSPATH%
+goto :eof
+
+
+
+:version
+
+set CLASSPATH=%CP%;%OLD_CLASSPATH%
+java %JAVA_OPTIONS% %JAVA_ARGS% com.tinkerpop.gremlin.Version
+
+set CLASSPATH=%OLD_CLASSPATH%
+goto :eof
+
+
+
+:concat
+
+if %1 == %2 goto skip
+
+SET strg=%strg% %1
+
+
+
+:concatsep
+
+if "%CP%" == "" (
+
+set CP=%LIBDIR%\%1
+
+)else (
+
+set CP=%CP%;%LIBDIR%\%1
+
+)
+
+
+
+:skip
View
29 gremlin-scala/src/main/bin/gremlin-scala.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+CP=$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
+#echo $CP
+
+# Find Java
+if [ "$JAVA_HOME" = "" ] ; then
+ JAVA="java -server"
+else
+ JAVA="$JAVA_HOME/bin/java -server"
+fi
+
+# Set Java options
+if [ "$JAVA_OPTIONS" = "" ] ; then
+ JAVA_OPTIONS="-Xms32m -Xmx512m"
+fi
+
+# Launch the application
+if [ "$1" = "-v" ]; then
+ $JAVA $JAVA_OPTIONS -cp $CP:$CLASSPATH com.tinkerpop.gremlin.Version
+else
+ $JAVA $JAVA_OPTIONS -cp $CP:$CLASSPATH com.tinkerpop.gremlin.scala.console.Console
+fi
+
+#Something in JLine 2.9.1 is leaving stty in "no echo" (-echo) mode; try to repair that on exit...
+stty echo
+
+# Return the program's exit code
+exit $?
View
9 gremlin-scala/src/main/java/com/tinkerpop/gremlin/scala/Dummy.java
@@ -0,0 +1,9 @@
+package com.tinkerpop.gremlin.scala;
+
+/**
+ * This is a dummy class that is necessary for generating javadoc sources for Central Repo
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class Dummy {
+}
View
1 gremlin-scala/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory
@@ -0,0 +1 @@
+com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory
View
30 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/package.scala
@@ -0,0 +1,30 @@
+package com.tinkerpop.gremlin
+
+import com.tinkerpop.pipes.PipeFunction
+import _root_.java.lang.{Boolean => JBoolean}
+
+/**Implicit conversions that make Gremlin easier to use in Scala. Users can just `import com.tinkerpop.gremlin.scala._`*/
+package object scala {
+ /**Most generic conversion: A => B to PipeFunction[A, B]. */
+ implicit def functionToPipeFunction[A, B](f: Function1[A, B]) =
+ new PipeFunction[A, B] {
+ def compute(a: A): B = f(a)
+ }
+
+ /**Mainly for GremlinPipeline.filter, to convert A => scala.Boolean to PipeFunction[A, java.lang.Boolean]. */
+ implicit def booleanFunctionToPipeFunction[A](f: Function1[A, Boolean]) =
+ new PipeFunction[A, JBoolean] {
+ def compute(a: A): JBoolean = Boolean box f(a)
+ }
+
+ /**Bring the wrap implicits into scope. The compiler will check the unwrap implicits on its own. */
+ implicit val wrapScalaVertex = ScalaVertex.wrap _
+ implicit val wrapScalaEdge = ScalaEdge.wrap _
+ implicit val wrapScalaGraph = ScalaGraph.wrap _
+
+ implicit def wrapScalaLoopBundle[T] = ScalaLoopBundle.wrap[T] _ //must be a def because of the type parameter
+
+ def ->[S]: GremlinScalaPipeline[S, S] = new GremlinScalaPipeline[S, S]()
+
+}
+
View
18 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/Gremlin.scala
@@ -0,0 +1,18 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.gremlin.Tokens
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+object Gremlin {
+
+ def version(): String = {
+ Tokens.VERSION;
+ }
+
+ def language(): String = {
+ "gremlin-scala";
+ }
+
+}
View
358 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/GremlinScalaPipeline.scala
@@ -0,0 +1,358 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.gremlin.java.GremlinPipeline
+import com.tinkerpop.blueprints.pgm._
+import com.tinkerpop.pipes.{PipeFunction, Pipe}
+import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle
+import java.util.{Map => JMap, List => JList, Iterator => JIterator, Collection => JCollection, ArrayList => JArrayList}
+import com.tinkerpop.gremlin.Tokens
+import com.tinkerpop.pipes.util.structures.{Tree, Table, Row, Pair => TPair}
+
+class GremlinScalaPipeline[S, E] extends GremlinPipeline[S, E] {
+
+ //def apply(key:String) = super.property(key);
+
+ def out: GremlinScalaPipeline[S, Vertex] =
+ super.out().asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ def in: GremlinScalaPipeline[S, Vertex] =
+ super.in().asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ def path: GremlinScalaPipeline[S, JList[_]] =
+ super.path().asInstanceOf[GremlinScalaPipeline[S, JList[_]]]
+
+ ////
+
+ def has[F <: Element, T](key: String, value: T): GremlinScalaPipeline[S, F] =
+ super.has(key, value).asInstanceOf[GremlinScalaPipeline[S, F]]
+
+ def has[F <: Element, T](key: String, comparison: Tokens.T, value: T): GremlinScalaPipeline[S, F] =
+ super.has(key, comparison, value).asInstanceOf[GremlinScalaPipeline[S, F]]
+
+ def hasNot[F <: Element, T](key: String, value: T): GremlinScalaPipeline[S, F] =
+ super.hasNot(key, value).asInstanceOf[GremlinScalaPipeline[S, F]]
+
+ def hasNot[F <: Element, T](key: String, comparison: Tokens.T, value: T): GremlinScalaPipeline[S, F] =
+ super.hasNot(key, comparison, value).asInstanceOf[GremlinScalaPipeline[S, F]]
+
+ override def bothE(labels: String*): GremlinScalaPipeline[S, Edge] =
+ super.bothE(labels: _*).asInstanceOf[GremlinScalaPipeline[S, Edge]]
+
+ override def both(labels: String*): GremlinScalaPipeline[S, Vertex] =
+ super.both(labels: _*).asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ override def bothV: GremlinScalaPipeline[S, Vertex] =
+ super.bothV.asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ override def E: GremlinScalaPipeline[S, Edge] =
+ super.E.asInstanceOf[GremlinScalaPipeline[S, Edge]]
+
+ override def idEdge(graph: Graph): GremlinScalaPipeline[S, Edge] =
+ super.idEdge(graph).asInstanceOf[GremlinScalaPipeline[S, Edge]]
+
+ override def id: GremlinScalaPipeline[S, Object] =
+ super.id.asInstanceOf[GremlinScalaPipeline[S, Object]]
+
+ override def idVertex(graph: Graph): GremlinScalaPipeline[S, Vertex] =
+ super.idVertex(graph).asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ override def inE(labels: String*): GremlinScalaPipeline[S, Edge] =
+ super.inE(labels: _*).asInstanceOf[GremlinScalaPipeline[S, Edge]]
+
+ override def in(labels: String*): GremlinScalaPipeline[S, Vertex] =
+ super.in(labels: _*).asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ override def inV: GremlinScalaPipeline[S, Vertex] =
+ super.inV.asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ override def label: GremlinScalaPipeline[S, String] =
+ super.label.asInstanceOf[GremlinScalaPipeline[S, String]]
+
+ override def outE(labels: String*): GremlinScalaPipeline[S, Edge] =
+ super.outE(labels: _*).asInstanceOf[GremlinScalaPipeline[S, Edge]]
+
+ override def out(labels: String*): GremlinScalaPipeline[S, Vertex] =
+ super.out(labels: _*).asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ override def outV: GremlinScalaPipeline[S, Vertex] =
+ super.outV.asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ def map[F <: Element]: GremlinScalaPipeline[S, JMap[String, Object]] = //TODO use scala Map here?
+ super.map.asInstanceOf[GremlinScalaPipeline[S, JMap[String, Object]]]
+
+ def property[F <: Element](key: String): GremlinScalaPipeline[S, Object] =
+ super.property(key).asInstanceOf[GremlinScalaPipeline[S, Object]]
+
+ override def V: GremlinScalaPipeline[S, Vertex] =
+ super.V.asInstanceOf[GremlinScalaPipeline[S, Vertex]]
+
+ def step[F](f: JIterator[E] => F): GremlinScalaPipeline[S, F] =
+ super.step(f).asInstanceOf[GremlinScalaPipeline[S, F]]
+
+ override def step[F](pipe: Pipe[E, F]): GremlinScalaPipeline[S, F] =
+ super.step(pipe).asInstanceOf[GremlinScalaPipeline[S, F]]
+
+ ////////////////////
+ /// BRANCH PIPES ///
+ ////////////////////
+ override def copySplit(pipes: Pipe[E, _]*): GremlinScalaPipeline[S, _] =
+ super.copySplit(pipes: _*).asInstanceOf[GremlinScalaPipeline[S, _]]
+
+ override def exhaustMerge: GremlinScalaPipeline[S, _] =
+ super.exhaustMerge.asInstanceOf[GremlinScalaPipeline[S, _]]
+
+ override def fairMerge: GremlinScalaPipeline[S, _] =
+ super.fairMerge.asInstanceOf[GremlinScalaPipeline[S, _]]
+
+ def ifThenElse(ifFunction: E => Boolean, thenFunction: E => _, elseFunction: E => _): GremlinScalaPipeline[S, _] =
+ super.ifThenElse(ifFunction, thenFunction, elseFunction).asInstanceOf[GremlinScalaPipeline[S, _]]
+
+ def loop(numberedStep: Int, whileFunction: LoopBundle[E] => Boolean): GremlinScalaPipeline[S, E] =
+ super.loop(numberedStep, whileFunction).asInstanceOf[GremlinScalaPipeline[S, E]]
+
+ def loop(namedStep: String, whileFunction: LoopBundle[E] => Boolean): GremlinScalaPipeline[S, E] =
+ super.loop(namedStep, whileFunction).asInstanceOf[GremlinScalaPipeline[S, E]]
+
+ def loop(numberedStep: Int, whileFunction: LoopBundle[E] => Boolean, emitFunction: LoopBundle[E] => Boolean): GremlinScalaPipeline[S, E] =
+ super.loop(numberedStep, whileFunction, emitFunction).asInstanceOf[GremlinScalaPipeline[S, E]]
+
+ def loop(namedStep: String, whileFunction: LoopBundle[E] => Boolean, emitFunction: LoopBundle[E] => Boolean): GremlinScalaPipeline[S, E] =
+ super.loop(namedStep, whileFunction, emitFunction).asInstanceOf[GremlinScalaPipeline[S, E]]
+
+ ////////////////////
+ /// FILTER PIPES ///
+ ////////////////////
+ override def and(pipes: Pipe[E, _]*): GremlinScalaPipeline[S, E] = {
+ super.and(pipes: _*).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def back(numberedStep: Int): GremlinScalaPipeline[S, _] = {
+ super.back(numberedStep).asInstanceOf[GremlinScalaPipeline[S, _]];
+ }
+
+ override def back(namedStep: String): GremlinScalaPipeline[S, _] = {
+ super.back(namedStep).asInstanceOf[GremlinScalaPipeline[S, _]];
+ }
+
+ override def dedup: GremlinScalaPipeline[S, E] = {
+ super.dedup().asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def dedup(dedupFunction: E => _): GremlinScalaPipeline[S, E] = {
+ super.dedup(dedupFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def except(collection: JCollection[E]): GremlinScalaPipeline[S, E] = {
+ super.except(collection).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def filter(filterFunction: E => Boolean): GremlinScalaPipeline[S, E] = {
+ super.filter(filterFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def or(pipes: Pipe[E, _]*): GremlinScalaPipeline[S, E] = {
+ super.or(pipes: _*).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def random(bias: Double): GremlinScalaPipeline[S, E] = {
+ super.random(bias).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def range(low: Int, high: Int): GremlinScalaPipeline[S, E] = {
+ super.range(low, high).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def retain(collection: JCollection[E]): GremlinScalaPipeline[S, E] = {
+ super.retain(collection).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def simplePath: GremlinScalaPipeline[S, E] = {
+ super.simplePath().asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ /////////////////////////
+ /// SIDE-EFFECT PIPES ///
+ /////////////////////////
+ override def aggregate(aggregate: JCollection[E]): GremlinScalaPipeline[S, E] = {
+ super.aggregate(aggregate).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def aggregate(aggregate: JCollection[_], aggregateFunction: E => _): GremlinScalaPipeline[S, E] = {
+ super.aggregate(aggregate, aggregateFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def aggregate(): GremlinScalaPipeline[S, E] = {
+ super.aggregate(new JArrayList[E]()).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def aggregate(aggregateFunction: E => _): GremlinScalaPipeline[S, E] = {
+ super.aggregate(new JArrayList[Object](), aggregateFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def optional(numberedStep: Int): GremlinScalaPipeline[S, _] = {
+ super.optional(numberedStep).asInstanceOf[GremlinScalaPipeline[S, _]];
+ }
+
+ override def optional(namedStep: String): GremlinScalaPipeline[S, _] = {
+ super.optional(namedStep).asInstanceOf[GremlinScalaPipeline[S, _]];
+ }
+
+ override def groupBy(map: JMap[_, JList[_]], keyFunction: PipeFunction[_, _], valueFunction: PipeFunction[_, _]): GremlinScalaPipeline[S, E] = {
+ super.groupBy(map, keyFunction, valueFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupBy(keyFunction: PipeFunction[_, _], valueFunction: PipeFunction[_, _]): GremlinScalaPipeline[S, E] = {
+ super.groupBy(keyFunction, valueFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupBy(keyFunction: PipeFunction[_, _], valueFunction: PipeFunction[_, _], reduceFunction: PipeFunction[_, _]): GremlinScalaPipeline[S, E] = {
+ super.groupBy(keyFunction, valueFunction, reduceFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupBy(reduceMap: JMap[_, _], keyFunction: PipeFunction[_, _], valueFunction: PipeFunction[_, _], reduceFunction: PipeFunction[_, _]): GremlinScalaPipeline[S, E] = {
+ super.groupBy(reduceMap, keyFunction, valueFunction, reduceFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupCount(map: JMap[_, Number], keyFunction: PipeFunction[_, _], valueFunction: PipeFunction[TPair[_, Number], Number]): GremlinScalaPipeline[S, E] = {
+ super.groupCount(map, keyFunction, valueFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupCount(keyFunction: PipeFunction[_, _], valueFunction: PipeFunction[TPair[_, Number], Number]): GremlinScalaPipeline[S, E] = {
+ super.groupCount(keyFunction, valueFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupCount(map: JMap[_, Number], keyFunction: PipeFunction[_, _]): GremlinScalaPipeline[S, E] = {
+ super.groupCount(map, keyFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupCount(keyFunction: PipeFunction[_, _]): GremlinScalaPipeline[S, E] = {
+ super.groupCount(keyFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupCount(map: JMap[_, Number]): GremlinScalaPipeline[S, E] = {
+ super.groupCount(map).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def groupCount: GremlinScalaPipeline[S, E] = {
+ super.groupCount().asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def sideEffect(sideEffectFunction: E => _): GremlinScalaPipeline[S, E] = {
+ super.sideEffect(sideEffectFunction).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def store(storage: JCollection[E]): GremlinScalaPipeline[S, E] = {
+ super.store(storage).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def store(storage: JCollection[_], storageFunction: E => _): GremlinScalaPipeline[S, E] = {
+ super.aggregate(storage, storageFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def store(): GremlinScalaPipeline[S, E] = {
+ super.store(new JArrayList[E]()).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ def store(storageFunction: E => _): GremlinScalaPipeline[S, E] = {
+ super.store(new JArrayList[Object](), storageFunction).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def table(table: Table, stepNames: JCollection[String], columnFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, E] = {
+ super.table(table, stepNames, columnFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def table(table: Table, columnFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, E] = {
+ super.table(table, columnFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def table(columnFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, E] = {
+ super.table(columnFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def table(table: Table): GremlinScalaPipeline[S, E] = {
+ super.table(table).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def table: GremlinScalaPipeline[S, E] = {
+ super.table().asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def tree(tree: Tree[_], branchFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, E] = {
+ super.tree(tree, branchFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def tree(branchFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, E] = {
+ super.tree(branchFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ ///////////////////////
+ /// TRANSFORM PIPES ///
+ ///////////////////////
+ override def gather: GremlinScalaPipeline[S, JList[_]] = {
+ super.gather().asInstanceOf[GremlinScalaPipeline[S, JList[_]]];
+ }
+
+ def gather(function: JList[_] => JList[_]): GremlinScalaPipeline[S, JList[_]] = {
+ super.gather(function).asInstanceOf[GremlinScalaPipeline[S, JList[_]]];
+ }
+
+ /*def _: GremlinPipeline[S, E] =
+ {
+ return this.add(new IdentityPipe[_])
+ }*/
+
+ override def memoize(namedStep: String): GremlinScalaPipeline[S, E] = {
+ super.memoize(namedStep).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def memoize(numberedStep: Int): GremlinScalaPipeline[S, E] = {
+ super.memoize(numberedStep).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def memoize(namedStep: String, map: JMap[_, _]): GremlinScalaPipeline[S, E] = {
+ super.memoize(namedStep, map).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def memoize(numberedStep: Int, map: JMap[_, _]): GremlinScalaPipeline[S, E] = {
+ super.memoize(numberedStep, map).asInstanceOf[GremlinScalaPipeline[S, E]];
+ }
+
+ override def path(pathFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, JList[_]] =
+ super.path(pathFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, JList[_]]]
+
+ override def select: GremlinScalaPipeline[S, Row[_]] = {
+ super.select().asInstanceOf[GremlinScalaPipeline[S, Row[_]]]
+ }
+
+ override def select(stepFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, Row[_]] = {
+ super.select(stepFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, Row[_]]]
+ }
+
+ override def select(stepNames: JCollection[String], stepFunctions: PipeFunction[_, _]*): GremlinScalaPipeline[S, Row[_]] = {
+ super.select(stepNames, stepFunctions: _*).asInstanceOf[GremlinScalaPipeline[S, Row[_]]]
+ }
+
+ override def scatter: GremlinScalaPipeline[S, _] = {
+ super.scatter().asInstanceOf[GremlinScalaPipeline[S, _]]
+ }
+
+ override def cap: GremlinScalaPipeline[S, _] = {
+ super.cap().asInstanceOf[GremlinScalaPipeline[S, _]];
+ }
+
+ def transform[T](function: E => T): GremlinScalaPipeline[S, T] = {
+ super.transform(function).asInstanceOf[GremlinScalaPipeline[S, T]]
+ }
+
+ //////////////////////
+ /// UTILITY PIPES ///
+ //////////////////////
+
+ override def as(name: String): GremlinScalaPipeline[S, E] = {
+ super.as(name).asInstanceOf[GremlinScalaPipeline[S, E]]
+ }
+
+ override def start(starts: S): GremlinScalaPipeline[S, S] = {
+ super.start(starts).asInstanceOf[GremlinScalaPipeline[S, S]]
+ }
+}
View
25 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaEdge.scala
@@ -0,0 +1,25 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.blueprints.pgm.{Vertex, Edge}
+
+/**Adds convenience methods to [[com.tinkerpop.blueprints.pgm.Edge]]. */
+class ScalaEdge(val edge: Edge) extends ScalaElement(edge) {
+ def inV: GremlinScalaPipeline[Edge, Vertex] =
+ new GremlinScalaPipeline[Edge, Vertex].start(edge).inV().asInstanceOf[GremlinScalaPipeline[Edge, Vertex]]
+
+ def outV: GremlinScalaPipeline[Edge, Vertex] =
+ new GremlinScalaPipeline[Edge, Vertex].start(edge).outV().asInstanceOf[GremlinScalaPipeline[Edge, Vertex]]
+
+ def bothV: GremlinScalaPipeline[Edge, Vertex] =
+ new GremlinScalaPipeline[Edge, Vertex].start(edge).bothV().asInstanceOf[GremlinScalaPipeline[Edge, Vertex]]
+
+ def -> : GremlinScalaPipeline[Edge, Edge] =
+ new GremlinScalaPipeline[Edge, Edge].start(edge).asInstanceOf[GremlinScalaPipeline[Edge, Edge]];
+}
+
+/**Implicit conversions between [[com.tinkerpop.blueprints.pgm.Edge]] and [[com.tinkerpop.gremlin.scala.ScalaEdge]]. */
+object ScalaEdge {
+ implicit def wrap(edge: Edge) = new ScalaEdge(edge)
+
+ implicit def unwrap(wrapper: ScalaEdge) = wrapper.edge
+}
View
17 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaElement.scala
@@ -0,0 +1,17 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.blueprints.pgm.Element
+import java.util.{Map => JMap}
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+abstract class ScalaElement(val element: Element) {
+
+ def as[T](key: String): Option[T] = Option(element.getProperty(key)).map(_.asInstanceOf[T])
+
+ def id: Any = element.getId
+
+ def apply(key: String): Object = element.getProperty(key)
+}
View
40 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaGraph.scala
@@ -0,0 +1,40 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.blueprints.pgm.{Graph, Vertex, Edge}
+
+/**Adds convenience methods to [[com.tinkerpop.blueprints.pgm.Graph]]. */
+class ScalaGraph(val graph: Graph) {
+ /**Returns all vertices. */
+ def V: GremlinScalaPipeline[Graph, Vertex] =
+ new GremlinScalaPipeline[Graph, Vertex].start(graph).V().asInstanceOf[GremlinScalaPipeline[Graph, Vertex]]
+
+ /**Returns the vertices with the specified IDs. */
+ def V(ids: Any*): Iterable[Vertex] = ids.map(graph.getVertex(_)) //TODO should'nt V and V(1,2) return the same type???
+
+ /**Returns the vertex with the specified ID. */
+ def v(id: Any): Vertex = graph getVertex id
+
+ /**Returns all edges. */
+ def E: GremlinScalaPipeline[Graph, Edge] =
+ new GremlinScalaPipeline[Graph, Edge].start(graph).E().asInstanceOf[GremlinScalaPipeline[Graph, Edge]]
+
+ /**Returns the edges with the specified IDs. */
+ def E(ids: Any*): Iterable[Edge] = ids map {
+ graph getEdge _
+ }
+
+ /**Returns the edge with the specified ID. */
+ def e(id: Any): Edge = graph getEdge id
+
+ def -> : GremlinScalaPipeline[Graph, Graph] =
+ new GremlinScalaPipeline[Graph, Graph].start(graph).asInstanceOf[GremlinScalaPipeline[Graph, Graph]];
+
+ //TODO def += for addVertex and addEdge?
+}
+
+/**Implicit conversions between [[com.tinkerpop.blueprints.pgm.Graph]] and [[com.tinkerpop.gremlin.scala.ScalaGraph]]. */
+object ScalaGraph {
+ implicit def wrap(graph: Graph) = new ScalaGraph(graph)
+
+ implicit def unwrap(wrapper: ScalaGraph) = wrapper.graph
+}
View
16 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaLoopBundle.scala
@@ -0,0 +1,16 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle
+
+/**Provides convenience methods for LoopBundle[T]. */
+class ScalaLoopBundle[T](val bundle: LoopBundle[T]) {
+ def loops = bundle.getLoops
+
+ def obj = bundle.getObject
+}
+
+object ScalaLoopBundle {
+ implicit def wrap[T](bundle: LoopBundle[T]) = new ScalaLoopBundle[T](bundle)
+
+ implicit def unwrap[T](wrapper: ScalaLoopBundle[T]) = wrapper.bundle
+}
View
53 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/ScalaVertex.scala
@@ -0,0 +1,53 @@
+package com.tinkerpop.gremlin.scala
+
+import java.util.{Map => JMap}
+import com.tinkerpop.blueprints.pgm.{Vertex, Edge}
+
+/**Adds convenience methods to [[com.tinkerpop.blueprints.pgm.Vertex]]. */
+class ScalaVertex(val vertex: Vertex) extends ScalaElement(vertex) {
+ def out: GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).out().asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]]
+
+ def out(labels: String*): GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).out(labels: _*).asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]]
+
+ def outE: GremlinScalaPipeline[Vertex, Edge] =
+ new GremlinScalaPipeline[Vertex, Edge].start(vertex).outE().asInstanceOf[GremlinScalaPipeline[Vertex, Edge]]
+
+ def outE(labels: String*): GremlinScalaPipeline[Vertex, Edge] =
+ new GremlinScalaPipeline[Vertex, Edge].start(vertex).outE(labels: _*).asInstanceOf[GremlinScalaPipeline[Vertex, Edge]]
+
+ def in: GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).in().asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]]
+
+ def in(labels: String*): GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).in(labels: _*).asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]]
+
+ def inE: GremlinScalaPipeline[Vertex, Edge] =
+ new GremlinScalaPipeline[Vertex, Edge].start(vertex).inE().asInstanceOf[GremlinScalaPipeline[Vertex, Edge]]
+
+ def inE(labels: String*): GremlinScalaPipeline[Vertex, Edge] =
+ new GremlinScalaPipeline[Vertex, Edge].start(vertex).inE(labels: _*).asInstanceOf[GremlinScalaPipeline[Vertex, Edge]]
+
+ def both: GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).both().asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]]
+
+ def both(labels: String*): GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).both(labels: _*).asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]]
+
+ def bothE: GremlinScalaPipeline[Vertex, Edge] =
+ new GremlinScalaPipeline[Vertex, Edge].start(vertex).bothE().asInstanceOf[GremlinScalaPipeline[Vertex, Edge]]
+
+ def bothE(labels: String*): GremlinScalaPipeline[Vertex, Edge] =
+ new GremlinScalaPipeline[Vertex, Edge].start(vertex).bothE(labels: _*).asInstanceOf[GremlinScalaPipeline[Vertex, Edge]]
+
+ def -> : GremlinScalaPipeline[Vertex, Vertex] =
+ new GremlinScalaPipeline[Vertex, Vertex].start(vertex).asInstanceOf[GremlinScalaPipeline[Vertex, Vertex]];
+}
+
+/**Implicit conversions between [[com.tinkerpop.blueprints.pgm.Vertex]] and [[com.tinkerpop.gremlin.scala.ScalaVertex]]. */
+object ScalaVertex {
+ implicit def wrap(vertex: Vertex) = new ScalaVertex(vertex)
+
+ implicit def unwrap(wrapper: ScalaVertex) = wrapper.vertex
+}
View
105 gremlin-scala/src/main/scala/com/tinkerpop/gremlin/scala/console/Console.scala
@@ -0,0 +1,105 @@
+package com.tinkerpop.gremlin.scala.console
+
+import scala.tools.nsc.Settings
+import scala.tools.nsc.reporters.ConsoleReporter
+import scala.tools.nsc.interpreter.{ILoop, ReplReporter}
+import com.tinkerpop.gremlin.Imports
+
+import scala.collection.JavaConversions._
+
+/**http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/compiler/scala/tools/nsc/interpreter/package.html */
+object Console {
+ def main(args: Array[String]) {
+ val settings = new Settings()
+ settings.usejavacp.value = true
+ settings.deprecation.value = true
+
+ val iloop = new GremlinILoop()
+ iloop.process(settings)
+ }
+}
+
+class GremlinILoop extends ILoop {
+ val inputPrompt = "gremlin> "
+ val resultPrompt = "==>"
+
+ override def prompt = inputPrompt
+
+ val welcome = "\n" +
+ " \\,,,/\n" +
+ " (o o)\n" +
+ "-----oOOo-(_)-oOOo-----"
+
+ override def printWelcome() {
+ echo(welcome)
+
+ //printWelcome() is the only decent place to init the intp while process() is setting things up...
+ intp beQuietDuring {
+ //calling addImports separately for each import is really slow, so only call it once
+ val imports = Imports.getImports("*", "_") :+ "com.tinkerpop.gremlin.scala._"
+ intp.addImports(imports: _*)
+ }
+ }
+
+ var gremlinIntp: GremlinInterpreter = _
+
+ override def createInterpreter() {
+ if (addedClasspath != "")
+ settings.classpath append addedClasspath
+ gremlinIntp = new GremlinInterpreter
+ intp = gremlinIntp
+ }
+
+ /**Overriden to print out the value evaluated from the specified line. */
+ override def command(line: String): Result = {
+ val r = super.command(line)
+
+ //TODO handle compiler error
+ //TODO handle exception
+ //TODO handle something like class on multilines
+ if (r.keepRunning && r.lineToRecord.isDefined) {
+ printLastValue()
+ }
+
+ r
+ }
+
+ /**Prints the last value by expanding its elements if it's iterator-like or collection-like. */
+ def printLastValue() = gremlinIntp.lastValue match {
+ case Right(value) => for (v <- toIterator(value)) out.println(resultPrompt + v)
+ case Left(throwable) => throwable.printStackTrace(out)
+ }
+
+ /**Coerces the specified value into an iterator. */
+ def toIterator(value: Any): Iterator[Any] = {
+ import scala.collection.JavaConverters._
+ value match {
+ case t: Traversable[Any] => t.toIterator
+ case a: Array[_] => a.toIterator
+ case i: java.lang.Iterable[Any] => i.asScala.toIterator
+ case i: java.util.Iterator[Any] => i.asScala
+ case m: java.util.Map[Any, Any] => m.asScala.toIterator
+ case _ => Iterator.single(value)
+ }
+ }
+
+ class GremlinInterpreter extends this.ILoopInterpreter {
+ //also descends from IMain, the core interpreter class
+ override lazy val reporter: ConsoleReporter = new GremlinReporter(this)
+
+ /**Returns the last request executed by this interpreter. */
+ def lastRequest: Option[Request] = prevRequestList.lastOption
+
+ /**Returns the last value evaluated by this interpreter. See https://issues.scala-lang.org/browse/SI-4899 for details. */
+ def lastValue: Either[Throwable, AnyRef] = lastRequest.getOrElse(throw new NullPointerException()).lineRep.callEither("$result")
+ }
+
+ /**Stop ReplReporter from printing to console. Instead we print in GremlinILoop.command. */
+ class GremlinReporter(intp: GremlinInterpreter) extends ReplReporter(intp) {
+ override def printMessage(msg: String) {}
+
+ //println("***" + msg)
+ }
+
+}
+
View
19 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/FunctionStepTest.scala
@@ -0,0 +1,19 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import java.util.{Iterator => JIterator}
+
+class FunctionStepTest extends com.tinkerpop.gremlin.test.FunctionStepTest {
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_stepXnext_nameX() {
+ //TODO can we use a scala Iterator here instead of JIterator?
+ super.test_g_v1_out_stepXnext_nameX(g.v(1).out.step({it: JIterator[Vertex] => it.next()("name").toString}))
+ }
+}
View
21 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/GremlinTest.scala
@@ -0,0 +1,21 @@
+package com.tinkerpop.gremlin.scala
+
+import junit.framework.TestCase
+import com.tinkerpop.gremlin.Tokens
+import junit.framework.Assert._
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class GremlinTest extends TestCase {
+
+ def testVersion() {
+ assertEquals(Gremlin.version(), Tokens.VERSION);
+ }
+
+ def testLanguage() {
+ assertEquals(Gremlin.language(), "gremlin-scala");
+ }
+
+}
View
35 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/UtilitiesTest.scala
@@ -0,0 +1,35 @@
+package com.tinkerpop.gremlin.scala
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class UtilitiesTest extends com.tinkerpop.gremlin.test.UtilitiesTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_toList() {
+ super.test_g_v1_out_toList(g.v(1).out.toList)
+ }
+
+ def test_g_v1_out_nextX1X() {
+ super.test_g_v1_out_nextX1X(g.v(1).out.next(1))
+ }
+
+ def test_g_v1_out_fillXlistX() {
+ super.test_g_v1_out_fillXlistX(g.v(1).out().fill(new java.util.ArrayList[Vertex]()));
+ }
+
+ def test_g_V_countXX() {
+ super.test_g_V_countXX(g.V.count());
+ }
+
+}
View
25 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/branch/IfThenElseStepTest.scala
@@ -0,0 +1,25 @@
+package com.tinkerpop.gremlin.scala.branch
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class IfThenElseStepTest extends com.tinkerpop.gremlin.test.branch.IfThenElseStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_ifThenElseXlang_eq_java__it__outX_name() {
+ super.test_g_v1_out_ifThenElseXlang_eq_java__it__outX_name(g.v(1).out.ifThenElse({v: Vertex => val lang = v.getProperty("lang"); lang != null && lang.equals("java")}, {v: Vertex => v}, {v: Vertex => v.out}).property("name").asInstanceOf[Pipe[Vertex, String]]);
+ }
+
+}
View
39 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/branch/LoopStepTest.scala
@@ -0,0 +1,39 @@
+package com.tinkerpop.gremlin.scala.branch
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+import com.tinkerpop.blueprints.pgm.{Graph, Vertex}
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class LoopStepTest extends com.tinkerpop.gremlin.test.branch.LoopStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_loopX1_loops_lt_3X_propertyXnameX() {
+ super.test_g_v1_out_loopX1_loops_lt_3X_propertyXnameX(g.v(1).out.loop(1, {lb: LoopBundle[Vertex] => lb.loops < 3}).property("name").asInstanceOf[Pipe[Vertex, String]]);
+ }
+
+ def test_g_v1_asXhereX_out_loopXhere_loops_lt_3X_propertyXnameX() {
+ super.test_g_v1_asXhereX_out_loopXhere_loops_lt_3X_propertyXnameX(g.v(1).->.as("here").out.loop("here", {lb: LoopBundle[Vertex] => lb.loops < 3}).property("name").asInstanceOf[Pipe[Vertex, String]]);
+ }
+
+ def test_g_V_out_loopX1_loops_lt_3X_propertyXnameX() {
+ super.test_g_V_out_loopX1_loops_lt_3X_propertyXnameX(g.V.out.loop(1, {lb: LoopBundle[Vertex] => lb.loops < 3}).property("name").asInstanceOf[Pipe[Graph, String]]);
+ }
+
+ def test_g_V_asXhereX_out_loopXhere_loops_lt_3X_propertyXnameX() {
+ super.test_g_V_asXhereX_out_loopXhere_loops_lt_3X_propertyXnameX(g.V.as("here").out().loop("here", {lb: LoopBundle[Vertex] => lb.loops < 3}).property("name").asInstanceOf[Pipe[Graph, String]]);
+ }
+
+
+}
View
32 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/branch/SplitMergeStepsTest.scala
@@ -0,0 +1,32 @@
+package com.tinkerpop.gremlin.scala.branch
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.pipes.Pipe
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class SplitMergeStepsTest extends com.tinkerpop.gremlin.test.branch.SplitMergeStepsTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_copySplitXpropertyXnameX__propertyXageXX_fairMerge() {
+ super.test_g_v1_out_copySplitXpropertyXnameX__propertyXageXX_fairMerge(g.v(1).out.copySplit(->[Vertex].property("name"), ->[Vertex].property("age")).fairMerge.asInstanceOf[Pipe[Vertex, Object]])
+ }
+
+ def test_g_v1_outXknowsX_copySplitXpropertyXnameX__propertyXageXX_exhaustMerge() {
+ super.test_g_v1_outXknowsX_copySplitXpropertyXnameX__propertyXageXX_exhaustMerge(g.v(1).out("knows").copySplit(->[Vertex].property("name"), ->[Vertex].property("age")).exhaustMerge.asInstanceOf[Pipe[Vertex, Object]]);
+ }
+
+ def test_g_v1_outXknowsX_copySplitXpropertyXnameX__propertyXageXX_exhaustMerge_path() {
+ super.test_g_v1_outXknowsX_copySplitXpropertyXnameX__propertyXageXX_exhaustMerge_path(g.v(1).out("knows").copySplit(->[Vertex].property("name"), ->[Vertex].property("age")).exhaustMerge.path);
+ }
+}
View
40 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/BackStepTest.scala
@@ -0,0 +1,40 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class BackStepTest extends com.tinkerpop.gremlin.test.filter.BackStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_backX1X() {
+ super.test_g_v1_out_backX1X(g.v(1).out.back(1));
+ }
+
+ def test_g_v1_asXhereX_out_backXhereX() {
+ super.test_g_v1_asXhereX_out_backXhereX(g.v(1).->.as("here").out.back("here").asInstanceOf[Pipe[Vertex, Vertex]]);
+ }
+
+ def test_g_v4_out_filterXlang_eq_javaX_backX1X() {
+ super.test_g_v4_out_filterXlang_eq_javaX_backX1X(g.v(4).out.filter {v: Vertex => v.as[String]("lang").exists(_ == "java")}.back(1))
+ }
+
+ def test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX() {
+ super.test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX(g.v(4).out.as("here").filter {v: Vertex => v.as[String]("lang").exists(_.equals("java"))}.back("here").asInstanceOf[Pipe[Vertex, Vertex]]);
+ }
+
+ def test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX_propertyXnameX() {
+ super.test_g_v4_out_asXhereX_filterXlang_eq_javaX_backXhereX_propertyXnameX(g.v(4).out.as("here").filter {v: Vertex => v.as[String]("lang").exists(_.equals("java"))}.back("here").property("name").asInstanceOf[Pipe[Vertex, String]]);
+ }
+}
View
28 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/DedupStepTest.scala
@@ -0,0 +1,28 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+import com.tinkerpop.blueprints.pgm.{Graph, Vertex}
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class DedupStepTest extends com.tinkerpop.gremlin.test.filter.DedupStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_V_both_dedup_name() {
+ super.test_g_V_both_dedup_name(g.V.both().dedup.property("name").asInstanceOf[Pipe[Graph, String]]);
+ }
+
+ def test_g_V_both_dedupXlangX_name() {
+ super.test_g_V_both_dedupXlangX_name(g.V.both().dedup {v: Vertex => v("lang")}.property("name").asInstanceOf[Pipe[Graph, String]])
+ }
+}
View
38 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/ExceptStepTest.scala
@@ -0,0 +1,38 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import java.util.{ArrayList, HashSet}
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class ExceptStepTest extends com.tinkerpop.gremlin.test.filter.ExceptStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_exceptXg_v2X() {
+ val x = new ArrayList[Vertex]();
+ x.add(g.v(2));
+ super.test_g_v1_out_exceptXg_v2X(g.v(1).out.except(x));
+ }
+
+ def test_g_v1_out_aggregateXxX_out_exceptXxX() {
+ val x = new HashSet[Vertex]();
+ super.test_g_v1_out_aggregateXxX_out_exceptXxX(g.v(1).out.aggregate(x).out.except(x));
+ }
+
+ def test_g_v1_outXcreatedX_inXcreatedX_exceptXg_v1X_propertyXnameX() {
+ import scala.collection.JavaConversions._
+ super.test_g_v1_outXcreatedX_inXcreatedX_exceptXg_v1X_propertyXnameX(g.v(1).out("created").in("created").except(List(g.v(1))).property("name").asInstanceOf[Pipe[Vertex, String]])
+ }
+
+}
View
40 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/FilterStepTest.scala
@@ -0,0 +1,40 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import java.lang.{Integer => JInteger}
+import com.tinkerpop.gremlin.scala._
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class FilterStepTest extends com.tinkerpop.gremlin.test.filter.FilterStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_V_filterXfalseX() {
+ super.test_g_V_filterXfalseX(g.V.filter {v: Vertex => false});
+ }
+
+ def test_g_V_filterXtrueX() {
+ super.test_g_V_filterXtrueX(g.V.filter {v: Vertex => true});
+ }
+
+ def test_g_V_filterXlang_eq_javaX() {
+ super.test_g_V_filterXlang_eq_javaX(g.V.filter {v: Vertex => v.as[String]("lang").exists(_.equals("java"))});
+ }
+
+ def test_g_v1_out_filterXage_gt_30X() {
+ super.test_g_v1_out_filterXage_gt_30X(g.v(1).out.filter {v: Vertex => v.as[JInteger]("age").exists(_ > 30)});
+ }
+
+ def test_g_V_filterXname_startsWith_m_OR_name_startsWith_pX() {
+ super.test_g_V_filterXname_startsWith_m_OR_name_startsWith_pX(g.V.filter {v: Vertex => v.as[String]("name").exists(n => n.startsWith("m") || n.startsWith("p"))});
+ }
+}
View
35 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/HasNotStepTest.scala
@@ -0,0 +1,35 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.gremlin.Tokens.T
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class HasNotStepTest extends com.tinkerpop.gremlin.test.filter.HasNotStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_V_hasNotXname_markoX() {
+ super.test_g_V_hasNotXname_markoX(g.V.hasNot("name", "marko"));
+ }
+
+ def test_g_V_hasNotXname_blahX() {
+ super.test_g_V_hasNotXname_blahX(g.V.hasNot("name", "blah"));
+ }
+
+ def test_g_V_hasNotXblah_nullX() {
+ super.test_g_V_hasNotXblah_nullX(g.V.hasNot("blah", null));
+ }
+
+ def test_g_V_hasNotXage_gt_32X() {
+ super.test_g_V_hasNotXage_gt_32X(g.V.hasNot("age", T.gt, 32));
+ }
+}
View
39 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/HasStepTest.scala
@@ -0,0 +1,39 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.gremlin.Tokens.T
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class HasStepTest extends com.tinkerpop.gremlin.test.filter.HasStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_V_hasXname_markoX() {
+ super.test_g_V_hasXname_markoX(g.V.has("name", "marko"));
+ }
+
+ def test_g_V_hasXname_blahX() {
+ super.test_g_V_hasXname_blahX(g.V.has("name", "blah"));
+ }
+
+ def test_g_V_hasXblah_nullX() {
+ super.test_g_V_hasXblah_nullX(g.V.has("blah", null));
+ }
+
+ def test_g_v1_out_hasXid_2X() {
+ super.test_g_v1_out_hasXid_2X(g.v(1).out.has("id", "2"));
+ }
+
+ def test_g_V_hasXage_gt_30X() {
+ super.test_g_V_hasXage_gt_30X(g.V.has("age", T.gt, 30));
+ }
+}
View
22 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/RangeStepTest.scala
@@ -0,0 +1,22 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.gremlin.test.ComplianceTest
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class RangeStepTest extends com.tinkerpop.gremlin.test.filter.RangeStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_v1_out_rangeX0_1X() {
+ super.test_g_v1_out_rangeX0_1X(g.v(1).out.range(0, 1));
+ }
+}
View
32 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/filter/RetainStepTest.scala
@@ -0,0 +1,32 @@
+package com.tinkerpop.gremlin.scala.filter
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import java.util.{HashSet, ArrayList}
+import com.tinkerpop.gremlin.scala._
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class RetainStepTest extends com.tinkerpop.gremlin.test.filter.RetainStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_out_retainXg_v2X() {
+ val x = new ArrayList[Vertex]();
+ x.add(g.v(2));
+ super.test_g_v1_out_retainXg_v2X(g.v(1).out.retain(x));
+ }
+
+ def test_g_v1_out_aggregateXxX_out_retainXxX() {
+ val x = new HashSet[Vertex]();
+ super.test_g_v1_out_aggregateXxX_out_retainXxX(g.v(1).out.aggregate(x).out.retain(x));
+ }
+
+}
View
35 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/AggregateStepTest.scala
@@ -0,0 +1,35 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import java.util.ArrayList
+import com.tinkerpop.pipes.Pipe
+import com.tinkerpop.blueprints.pgm.{Vertex, Graph}
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class AggregateStepTest extends com.tinkerpop.gremlin.test.sideeffect.AggregateStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_v1_aggregateXxX_outXcreatedX_inXcreatedX_exceptXxX() {
+ val x = new ArrayList[Vertex]();
+ super.test_g_v1_aggregateXxX_outXcreatedX_inXcreatedX_exceptXxX(g.v(1).->.aggregate(x).out("created").in("created").except(x))
+ }
+
+ def test_g_V_propertyXnameX_aggregate_cap() {
+ super.test_g_V_propertyXnameX_aggregate_cap(g.V.property("name").aggregate().cap.asInstanceOf[Pipe[Graph, java.util.List[String]]]);
+ }
+
+ def test_g_V_aggregateXnameX_cap() {
+ super.test_g_V_aggregateXnameX_cap(g.V.aggregate {v: Vertex => v("name")}.cap.asInstanceOf[Pipe[Graph, java.util.List[String]]]);
+ }
+}
View
25 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/GroupByStepTest.scala
@@ -0,0 +1,25 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class GroupByStepTest extends com.tinkerpop.gremlin.test.sideeffect.GroupByStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_V_groupByXlang_nameX() {
+ val m = new java.util.HashMap[String, java.util.List[String]]();
+ super.test_g_V_groupByXlang_nameX(g.V.groupBy(m.asInstanceOf[java.util.HashMap[_, java.util.List[_]]], {v: Vertex => v("lang")}, {v: Vertex => v("name")}), m);
+ }
+}
+
View
44 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/GroupCountStepTest.scala
@@ -0,0 +1,44 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.blueprints.pgm.{Graph, Vertex}
+import com.tinkerpop.pipes.Pipe
+import com.tinkerpop.pipes.util.structures.{Pair => TPair}
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class GroupCountStepTest extends com.tinkerpop.gremlin.test.sideeffect.GroupCountStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_V_outXcreatedX_groupCountXm__nameX() {
+ val m = new java.util.HashMap[String, Number]();
+ super.test_g_V_outXcreatedX_groupCountXm__nameX(g.V.out("created").groupCount(m, {v: Vertex => v("name")}).asInstanceOf[Pipe[Graph, Vertex]], m);
+ }
+
+ // TODO: Why is the implicit converstion of a => to a PipeFunction not being respected?
+ def test_g_V_outXcreatedX_groupCountXm__name__plus_2X() {
+ val m = new java.util.HashMap[String, Number]();
+
+ //this works but has ugly function call instead of implicit
+ //val pipeline = g.V.out("created").groupCount(m, {v: Vertex => v("name")}, com.tinkerpop.gremlin.scala.functionToPipeFunction({p: TPair[_, Number] => (p.getB.longValue() + 2l).asInstanceOf[Number]})).asInstanceOf[Pipe[Graph, Vertex]]
+
+ //attempting to get implicit working
+ val pipeline = g.V.out("created").groupCount(m, {v: Vertex => v("name")}, {p: TPair[_, Number] => (p.getB.longValue() + 2l).asInstanceOf[Number]}).asInstanceOf[Pipe[Graph, Vertex]]
+
+ super.test_g_V_outXcreatedX_groupCountXm__name__plus_2X(pipeline, m);
+ }
+
+ def test_g_V_outXcreatedX_groupCountXnameX_cap() {
+ super.test_g_V_outXcreatedX_groupCountXnameX_cap(g.V.out("created").groupCount {v: Vertex => v("name")}.cap.asInstanceOf[Pipe[Graph, java.util.Map[String, Number]]]);
+ }
+}
+
View
39 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/SideEffectStepTest.scala
@@ -0,0 +1,39 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+import junit.framework.Assert._
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class SideEffectStepTest extends com.tinkerpop.gremlin.test.sideeffect.SideEffectStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_v1_sideEffectXstore_aX_propertyXnameX() {
+ var a = g.getVertex(2)
+ super.test_g_v1_sideEffectXstore_aX_propertyXnameX(g.v(1).->.sideEffect {v: Vertex => a = v}.property("name").asInstanceOf[Pipe[Vertex, String]])
+ assertEquals(a, g.v(1))
+ }
+
+ def test_g_v1_out_sideEffectXincr_cX_propertyXnameX() {
+ var c = 0;
+ super.test_g_v1_out_sideEffectXincr_cX_propertyXnameX(g.v(1).->.out.sideEffect {v: Vertex => c = c + 1}.property("name").asInstanceOf[Pipe[Vertex, String]]);
+ assertEquals(c, 3);
+ }
+
+ def test_g_v1_out_sideEffectXfalseX_propertyXnameX() {
+ super.test_g_v1_out_sideEffectXfalseX_propertyXnameX(g.v(1).->.out.sideEffect {v: Vertex => false}.property("name").asInstanceOf[Pipe[Vertex, String]]);
+ }
+
+}
+
View
28 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/StoreStepTest.scala
@@ -0,0 +1,28 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+import com.tinkerpop.blueprints.pgm.{Graph, Vertex}
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class StoreStepTest extends com.tinkerpop.gremlin.test.sideeffect.StoreStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_V_propertyXnameX_store_cap() {
+ super.test_g_V_propertyXnameX_store_cap(g.V.property("name").store().cap.asInstanceOf[Pipe[Graph, java.util.List[String]]]);
+ }
+
+ def test_g_V_storeXnameX_cap() {
+ super.test_g_V_storeXnameX_cap(g.V.store {v: Vertex => v("name")}.cap.asInstanceOf[Pipe[Graph, java.util.List[String]]]);
+ }
+}
View
33 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/TableStepTest.scala
@@ -0,0 +1,33 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.util.structures.Table
+import com.tinkerpop.pipes.Pipe
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class TableStepTest extends com.tinkerpop.gremlin.test.sideeffect.TableStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_v1_asXaX_out_properyXnameX_asXbX_table_cap() {
+ super.test_g_v1_asXaX_out_properyXnameX_asXbX_table_cap(g.v(1).->.as("a").out.property("name").as("b").table.cap.asInstanceOf[Pipe[Vertex, Table]]);
+ }
+
+ def test_g_v1_asXaX_out_asXbX_tableXnameX_cap() {
+ super.test_g_v1_asXaX_out_asXbX_tableXnameX_cap(g.v(1).->.as("a").out.as("b").table {v: Vertex => v("name")}.cap.asInstanceOf[Pipe[Vertex, Table]]);
+ }
+
+ def test_g_v1_asXaX_out_propertyXnameX_asXbX_tableXname_lengthX_cap() {
+ super.test_g_v1_asXaX_out_propertyXnameX_asXbX_tableXname_lengthX_cap(g.v(1).->.as("a").out.property("name").as("b").table({v: Vertex => v("name")}, {s: String => s.length()}).cap.asInstanceOf[Pipe[Vertex, Table]]);
+ }
+}
View
25 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/sideeffect/TreeStepTest.scala
@@ -0,0 +1,25 @@
+package com.tinkerpop.gremlin.scala.sideeffect
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.Pipe
+import com.tinkerpop.pipes.util.structures.Tree
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class TreeStepTest extends com.tinkerpop.gremlin.test.sideeffect.TreeStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph();
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass);
+ }
+
+ def test_g_v1_out_out_treeXnameX_cap() {
+ super.test_g_v1_out_out_treeXnameX_cap(g.v(1).out.out.tree {v: Vertex => v("name")}.cap.asInstanceOf[Pipe[Vertex, Tree[_]]]);
+ }
+}
View
22 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/MapStepTest.scala
@@ -0,0 +1,22 @@
+package com.tinkerpop.gremlin.scala.transform
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.blueprints.pgm.Vertex
+
+class MapStepTest extends com.tinkerpop.gremlin.test.transform.MapStepTest {
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_map() {
+ super.test_g_v1_map(g.v(1).->.map.asInstanceOf[GremlinScalaPipeline[Vertex, java.util.Map[String, Object]]])
+ }
+
+ def test_g_v1_outXknowsX_map() {
+ super.test_g_v1_outXknowsX_map(g.v(1).out("knows").map);
+ }
+}
View
28 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/PathStepTest.scala
@@ -0,0 +1,28 @@
+package com.tinkerpop.gremlin.scala.transform
+
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle
+
+class PathStepTest extends com.tinkerpop.gremlin.test.transform.PathStepTest {
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_propertyXnameX_path() {
+ super.test_g_v1_propertyXnameX_path(g.v(1).->.property("name").path())
+ }
+
+ def test_g_v1_out_pathXage__nameX() {
+ super.test_g_v1_out_pathXage__nameX(g.v(1).out.path({v: Vertex => v("age")}, {v: Vertex => v("name")}))
+ }
+
+ def test_g_V_out_loopX1__loops_lt_3X_pathXit__name__langX() {
+ val p = g.V.out.loop(1, {lb: LoopBundle[Vertex] => lb.loops < 3}).path({v: Vertex => v}, {v: Vertex => v("name")}, {v: Vertex => v("lang")})
+ super.test_g_V_out_loopX1__loops_lt_3X_pathXit__name__langX(p)
+ }
+}
View
36 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/SelectStepTest.scala
@@ -0,0 +1,36 @@
+package com.tinkerpop.gremlin.scala.transform
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.blueprints.pgm.Vertex
+import java.util.Arrays
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+class SelectStepTest extends com.tinkerpop.gremlin.test.transform.SelectStepTest {
+
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_asXaX_outXknowsX_asXbX_select() {
+ super.test_g_v1_asXaX_outXknowsX_asXbX_select(g.v(1).->.as("a").out("knows").as("b").select())
+ }
+
+ def test_g_v1_asXaX_outXknowsX_asXbX_selectXnameX() {
+ super.test_g_v1_asXaX_outXknowsX_asXbX_selectXnameX(g.v(1).->.as("a").out("knows").as("b").select({v: Vertex => v("name")}))
+ }
+
+ def test_g_v1_asXaX_outXknowsX_asXbX_selectXaX() {
+ super.test_g_v1_asXaX_outXknowsX_asXbX_selectXaX(g.v(1).->.as("a").out("knows").as("b").select(Arrays.asList("a")))
+ }
+
+ def test_g_v1_asXaX_outXknowsX_asXbX_selectXa_nameX() {
+ super.test_g_v1_asXaX_outXknowsX_asXbX_selectXa_nameX(g.v(1).->.as("a").out("knows").as("b").select(Arrays.asList("a"), {v: Vertex => v("name")}))
+ }
+}
View
26 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/TransformStepTest.scala
@@ -0,0 +1,26 @@
+package com.tinkerpop.gremlin.scala.transform
+
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.blueprints.pgm.Vertex
+import com.tinkerpop.gremlin.scala._
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+
+class TransformStepTest extends com.tinkerpop.gremlin.test.transform.TransformStepTest {
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_v1_transformXnameX() {
+ super.test_g_v1_transformXnameX(g.v(1).->.transform({v: Vertex => v.getProperty("name").toString}))
+ }
+
+ def test_g_v1_outE_label_transformXlengthX() {
+ super.test_g_v1_outE_label_transformXlengthX(g.v(1).outE.label.transform({s: String => s.length(): java.lang.Integer})) //TODO eliminate the :java.lang.Integer
+ }
+
+ def test_g_v1_out_transformXnameX_transformXlengthX() {
+ super.test_g_v1_out_transformXnameX_transformXlengthX(g.v(1).out.transform({v: Vertex => v.getProperty("name").toString}).transform({s: String => s.length(): java.lang.Integer})) //TODO eliminate the :java.lang.Integer
+ }
+}
View
81 gremlin-scala/src/test/scala/com/tinkerpop/gremlin/scala/transform/TraversalStepsTest.scala
@@ -0,0 +1,81 @@
+package com.tinkerpop.gremlin.scala.transform
+
+import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
+import com.tinkerpop.gremlin.test.ComplianceTest
+import com.tinkerpop.gremlin.scala._
+
+class TraversalStepsTest extends com.tinkerpop.gremlin.test.transform.TraversalStepsTest {
+ val g = TinkerGraphFactory.createTinkerGraph()
+
+ override def testCompliance() {
+ ComplianceTest.testCompliance(this.getClass)
+ }
+
+ def test_g_V() {
+ super.test_g_V(g.V)
+ }
+
+ def test_g_v1_out() {
+ super.test_g_v1_out(g.v(1).out)
+ }
+
+ def test_g_v2_in() {
+ super.test_g_v2_in(g.v(2).in)
+ }
+
+ def test_g_v4_both() {
+ super.test_g_v4_both(g.v(4).both)
+ }
+
+ def test_g_E() {
+ super.test_g_E(g.E)
+ }
+
+ def test_g_v1_outE() {
+ super.test_g_v1_outE(g.v(1).outE)
+ }
+
+ def test_g_v2_inE() {
+ super.test_g_v2_inE(g.v(2).inE)
+ }
+
+ def test_g_v4_bothE() {
+ super.test_g_v4_bothE(g.v(4).bothE)
+ }
+
+ def test_g_v1_outE_inV() {
+ super.test_g_v1_outE_inV(g.v(1).outE.inV)
+ }
+
+ def test_g_v2_inE_outV() {
+ super.test_g_v2_inE_outV(g.v(2).inE.outV)
+ }
+
+ def test_g_v1_outXknowsX() {
+ super.test_g_v1_outXknowsX(g.v(1).out("knows"))
+ }
+
+ def test_g_v1_outXknows_createdX() {
+ super.test_g_v1_outXknows_createdX(g.v(1).out("knows", "created"))
+ }
+
+ def test_g_v1_outEXknowsX_inV() {
+ super.test_g_v1_outEXknowsX_inV(g.v(1).outE("knows").inV)
+ }
+
+ def test_g_v1_outEXknows_createdX_inV() {
+ super.test_g_v1_outEXknows_createdX_inV(g.v(1).outE("knows", "created").inV)
+ }
+
+ def test_g_V_out_out() {
+ super.test_g_V_out_out(g.V.out.out)
+ }
+
+ def test_g_v1_out_out_out() {
+ super.test_g_v1_out_out_out(g.v(1).out.out.out)
+ }
+
+ def test_g_v1_out_propertyXnameX() {
+ super.test_g_v1_out_propertyXnameX(g.v(1).out.property("name"))
+ }
+}

0 comments on commit 5e8c4b9

Please sign in to comment.
Something went wrong with that request. Please try again.