use of org.structr.core.graph.NodeFactory in project structr by structr.
the class CypherQueryHandler method setSecurityContext.
public void setSecurityContext(SecurityContext securityContext) {
this.securityContext = securityContext;
this.nodeFactory = new NodeFactory(securityContext);
this.relFactory = new RelationshipFactory(securityContext);
}
use of org.structr.core.graph.NodeFactory 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.core.graph.NodeFactory in project structr by structr.
the class DumpDatabaseCommand method execute.
@Override
public void execute(Map<String, Object> attributes) throws FrameworkException {
try {
final NodeFactory nodeFactory = new NodeFactory(SecurityContext.getSuperUserInstance());
final RelationshipFactory relFactory = new RelationshipFactory(SecurityContext.getSuperUserInstance());
final App app = StructrApp.getInstance();
final String fileName = (String) attributes.get("name");
if (fileName == null || fileName.isEmpty()) {
throw new FrameworkException(400, "Please specify name.");
}
try (final Tx tx = app.tx()) {
final File file = FileHelper.createFile(securityContext, new byte[0], "application/zip", File.class, fileName);
// make file visible for auth. users
file.setProperties(securityContext, new PropertyMap(File.visibleToAuthenticatedUsers, true));
// Don't include files
SyncCommand.exportToStream(file.getOutputStream(), nodeFactory.bulkInstantiate(app.getDatabaseService().getAllNodes()), relFactory.bulkInstantiate(app.getDatabaseService().getAllRelationships()), null, false);
tx.success();
}
} catch (Throwable t) {
throw new FrameworkException(500, t.getMessage());
}
}
use of org.structr.core.graph.NodeFactory 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.core.graph.NodeFactory 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