Package org.neo4j.graphdb.traversal

Examples of org.neo4j.graphdb.traversal.TraversalDescription


                    public void doBeforeCommit(ImprovedTransactionData td) {
                        Map<Long, Change<Node>> changed = changesToMap(td.getAllChangedNodes());

                        Node previous = changed.get(1L).getPrevious();

                        TraversalDescription traversalDescription = db.traversalDescription()
                                .relationships(R1, OUTGOING)
                                .relationships(R2, OUTGOING)
                                .depthFirst()
                                .uniqueness(Uniqueness.NODE_GLOBAL)
                                .evaluator(Evaluators.toDepth(3));

                        assertEquals(4, count(traversalDescription.traverse(previous).nodes()));
                    }
                }
        );
    }
View Full Code Here


                    @Override
                    public void doBeforeCommit(ImprovedTransactionData td) {
                        Map<Long, Change<Node>> changed = changesToMap(td.getAllChangedNodes());
                        Node current = changed.get(1L).getCurrent();

                        TraversalDescription traversalDescription = db.traversalDescription()
                                .relationships(R1, OUTGOING)
                                .relationships(R2, OUTGOING)
                                .depthFirst()
                                .uniqueness(Uniqueness.NODE_GLOBAL);

                        assertEquals(3, count(traversalDescription.traverse(current).nodes()));

                    }
                }
        );
    }
View Full Code Here

                        Map<Long, Node> deletedNodes = toMap(td.getAllDeletedNodes());
                        Node deleted = deletedNodes.get(2L);

                        Node one = td.getDeleted(deleted).getSingleRelationship(R1, INCOMING).getStartNode();

                        TraversalDescription traversalDescription = db.traversalDescription()
                                .relationships(R1, OUTGOING)
                                .relationships(R2, OUTGOING)
                                .depthFirst()
                                .uniqueness(Uniqueness.NODE_GLOBAL)
                                .evaluator(Evaluators.toDepth(3));

                        assertEquals(4, count(traversalDescription.traverse(one).nodes()));
                    }
                }
        );
    }
View Full Code Here

                    @Override
                    public void doBeforeCommit(ImprovedTransactionData transactionData) {
                        Map<Long, Change<Relationship>> changed = changesToMap(transactionData.getAllChangedRelationships());
                        Relationship previous = getSingleValue(changed).getPrevious();

                        TraversalDescription traversalDescription = db.traversalDescription()
                                .relationships(R1, OUTGOING)
                                .relationships(R2, OUTGOING)
                                .depthFirst()
                                .uniqueness(Uniqueness.NODE_GLOBAL)
                                .evaluator(Evaluators.toDepth(3));

                        assertEquals(4, count(traversalDescription.traverse(previous.getEndNode()).nodes()));
                    }
                }
        );
    }
View Full Code Here

                    @Override
                    public void doBeforeCommit(ImprovedTransactionData td) {
                        Map<Long, Change<Relationship>> changed = changesToMap(td.getAllChangedRelationships());
                        Relationship current = getSingleValue(changed).getCurrent();

                        TraversalDescription traversalDescription = db.traversalDescription()
                                .relationships(R1, OUTGOING)
                                .relationships(R2, OUTGOING)
                                .depthFirst()
                                .uniqueness(Uniqueness.NODE_GLOBAL);

                        assertEquals(3, count(traversalDescription.traverse(current.getEndNode()).nodes()));
                    }
                }
        );
    }
View Full Code Here

public class RestTraversalExecutionTests extends RestTestBase {
    @Test
    public void testTraverseToNeighbour() {
        final Relationship rel = relationship();
        final TraversalDescription traversalDescription = RestTraversal.description().maxDepth(1).breadthFirst();
        System.out.println("traversalDescription = " + traversalDescription);
        final Traverser traverser = traversalDescription.traverse(rel.getStartNode());
        final Iterable<Node> nodes = traverser.nodes();
        Assert.assertEquals(rel.getEndNode(), nodes.iterator().next());
    }
View Full Code Here

public class RestTraversalExecutionTest extends RestTestBase {
    @Test
    public void testTraverseToNeighbour() {
        final Relationship rel = relationship();
        final TraversalDescription traversalDescription = RestTraversal.description().maxDepth(1).breadthFirst();
        System.out.println("traversalDescription = " + traversalDescription);
        final Traverser traverser = traversalDescription.traverse(rel.getStartNode());
        final Iterable<Node> nodes = traverser.nodes();
        Assert.assertEquals(rel.getEndNode(), nodes.iterator().next());
    }
View Full Code Here

        final Node subReference = obtainSubreferenceNode(alias);
        Relationship instanceOf = state.getSingleRelationship(INSTANCE_OF_RELATIONSHIP_TYPE, Direction.OUTGOING);
        instanceOf.delete();
        if (log.isDebugEnabled())
            log.debug("Removed link to subref node: " + subReference + " with alias: " + alias);
        TraversalDescription traversal = Traversal.description().depthFirst().relationships(SUBCLASS_OF_RELATIONSHIP_TYPE, Direction.OUTGOING);
        for (Node node : traversal.traverse(subReference).nodes()) {
            Integer count = (Integer) node.getProperty(SUBREFERENCE_NODE_COUNTER_KEY);
            Integer newCount = decrementAndGetCounter(node, SUBREFERENCE_NODE_COUNTER_KEY, 0);
            if (log.isDebugEnabled()) log.debug("count on ref " + node + " was " + count + " new " + newCount);
        }
    }
View Full Code Here

          throw new InvalidDataAccessApiUsageException("Cannot set readonly traversal description field " + property);
      }

      @Override
      public Object getValue(final Object entity, MappingPolicy mappingPolicy) {
          final TraversalDescription traversalDescription = fieldTraversalDescriptionBuilder.build(entity, property,params);
            return doReturn(template.traverse(entity, target, traversalDescription));
      }
View Full Code Here

        this.movieRepository = movieRepository;
        this.ratingDistance = ratingDistance;
    }

    public Map<Movie, ?> getRecommendationsFor(User user) {
        TraversalDescription traversal= Traversal.description().breadthFirst()
                .uniqueness(Uniqueness.NODE_PATH)
                .relationships(withName(User.FRIEND))
                .relationships(withName(User.RATED), OUTGOING)
                .evaluator(this);
        return averageRecommendations(user, traversal);
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.traversal.TraversalDescription

Copyright © 2018 www.massapicom. 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.