Examples of GlobalGraphOperations


Examples of org.neo4j.tooling.GlobalGraphOperations

        }
        return result;
    }

    public static SubGraph from(GraphDatabaseService gdb) {
        final GlobalGraphOperations operations = GlobalGraphOperations.at(gdb);
        final SubGraph graph = new SubGraph();
        for (Node node : operations.getAllNodes()) {
            graph.add(node);
        }
        for (Relationship relationship : operations.getAllRelationships()) {
            graph.add(relationship);
        }
        return graph;
    }
View Full Code Here

Examples of org.neo4j.tooling.GlobalGraphOperations

            rawGraphDB = builder.newGraphDatabase();

            Transaction tx = rawGraphDB.beginTx();
            try {
                GlobalGraphOperations graphOperations = GlobalGraphOperations.at(rawGraphDB);
                if (this.vertexIndexKeys.size() > 0)
                    populateKeyIndices(rawGraphDB, rawGraphDB.index().getNodeAutoIndexer(), graphOperations.getAllNodes(), Vertex.class);
                if (this.edgeIndexKeys.size() > 0)
                    populateKeyIndices(rawGraphDB, rawGraphDB.index().getRelationshipAutoIndexer(), graphOperations.getAllRelationships(), Edge.class);
                tx.success();
            } finally {
                tx.close();
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.neo4j.tooling.GlobalGraphOperations

                tx.failure();
            } finally {
                tx.finish();
            }

            GlobalGraphOperations graphOperations = GlobalGraphOperations.at(rawGraphDB);
            if (this.vertexIndexKeys.size() > 0)
                populateKeyIndices(rawGraphDB, rawGraphDB.index().getNodeAutoIndexer(), graphOperations.getAllNodes(), Vertex.class);
            if (this.edgeIndexKeys.size() > 0)
                populateKeyIndices(rawGraphDB, rawGraphDB.index().getRelationshipAutoIndexer(), graphOperations.getAllRelationships(), Edge.class);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        } finally {
            if (rawGraphDB != null) rawGraphDB.shutdown();
        }
View Full Code Here

Examples of org.neo4j.tooling.GlobalGraphOperations

        //Import OSM data into the Neo4j database
        new OsmImporter(db).importXML(OSM_MAP);


        //Optimize previously loaded database
        GlobalGraphOperations graphOperations = GlobalGraphOperations.at(db);
        System.out.printf("BEFORE OPTIMIZE nodes =  %d  ways = %d  \n", nodesCount(graphOperations), relCount(graphOperations));

        new OsmRoutingOptimizer(db).optimize();
        System.out.printf("AFTER OPTIMIZE nodes =  %d  ways = %d  \n", nodesCount(graphOperations), relCount(graphOperations));
View Full Code Here

Examples of org.neo4j.tooling.GlobalGraphOperations

  public void execute(Map<String, Object> attributes) throws FrameworkException {

    try {

      final GraphDatabaseService graphDb = Services.getInstance().getService(NodeService.class).getGraphDb();
      final GlobalGraphOperations ggop  = GlobalGraphOperations.at(graphDb);
      final Iterable<Relationship> rels = ggop.getAllRelationships();
      final Iterable<Node> nodes        = ggop.getAllNodes();
      final App app                     = StructrApp.getInstance();
      final String fileName             = (String)attributes.get("name");

      if (fileName == null || fileName.isEmpty()) {
View Full Code Here

Examples of org.neo4j.tooling.GlobalGraphOperations

    public static void cleanDb(Neo4jTemplate template) {
        cleanDb(template.getGraphDatabaseService());
    }

    public static void dumpDb(GraphDatabaseService gds) {
        final GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(gds);
        for (Node node : globalGraphOperations.getAllNodes()) {
            System.out.println(dump(node));
        }
        for (Node node : globalGraphOperations.getAllNodes()) {
            for (Relationship rel : node.getRelationships(Direction.OUTGOING)) {
                System.out.println(node +"-[:"+rel.getType().name() +" "+dump(rel)+"]->"+rel.getEndNode());
            }
        }
    }
View Full Code Here

Examples of org.neo4j.tooling.GlobalGraphOperations

    }

    private static void removeNodes(GraphDatabaseService graphDatabaseService, boolean includeReferenceNode) {
        GraphDatabaseAPI api = (GraphDatabaseAPI) graphDatabaseService;
        NodeManager nodeManager = api.getDependencyResolver().resolveDependency(NodeManager.class);
        final GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(graphDatabaseService);
        for (Node node : globalGraphOperations.getAllNodes()) {
            for (Relationship rel : node.getRelationships(Direction.OUTGOING)) {
                try {
                    if (nodeManager.isDeleted(rel)) continue;
                    rel.delete();
                } catch(IllegalStateException ise) {
                    if (!ise.getMessage().contains("since it has already been deleted")) throw ise;
                }

            }
            for (Label label: node.getLabels()) {
                node.removeLabel(label);
            }
        }
        for (Node node : globalGraphOperations.getAllNodes()) {
            try {
                if (nodeManager.isDeleted(node)) continue;
                node.delete();
            } catch(IllegalStateException ise) {
                if (!ise.getMessage().contains("since it has already been deleted")) throw ise;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.