You can build a SideEffect pipe that will work. In the simple case, do the following:
gv(1)._().sideEffect{it.firstname='Marko'; it.lastname='Rodriguez'}
Alternatively, if you only need to work with one node and have a map, you can use the each method for the map:
m = [firstname:'Marko', lastname:'Rodriguez'] m.each{gv(1).setProperty(it.key, it.value)}
Or you can do this inside a pipe where you have a hash with the values you want to set. Once again, we will use the sideEffect tube. Since there is a closure inside the closure, we need to assign the value it from the first closure to something else, in this case tn , shortened to "this node", so it is available in the second closure :.
g = new TinkerGraph() g.addVertex() g.addVertex() m = ['0': [firstname: 'Marko', lastname: 'Rodriguez'], '1': [firstname: 'William', lastname: 'Clinton']] gVsideEffect{tn = it; m[tn.id].each{tn.setProperty(it.key, it.value)}}
This will give the following:
gremlin> gv(0).map ==>lastname=Rodriguez ==>firstname=Marko gremlin> gv(1).map ==>lastname=Clinton ==>firstname=William
One of the possible ways to get this method is that you need to remember that the identifier of the vertices is strings, not integers, so be sure to specify them accordingly.
source share