public ListRepresentation getNodeRelationships( long nodeId, RelationshipDirection direction, Collection<String> types) throws NodeNotFoundException { Node node = node(nodeId); Expander expander; if (types.isEmpty()) { expander = Traversal.expanderForAllTypes(direction.internal); } else { expander = Traversal.emptyExpander(); for (String type : types) { expander = expander.add(DynamicRelationshipType.withName(type), direction.internal); } } return RelationshipRepresentation.list(expander.expand(node)); }
protected static RelationshipExpander toExpander( GraphDatabaseService db, Direction defaultDirection, Map<String, Object> relationshipTypes, boolean caseInsensitiveFilters, boolean looseFilters) throws ShellException { defaultDirection = defaultDirection != null ? defaultDirection : Direction.BOTH; Map<String, Direction> matches = filterMapToTypes( db, defaultDirection, relationshipTypes, caseInsensitiveFilters, looseFilters); Expander expander = Traversal.emptyExpander(); if (matches == null) return EMPTY_EXPANDER; for (Map.Entry<String, Direction> entry : matches.entrySet()) { expander = expander.add(DynamicRelationshipType.withName(entry.getKey()), entry.getValue()); } return expander; }