Search in sources :

Example 6 with OCommandSQL

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");
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) List(java.util.List) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 7 with OCommandSQL

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;
    }
}
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 8 with OCommandSQL

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();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) InputStream(java.io.InputStream) OCommandScript(com.orientechnologies.orient.core.command.script.OCommandScript) Before(org.junit.Before)

Example 9 with OCommandSQL

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);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 10 with OCommandSQL

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);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)646 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)440 Test (org.junit.Test)109 Test (org.testng.annotations.Test)93 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)85 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)83 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)81 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)65 ORID (com.orientechnologies.orient.core.id.ORID)65 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)54 Set (java.util.Set)53 HashMap (java.util.HashMap)48 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)42 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)42 List (java.util.List)27 Before (org.junit.Before)25 OStorage (com.orientechnologies.orient.core.storage.OStorage)23 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)23 OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)22 ORecordId (com.orientechnologies.orient.core.id.ORecordId)21