TINKERPOP-1562 Hook up Console to do core imports under v3d3

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

Branch: refs/heads/TINKERPOP-1562
Commit: 7cb74255fcc6560ebdb8fda6f7b0214bdf17a31a
Parents: d928f3d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 30 07:28:37 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Dec 1 06:41:43 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    | 21 +++++++++++++-------
 .../ConsoleImportCustomizerProvider.groovy      |  2 ++
 2 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7cb74255/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 d39e085..a2e518c 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
@@ -31,6 +31,8 @@ import 
org.apache.tinkerpop.gremlin.console.commands.UninstallCommand
 import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn
 import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
+import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation
 import org.apache.tinkerpop.gremlin.structure.Edge
 import org.apache.tinkerpop.gremlin.structure.T
@@ -103,13 +105,18 @@ class Console {
         // hide output temporarily while imports execute
         showShellEvaluationOutput(false)
 
-        // TODO: register CoreGremlinPlugin if using v3d3
-
-        // add the default imports
-        new ConsoleImportCustomizerProvider().getCombinedImports().stream()
-                .collect { IMPORT_SPACE + it }.each { groovy.execute(it) }
-        new 
ConsoleImportCustomizerProvider().getCombinedStaticImports().stream()
-                .collect { IMPORT_STATIC_SPACE + it }.each { 
groovy.execute(it) }
+        if (Mediator.useV3d3) {
+            def imports = (ImportCustomizer) 
CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").get()[0]
+            imports.classImports.collect { IMPORT_SPACE + it.canonicalName 
}.each { groovy.execute(it) }
+            imports.methodImports.collect { IMPORT_STATIC_SPACE + 
it.getDeclaringClass().getCanonicalName() + "." + it.name}.each{ 
groovy.execute(it) }
+            imports.enumImports.collect { IMPORT_STATIC_SPACE + 
it.getDeclaringClass().getCanonicalName() + "." + it.name()}.each{ 
groovy.execute(it) }
+        } else {
+            // add the default imports
+            new ConsoleImportCustomizerProvider().getCombinedImports().stream()
+                    .collect { IMPORT_SPACE + it }.each { groovy.execute(it) }
+            new 
ConsoleImportCustomizerProvider().getCombinedStaticImports().stream()
+                    .collect { IMPORT_STATIC_SPACE + it }.each { 
groovy.execute(it) }
+        }
 
         final InteractiveShellRunner runner = new 
InteractiveShellRunner(groovy, handlePrompt)
         runner.setErrorHandler(handleError)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7cb74255/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
index 0404e93..85fda8c 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
@@ -23,7 +23,9 @@ import groovy.sql.Sql
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 class ConsoleImportCustomizerProvider extends AbstractImportCustomizerProvider 
{
     public ConsoleImportCustomizerProvider() {
         // useful groovy bits that are good for the Console

Reply via email to