Search in sources :

Example 1 with OCommandGremlin

use of com.orientechnologies.orient.graph.gremlin.OCommandGremlin in project orientdb by orientechnologies.

the class OCommandTransformer method executeTransform.

@Override
public Object executeTransform(final Object input) throws Exception {
    String runtimeCommand = (String) resolve(command);
    final OCommandRequest cmd;
    if (language.equals("sql")) {
        cmd = new OCommandSQL(runtimeCommand);
        log(OETLProcessor.LOG_LEVELS.DEBUG, "executing command=%s...", runtimeCommand);
    } else if (language.equals("gremlin")) {
        cmd = new OCommandGremlin(runtimeCommand);
    } else {
        cmd = new OCommandScript(language, runtimeCommand);
    }
    cmd.setContext(context);
    try {
        Object result = pipeline.getDocumentDatabase().command(cmd).execute();
        log(OETLProcessor.LOG_LEVELS.DEBUG, "executed command=%s, result=%s", cmd, result);
        return result;
    } catch (Exception e) {
        log(OETLProcessor.LOG_LEVELS.ERROR, "exception=%s - input=%s - command=%s ", e.getMessage(), input, cmd);
        throw e;
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OCommandScript(com.orientechnologies.orient.core.command.script.OCommandScript) OCommandGremlin(com.orientechnologies.orient.graph.gremlin.OCommandGremlin) OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest)

Example 2 with OCommandGremlin

use of com.orientechnologies.orient.graph.gremlin.OCommandGremlin in project orientdb by orientechnologies.

the class OScriptGraphWrapper method command.

@SuppressWarnings("unchecked")
public Object command(final String language, final String iText, final Object[] iArgs) {
    Object result;
    if (language.equalsIgnoreCase("sql"))
        result = graph.command(new OCommandSQL(iText)).execute(iArgs);
    else if (language.equalsIgnoreCase("gremlin"))
        result = graph.command(new OCommandGremlin(iText)).execute(iArgs);
    else
        result = graph.command(new OCommandScript(language, iText)).execute(iArgs);
    if (result instanceof Iterable<?>) {
        // FOR SAKE OF SIMPLICITY TRANSFORM ANY ITERABLE IN ARRAY
        final List<Object> list = new ArrayList<Object>();
        for (Object o : (Iterable<Object>) result) {
            list.add(o);
        }
        result = list.toArray();
    }
    return result;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OCommandScript(com.orientechnologies.orient.core.command.script.OCommandScript) ArrayList(java.util.ArrayList) OCommandGremlin(com.orientechnologies.orient.graph.gremlin.OCommandGremlin)

Aggregations

OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)2 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)2 OCommandGremlin (com.orientechnologies.orient.graph.gremlin.OCommandGremlin)2 OCommandRequest (com.orientechnologies.orient.core.command.OCommandRequest)1 ArrayList (java.util.ArrayList)1