Search in sources :

Example 1 with IterableAdapter

use of org.structr.core.IterableAdapter in project structr by structr.

the class AbstractNode method getRelationships.

@Override
public final <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target, R extends Relation<A, B, S, T>> Iterable<R> getRelationships(final Class<R> type) {
    final RelationshipFactory<R> factory = new RelationshipFactory<>(securityContext);
    final R template = getRelationshipForType(type);
    final Direction direction = template.getDirectionForType(entityType);
    final RelationshipType relType = template;
    return new IterableAdapter<>(dbNode.getRelationships(direction, relType), factory);
}
Also used : IterableAdapter(org.structr.core.IterableAdapter) RelationshipFactory(org.structr.core.graph.RelationshipFactory) RelationshipType(org.structr.api.graph.RelationshipType) Direction(org.structr.api.graph.Direction)

Example 2 with IterableAdapter

use of org.structr.core.IterableAdapter in project structr by structr.

the class AbstractNode method getRelationshipsAsSuperUser.

protected final <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target, R extends Relation<A, B, S, T>> Iterable<R> getRelationshipsAsSuperUser(final Class<R> type) {
    final RelationshipFactory<R> factory = new RelationshipFactory<>(SecurityContext.getSuperUserInstance());
    final R template = getRelationshipForType(type);
    final Direction direction = template.getDirectionForType(entityType);
    final RelationshipType relType = template;
    return new IterableAdapter<>(dbNode.getRelationships(direction, relType), factory);
}
Also used : IterableAdapter(org.structr.core.IterableAdapter) RelationshipFactory(org.structr.core.graph.RelationshipFactory) RelationshipType(org.structr.api.graph.RelationshipType) Direction(org.structr.api.graph.Direction)

Example 3 with IterableAdapter

use of org.structr.core.IterableAdapter in project structr by structr.

the class ChildrenCommand method processMessage.

@Override
public void processMessage(final WebSocketMessage webSocketData) {
    final RelationshipFactory factory = new RelationshipFactory(this.getWebSocket().getSecurityContext());
    final AbstractNode node = getNode(webSocketData.getId());
    if (node == null) {
        return;
    }
    final Iterable<RelationshipInterface> rels = new IterableAdapter<>(node.getNode().getRelationships(Direction.OUTGOING, RelType.CONTAINS), factory);
    final List<GraphObject> result = new LinkedList();
    for (RelationshipInterface rel : rels) {
        NodeInterface endNode = rel.getTargetNode();
        if (endNode == null) {
            continue;
        }
        result.add(endNode);
    }
    webSocketData.setView(PropertyView.Ui);
    webSocketData.setResult(result);
    // send only over local connection
    getWebSocket().send(webSocketData, true);
}
Also used : IterableAdapter(org.structr.core.IterableAdapter) AbstractNode(org.structr.core.entity.AbstractNode) RelationshipFactory(org.structr.core.graph.RelationshipFactory) RelationshipInterface(org.structr.core.graph.RelationshipInterface) GraphObject(org.structr.core.GraphObject) NodeInterface(org.structr.core.graph.NodeInterface)

Aggregations

IterableAdapter (org.structr.core.IterableAdapter)3 RelationshipFactory (org.structr.core.graph.RelationshipFactory)3 Direction (org.structr.api.graph.Direction)2 RelationshipType (org.structr.api.graph.RelationshipType)2 GraphObject (org.structr.core.GraphObject)1 AbstractNode (org.structr.core.entity.AbstractNode)1 NodeInterface (org.structr.core.graph.NodeInterface)1 RelationshipInterface (org.structr.core.graph.RelationshipInterface)1