Hi @ all,
got a little problem here:
I'm trying to add a node to a graph like this
Node userNode = createUser(tmp);
referenceNode.createRelationshipTo(userNode, RelTypes.USER);
tx.success();
tx.finish();
tx = graphDb.beginTx();
addOccupation(userNode, tmp[3]);
The userNode should be than added to the graph. In addOccupation I'm doing
the following:
Node firstNode = getFirstNode();
Traverser usersTraverser = firstNode.traverse(Order.BREADTH_FIRST,
StopEvaluator.END_OF_GRAPH,
ReturnableEvaluator.ALL_BUT_START_NODE,
RelTypes.HAS_OCCUPATION, Direction.OUTGOING);
if (usersTraverser.currentPosition() != null) {
for (Node occupationNode : usersTraverser) {
if(occupationNode.getProperty("occupation").equals(occupations.get(Integer.parseInt(occupation))))
{
user.createRelationshipTo(occupationNode,
RelTypes.HAS_OCCUPATION);
return;
}
}
}
Node newOccupation = graphDb.createNode();
newOccupation.setProperty("type", "Occupation");
newOccupation.setProperty("occupation",
occupations.get(Integer.parseInt(occupation)));
Checking if there is already a node with certain occupation and if not, I'm
adding a new one. Otherwise a relationship is made to the found one.
The problem is that after couple turns a node with the occupation that I'm
looking for is there, but the usersTraverser.currentPosition() is always
null...
Assume, that the graph is committed every time when a new user is added, so
the newest graph can be traversed.
Where is my error? What am I doing wrong?
Thanks for your replays :)
--
View this message in context:
http://neo4j-community-discussions.438527.n3.nabble.com/Traversing-graph-after-adding-node-tp3448023p3448023.html
Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user