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);
}
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);
}
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);
}
Aggregations