use of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine in project atlas by apache.
the class AtlasJanusGraph method getGremlinScriptEngine.
@Override
public GremlinGroovyScriptEngine getGremlinScriptEngine() {
Set<String> extraImports = new HashSet<String>();
extraImports.add(java.util.function.Function.class.getName());
Set<String> extraStaticImports = new HashSet<String>();
extraStaticImports.add(P.class.getName() + ".*");
extraStaticImports.add(__.class.getName() + ".*");
CompilerCustomizerProvider provider = new DefaultImportCustomizerProvider(extraImports, extraStaticImports);
GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider);
return scriptEngine;
}
use of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine in project incubator-atlas by apache.
the class Titan1Graph method getGremlinScriptEngine.
@Override
public GremlinGroovyScriptEngine getGremlinScriptEngine() {
Set<String> extraImports = new HashSet<String>();
extraImports.add(java.util.function.Function.class.getName());
Set<String> extraStaticImports = new HashSet<String>();
extraStaticImports.add(P.class.getName() + ".*");
extraStaticImports.add(__.class.getName() + ".*");
CompilerCustomizerProvider provider = new DefaultImportCustomizerProvider(extraImports, extraStaticImports);
GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider);
return scriptEngine;
}
use of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine in project titan by thinkaurelius.
the class ScriptExecutor method evaluate.
protected static void evaluate(final Reader reader, final List<String> arguments) {
final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
final Bindings bindings = engine.createBindings();
bindings.put("args", arguments.toArray());
// TODO: Deprecate this
if (arguments.size() > 0) {
for (int i = 0; i < arguments.size(); i++) {
bindings.put("a" + (i + 1), arguments.get(i));
}
}
try {
engine.eval(reader, bindings);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
use of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine in project atlas by apache.
the class AtlasJanusGraph 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, e, gremlinQuery);
} finally {
releaseGremlinScriptEngine(scriptEngine);
}
}
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);
}
}
Aggregations