Skip to content

Instantly share code, notes, and snippets.

@vad
Created April 9, 2013 15:24
Show Gist options
  • Save vad/5346626 to your computer and use it in GitHub Desktop.
Save vad/5346626 to your computer and use it in GitHub Desktop.
slice.groovy
def slice() {
m = []
g.V('type', 'parent').transform({ node ->
myID = node.myID
data = [:]
tmp = []
node.out('child').order{-1 * (it.a.created <=> it.b.created)}.map.fill(tmp)
data.name = tmp.collect{it.name}.findResults{it}[0]
data.latitude = tmp.collect{it.latitude}?.findResults{it}[0]
data.longitude = tmp.collect{it.longitude}?.findResults{it}[0]
if ([data.latitude, data.longitude].any{it == null}) {
return null
}
data.myID = myID
return data
}).filter{it != null}.fill(m)
return m
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment