neo4j 1.0.0.beta.20 → 3.0.0.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +243 -0
  3. data/CONTRIBUTORS +12 -0
  4. data/Gemfile +10 -11
  5. data/README.md +23 -0
  6. data/bin/neo4j-jars +33 -0
  7. data/config/locales/en.yml +5 -0
  8. data/config/neo4j/config.yml +98 -0
  9. data/lib/neo4j.rb +28 -68
  10. data/lib/neo4j/active_node.rb +60 -0
  11. data/lib/neo4j/active_node/callbacks.rb +41 -0
  12. data/lib/neo4j/active_node/has_n.rb +138 -0
  13. data/lib/neo4j/active_node/has_n/decl_rel.rb +236 -0
  14. data/lib/neo4j/active_node/has_n/nodes.rb +82 -0
  15. data/lib/neo4j/active_node/identity.rb +28 -0
  16. data/lib/neo4j/active_node/initialize.rb +24 -0
  17. data/lib/neo4j/active_node/labels.rb +142 -0
  18. data/lib/neo4j/active_node/persistence.rb +193 -0
  19. data/lib/neo4j/active_node/property.rb +41 -0
  20. data/lib/neo4j/active_node/rels.rb +11 -0
  21. data/lib/neo4j/active_node/validations.rb +51 -0
  22. data/lib/neo4j/railtie.rb +40 -0
  23. data/lib/neo4j/version.rb +1 -1
  24. data/lib/neo4j/wrapper.rb +25 -0
  25. data/neo4j.gemspec +25 -15
  26. metadata +136 -149
  27. data/README.rdoc +0 -135
  28. data/lib/generators/neo4j.rb +0 -65
  29. data/lib/generators/neo4j/model/model_generator.rb +0 -39
  30. data/lib/generators/neo4j/model/templates/model.erb +0 -7
  31. data/lib/neo4j/config.rb +0 -153
  32. data/lib/neo4j/database.rb +0 -56
  33. data/lib/neo4j/equal.rb +0 -21
  34. data/lib/neo4j/event_handler.rb +0 -116
  35. data/lib/neo4j/index/class_methods.rb +0 -62
  36. data/lib/neo4j/index/index.rb +0 -33
  37. data/lib/neo4j/index/indexer.rb +0 -312
  38. data/lib/neo4j/index/indexer_registry.rb +0 -68
  39. data/lib/neo4j/index/lucene_query.rb +0 -191
  40. data/lib/neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
  41. data/lib/neo4j/jars/lucene-core-3.0.2.jar +0 -0
  42. data/lib/neo4j/jars/neo4j-index-1.2-1.2.M03.jar +0 -0
  43. data/lib/neo4j/jars/neo4j-kernel-1.2-1.2.M03.jar +0 -0
  44. data/lib/neo4j/jars/neo4j-lucene-index-0.2-1.2.M03.jar +0 -0
  45. data/lib/neo4j/load.rb +0 -21
  46. data/lib/neo4j/mapping/class_methods/init_node.rb +0 -50
  47. data/lib/neo4j/mapping/class_methods/init_rel.rb +0 -35
  48. data/lib/neo4j/mapping/class_methods/property.rb +0 -80
  49. data/lib/neo4j/mapping/class_methods/relationship.rb +0 -90
  50. data/lib/neo4j/mapping/class_methods/root.rb +0 -31
  51. data/lib/neo4j/mapping/class_methods/rule.rb +0 -295
  52. data/lib/neo4j/mapping/decl_relationship_dsl.rb +0 -214
  53. data/lib/neo4j/mapping/has_n.rb +0 -83
  54. data/lib/neo4j/mapping/node_mixin.rb +0 -97
  55. data/lib/neo4j/mapping/relationship_mixin.rb +0 -117
  56. data/lib/neo4j/model.rb +0 -4
  57. data/lib/neo4j/neo4j.rb +0 -95
  58. data/lib/neo4j/node.rb +0 -131
  59. data/lib/neo4j/node_mixin.rb +0 -4
  60. data/lib/neo4j/node_relationship.rb +0 -149
  61. data/lib/neo4j/node_traverser.rb +0 -157
  62. data/lib/neo4j/property.rb +0 -111
  63. data/lib/neo4j/rails/finders.rb +0 -121
  64. data/lib/neo4j/rails/lucene_connection_closer.rb +0 -19
  65. data/lib/neo4j/rails/mapping/property.rb +0 -35
  66. data/lib/neo4j/rails/model.rb +0 -324
  67. data/lib/neo4j/rails/railtie.rb +0 -16
  68. data/lib/neo4j/rails/transaction.rb +0 -67
  69. data/lib/neo4j/rails/tx_methods.rb +0 -15
  70. data/lib/neo4j/rails/validations/non_nil.rb +0 -11
  71. data/lib/neo4j/rails/validations/uniqueness.rb +0 -31
  72. data/lib/neo4j/rails/value.rb +0 -124
  73. data/lib/neo4j/rails/value_properties.rb +0 -29
  74. data/lib/neo4j/relationship.rb +0 -169
  75. data/lib/neo4j/relationship_mixin.rb +0 -4
  76. data/lib/neo4j/relationship_traverser.rb +0 -92
  77. data/lib/neo4j/to_java.rb +0 -31
  78. data/lib/neo4j/transaction.rb +0 -68
  79. data/lib/neo4j/type_converters.rb +0 -98
