Search in sources :

Example 91 with OrientGraph

use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.

the class IndexTest method testNullIteration.

public void testNullIteration() {
    ODatabaseDocumentTx database = (ODatabaseDocumentTx) this.database.getUnderlying();
    OrientGraph graph = new OrientGraph(database, false);
    OClass v = database.getMetadata().getSchema().getClass("V");
    OClass testNullIteration = database.getMetadata().getSchema().createClass("NullIterationTest", v);
    testNullIteration.createProperty("name", OType.STRING);
    testNullIteration.createProperty("birth", OType.DATETIME);
    database.command(new OCommandSQL("CREATE VERTEX NullIterationTest SET name = 'Andrew', birth = sysdate()")).execute();
    database.command(new OCommandSQL("CREATE VERTEX NullIterationTest SET name = 'Marcel', birth = sysdate()")).execute();
    database.command(new OCommandSQL("CREATE VERTEX NullIterationTest SET name = 'Olivier'")).execute();
    ODocument metadata = new ODocument();
    metadata.field("ignoreNullValues", false);
    testNullIteration.createIndex("NullIterationTestIndex", INDEX_TYPE.NOTUNIQUE.name(), null, metadata, new String[] { "birth" });
    List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("SELECT FROM NullIterationTest ORDER BY birth ASC"));
    Assert.assertEquals(result.size(), 3);
    result = database.query(new OSQLSynchQuery<ODocument>("SELECT FROM NullIterationTest ORDER BY birth DESC"));
    Assert.assertEquals(result.size(), 3);
    result = database.query(new OSQLSynchQuery<ODocument>("SELECT FROM NullIterationTest"));
    Assert.assertEquals(result.size(), 3);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 92 with OrientGraph

use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.

the class SQLCreateVertexTest method testIsClassName.

public void testIsClassName() {
    OrientGraph graph = new OrientGraph(database, false);
    graph.shutdown();
    database.open("admin", "admin");
    graph.createVertexType("Like").createProperty("anything", OType.STRING);
    graph.createVertexType("Is").createProperty("anything", OType.STRING);
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph)

Example 93 with OrientGraph

use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.

the class SQLCreateVertexTest method testCreateVertexBooleanProp.

public void testCreateVertexBooleanProp() {
    OrientGraph graph = new OrientGraph(database, false);
    graph.shutdown();
    database.open("admin", "admin");
    database.command(new OCommandSQL("create vertex set script = true")).execute();
    database.command(new OCommandSQL("create vertex")).execute();
    database.command(new OCommandSQL("create vertex V")).execute();
// TODO complete this!
// database.command(new OCommandSQL("create vertex set")).execute();
// database.command(new OCommandSQL("create vertex set set set = 1")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph)

Example 94 with OrientGraph

use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.

the class TransactionConsistencyTest method testQueryIsolation.

@Test
public void testQueryIsolation() {
    OrientGraph graph = new OrientGraph(url);
    try {
        graph.addVertex(null, "purpose", "testQueryIsolation");
        if (!url.startsWith("remote")) {
            List<OIdentifiable> result = graph.getRawGraph().query(new OSQLSynchQuery<Object>("select from V where purpose = 'testQueryIsolation'"));
            Assert.assertEquals(result.size(), 1);
        }
        graph.commit();
        List<OIdentifiable> result = graph.getRawGraph().query(new OSQLSynchQuery<Object>("select from V where purpose = 'testQueryIsolation'"));
        Assert.assertEquals(result.size(), 1);
    } finally {
        graph.shutdown();
    }
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test) DatabaseAbstractTest(com.orientechnologies.DatabaseAbstractTest)

Aggregations

OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)94 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)43 Test (org.junit.Test)33 Vertex (com.tinkerpop.blueprints.Vertex)22 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)19 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)18 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)13 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)13 OrientVertexType (com.tinkerpop.blueprints.impls.orient.OrientVertexType)12 Edge (com.tinkerpop.blueprints.Edge)8 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)7 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)7 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)7 OConcurrentModificationException (com.orientechnologies.orient.core.exception.OConcurrentModificationException)6 Test (org.testng.annotations.Test)6 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)5 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)5 Before (org.junit.Before)5 BeforeClass (org.junit.BeforeClass)5 ORecordDuplicatedException (com.orientechnologies.orient.core.storage.ORecordDuplicatedException)4