Search in sources :

Example 1 with ExportSet

use of org.structr.cloud.ExportSet in project structr by structr.

the class PullNodeRequestContainer method onRequest.

@Override
public void onRequest(CloudConnection serverConnection) throws IOException, FrameworkException {
    try {
        final App app = serverConnection.getApplicationContext();
        // try node first, then relationship
        GraphObject syncable = app.nodeQuery().and(GraphObject.id, rootNodeId).includeDeletedAndHidden().getFirst();
        if (syncable == null) {
            syncable = app.relationshipQuery().and(GraphObject.id, rootNodeId).includeDeletedAndHidden().getFirst();
        }
        if (syncable != null) {
            final ExportSet exportSet = ExportSet.getInstance(syncable, recursive);
            // collect export set
            numNodes = exportSet.getNodes().size();
            numRels = exportSet.getRelationships().size();
            key = NodeServiceCommand.getNextUuid();
            serverConnection.storeValue(key + "Nodes", new ArrayList<>(exportSet.getNodes()));
            serverConnection.storeValue(key + "Rels", new ArrayList<>(exportSet.getRelationships()));
            // send this back
            serverConnection.send(this);
        }
    } catch (FrameworkException fex) {
        logger.warn("", fex);
    }
}
Also used : App(org.structr.core.app.App) ExportSet(org.structr.cloud.ExportSet) FrameworkException(org.structr.common.error.FrameworkException) GraphObject(org.structr.core.GraphObject)

Aggregations

ExportSet (org.structr.cloud.ExportSet)1 FrameworkException (org.structr.common.error.FrameworkException)1 GraphObject (org.structr.core.GraphObject)1 App (org.structr.core.app.App)1