Search in sources :

Example 1 with OrientEdgeType

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

the class AbstractServerClusterSQLGraphTest method onAfterDatabaseCreation.

@Override
protected void onAfterDatabaseCreation(final OrientBaseGraph graph) {
    System.out.println("Creating graph schema...");
    // CREATE BASIC SCHEMA
    OrientVertexType personClass = graph.createVertexType("Person");
    personClass.createProperty("id", OType.STRING);
    personClass.createProperty("name", OType.STRING);
    personClass.createProperty("birthday", OType.DATE);
    personClass.createProperty("children", OType.STRING);
    OrientVertexType person = graph.getVertexType("Person");
    idx = person.createIndex("Person.name", OClass.INDEX_TYPE.UNIQUE, "name");
    OrientVertexType customer = graph.createVertexType("Customer", person);
    customer.createProperty("totalSold", OType.DECIMAL);
    OrientVertexType provider = graph.createVertexType("Provider", person);
    provider.createProperty("totalPurchased", OType.DECIMAL);
    OrientEdgeType knows = graph.createEdgeType("Knows");
    factory = new OrientGraphFactory(graph.getRawGraph().getURL(), "admin", "admin", false);
    factory.setStandardElementConstraints(false);
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) OrientGraphFactory(com.tinkerpop.blueprints.impls.orient.OrientGraphFactory) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType)

Example 2 with OrientEdgeType

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

the class GraphValidationTest method testValidationOnVertices.

@Test
public void testValidationOnVertices() {
    OrientGraphNoTx g1 = new OrientGraphNoTx(URL, "admin", "admin");
    try {
        final OrientVertexType validationTestType = g1.createVertexType("ValidationTest");
        validationTestType.createEdgeProperty(Direction.OUT, "Connection").setMandatory(true);
        validationTestType.createEdgeProperty(Direction.IN, "Connection").setMandatory(true);
        final OrientEdgeType connectionType = g1.createEdgeType("Connection");
        connectionType.createProperty("in", OType.LINK, validationTestType).setMandatory(true);
        connectionType.createProperty("out", OType.LINK, validationTestType).setMandatory(true);
    } finally {
        g1.shutdown();
    }
    OrientGraph g2 = new OrientGraph(URL, "admin", "admin");
    try {
        OrientVertex vertex1 = g2.addTemporaryVertex("ValidationTest");
        OrientVertex vertex2 = g2.addTemporaryVertex("ValidationTest");
        OrientVertex vertex3 = g2.addTemporaryVertex("ValidationTest");
        OrientVertex vertex4 = g2.addTemporaryVertex("ValidationTest");
        vertex1.addEdge("Connection", vertex2);
        vertex2.addEdge("Connection", vertex3);
        vertex3.addEdge("Connection", vertex4);
        vertex4.addEdge("Connection", vertex1);
        g2.commit();
    } finally {
        g2.shutdown();
    }
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) Test(org.junit.Test)

Example 3 with OrientEdgeType

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

the class BlueprintsConcurrentGraphChangesTestNoTx method initGraph.

private void initGraph() {
    OrientBaseGraph graph = getGraph();
    graph.setAutoStartTx(false);
    graph.commit();
    final OrientVertexType vertexType = graph.createVertexType("TestVertex");
    vertexType.createProperty("uuid", OType.STRING);
    vertexType.createIndex("TestVertexUuidIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "uuid");
    final OrientEdgeType edgeType = graph.createEdgeType("TestEdge");
    edgeType.createProperty("uuid", OType.STRING);
    edgeType.createIndex("TestEdgeUuidIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "uuid");
    graph.shutdown();
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 4 with OrientEdgeType

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

the class IndexAgainstEdges method indexes.

@Test
public void indexes() {
    OrientGraph g = new OrientGraph(URL, "admin", "admin");
    try {
        if (g.getVertexType("Profile") == null)
            g.createVertexType("Profile");
        if (g.getEdgeType("Friend") == null) {
            final OrientEdgeType f = g.createEdgeType("Friend");
            f.createProperty("in", OType.LINK);
            f.createProperty("out", OType.LINK);
            f.createIndex("Friend.in_out", OClass.INDEX_TYPE.UNIQUE, "in", "out");
        }
        OrientVertex luca = g.addVertex("class:Profile", "name", "Luca");
        OrientVertex jay = g.addVertex("class:Profile", "name", "Jay");
        OrientEdge friend = (OrientEdge) luca.addEdge("Friend", jay);
        assertFalse(friend.isLightweight());
    } finally {
        g.shutdown();
    }
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientEdge(com.tinkerpop.blueprints.impls.orient.OrientEdge) Test(org.junit.Test)

Example 5 with OrientEdgeType

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

the class OEdgeTransformerTest method setUp.

@Override
public void setUp() {
    super.setUp();
    final OrientVertexType v1 = graph.createVertexType("V1");
    final OrientVertexType v2 = graph.createVertexType("V2");
    final OrientEdgeType edgeType = graph.createEdgeType("Friend");
    edgeType.createProperty("in", OType.LINK, v2);
    edgeType.createProperty("out", OType.LINK, v1);
    // ASSURE NOT DUPLICATES
    edgeType.createIndex("out_in", OClass.INDEX_TYPE.UNIQUE, "in", "out");
    graph.addVertex("class:V2").setProperty("name", "Luca");
    graph.commit();
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType)

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