Advertisement
Guest User

Untitled

a guest
May 9th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.39 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. mgmt.buildIndex('names', Vertex.class).addKey(name).buildCompositeIndex()
  5.  
  6. isIn = mgmt.makeEdgeLabel('isIn').multiplicity(MANY2ONE).make()
  7. belongsTo = mgmt.makeEdgeLabel('belongsTo').multiplicity(MANY2ONE).make()
  8.  
  9. directory = mgmt.makeVertexLabel('directory').make()
  10. directoryId = mgmt.makePropertyKey('directoryId').dataType(UUID.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  11. mgmt.addProperties(directory, name, directoryId)
  12. mgmt.buildIndex('directoryIds', Vertex.class).addKey(directoryId).buildCompositeIndex()
  13.  
  14. file = mgmt.makeVertexLabel('file').make()
  15. fileId = mgmt.makePropertyKey('fileId').dataType(UUID.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  16. mgmt.addProperties(file, name, fileId)
  17. mgmt.buildIndex('fileIds', Vertex.class).addKey(fileId).buildCompositeIndex()
  18.  
  19. user = mgmt.makeVertexLabel('user').make()
  20. userId = mgmt.makePropertyKey('userId').dataType(UUID.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
  21. mgmt.addProperties(user, name, userId)
  22. mgmt.buildIndex('userIds', Vertex.class).addKey(userId).buildCompositeIndex()
  23.  
  24. mgmt.addConnection(isIn, file, directory)
  25. mgmt.addConnection(isIn, directory, directory)
  26. mgmt.addConnection(belongsTo, directory, user)
  27.  
  28. mgmt.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement