use of org.neo4j.server.rest.repr.PathRepresentation in project neo4j by neo4j.
the class TransactionWrappedDatabaseActions method findSinglePath.
@Override
public PathRepresentation findSinglePath(long startId, long endId, Map<String, Object> map) {
try (Transaction transaction = graph.beginTx()) {
PathRepresentation singlePath = super.findSinglePath(startId, endId, map);
transaction.success();
return singlePath;
}
}
use of org.neo4j.server.rest.repr.PathRepresentation in project neo4j by neo4j.
the class DatabaseActions method findPaths.
@SuppressWarnings({ "rawtypes", "unchecked" })
public ListRepresentation findPaths(long startId, long endId, Map<String, Object> map) {
final FindParams findParams = new FindParams(startId, endId, map).invoke();
PathFinder finder = findParams.getFinder();
Node startNode = findParams.getStartNode();
Node endNode = findParams.getEndNode();
Iterable paths = finder.findAllPaths(startNode, endNode);
IterableWrapper<PathRepresentation, Path> pathRepresentations = new IterableWrapper<PathRepresentation, Path>(paths) {
@Override
protected PathRepresentation underlyingObjectToObject(Path path) {
return findParams.pathRepresentationOf(path);
}
};
return new ListRepresentation(RepresentationType.PATH, pathRepresentations);
}
use of org.neo4j.server.rest.repr.PathRepresentation in project neo4j by neo4j.
the class RestRepresentationWriter method write.
private void write(JsonGenerator out, RepresentationFormat format, Object value, TransactionStateChecker checker) throws IOException {
if (value instanceof Map<?, ?>) {
out.writeStartObject();
try {
for (Map.Entry<String, ?> entry : ((Map<String, ?>) value).entrySet()) {
out.writeFieldName(entry.getKey());
write(out, format, entry.getValue(), checker);
}
} finally {
out.writeEndObject();
}
} else if (value instanceof Path) {
write(format, new PathRepresentation<>((Path) value));
} else if (value instanceof Iterable<?>) {
out.writeStartArray();
try {
for (Object item : (Iterable<?>) value) {
write(out, format, item, checker);
}
} finally {
out.writeEndArray();
}
} else if (value instanceof Node) {
NodeRepresentation representation = new NodeRepresentation((Node) value);
representation.setTransactionStateChecker(checker);
write(format, representation);
} else if (value instanceof Relationship) {
RelationshipRepresentation representation = new RelationshipRepresentation((Relationship) value);
representation.setTransactionStateChecker(checker);
write(format, representation);
} else {
out.writeObject(value);
}
}
Aggregations