I'm trying to learn to write my own procedures and I'm stuck on what to return and how to stream it.
For example:
@Procedure(name = "myProcedure.loadData", mode = Mode.WRITE)
@Description("Call myProcedure.loadData(theData, theParam)")
public Stream<[Whatever]> makeDataGraphs(
@Name("theData") String theData,
@Name("theParam") String param
) throws InterruptedException {
List<Node> childNodes = parseChildNodes(theData);
Node parentNode = parseParentNode(theData);
for (Node c : childNodes) {
Relationship r = parentNode.createRelationshipTo(c, HAS_CHILD);
[ Should I add this relationship to a list or something? ]
}
private Node parseParentNode(Object data) {
// do things
Node parent = db.createNode(Parent);
return parent;
}
private List<Node> parseChildNodes(Object data) {
// do things
List<Node> children = new ArrayList();
for (String s : someList) {
Node c = db.createNode(Child);
c.setProperty("name", s);
children.add(c);
}
return children;
}
someIterable [ How do I collect up the parent and children? ]
return someIterable.stream();
}
What result class should I use return [Whatever] ?
Should I be collecting Maps of {"parent": parent, "has": r, "child": child} "
Do I need to return a stream or could I just return boolean upon success?