Mark,
this is the typical code of converting a more involved and fine granular object network to simpler UI-view-object structures. It could be cleaned up a bit e.g. by moving calculateListOfItems to ListOfDomains, and by ItemListItem being able to hydrate itself from a ItemNeededForEvent.
a cypher query for that could look like (so it is not much less involved than the code you have). It is probably just the complexity that lies in this conversion?).
Code:
start user=node({user}), event=node({eventId})
match user-[host?:HOSTS]->event,
event-[:ITEMS_NEEDED]->neededItem-[:ITEM]->item,
event-[:ITEMS_SIGNED_UP_FOR]-> signedUpToBringToEvent-[userSignedUp?:USER]->user
return host!=null as isHost, ID(neededItem) as neededItemId, neededItem.quantity as quantity, item.name as itemName,
userSignedUp!=null as currentUserSignedUp, ID(signedUpToBringToEvent) as itemSignedUpId
The convert I meant are the
Code:
List<ItemListItem> = template.query().to(ItemListItem.class, new ResultConverter<Map<String,Object>, ItemListItem >() {
ItemListItem convert(Map<String,Object> row) {
create ItemListItem and set the fields from the row
}
}).as(List.class);
HTH
Michael