Java Code Examples for com.tinkerpop.blueprints.impls.orient.OrientGraph#addEdge()

The following examples show how to use com.tinkerpop.blueprints.impls.orient.OrientGraph#addEdge() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPeopleDao.java    From thorntail with Apache License 2.0 6 votes vote down vote up
public OrientEdge addFriend(String outName, String inName) {
    OrientGraph database = new OrientGraph(databasePool);
    try {
        Vertex outVertex = database.addVertex(null);
        Vertex inVertex = database.addVertex(null);
        outVertex.setProperty("name", outName);
        inVertex.setProperty("name", inName);
        OrientEdge edge = database.addEdge(null, outVertex, inVertex, "knows");
        database.commit();
        return edge;
    } catch (Exception e) {
        database.rollback();
    } finally {
        database.shutdown();
    }

    return null;
}
 
Example 2
Source File: CreateEdgeCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private void createEdge(List<ODocument> documents, OClass edgeClass) {
    OrientGraph tx = orientGraphProvider.get();
    for (ODocument createTo : documents) {
        tx.addEdge(null, tx.getVertex(documentModel.getObject().getIdentity()), tx.getVertex(createTo.getIdentity()), edgeClass.getName());
    }
    tx.commit();tx.begin();
}
 
Example 3
Source File: CreateVertexCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private OrientVertex createVertex(OClass vertexClass, OClass edgeClass) {
    OrientGraph tx = orientGraphProvider.get();
    OrientVertex newVertex = tx.addVertex(vertexClass.getName(), (String) null);
    OrientVertex vertex = tx.getVertex(documentModel.getObject().getIdentity());
    tx.addEdge(null, vertex, newVertex, edgeClass.getName());
    tx.commit();tx.begin();
    return newVertex;
}