Search in sources :

Example 31 with OrientEdge

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

the class TestDeleteEdge method testDeleteEdge.

@Test
public void testDeleteEdge() {
    for (int i = 0; i < 10; i++) {
        OrientVertex v1 = graph.addVertex("class:TestVertex");
        OrientVertex v2 = graph.addVertex("class:TestVertex");
        OrientVertex v3 = graph.addVertex("class:TestVertex");
        OrientVertex v4 = graph.addVertex("class:TestVertex");
        Map<String, Object> p1 = new HashMap<String, Object>();
        p1.put("based_on", "0001");
        OrientEdge e1 = v1.addEdge(null, v2, "TestEdge", null, p1);
        e1.save();
        Map<String, Object> p2 = new HashMap<String, Object>();
        p2.put("based_on", "0002");
        OrientEdge e2 = v3.addEdge(null, v4, "TestEdge", null, p2);
        e2.save();
        graph.commit();
        graph.command(new OCommandSQL("delete edge TestEdge where based_on = '0001'")).execute();
        Iterable<OrientVertex> edges = graph.command(new OCommandSQL("select count(*) from TestEdge where based_on = '0001'")).execute();
        assertTrue(edges.iterator().hasNext());
        assertEquals(edges.iterator().next().getProperty("count"), 0l);
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) HashMap(java.util.HashMap) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientEdge(com.tinkerpop.blueprints.impls.orient.OrientEdge) Test(org.junit.Test)

Example 32 with OrientEdge

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

the class GraphDatabaseTest method testInsertOfEdgeWithInsertCommandUnsafe.

public void testInsertOfEdgeWithInsertCommandUnsafe() {
    OrientEdge insertedEdge = database.command(new OCommandSQL("insert into E set in = #9:0, out = #9:1, a = 33 unsafe")).execute();
    Assert.assertNotNull(insertedEdge);
    Integer confirmDeleted = database.command(new OCommandSQL("delete from " + insertedEdge.getIdentity() + " unsafe")).execute();
    Assert.assertEquals(confirmDeleted.intValue(), 1);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientEdge(com.tinkerpop.blueprints.impls.orient.OrientEdge)

Aggregations

OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)32 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)26 Test (org.junit.Test)17 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)12 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)9 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)9 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)6 Edge (com.tinkerpop.blueprints.Edge)5 HashSet (java.util.HashSet)5 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)4 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)4 HashMap (java.util.HashMap)4 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)3 OMultiCollectionIterator (com.orientechnologies.common.collection.OMultiCollectionIterator)2 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)2 OCompositeKey (com.orientechnologies.orient.core.index.OCompositeKey)2 OIndex (com.orientechnologies.orient.core.index.OIndex)2 OImmutableClass (com.orientechnologies.orient.core.metadata.schema.OImmutableClass)2 ODirtyManager (com.orientechnologies.orient.core.record.impl.ODirtyManager)2