Search in sources :

Example 1 with FilteredQuery

use of org.neo4j.ogm.session.request.FilteredQuery in project neo4j-ogm by neo4j.

the class CountStatements method countNodes.

@Override
public CypherQuery countNodes(String label, Iterable<Filter> filters) {
    FilteredQuery query = FilteredQueryBuilder.buildNodeQuery(label, filters);
    query.setReturnClause(" RETURN COUNT(n)");
    return new DefaultRowModelRequest(query.statement(), query.parameters());
}
Also used : FilteredQuery(org.neo4j.ogm.session.request.FilteredQuery) DefaultRowModelRequest(org.neo4j.ogm.cypher.query.DefaultRowModelRequest)

Example 2 with FilteredQuery

use of org.neo4j.ogm.session.request.FilteredQuery in project neo4j-ogm by neo4j.

the class NodeQueryStatements method findByType.

@Override
public PagingAndSortingQuery findByType(String label, Filters parameters, int depth) {
    FilteredQuery filteredQuery = FilteredQueryBuilder.buildNodeQuery(label, parameters);
    String matchClause = filteredQuery.statement();
    String returnClause = loadClauseBuilder.build(label, depth);
    return new PagingAndSortingQuery(matchClause, returnClause, filteredQuery.parameters(), depth != 0, true);
}
Also used : FilteredQuery(org.neo4j.ogm.session.request.FilteredQuery) PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery)

Example 3 with FilteredQuery

use of org.neo4j.ogm.session.request.FilteredQuery in project neo4j-ogm by neo4j.

the class RelationshipDeleteStatements method delete.

@Override
public CypherQuery delete(String type, Iterable<Filter> filters) {
    FilteredQuery query = FilteredQueryBuilder.buildRelationshipQuery(type, filters);
    query.setReturnClause(" DELETE r0");
    return new DefaultRowModelRequest(query.statement(), query.parameters());
}
Also used : FilteredQuery(org.neo4j.ogm.session.request.FilteredQuery) DefaultRowModelRequest(org.neo4j.ogm.cypher.query.DefaultRowModelRequest)

Example 4 with FilteredQuery

use of org.neo4j.ogm.session.request.FilteredQuery in project neo4j-ogm by neo4j.

the class RelationshipQueryStatements method findByType.

@Override
public PagingAndSortingQuery findByType(String type, Filters parameters, int depth) {
    if (depth > 0) {
        FilteredQuery query = FilteredQueryBuilder.buildRelationshipQuery(type, parameters);
        String matchClause = query.statement() + " WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m";
        String returnClause = loadClauseBuilder.build("r0", type, depth);
        return new PagingAndSortingQuery(matchClause, returnClause, query.parameters(), true, true, "r0");
    } else {
        throw new InvalidDepthException("Cannot load a relationship entity with depth 0 i.e. no start or end node");
    }
}
Also used : InvalidDepthException(org.neo4j.ogm.exception.core.InvalidDepthException) FilteredQuery(org.neo4j.ogm.session.request.FilteredQuery) PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery)

Example 5 with FilteredQuery

use of org.neo4j.ogm.session.request.FilteredQuery in project neo4j-ogm by neo4j.

the class CountStatements method countEdges.

@Override
public CypherQuery countEdges(String type, Iterable<Filter> filters) {
    FilteredQuery query = FilteredQueryBuilder.buildRelationshipQuery(type, filters);
    query.setReturnClause(" RETURN COUNT(r0)");
    return new DefaultRowModelRequest(query.statement(), query.parameters());
}
Also used : FilteredQuery(org.neo4j.ogm.session.request.FilteredQuery) DefaultRowModelRequest(org.neo4j.ogm.cypher.query.DefaultRowModelRequest)

Aggregations

FilteredQuery (org.neo4j.ogm.session.request.FilteredQuery)8 DefaultRowModelRequest (org.neo4j.ogm.cypher.query.DefaultRowModelRequest)6 PagingAndSortingQuery (org.neo4j.ogm.cypher.query.PagingAndSortingQuery)2 InvalidDepthException (org.neo4j.ogm.exception.core.InvalidDepthException)1