Search in sources :

Example 16 with SessionTransaction

use of org.structr.bolt.SessionTransaction in project structr by structr.

the class RelationshipWrapper method newInstance.

public static RelationshipWrapper newInstance(final BoltDatabaseService db, final long id) {
    synchronized (relationshipCache) {
        RelationshipWrapper wrapper = relationshipCache.get(id);
        if (wrapper == null) {
            final SessionTransaction tx = db.getCurrentTransaction();
            final Map<String, Object> map = new HashMap<>();
            final StringBuilder buf = new StringBuilder();
            final String tenantIdentifier = db.getTenantIdentifier();
            map.put("id", id);
            buf.append("MATCH (");
            if (tenantIdentifier != null) {
                buf.append(":");
                buf.append(tenantIdentifier);
            }
            buf.append(")-[n]-(");
            if (tenantIdentifier != null) {
                buf.append(":");
                buf.append(tenantIdentifier);
            }
            buf.append(") WHERE ID(n) = {id} RETURN n");
            wrapper = new RelationshipWrapper(db, tx.getRelationship(buf.toString(), map));
            relationshipCache.put(id, wrapper);
        }
        return wrapper;
    }
}
Also used : HashMap(java.util.HashMap) SessionTransaction(org.structr.bolt.SessionTransaction)

Example 17 with SessionTransaction

use of org.structr.bolt.SessionTransaction in project structr by structr.

the class NodeResultStream method fetchData.

@Override
protected QueryResult<Node> fetchData(final BoltDatabaseService db, final String statement, final Map<String, Object> data) {
    final SessionTransaction tx = db.getCurrentTransaction();
    tx.setIsPing(getQuery().getQueryContext().isPing());
    return tx.getNodes(statement, data);
}
Also used : SessionTransaction(org.structr.bolt.SessionTransaction)

Aggregations

SessionTransaction (org.structr.bolt.SessionTransaction)17 HashMap (java.util.HashMap)14 LinkedHashMap (java.util.LinkedHashMap)9 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 Relationship (org.structr.api.graph.Relationship)3 RelationshipRelationshipMapper (org.structr.bolt.mapper.RelationshipRelationshipMapper)3 LinkedList (java.util.LinkedList)1 NoSuchRecordException (org.neo4j.driver.v1.exceptions.NoSuchRecordException)1 NotFoundException (org.structr.api.NotFoundException)1 Label (org.structr.api.graph.Label)1