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;
}
}
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;
}
Aggregations