Search in sources :

Example 1 with NodeIterator

use of org.neo4j.android.client.NodeIterator in project neo4j-mobile-android by neo4j-contrib.

the class RelationshipActivity method getAllNodeIds.

private List<Long> getAllNodeIds() throws RemoteException, Neo4jServiceException {
    GraphDatabase database = dbManager.getCurrentNeo4jDatabase();
    database.beginTx();
    try {
        NodeIterator iterator = database.getAllNodes();
        List<Long> nodeIds = new ArrayList<Long>();
        while (iterator.hasNext()) {
            ParcelableNode node = iterator.next();
            nodeIds.add(node.getId());
        }
        return nodeIds;
    } finally {
        database.txFinish();
    }
}
Also used : NodeIterator(org.neo4j.android.client.NodeIterator) GraphDatabase(org.neo4j.android.client.GraphDatabase) ArrayList(java.util.ArrayList) ParcelableNode(org.neo4j.android.common.ParcelableNode)

Example 2 with NodeIterator

use of org.neo4j.android.client.NodeIterator in project neo4j-mobile-android by neo4j-contrib.

the class RootNodeActivity method updateNodesList.

private void updateNodesList() {
    try {
        referenceNodeLayout.removeAllViews();
        rootNodesLayout.removeAllViews();
        cycleNodesLayout.removeAllViews();
        GraphDatabase database = dbManager.getCurrentNeo4jDatabase();
        database.beginTx();
        try {
            ParcelableNode referenceNode = database.getReferenceNode();
            addNodeListItem(referenceNodeLayout, referenceNode);
            List<ParcelableNode> rootNodes = new ArrayList<ParcelableNode>();
            NodeIterator nodeIterator = database.getAllNodes();
            while (nodeIterator.hasNext()) {
                ParcelableNode node = nodeIterator.next();
                if (!node.hasRelationship(Direction.INCOMING)) {
                    rootNodes.add(node);
                }
            }
            for (ParcelableNode rootNode : rootNodes) {
                addNodeListItem(rootNodesLayout, rootNode);
            }
        // TODO: [eRiC] what happens if all graphs are circular? ->
        // pick
        // one node per graph:
        } finally {
            database.txFinish();
        }
    } catch (Exception e) {
        Ln.e(e, "database exception");
        showErrorDialog();
    }
}
Also used : NodeIterator(org.neo4j.android.client.NodeIterator) GraphDatabase(org.neo4j.android.client.GraphDatabase) ArrayList(java.util.ArrayList) ParcelableNode(org.neo4j.android.common.ParcelableNode) Neo4jServiceException(org.neo4j.android.client.Neo4jServiceException) RemoteException(android.os.RemoteException)

Aggregations

ArrayList (java.util.ArrayList)2 GraphDatabase (org.neo4j.android.client.GraphDatabase)2 NodeIterator (org.neo4j.android.client.NodeIterator)2 ParcelableNode (org.neo4j.android.common.ParcelableNode)2 RemoteException (android.os.RemoteException)1 Neo4jServiceException (org.neo4j.android.client.Neo4jServiceException)1