Package org.neo4j.graphdb.schema

Examples of org.neo4j.graphdb.schema.Schema


    }

    @Test
    public void shouldReturnResultsLabeledIndexOnVertexWithHasHas() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.indexFor(DynamicLabel.label("Person")).on("name").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.tx().commit();
        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
View Full Code Here


    }

    @Test
    public void shouldEnsureColonedKeyIsTreatedAsNormalKey() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.indexFor(DynamicLabel.label("Person")).on("name").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.tx().commit();
        assertEquals(2, this.g.V().has(T.label, "Person").has("name", "marko").count().next(), 0);
View Full Code Here

    }

    @Test
    public void shouldReturnResultsUsingLabeledIndexOnVertexWithHasHasHas() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.indexFor(DynamicLabel.label("Person")).on("name").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko", "color", "blue");
        this.g.addVertex(T.label, "Person", "name", "marko", "color", "green");
        this.g.tx().commit();
        assertEquals(1, this.g.V().has(T.label, "Person").has("name", "marko").has("color", "blue").count().next(), 0);
View Full Code Here

    }

    @Test
    public void shouldReturnResultsUsingLabeledIndexOnVertexWithColonFails() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.indexFor(DynamicLabel.label("Person")).on("name").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.tx().commit();
        assertNotEquals(2l, this.g.V().has("Person:name", "marko").count().next().longValue());
View Full Code Here

    }

    @Test
    public void shouldEnforceUniqueConstraint() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("name").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.tx().commit();
        assertEquals("marko", g.V().<Vertex>has(T.label, "Person").<Vertex>has("name", "marko").next().value("name"));
    }
View Full Code Here

    }

    @Test
    public void shouldEnforceMultipleUniqueConstraint() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("name").create();
        schema.constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("surname").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.addVertex(T.label, "Person", "surname", "aaaa");
        this.g.tx().commit();
        boolean failSurname = false;
View Full Code Here

    }

    @Test
    public void shouldDropMultipleUniqueConstraint() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("name").create();
        schema.constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("surname").create();
        this.g.tx().commit();

        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.addVertex(T.label, "Person", "surname", "aaaa");
        this.g.tx().commit();
        boolean failSurname = false;
        try {
            this.g.addVertex(T.label, "Person", "surname", "aaaa");
        } catch (ConstraintViolationException e) {
            failSurname = true;
        }
        assertTrue(failSurname);
        boolean failName = false;
        try {
            this.g.addVertex(T.label, "Person", "name", "marko");
        } catch (ConstraintViolationException e) {
            failName = true;
        }
        assertTrue(failName);
        this.g.tx().commit();

        this.g.tx().readWrite();
        for (ConstraintDefinition cd : schema.getConstraints(DynamicLabel.label("Person"))) {
            cd.drop();
        }

        this.g.tx().commit();
        assertEquals(1, this.g.V().has(T.label, "Person").<Vertex>has("name", "marko").count().next(), 0);
View Full Code Here

    }

    @Test(expected = ConstraintViolationException.class)
    public void shouldFailUniqueConstraint() {
        this.g.tx().readWrite();
        final Schema schema = this.g.getBaseGraph().schema();
        schema.constraintFor(DynamicLabel.label("Person")).assertPropertyIsUnique("name").create();
        this.g.tx().commit();
        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.tx().commit();
        assertEquals("marko", g.V().<Vertex>has(T.label, "Person").<Vertex>has("name", "marko").next().value("name"));
        this.g.addVertex(T.label, "Person", "name", "marko");
View Full Code Here

    @Test
    public void shouldDoLabelAndIndexSearch() {
        g.tx().readWrite();

        final Schema schema = g.getBaseGraph().schema();
        schema.indexFor(DynamicLabel.label("Person")).on("name").create();
        this.g.tx().commit();

        this.g.addVertex(T.label, "Person", "name", "marko");
        this.g.addVertex(T.label, "Person", "name", "john");
        this.g.addVertex(T.label, "Person", "name", "pete");
View Full Code Here

    @Test
    public void shouldDoLabelAndLegacyIndexSearch() {
        g.tx().readWrite();

        final Schema schema = g.getBaseGraph().schema();
        schema.indexFor(DynamicLabel.label("Person")).on("name").create();

        final AutoIndexer<Node> nodeAutoIndexer = this.g.getBaseGraph().index().getNodeAutoIndexer();
        nodeAutoIndexer.startAutoIndexingProperty("name");

        this.g.tx().commit();
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.schema.Schema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.