Advertisement
Guest User

Untitled

a guest
May 9th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.85 KB | None | 0 0
  1. mgmt = graph.openManagement()
  2.  
  3. name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  4. created = mgmt.makePropertyKey('created').dataType(Date.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  5. updated = mgmt.makePropertyKey('updated').dataType(Date.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  6. mgmt.buildIndex('names', Vertex.class).addKey(name).buildCompositeIndex()
  7.  
  8. isIn = mgmt.makeEdgeLabel('isIn').multiplicity(MANY2ONE).make()
  9. belongsTo = mgmt.makeEdgeLabel('belongsTo').multiplicity(MANY2ONE).make()
  10. sharedWith = mgmt.makeEdgeLabel('sharedWith').multiplicity(MANY2ONE).make()
  11.  
  12. directory = mgmt.makeVertexLabel('directory').make()
  13. directoryId = mgmt.makePropertyKey('directoryId').dataType(UUID.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  14. mgmt.addProperties(directory, name, created, updated, directoryId)
  15. mgmt.buildIndex('directoryIds', Vertex.class).addKey(directoryId).buildCompositeIndex()
  16.  
  17. file = mgmt.makeVertexLabel('file').make()
  18. fileId = mgmt.makePropertyKey('fileId').dataType(UUID.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  19. mgmt.addProperties(file, name, created, updated, fileId)
  20. mgmt.buildIndex('fileIds', Vertex.class).addKey(fileId).buildCompositeIndex()
  21.  
  22. user = mgmt.makeVertexLabel('user').make()
  23. userId = mgmt.makePropertyKey('userId').dataType(UUID.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  24. mgmt.addProperties(user, name, userId)
  25. mgmt.buildIndex('userIds', Vertex.class).addKey(userId).buildCompositeIndex()
  26.  
  27. mgmt.addConnection(isIn, file, directory)
  28. mgmt.addConnection(isIn, directory, directory)
  29. mgmt.addConnection(belongsTo, directory, user)
  30. mgmt.addConnection(sharedWith, file, user)
  31. mgmt.addConnection(sharedWith, directory, user)
  32.  
  33. mgmt.commit()
  34.  
  35. graph.tx().commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement