Search in sources :

Example 1 with CypherQuery

use of org.neo4j.ogm.cypher.query.CypherQuery in project neo4j-ogm by neo4j.

the class RelationshipDeleteStatementsTest method testDeleteWithTypeAndFiltersAndList.

@Test
public void testDeleteWithTypeAndFiltersAndList() {
    CypherQuery query = statements.deleteAndList("INFLUENCE", new Filters().add(new Filter("score", ComparisonOperator.EQUALS, -12.2)));
    assertThat(query.getStatement()).isEqualTo("MATCH (n)-[r0:`INFLUENCE`]->(m) WHERE r0.`score` = $`score_0`  DELETE r0 RETURN ID(r0)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) Test(org.junit.Test)

Example 2 with CypherQuery

use of org.neo4j.ogm.cypher.query.CypherQuery in project neo4j-ogm by neo4j.

the class RelationshipDeleteStatementsTest method testDeleteWithTypeAndFilters.

@Test
public void testDeleteWithTypeAndFilters() {
    CypherQuery query = statements.delete("INFLUENCE", new Filters().add(new Filter("score", ComparisonOperator.EQUALS, -12.2)));
    assertThat(query.getStatement()).isEqualTo("MATCH (n)-[r0:`INFLUENCE`]->(m) WHERE r0.`score` = $`score_0`  DELETE r0");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) Test(org.junit.Test)

Example 3 with CypherQuery

use of org.neo4j.ogm.cypher.query.CypherQuery in project neo4j-ogm by neo4j.

the class CountStatementsTest method testCountNodesWithLabelAndFilters.

@Test
public void testCountNodesWithLabelAndFilters() throws Exception {
    CypherQuery query = statements.countNodes("Person", new Filters().add(new Filter("name", ComparisonOperator.EQUALS, "Jim")));
    assertThat(query.getStatement()).isEqualTo("MATCH (n:`Person`) WHERE n.`name` = $`name_0` WITH n RETURN COUNT(n)");
    assertThat(query.getParameters().toString()).isEqualTo("{name_0=Jim}");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) Test(org.junit.Test)

Example 4 with CypherQuery

use of org.neo4j.ogm.cypher.query.CypherQuery in project neo4j-ogm by neo4j.

the class NodeDeleteStatementsTest method testDeleteWithLabelAndFiltersAndList.

@Test
public void testDeleteWithLabelAndFiltersAndList() throws Exception {
    CypherQuery query = statements.deleteAndList("INFLUENCE", new Filters().add(new Filter("score", ComparisonOperator.EQUALS, -12.2)));
    assertThat(query.getStatement()).isEqualTo("MATCH (n:`INFLUENCE`) " + "WHERE n.`score` = $`score_0` " + "WITH n " + "OPTIONAL MATCH (n)-[r0]-() " + "DELETE r0, n RETURN ID(n)");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) Test(org.junit.Test)

Example 5 with CypherQuery

use of org.neo4j.ogm.cypher.query.CypherQuery in project neo4j-ogm by neo4j.

the class ExecuteQueriesDelegate method count.

public long count(Class<?> clazz, Iterable<Filter> filters) {
    ClassInfo classInfo = session.metaData().classInfo(clazz.getSimpleName());
    if (classInfo != null) {
        resolvePropertyAnnotations(clazz, filters);
        CypherQuery query;
        if (classInfo.isRelationshipEntity()) {
            query = new CountStatements().countEdges(classInfo.neo4jName(), filters);
        } else {
            query = new CountStatements().countNodes(classInfo.neo4jName(), filters);
        }
        return count(query, classInfo.isRelationshipEntity());
    }
    throw new RuntimeException(clazz.getName() + " is not a persistable class");
}
Also used : CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) CountStatements(org.neo4j.ogm.session.request.strategy.impl.CountStatements) ClassInfo(org.neo4j.ogm.metadata.ClassInfo)

Aggregations

CypherQuery (org.neo4j.ogm.cypher.query.CypherQuery)9 Test (org.junit.Test)6 Filter (org.neo4j.ogm.cypher.Filter)6 Filters (org.neo4j.ogm.cypher.Filters)6 ClassInfo (org.neo4j.ogm.metadata.ClassInfo)3 CountStatements (org.neo4j.ogm.session.request.strategy.impl.CountStatements)2 EndNode (org.neo4j.ogm.annotation.EndNode)1 FieldInfo (org.neo4j.ogm.metadata.FieldInfo)1 RowModel (org.neo4j.ogm.model.RowModel)1 NodeDeleteStatements (org.neo4j.ogm.session.request.strategy.impl.NodeDeleteStatements)1 RelationshipDeleteStatements (org.neo4j.ogm.session.request.strategy.impl.RelationshipDeleteStatements)1