use of org.structr.api.graph.Relationship in project structr by structr.
the class UpdateTransmission method doRemote.
@Override
public Boolean doRemote(final CloudConnection client) throws IOException, FrameworkException {
// send synchronization request first
client.send(new Synchronize());
// send all node and relationship data
final DatabaseService graphDb = StructrApp.getInstance().getDatabaseService();
final NodeFactory nodeFactory = new NodeFactory(SecurityContext.getSuperUserInstance());
final RelationshipFactory relFactory = new RelationshipFactory(SecurityContext.getSuperUserInstance());
for (final Node neo4jNode : graphDb.getAllNodes()) {
final NodeInterface node = nodeFactory.instantiate(neo4jNode);
if (node instanceof File) {
PushTransmission.sendFile(client, (File) node, CloudService.CHUNK_SIZE);
} else {
client.send(new NodeDataContainer(node, 0));
}
}
for (final Relationship relationship : graphDb.getAllRelationships()) {
final RelationshipInterface relationshipInterface = relFactory.instantiate(relationship);
client.send(new RelationshipDataContainer(relationshipInterface, 0));
}
// wait for end of transmission
client.waitForTransmission();
return true;
}
use of org.structr.api.graph.Relationship in project structr by structr.
the class AbstractNode method getOutgoingRelationshipAsSuperUser.
@Override
public <A extends NodeInterface, B extends NodeInterface, S extends Source, R extends Relation<A, B, S, OneEndpoint<B>>> R getOutgoingRelationshipAsSuperUser(final Class<R> type) {
final RelationshipFactory<R> factory = new RelationshipFactory<>(SecurityContext.getSuperUserInstance());
final R template = getRelationshipForType(type);
final Relationship relationship = template.getTarget().getRawSource(SecurityContext.getSuperUserInstance(), dbNode, null);
if (relationship != null) {
return factory.adapt(relationship);
}
return null;
}
use of org.structr.api.graph.Relationship 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.api.graph.Relationship in project structr by structr.
the class OneEndpoint method get.
@Override
public T get(final SecurityContext securityContext, final NodeInterface node, final Predicate<GraphObject> predicate) {
final NodeFactory<T> nodeFactory = new NodeFactory<>(securityContext);
final Relationship rel = getRawSource(securityContext, node.getNode(), predicate);
if (rel != null) {
return nodeFactory.instantiate(rel.getEndNode(), rel);
}
return null;
}
use of org.structr.api.graph.Relationship in project structr by structr.
the class OneStartpoint method get.
@Override
public S get(final SecurityContext securityContext, final NodeInterface node, final Predicate<GraphObject> predicate) {
final NodeFactory<S> nodeFactory = new NodeFactory<>(securityContext);
final Relationship rel = getRawSource(securityContext, node.getNode(), predicate);
if (rel != null) {
return nodeFactory.instantiate(rel.getStartNode(), rel);
}
return null;
}
Aggregations