org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HugeGraphAuthProxy.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@Override
public void applyStrategies(Admin<?, ?> traversal) {
    String script;
    if (traversal instanceof HugeScriptTraversal) {
        script = ((HugeScriptTraversal<?, ?>) traversal).script();
    } else {
        GroovyTranslator translator = GroovyTranslator.of("g");
        script = translator.translate(traversal.getBytecode());
    }

    verifyNamePermission(HugePermission.EXECUTE,
                         ResourceType.GREMLIN, script);
    this.strategies.applyStrategies(traversal);
}
 
Example #2
Source File: App.java    From graph-examples with Apache License 2.0 5 votes vote down vote up
private static void printTraversal(Terminal terminal, String title, GraphTraversal traversal) {
    terminal.writer().println(new AttributedStringBuilder()
            .style(AttributedStyle.DEFAULT.foreground(AttributedStyle.GREEN))
            .append(title).append("\n")
            .style(AttributedStyle.DEFAULT).toAnsi());
    terminal.writer().println(formatTraversal(GroovyTranslator.of("g").translate(traversal.asAdmin().getBytecode())));
}
 
Example #3
Source File: GremlinQueryDebugger.java    From amazon-neptune-tools with Apache License 2.0 4 votes vote down vote up
public static String queryAsString(Object o){
    return String.valueOf(new GroovyTranslator.DefaultTypeTranslator().apply("g", o));
}