Search in sources :

Example 61 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 62 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 63 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 64 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)

Example 65 with OrientGraph

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

the class OGraphBatchInsertTest method testHoles.

public void testHoles() {
    String dbUrl = "memory:batchinsert_testHoles";
    OGraphBatchInsert batch = new OGraphBatchInsert(dbUrl, "admin", "admin");
    batch.setParallel(1);
    batch.begin();
    batch.createEdge(0L, 1L, null);
    batch.createEdge(1L, 3L, null);
    batch.createEdge(3L, 4L, null);
    Map<String, Object> vertexProps = new HashMap<String, Object>();
    vertexProps.put("foo", "aa");
    batch.setVertexProperties(3L, vertexProps);
    vertexProps.put("foo", "bar");
    batch.setVertexProperties(4L, vertexProps);
    batch.end();
    OrientGraph g = new OrientGraph(dbUrl, "admin", "admin");
    Iterable<Vertex> result = g.command(new OSQLSynchQuery<Vertex>("select expand(out().in().out().out().in().out().out().in().out()) from V where uid = ?")).execute(0L);
    boolean found = false;
    for (Vertex v : result) {
        assertFalse(found);
        assertEquals("bar", v.getProperty("foo"));
        found = true;
    }
    assertTrue(found);
    g.shutdown();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) HashMap(java.util.HashMap) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)

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