Created
April 9, 2013 15:24
-
-
Save vad/5346626 to your computer and use it in GitHub Desktop.
slice.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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