Examples of GremlinGroovyScriptEngine


Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

                    logger.warn("Could not instantiate GroovyInterceptor implementation [%s] for the SecurityCustomizerProvider.  It will not be applied.", clazz);
                    securityCustomizerProvider = null;
                }
            }

            return Optional.of((ScriptEngine) new GremlinGroovyScriptEngine(
                    new DefaultImportCustomizerProvider(imports, staticImports), securityCustomizerProvider));
        } else {
            final ScriptEngineManager manager = new ScriptEngineManager();
            return Optional.ofNullable(manager.getEngineByName(language));
        }
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

        this.g.addVertex(T.label, "Person", "name", "marko");
    }

    @Test
    public void shouldEnsureTraverseRelationshipNeedsTx() throws ScriptException {
        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
        final Bindings bindings = engine.createBindings();
        bindings.put("g", g);
        bindings.put("#jsr223.groovy.engine.keep.globals", "phantom");

        Vertex marko = this.g.addVertex(T.label, "Person", "name", "marko");
        Vertex john = this.g.addVertex(T.label, "Person", "name", "john");
        Vertex pete = this.g.addVertex(T.label, "Person", "name", "pete");
        marko.addEdge("friend", john);
        marko.addEdge("friend", pete);
        this.g.tx().commit();

        Object result = engine.eval("g.v(" + marko.id().toString() + ").outE('friend')", bindings);
        assertTrue(result instanceof GraphTraversal);

        this.g.tx().commit();
        assertEquals(2L, ((GraphTraversal) result).count().next());
    }
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

        assertEquals(2L, ((GraphTraversal) result).count().next());
    }

    @Test
    public void shouldEnsureTraversalOfVerticesNeedsTx() throws ScriptException {
        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
        final Bindings bindings = engine.createBindings();
        bindings.put("g", g);
        bindings.put("#jsr223.groovy.engine.keep.globals", "phantom");

        Vertex marko = this.g.addVertex(T.label, "Person", "name", "marko");
        Vertex john = this.g.addVertex(T.label, "Person", "name", "john");
        Vertex pete = this.g.addVertex(T.label, "Person", "name", "pete");
        marko.addEdge("friend", john);
        marko.addEdge("friend", pete);
        this.g.tx().commit();

        Object result = engine.eval("g.v(" + marko.id().toString() + ").out('friend')", bindings);
        assertTrue(result instanceof GraphTraversal);

        this.g.tx().commit();
        assertEquals(2L, ((GraphTraversal) result).count().next());
    }
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

            this.graph = BlueprintsGraphOutputMapReduce.generateGraph(context.getConfiguration());
            final String file = context.getConfiguration().get(FAUNUS_GRAPH_OUTPUT_BLUEPRINTS_SCRIPT_FILE, null);
            if (null != file && firstRead) {
                final FileSystem fs = FileSystem.get(context.getConfiguration());
                try {
                    engine = new GremlinGroovyScriptEngine();
                    engine.eval(new InputStreamReader(fs.open(new Path(file))));
                    try {
                        engine.eval("getOrCreateVertex(null,null,null)");
                    } catch (ScriptException se) {
                        if (se.getCause().getCause() instanceof MissingMethodException)
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

            this.graph = BlueprintsGraphOutputMapReduce.generateGraph(context.getConfiguration());
            final String file = context.getConfiguration().get(FAUNUS_GRAPH_OUTPUT_BLUEPRINTS_SCRIPT_FILE, null);
            if (null != file && firstRead) {
                final FileSystem fs = FileSystem.get(context.getConfiguration());
                try {
                    engine = new GremlinGroovyScriptEngine();
                    engine.eval(new InputStreamReader(fs.open(new Path(file))));
                    try {
                        engine.eval("getOrCreateEdge(null,null,null,null,null)");
                    } catch (ScriptException se) {
                        if (se.getCause().getCause() instanceof MissingMethodException)
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

                // this.graph = BlueprintsGraphOutputMapReduce.generateGraph(context.getConfiguration());
                final String file = context.getConfiguration().get(FAUNUS_GRAPH_OUTPUT_BLUEPRINTS_SCRIPT_FILE, null);
                if (null != file && firstRead) {
                    final FileSystem fs = FileSystem.get(context.getConfiguration());
                    try {
                        engine = new GremlinGroovyScriptEngine();
                        engine.eval(new InputStreamReader(fs.open(new Path(file))));
                        try {
                            engine.eval("getOrCreateVertex(null,null,null)");
                        } catch (ScriptException se) {
                            if (se.getCause().getCause() instanceof MissingMethodException)
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

                //this.graph = BlueprintsGraphOutputMapReduce.generateGraph(context.getConfiguration());
                final String file = context.getConfiguration().get(FAUNUS_GRAPH_OUTPUT_BLUEPRINTS_SCRIPT_FILE, null);
                if (null != file && firstRead) {
                    final FileSystem fs = FileSystem.get(context.getConfiguration());
                    try {
                        engine = new GremlinGroovyScriptEngine();
                        engine.eval(new InputStreamReader(fs.open(new Path(file))));
                        try {
                            engine.eval("getOrCreateEdge(null,null,null,null,null)");
                        } catch (ScriptException se) {
                            if (se.getCause().getCause() instanceof MissingMethodException)
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

    }
  }

  public ScriptEngine acquireEngine() {
    checkStatus();
    return new GremlinGroovyScriptEngine();// enginePool.getResource(ONE, Long.MAX_VALUE);
  }
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

        // REUSE IT
        return engine;
    }

    // CREATE A NEW ONE
    engine = new GremlinGroovyScriptEngine();
    engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", iGraph);
    set(engine);

    return engine;
  }
View Full Code Here

Examples of com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine

    protected volatile static boolean initiated = false;

    public static ScriptEngine createGremlinScriptEngine(Map<String, Object> context) {
        try {
            ScriptEngine engine = new GremlinGroovyScriptEngine();

            Bindings bindings = new SimpleBindings();
            bindings.putAll(context);

            engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);

            return engine;
        } catch (Throwable e) {
            // Pokemon catch b/c fails here get hidden until the server exits.
            e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.