Guest User

Untitled

a guest
Apr 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. include Java
  4.  
  5. import org.neo4j.api.core.Node
  6. import org.neo4j.api.core.RelationshipType
  7. import org.neo4j.api.core.EmbeddedNeo
  8. import org.neo4j.api.core.Transaction
  9.  
  10. class Family
  11. include RelationshipType
  12.  
  13. attr_accessor :name
  14.  
  15. def initialize(name)
  16. @name = name
  17. end
  18. end
  19.  
  20. if __FILE__ == $0
  21. neo = EmbeddedNeo.new('dysingers')
  22. tx = Transaction.begin
  23. begin
  24. tim = neo.create_node
  25. tim.set_property('first_name', "Tim")
  26. tim.set_property('last_name', "Dysinger")
  27. sara = neo.create_node
  28. sara.set_property('first_name', "Sara")
  29. sara.set_property('last_name', "Dysinger")
  30. marriage = tim.create_relationship_to(sara, Family.new('marriage'))
  31. marriage.set_property('date', 'Dec 14, 1996')
  32. jacob = neo.create_node
  33. jacob.set_property('first_name', "Jacob")
  34. jacob.set_property('last_name', "Dysinger")
  35. tim.create_relationship_to(jacob, Family.new('parent'))
  36. sara.create_relationship_to(jacob, Family.new('parent'))
  37. tx.success
  38. rescue Exception => e
  39. puts e.inspect
  40. ensure
  41. tx.finish
  42. neo.shutdown
  43. end
  44. end
Add Comment
Please, Sign In to add comment