neo4j-contrib / gremlin-plugin

A Plugin for the Neo4j server add Tinkerpop-related functionality
Other
55 stars 23 forks source link

Plugin Isn't Converting ArrayLists to Primitive Lists #2

Open espeed opened 11 years ago

espeed commented 11 years ago

This issue came up a while back because the Gremlin Plugin wasn't automatically converting the JSON ArrayList to a primitive String list, like the REST API does.

See https://groups.google.com/d/msg/neo4j/sjH2f5dulTQ/ZwOeAsWovtUJ

However, Peter added the code to do this in Blueprints Neo4jGraph:

https://github.com/tinkerpop/blueprints/blob/master/blueprints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/Neo4jElement.java#L48

Why this is no longer working?

Latest thread on this issue: https://groups.google.com/d/msg/neo4j/ykwPv9zxI_g/_Jjd2_Pk608J

peterneubauer commented 11 years ago

So what is the script being sent over, so I can write a test case for this?

espeed commented 11 years ago

His example...

n  = g.entity.get_or_create("list", ['Team', 'Blue'], list = ['Team', 'Blue'])

...is executing this Gremlin script with the following params...

data = ['list': ['Team', 'Blue']]
index_name = "entity"
keys = null
def create_indexed_vertex(data,index_name,keys) {
  neo4j = g.getRawGraph()
  manager = neo4j.index()
  g.setMaxBufferSize(0)
  g.startTransaction()
  try {
    index = manager.forNodes(index_name)
    vertex = neo4j.createNode()
    for (entry in data.entrySet()) {
      if (entry.value == null) continue;
      vertex.setProperty(entry.key,entry.value)
      if (keys == null || keys.contains(entry.key))
    index.add(vertex,entry.key,String.valueOf(entry.value))
    }
    g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS)
    return vertex
  } catch (e) {
    g.stopTransaction(TransactionalGraph.Conclusion.FAILURE)  
    return e
  }
}