Search in sources :

Example 1 with Parameter

use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.

the class DistributedDatabaseCRUDTest method createVertexTypeWithUniqueIndex.

/**
   * Create vertex and edge type with non unique index.
   *
   * @param orientGraph
   * @param className
   */
public void createVertexTypeWithUniqueIndex(OrientBaseGraph orientGraph, String className, String property, String keyIndexProperty) {
    String edgeClassName = className;
    String vertexClassName = className + "Node";
    OClass clazz = orientGraph.getEdgeType(edgeClassName);
    if (clazz == null) {
        log("Creating edge type - " + edgeClassName);
        orientGraph.createEdgeType(edgeClassName);
    } else {
        log("Edge " + edgeClassName + " already exists");
    }
    clazz = orientGraph.getVertexType(vertexClassName);
    if (clazz == null) {
        log("Creating vertex type - " + vertexClassName);
        clazz = orientGraph.createVertexType(vertexClassName);
        clazz.createProperty(property, OType.STRING);
        clazz.createProperty(keyIndexProperty, OType.STRING);
        orientGraph.createKeyIndex(keyIndexProperty, Vertex.class, new Parameter("class", vertexClassName), new Parameter("type", "UNIQUE"));
        clazz.createIndex(vertexClassName + "_Index_" + property, INDEX_TYPE.UNIQUE, property);
    } else {
        log("Class " + vertexClassName + " already exists");
    }
}
Also used : OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Parameter(com.tinkerpop.blueprints.Parameter)

Example 2 with Parameter

use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.

the class GraphEmbeddedTest method testGetVericesFilterClass.

@Test
public void testGetVericesFilterClass() {
    graph.createVertexType("One");
    graph.createVertexType("Two");
    graph.createKeyIndex("name", Vertex.class, new Parameter("type", "NOTUNIQUE"));
    graph.getRawGraph().begin();
    graph.addVertex("class:One", new Object[] { "name", "Same" });
    graph.addVertex("class:Two", new Object[] { "name", "Same" });
    graph.commit();
    Iterable<Vertex> vertexes = graph.getVertices("One", new String[] { "name" }, new Object[] { "Same" });
    int size = 0;
    for (Vertex v : vertexes) {
        size++;
        Assert.assertNotNull(v);
    }
    Assert.assertEquals(1, size);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Parameter(com.tinkerpop.blueprints.Parameter) Test(org.junit.Test)

Example 3 with Parameter

use of com.tinkerpop.blueprints.Parameter in project blueprints by tinkerpop.

the class Neo4jBatchGraphTest method testIndexParameters.

public void testIndexParameters() throws Exception {
    final String directory = this.getWorkingDirectory();
    final Neo4jBatchGraph batch = new Neo4jBatchGraph(directory);
    Index<Vertex> index = batch.createIndex("testIdx", Vertex.class, new Parameter("analyzer", LowerCaseKeywordAnalyzer.class.getName()));
    Vertex a = batch.addVertex(null);
    a.setProperty("name", "marko");
    index.put("name", "marko", a);
    batch.flushIndices();
    batch.shutdown();
    // native neo4j graph load
    IndexableGraph graph = new Neo4jGraph(directory);
    Iterator<Vertex> itty = graph.getIndex("testIdx", Vertex.class).query("name", "*rko").iterator();
    int counter = 0;
    while (itty.hasNext()) {
        counter++;
        assertEquals(itty.next().getProperty("name"), "marko");
    }
    assertEquals(counter, 1);
    itty = graph.getIndex("testIdx", Vertex.class).query("name", "MaRkO").iterator();
    counter = 0;
    while (itty.hasNext()) {
        counter++;
        assertEquals(itty.next().getProperty("name"), "marko");
    }
    assertEquals(counter, 1);
    graph.shutdown();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IndexableGraph(com.tinkerpop.blueprints.IndexableGraph) Neo4jGraph(com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph) Parameter(com.tinkerpop.blueprints.Parameter)

Example 4 with Parameter

use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.

the class DistributedConfigReloadTest method createVertexType.

public void createVertexType(OrientBaseGraph orientGraph, String className, String property, String keyIndexProperty) {
    String edgeClassName = className;
    String vertexClassName = className + "Node";
    OClass clazz = orientGraph.getEdgeType(edgeClassName);
    if (clazz == null) {
        log("Creating edge type - " + edgeClassName);
        clazz = orientGraph.createEdgeType(edgeClassName);
        clazz.createProperty("linkKey", OType.STRING);
        orientGraph.createKeyIndex("linkKey", Edge.class, new Parameter("class", edgeClassName), new Parameter("type", "UNIQUE"));
    } else {
        log("Edge " + edgeClassName + " already exists");
    }
    clazz = orientGraph.getVertexType(vertexClassName);
    if (clazz == null) {
        log("Creating vertex type - " + vertexClassName);
        clazz = orientGraph.createVertexType(vertexClassName);
        clazz.createProperty(property, OType.STRING);
        clazz.createProperty(keyIndexProperty, OType.STRING);
        orientGraph.createKeyIndex(keyIndexProperty, Vertex.class, new Parameter("class", vertexClassName), new Parameter("type", "UNIQUE"));
        clazz.createIndex(vertexClassName + "_Index_" + property, INDEX_TYPE.UNIQUE, property);
    } else {
        log("Class " + vertexClassName + " already exists");
    }
}
Also used : OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Parameter(com.tinkerpop.blueprints.Parameter)

Example 5 with Parameter

use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.

the class DistributedDatabaseCRUDTest method createVertexType.

// ----------------------------------------------------------------------------------------------------------------
// ---------------------------- End Database Methods -----------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// ----------------------- Utility Methods ------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
/**
   * Create vertex and edge type with non unique index.
   *
   * @param orientGraph
   * @param className
   */
public void createVertexType(OrientBaseGraph orientGraph, String className, String property, String keyIndexProperty) {
    String edgeClassName = className;
    String vertexClassName = className + "Node";
    OClass clazz = orientGraph.getEdgeType(edgeClassName);
    if (clazz == null) {
        log("Creating edge type - " + edgeClassName);
        orientGraph.createEdgeType(edgeClassName);
    } else {
        log("Edge " + edgeClassName + " already exists");
    }
    clazz = orientGraph.getVertexType(vertexClassName);
    if (clazz == null) {
        log("Creating vertex type - " + vertexClassName);
        clazz = orientGraph.createVertexType(vertexClassName);
        clazz.createProperty(property, OType.STRING);
        clazz.createProperty(keyIndexProperty, OType.STRING);
        orientGraph.createKeyIndex(keyIndexProperty, Vertex.class, new Parameter("class", vertexClassName));
        clazz.createIndex(vertexClassName + "_Index_" + property, INDEX_TYPE.NOTUNIQUE, property);
    } else {
        log("Class " + vertexClassName + " already exists");
    }
}
Also used : OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Parameter(com.tinkerpop.blueprints.Parameter)

Aggregations

Parameter (com.tinkerpop.blueprints.Parameter)5 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)3 Vertex (com.tinkerpop.blueprints.Vertex)2 IndexableGraph (com.tinkerpop.blueprints.IndexableGraph)1 Neo4jGraph (com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph)1 Test (org.junit.Test)1