data/lib/neo4j/to_java.rb DELETED
@@ -1,31 +0,0 @@
1
- module Neo4j
2
- module ToJava
3
-
4
- def type_to_java(type)
5
- org.neo4j.graphdb.DynamicRelationshipType.withName(type.to_s)
6
- end
7
-
8
- def dir_to_java(dir)
9
- case dir
10
- when :outgoing then org.neo4j.graphdb.Direction::OUTGOING
11
- when :both then org.neo4j.graphdb.Direction::BOTH
12
- when :incoming then org.neo4j.graphdb.Direction::INCOMING
13
- else raise "unknown direction '#{dir}', expects :outgoing, :incoming or :both"
14
- end
15
- end
16
- end
17
- end
18
-
19
-
20
- org.neo4j.kernel.impl.core.IntArrayIterator.class_eval do
21
- def each_wrapped
22
- while(hasNext())
23
- yield self.next().wrapper
24
- end
25
- end
26
-
27
- def wrapped
28
- Enumerator.new(self, :each_wrapped)
29
- end
30
-
31
- end
@@ -1,68 +0,0 @@
1
- module Neo4j
2
- #
3
- # All modifying operations that work with the node space must be wrapped in a transaction. Transactions are thread confined.
4
- # Neo4j does not implement true nested transaction, instead it uses flat nested transactions
5
- # see http://wiki.neo4j.org/content/Flat_nested_transactions
6
- #
7
- class Transaction
8
-
9
- # Starts a new Neo4j Transaction
10
- # Returns a Java Neo4j Transaction object
11
- # See http://api.neo4j.org/current/org/neo4j/graphdb/Transaction.html
12
- #
13
- # Example:
14
- # tx = Neo4j::Transaction.new
15
- # # modify something
16
- # tx.success
17
- # tx.finish
18
- def self.new(instance = Neo4j.started_db)
19
- instance.begin_tx
20
- end
21
-
22
- # Runs a block in a Neo4j transaction
23
- #
24
- # Many operations on neo requires an transaction. You will get much better performance if
25
- # one transaction is wrapped around several neo operation instead of running one transaction per
26
- # neo operation.
27
- # If one transaction is already running then a 'placebo' transaction will be created.
28
- # Performing a finish on a placebo transaction will not finish the 'real' transaction.
29
- #
30
- # ==== Params
31
- # ::yield:: the block to be performed in one transaction
32
- #
33
- # ==== Examples
34
- # include 'neo4j'
35
- #
36
- # Neo4j::Transaction.run {
37
- # node = PersonNode.new
38
- # }
39
- #
40
- # You have also access to transaction object
41
- #
42
- # Neo4j::Transaction.run { |t|
43
- # # something failed
44
- # t.failure # will cause a rollback
45
- # }
46
-
47
- # If an exception occurs inside the block the transaction will rollback automatically
48
- #
49
- # ==== Returns
50
- # The value of the evaluated provided block
51
- #
52
- def self.run # :yield: block that will be executed in a transaction
53
- raise ArgumentError.new("Expected a block to run in Transaction.run") unless block_given?
54
-
55
- begin
56
- tx = Neo4j::Transaction.new
57
- ret = yield tx
58
- tx.success
59
- rescue Exception
60
- tx.failure unless tx.nil?
61
- raise
62
- ensure
63
- tx.finish unless tx.nil?
64
- end
65
- ret
66
- end
67
- end
68
- end
@@ -1,98 +0,0 @@
1
- module Neo4j
2
-
3
- # Responsible for converting values from and to Java Neo4j and Lucene.
4
- # You can implement your own converter by implementing the method <tt>to_java</tt> and <tt>to_ruby</tt>
5
- # and add it to the Neo4j::Config with the key <tt>:converters</tt>
6
- #
7
- # There are currently two default converters that are triggered when a Date or a DateTime is read or written.
8
- #
9
- module TypeConverters
10
-
11
- # Converts Date objects to Java long types. Must be timezone UTC.
12
- class DateConverter
13
- class << self
14
- def to_java(value)
15
- return nil if value.nil?
16
- Time.utc(value.year, value.month, value.day).to_i
17
- end
18
-
19
- def to_ruby(value)
20
- return nil if value.nil?
21
- Time.at(value).utc
22
- end
23
- end
24
- end
25
-
26
- # Converts DateTime objects to and from Java long types. Must be timezone UTC.
27
- class DateTimeConverter
28
- class << self
29
- # Converts the given DateTime (UTC) value to an Fixnum.
30
- # Only utc times are supported !
31
- def to_java(value)
32
- return nil if value.nil?
33
- Time.utc(value.year, value.month, value.day, value.hour, value.min, value.sec).to_i
34
- end
35
-
36
- def to_ruby(value)
37
- return nil if value.nil?
38
- t = Time.at(value).utc
39
- DateTime.civil(t.year, t.month, t.day, t.hour, t.min, t.sec)
40
- end
41
- end
42
- end
43
-
44
- class TimeConverter
45
- class << self
46
- # Converts the given DateTime (UTC) value to an Fixnum.
47
- # Only utc times are supported !
48
- def to_java(value)
49
- return nil if value.nil?
50
- value.utc.to_i
51
- end
52
-
53
- def to_ruby(value)
54
- return nil if value.nil?
55
- Time.at(value).utc
56
- end
57
- end
58
- end
59
-
60
- # Converts the given value to a Java type by using the registered converters.
61
- # It just looks at the class of the given value and will convert it if there is a converter
62
- # registered (in Neo4j::Config) for this value.
63
- def self.convert(value)
64
- type = value.class
65
- converter = Neo4j.converters[type]
66
- return value unless converter
67
- converter.to_java(value)
68
- end
69
-
70
- # Converts the given property (key, value) to Java by using configuration from the given class.
71
- # If no Converter is defined for this value then it simply returns the given value.
72
- def self.to_java(clazz, key, value)
73
- type = clazz._decl_props[key] && clazz._decl_props[key][:type]
74
- if type
75
- converter = Neo4j.converters[type]
76
- converter ? converter.to_java(value) : value
77
- elsif clazz.superclass != Object
78
- to_java(clazz.superclass, key, value)
79
- else
80
- value
81
- end
82
- end
83
-
84
- # Converts the given property (key, value) to Ruby by using configuration from the given class.
85
- # If no Converter is defined for this value then it simply returns the given value.
86
- def self.to_ruby(clazz, key, value)
87
- type = clazz._decl_props[key] && clazz._decl_props[key][:type]
88
- if type
89
- converter = Neo4j.converters[type]
90
- converter ? converter.to_ruby(value) : value
91
- elsif clazz.superclass != Object
92
- to_ruby(clazz.superclass, key, value)
93
- else
94
- value
95
- end
96
- end
97
- end
98
- end