use of org.structr.core.graph.RelationshipFactory in project structr by structr.
the class AbstractNode method getIncomingRelationshipAsSuperUser.
protected <A extends NodeInterface, B extends NodeInterface, T extends Target, R extends Relation<A, B, OneStartpoint<A>, T>> R getIncomingRelationshipAsSuperUser(final Class<R> type) {
final RelationshipFactory<R> factory = new RelationshipFactory<>(SecurityContext.getSuperUserInstance());
final R template = getRelationshipForType(type);
final Relationship relationship = template.getSource().getRawSource(SecurityContext.getSuperUserInstance(), dbNode, null);
if (relationship != null) {
return factory.adapt(relationship);
}
return null;
}
use of org.structr.core.graph.RelationshipFactory 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