use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class OSchedulerTest method getLogCounter.
private Long getLogCounter(final ODatabaseDocumentTx db) {
db.activateOnCurrentThread();
List<ODocument> result = (List<ODocument>) db.command(new OCommandSQL("select count(*) from scheduler_log")).execute();
return result.get(0).field("count");
}
use of com.orientechnologies.orient.core.sql.OCommandSQL 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.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class LuceneSingleFieldEmbeddedTest method init.
@Before
public void init() {
InputStream stream = ClassLoader.getSystemResourceAsStream("testLuceneIndex.sql");
db.command(new OCommandScript("sql", getScriptFromStream(stream))).execute();
db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute();
db.command(new OCommandSQL("create index Song.author on Song (author) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class FunctionsTest method createFunctionBug2415.
@Test
public void createFunctionBug2415() {
OIdentifiable result = database.command(new OCommandSQL("create function FunctionsTest \"return a + b\" PARAMETERS [a,b] IDEMPOTENT true LANGUAGE Javascript")).execute();
final ODocument record = result.getRecord();
record.reload();
final List<String> parameters = record.field("parameters");
Assert.assertNotNull(parameters);
Assert.assertEquals(parameters.size(), 2);
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class FunctionsTest method testFunctionCacheAndReload.
@Test
public void testFunctionCacheAndReload() {
OIdentifiable f = database.command(new OCommandSQL("create function testCache \"return 1;\" LANGUAGE Javascript")).execute();
Assert.assertNotNull(f);
OResultSet<OIdentifiable> res1 = database.command(new OCommandSQL("select testCache()")).execute();
Assert.assertNotNull(res1);
Assert.assertNotNull(res1.get(0));
Assert.assertEquals(((ODocument) res1.get(0)).field("testCache"), 1);
ODocument func = f.getRecord();
func.field("code", "return 2;");
func.save();
OResultSet<OIdentifiable> res2 = database.command(new OCommandSQL("select testCache()")).execute();
Assert.assertNotNull(res2);
Assert.assertNotNull(res2.get(0));
Assert.assertEquals(((ODocument) res2.get(0)).field("testCache"), 2);
}
Aggregations