@Transactional public void setupReferenceRelationship() { Node referenceNode = template.getReferenceNode(); Actor bacon = actorRepository.findByPropertyValue("name", "Bacon, Kevin"); if (bacon == null) throw new NoSuchElementException("Unable to find Kevin Bacon actor"); referenceNode.createRelationshipTo(bacon.getPersistentState(), RelTypes.IMDB); }
public List<?> getBaconPath(final Actor actor) { if (actor == null) throw new IllegalArgumentException("Null actor"); Actor bacon = actorRepository.findByPropertyValue("name", "Bacon, Kevin"); Path path = GraphAlgoFactory.shortestPath( (PathExpander) StandardExpander.DEFAULT.add(RelTypes.ACTS_IN), 10) .findSinglePath(bacon.getPersistentState(), actor.getPersistentState()); if (path == null) return Collections.emptyList(); return convertNodesToActorsAndMovies(path); }
public Actor getActor(final String name) { Actor actor = actorRepository.findByPropertyValue("name", name); if (actor != null) return actor; return searchEngine.searchActor(name); }