Search in sources :

Example 1 with SimpleCypherQuery

use of org.structr.bolt.index.SimpleCypherQuery in project structr by structr.

the class BoltDatabaseService method getAllRelationships.

@Override
public QueryResult<Relationship> getAllRelationships() {
    final StringBuilder buf = new StringBuilder();
    buf.append("MATCH (");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(")-[r]->(");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(") RETURN r");
    return QueryUtils.map(new RelationshipRelationshipMapper(this), new RelationshipResultStream(this, new SimpleCypherQuery(buf.toString())));
}
Also used : SimpleCypherQuery(org.structr.bolt.index.SimpleCypherQuery) RelationshipResultStream(org.structr.bolt.index.RelationshipResultStream) RelationshipRelationshipMapper(org.structr.bolt.mapper.RelationshipRelationshipMapper)

Example 2 with SimpleCypherQuery

use of org.structr.bolt.index.SimpleCypherQuery in project structr by structr.

the class BoltDatabaseService method getRelationshipsByType.

@Override
public QueryResult<Relationship> getRelationshipsByType(final String type) {
    if (type == null) {
        return getAllRelationships();
    }
    final StringBuilder buf = new StringBuilder();
    buf.append("MATCH (");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(")-[r:");
    buf.append(type);
    buf.append("]->(");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(") RETURN r");
    return QueryUtils.map(new RelationshipRelationshipMapper(this), new RelationshipResultStream(this, new SimpleCypherQuery(buf.toString())));
}
Also used : SimpleCypherQuery(org.structr.bolt.index.SimpleCypherQuery) RelationshipResultStream(org.structr.bolt.index.RelationshipResultStream) RelationshipRelationshipMapper(org.structr.bolt.mapper.RelationshipRelationshipMapper)

Example 3 with SimpleCypherQuery

use of org.structr.bolt.index.SimpleCypherQuery in project structr by structr.

the class BoltDatabaseService method getNodesByLabel.

@Override
public QueryResult<Node> getNodesByLabel(final String type) {
    if (type == null) {
        return getAllNodes();
    }
    final StringBuilder buf = new StringBuilder();
    buf.append("MATCH (n");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(":");
    buf.append(type);
    buf.append(") RETURN n");
    return QueryUtils.map(new NodeNodeMapper(this), new NodeResultStream(this, new SimpleCypherQuery(buf.toString())));
}
Also used : NodeResultStream(org.structr.bolt.index.NodeResultStream) SimpleCypherQuery(org.structr.bolt.index.SimpleCypherQuery) NodeNodeMapper(org.structr.bolt.mapper.NodeNodeMapper)

Example 4 with SimpleCypherQuery

use of org.structr.bolt.index.SimpleCypherQuery in project structr by structr.

the class BoltDatabaseService method getNodesByTypeProperty.

@Override
public QueryResult<Node> getNodesByTypeProperty(final String type) {
    if (type == null) {
        return getAllNodes();
    }
    final StringBuilder buf = new StringBuilder();
    buf.append("MATCH (n");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(") WHERE n.type = {type} RETURN n");
    final SimpleCypherQuery query = new SimpleCypherQuery(buf.toString());
    query.getParameters().put("type", type);
    // return QueryUtils.map(mapper, tx.getNodes("MATCH (n) WHERE n.type = {type} RETURN n", map));
    return QueryUtils.map(new NodeNodeMapper(this), new NodeResultStream(this, query));
}
Also used : NodeResultStream(org.structr.bolt.index.NodeResultStream) SimpleCypherQuery(org.structr.bolt.index.SimpleCypherQuery) NodeNodeMapper(org.structr.bolt.mapper.NodeNodeMapper)

Example 5 with SimpleCypherQuery

use of org.structr.bolt.index.SimpleCypherQuery in project structr by structr.

the class BoltDatabaseService method getAllNodes.

@Override
public QueryResult<Node> getAllNodes() {
    final StringBuilder buf = new StringBuilder();
    buf.append("MATCH (n");
    if (tenantId != null) {
        buf.append(":");
        buf.append(tenantId);
    }
    buf.append(") RETURN n");
    return QueryUtils.map(new NodeNodeMapper(this), new NodeResultStream(this, new SimpleCypherQuery(buf.toString())));
}
Also used : NodeResultStream(org.structr.bolt.index.NodeResultStream) SimpleCypherQuery(org.structr.bolt.index.SimpleCypherQuery) NodeNodeMapper(org.structr.bolt.mapper.NodeNodeMapper)

Aggregations

SimpleCypherQuery (org.structr.bolt.index.SimpleCypherQuery)5 NodeResultStream (org.structr.bolt.index.NodeResultStream)3 NodeNodeMapper (org.structr.bolt.mapper.NodeNodeMapper)3 RelationshipResultStream (org.structr.bolt.index.RelationshipResultStream)2 RelationshipRelationshipMapper (org.structr.bolt.mapper.RelationshipRelationshipMapper)2