Search in sources :

Example 6 with OrientEdgeType

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

the class SQLMoveVertexCommandTest method reinitEdgeType.

private OrientEdgeType reinitEdgeType(String className) {
    OrientEdgeType clazz = graph.getEdgeType(className);
    if (clazz != null) {
        graph.command(new OCommandSQL("delete edge " + className)).execute();
        graph.dropVertexType(className);
    }
    clazz = graph.createEdgeType(className);
    return clazz;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType)

Example 7 with OrientEdgeType

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

the class IndexTest method testIndexEdgeComposite.

public void testIndexEdgeComposite() {
    OrientGraph graphNoTx = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying());
    OrientVertexType vertexType = null;
    if (!graphNoTx.getRawGraph().existsCluster("CustomVertex")) {
        vertexType = graphNoTx.createVertexType("CustomVertex");
    } else {
        vertexType = graphNoTx.getVertexType("CustomVertex");
    }
    if (!graphNoTx.getRawGraph().existsCluster("CustomEdge")) {
        OrientEdgeType edgeType = graphNoTx.createEdgeType("CustomEdge");
        edgeType.createProperty("out", OType.LINK, vertexType);
        edgeType.createProperty("in", OType.LINK, vertexType);
        edgeType.createIndex("CustomEdge.in", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "in" });
        edgeType.createIndex("CustomEdge.out", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "out" });
        edgeType.createIndex("CustomEdge.compositeInOut", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "out", "in" });
    }
    // graphNoTx.shutdown();
    OrientGraph graph = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying());
    Vertex inVert = null;
    for (int i = 0; i < 5; ++i) {
        Vertex currentVert = graph.addVertex("class:CustomVertex");
        if (inVert != null) {
            graph.addEdge("class:CustomEdge", currentVert, inVert, "CustomEdge");
        }
        inVert = currentVert;
    }
    graph.commit();
    Iterable<Vertex> verts = graph.getVertices();
    StringBuilder vertIds = new StringBuilder();
    for (Vertex vert : verts) {
        vertIds.append(vert.getId().toString()).append(" ");
    }
    System.out.println("Vertices: " + vertIds);
    System.out.println();
    checkIndexKeys(graph, "CustomEdge.in");
    checkIndexKeys(graph, "CustomEdge.out");
    checkIndexKeys(graph, "CustomEdge.compositeInOut");
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) Vertex(com.tinkerpop.blueprints.Vertex) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OrientEdgeType (com.tinkerpop.blueprints.impls.orient.OrientEdgeType)7 OrientVertexType (com.tinkerpop.blueprints.impls.orient.OrientVertexType)5 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)3 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)2 Test (org.junit.Test)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 Vertex (com.tinkerpop.blueprints.Vertex)1 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)1 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)1 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)1 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)1