Search in sources :

Example 6 with GremlinGroovyScriptEngine

use of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine in project incubator-atlas by apache.

the class Titan1Graph method executeGremlinScript.

private Object executeGremlinScript(String gremlinQuery) throws AtlasBaseException {
    GremlinGroovyScriptEngine scriptEngine = getGremlinScriptEngine();
    try {
        Bindings bindings = scriptEngine.createBindings();
        bindings.put("graph", getGraph());
        bindings.put("g", getGraph().traversal());
        Object result = scriptEngine.eval(gremlinQuery, bindings);
        return result;
    } catch (ScriptException e) {
        throw new AtlasBaseException(AtlasErrorCode.GREMLIN_SCRIPT_EXECUTION_FAILED, gremlinQuery);
    } finally {
        releaseGremlinScriptEngine(scriptEngine);
    }
}
Also used : ScriptException(javax.script.ScriptException) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) GremlinGroovyScriptEngine(org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine) Bindings(javax.script.Bindings)

Aggregations

GremlinGroovyScriptEngine (org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine)4 Bindings (javax.script.Bindings)3 Function (com.google.common.base.Function)2 GremlinGroovyScriptEngine (com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine)2 HashSet (java.util.HashSet)2 ScriptException (javax.script.ScriptException)2 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)2 CompilerCustomizerProvider (org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider)2 DefaultImportCustomizerProvider (org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider)2 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)1 ScriptEngine (javax.script.ScriptEngine)1