neo4j 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGELOG +141 -0
  2. data/CONTRIBUTORS +15 -0
  3. data/Gemfile +3 -0
  4. data/README.rdoc +2015 -0
  5. data/lib/neo4j.old/batch_inserter.rb +144 -0
  6. data/lib/neo4j.old/config.rb +138 -0
  7. data/lib/neo4j.old/event_handler.rb +73 -0
  8. data/lib/neo4j.old/extensions/activemodel.rb +158 -0
  9. data/lib/neo4j.old/extensions/aggregate.rb +12 -0
  10. data/lib/neo4j.old/extensions/aggregate/aggregate_enum.rb +40 -0
  11. data/lib/neo4j.old/extensions/aggregate/ext/node_mixin.rb +69 -0
  12. data/lib/neo4j.old/extensions/aggregate/node_aggregate.rb +8 -0
  13. data/lib/neo4j.old/extensions/aggregate/node_aggregate_mixin.rb +331 -0
  14. data/lib/neo4j.old/extensions/aggregate/node_aggregator.rb +216 -0
  15. data/lib/neo4j.old/extensions/aggregate/node_group.rb +43 -0
  16. data/lib/neo4j.old/extensions/aggregate/prop_group.rb +30 -0
  17. data/lib/neo4j.old/extensions/aggregate/property_enum.rb +24 -0
  18. data/lib/neo4j.old/extensions/aggregate/props_aggregate.rb +8 -0
  19. data/lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb +31 -0
  20. data/lib/neo4j.old/extensions/aggregate/props_aggregator.rb +80 -0
  21. data/lib/neo4j.old/extensions/find_path.rb +117 -0
  22. data/lib/neo4j.old/extensions/graph_algo.rb +1 -0
  23. data/lib/neo4j.old/extensions/graph_algo/all_simple_paths.rb +133 -0
  24. data/lib/neo4j.old/extensions/graph_algo/neo4j-graph-algo-0.3.jar +0 -0
  25. data/lib/neo4j.old/extensions/reindexer.rb +104 -0
  26. data/lib/neo4j.old/extensions/rest.rb +21 -0
  27. data/lib/neo4j.old/extensions/rest/rest.rb +336 -0
  28. data/lib/neo4j.old/extensions/rest/rest_mixin.rb +193 -0
  29. data/lib/neo4j.old/extensions/rest/server.rb +50 -0
  30. data/lib/neo4j.old/extensions/rest/stubs.rb +141 -0
  31. data/lib/neo4j.old/extensions/rest_master.rb +34 -0
  32. data/lib/neo4j.old/extensions/rest_slave.rb +31 -0
  33. data/lib/neo4j.old/extensions/tx_tracker.rb +392 -0
  34. data/lib/neo4j.old/indexer.rb +187 -0
  35. data/lib/neo4j.old/jars.rb +6 -0
  36. data/lib/neo4j.old/jars/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
  37. data/lib/neo4j.old/jars/neo4j-kernel-1.0.jar +0 -0
  38. data/lib/neo4j.old/mixins/java_list_mixin.rb +139 -0
  39. data/lib/neo4j.old/mixins/java_node_mixin.rb +205 -0
  40. data/lib/neo4j.old/mixins/java_property_mixin.rb +169 -0
  41. data/lib/neo4j.old/mixins/java_relationship_mixin.rb +60 -0
  42. data/lib/neo4j.old/mixins/migration_mixin.rb +157 -0
  43. data/lib/neo4j.old/mixins/node_mixin.rb +249 -0
  44. data/lib/neo4j.old/mixins/property_class_methods.rb +265 -0
  45. data/lib/neo4j.old/mixins/rel_class_methods.rb +167 -0
  46. data/lib/neo4j.old/mixins/relationship_mixin.rb +103 -0
  47. data/lib/neo4j.old/neo.rb +247 -0
  48. data/lib/neo4j.old/node.rb +49 -0
  49. data/lib/neo4j.old/reference_node.rb +15 -0
  50. data/lib/neo4j.old/relationship.rb +85 -0
  51. data/lib/neo4j.old/relationships/decl_relationship_dsl.rb +164 -0
  52. data/lib/neo4j.old/relationships/has_list.rb +101 -0
  53. data/lib/neo4j.old/relationships/has_n.rb +129 -0
  54. data/lib/neo4j.old/relationships/node_traverser.rb +138 -0
  55. data/lib/neo4j.old/relationships/relationship_dsl.rb +149 -0
  56. data/lib/neo4j.old/relationships/traversal_position.rb +50 -0
  57. data/lib/neo4j.old/relationships/wrappers.rb +51 -0
  58. data/lib/neo4j.old/search_result.rb +72 -0
  59. data/lib/neo4j.old/transaction.rb +254 -0
  60. data/lib/neo4j.old/version.rb +3 -0
  61. data/lib/neo4j.rb +50 -0
  62. data/lib/neo4j/config.rb +137 -0
  63. data/lib/neo4j/database.rb +43 -0
  64. data/lib/neo4j/equal.rb +22 -0
  65. data/lib/neo4j/event_handler.rb +91 -0
  66. data/lib/neo4j/index.rb +157 -0
  67. data/lib/neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
  68. data/lib/neo4j/jars/lucene-core-2.9.2.jar +0 -0
  69. data/lib/neo4j/jars/lucene-core-3.0.1.jar +0 -0
  70. data/lib/neo4j/jars/neo4j-index-1.1.jar +0 -0
  71. data/lib/neo4j/jars/neo4j-kernel-1.1.1.jar +0 -0
  72. data/lib/neo4j/jars/neo4j-kernel-1.1.jar +0 -0
  73. data/lib/neo4j/jars/neo4j-lucene-index-0.1-20100916.085626-67.jar +0 -0
  74. data/lib/neo4j/mapping/class_methods/index.rb +21 -0
  75. data/lib/neo4j/mapping/class_methods/property.rb +139 -0
  76. data/lib/neo4j/mapping/class_methods/relationship.rb +96 -0
  77. data/lib/neo4j/mapping/class_methods/rule.rb +135 -0
  78. data/lib/neo4j/mapping/decl_relationship_dsl.rb +151 -0
  79. data/lib/neo4j/mapping/has_n.rb +117 -0
  80. data/lib/neo4j/mapping/node_mixin.rb +70 -0
  81. data/lib/neo4j/neo4j.rb +65 -0
  82. data/lib/neo4j/node.rb +82 -0
  83. data/lib/neo4j/node_mixin.rb +4 -0
  84. data/lib/neo4j/node_relationship.rb +60 -0
  85. data/lib/neo4j/node_traverser.rb +141 -0
  86. data/lib/neo4j/property.rb +72 -0
  87. data/lib/neo4j/rails/lucene_connection_closer.rb +19 -0
  88. data/lib/neo4j/rails/model.rb +210 -0
  89. data/lib/neo4j/rails/railtie.rb +16 -0
  90. data/lib/neo4j/rails/transaction.rb +29 -0
  91. data/lib/neo4j/rails/value.rb +43 -0
  92. data/lib/neo4j/relationship.rb +88 -0
  93. data/lib/neo4j/relationship_traverser.rb +57 -0
  94. data/lib/neo4j/to_java.rb +17 -0
  95. data/lib/neo4j/transaction.rb +69 -0
  96. data/lib/neo4j/version.rb +3 -0
  97. data/neo4j.gemspec +30 -0
  98. metadata +243 -0
@@ -0,0 +1,57 @@
1
+ module Neo4j
2
+
3
+ class RelationshipTraverser
4
+ include Enumerable
5
+ include ToJava
6
+
7
+ def initialize(node, types, dir)
8
+ @node = node
9
+ if types.size > 1
10
+ @types = types.inject([]) { |result, type| result << type_to_java(type) }.to_java(:'org.neo4j.graphdb.RelationshipType')
11
+ elsif types.size == 1
12
+ @type = type_to_java(types[0])
13
+ end
14
+
15
+ @dir = dir_to_java(dir)
16
+ end
17
+
18
+ def each
19
+ iter = iterator
20
+ while (iter.hasNext) do
21
+ yield iter.next
22
+ end
23
+ end
24
+
25
+ def iterator
26
+ if @types
27
+ @node.get_relationships(@types).iterator
28
+ elsif @type
29
+ @node.get_relationships(@type, @dir).iterator
30
+ else
31
+ @node.get_relationships(@dir).iterator
32
+ end
33
+ end
34
+
35
+ def size
36
+ [*self].size
37
+ end
38
+
39
+ def both
40
+ @dir = dir_to_java(:both)
41
+ self
42
+ end
43
+
44
+ def incoming
45
+ raise "Not allowed calling incoming when finding several relationships types" if @types
46
+ @dir = dir_to_java(:incoming)
47
+ self
48
+ end
49
+
50
+ def outgoing
51
+ raise "Not allowed calling outgoing when finding several relationships types" if @types
52
+ @dir = dir_to_java(:outgoing)
53
+ self
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,69 @@
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
+
19
+ def self.new(instance = Neo4j.started_db)
20
+ instance.begin_tx
21
+ end
22
+
23
+ # Runs a block in a Neo4j transaction
24
+ #
25
+ # Many operations on neo requires an transaction. You will get much better performance if
26
+ # one transaction is wrapped around several neo operation instead of running one transaction per
27
+ # neo operation.
28
+ # If one transaction is already running then a 'placebo' transaction will be created.
29
+ # Performing a finish on a placebo transaction will not finish the 'real' transaction.
30
+ #
31
+ # ==== Params
32
+ # ::yield:: the block to be performed in one transaction
33
+ #
34
+ # ==== Examples
35
+ # include 'neo4j'
36
+ #
37
+ # Neo4j::Transaction.run {
38
+ # node = PersonNode.new
39
+ # }
40
+ #
41
+ # You have also access to transaction object
42
+ #
43
+ # Neo4j::Transaction.run { |t|
44
+ # # something failed
45
+ # t.failure # will cause a rollback
46
+ # }
47
+
48
+ # If an exception occurs inside the block the transaction will rollback automatically
49
+ #
50
+ # ==== Returns
51
+ # The value of the evaluated provided block
52
+ #
53
+ def self.run # :yield: block that will be executed in a transaction
54
+ raise ArgumentError.new("Expected a block to run in Transaction.run") unless block_given?
55
+
56
+ begin
57
+ tx = Neo4j::Transaction.new
58
+ ret = yield tx
59
+ tx.success
60
+ rescue Exception
61
+ tx.failure unless tx.nil?
62
+ raise
63
+ ensure
64
+ tx.finish unless tx.nil?
65
+ end
66
+ ret
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,3 @@
1
+ module Neo4j
2
+ VERSION = "1.0.0.beta.1"
3
+ end
data/neo4j.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require 'neo4j/version'
5
+
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "neo4j"
9
+ s.version = Neo4j::VERSION
10
+ # s.platform = Gem::Platform::CURRENT # will probably support C Ruby via RJB also in the future
11
+ s.authors = "Andreas Ronge"
12
+ s.email = 'andreas.ronge@gmail.com'
13
+ s.homepage = "http://github.com/andreasronge/neo4j/tree"
14
+ s.rubyforge_project = 'neo4j'
15
+ s.summary = "A graph database for JRuby"
16
+ s.description = s.summary
17
+ s.require_path = 'lib'
18
+ s.files = Dir.glob("{bin,lib}/**/*") + %w(README.rdoc CHANGELOG CONTRIBUTORS Gemfile neo4j.gemspec)
19
+ s.has_rdoc = true
20
+ s.extra_rdoc_files = %w( README.rdoc )
21
+ s.rdoc_options = ["--quiet", "--title", "Neo4j.rb", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
22
+ s.required_ruby_version = ">= 1.8.7"
23
+ s.add_dependency("activemodel", ["~> 3.0.0"])
24
+ s.add_dependency("railties", ["~> 3.0.0"])
25
+ s.add_development_dependency "rspec-apigen", ">= 0.0.4"
26
+ s.add_development_dependency "rspec", ">= 2.0.0.beta.20"
27
+ s.add_development_dependency "rspec-rails-matchers", "= 0.2.1"
28
+
29
+ # s.add_development_dependency "rspec-unit", ">= 0.0.1"
30
+ end
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neo4j
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: true
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ - beta
10
+ - 1
11
+ version: 1.0.0.beta.1
12
+ platform: ruby
13
+ authors:
14
+ - Andreas Ronge
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-09-21 00:00:00 +02:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: activemodel
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: railties
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 3
45
+ - 0
46
+ - 0
47
+ version: 3.0.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec-apigen
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ - 0
60
+ - 4
61
+ version: 0.0.4
62
+ type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: rspec
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 2
73
+ - 0
74
+ - 0
75
+ - beta
76
+ - 20
77
+ version: 2.0.0.beta.20
78
+ type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec-rails-matchers
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ - 2
90
+ - 1
91
+ version: 0.2.1
92
+ type: :development
93
+ version_requirements: *id005
94
+ description: A graph database for JRuby
95
+ email: andreas.ronge@gmail.com
96
+ executables: []
97
+
98
+ extensions: []
99
+
100
+ extra_rdoc_files:
101
+ - README.rdoc
102
+ files:
103
+ - lib/neo4j.rb
104
+ - lib/neo4j.old/reference_node.rb
105
+ - lib/neo4j.old/event_handler.rb
106
+ - lib/neo4j.old/indexer.rb
107
+ - lib/neo4j.old/search_result.rb
108
+ - lib/neo4j.old/config.rb
109
+ - lib/neo4j.old/neo.rb
110
+ - lib/neo4j.old/transaction.rb
111
+ - lib/neo4j.old/node.rb
112
+ - lib/neo4j.old/jars.rb
113
+ - lib/neo4j.old/batch_inserter.rb
114
+ - lib/neo4j.old/version.rb
115
+ - lib/neo4j.old/relationship.rb
116
+ - lib/neo4j.old/relationships/node_traverser.rb
117
+ - lib/neo4j.old/relationships/decl_relationship_dsl.rb
118
+ - lib/neo4j.old/relationships/wrappers.rb
119
+ - lib/neo4j.old/relationships/has_n.rb
120
+ - lib/neo4j.old/relationships/relationship_dsl.rb
121
+ - lib/neo4j.old/relationships/has_list.rb
122
+ - lib/neo4j.old/relationships/traversal_position.rb
123
+ - lib/neo4j.old/mixins/java_node_mixin.rb
124
+ - lib/neo4j.old/mixins/java_relationship_mixin.rb
125
+ - lib/neo4j.old/mixins/migration_mixin.rb
126
+ - lib/neo4j.old/mixins/node_mixin.rb
127
+ - lib/neo4j.old/mixins/java_property_mixin.rb
128
+ - lib/neo4j.old/mixins/java_list_mixin.rb
129
+ - lib/neo4j.old/mixins/relationship_mixin.rb
130
+ - lib/neo4j.old/mixins/rel_class_methods.rb
131
+ - lib/neo4j.old/mixins/property_class_methods.rb
132
+ - lib/neo4j.old/jars/neo4j-kernel-1.0.jar
133
+ - lib/neo4j.old/jars/geronimo-jta_1.1_spec-1.1.1.jar
134
+ - lib/neo4j.old/extensions/aggregate.rb
135
+ - lib/neo4j.old/extensions/find_path.rb
136
+ - lib/neo4j.old/extensions/reindexer.rb
137
+ - lib/neo4j.old/extensions/graph_algo.rb
138
+ - lib/neo4j.old/extensions/rest.rb
139
+ - lib/neo4j.old/extensions/tx_tracker.rb
140
+ - lib/neo4j.old/extensions/rest_slave.rb
141
+ - lib/neo4j.old/extensions/activemodel.rb
142
+ - lib/neo4j.old/extensions/rest_master.rb
143
+ - lib/neo4j.old/extensions/rest/server.rb
144
+ - lib/neo4j.old/extensions/rest/rest.rb
145
+ - lib/neo4j.old/extensions/rest/rest_mixin.rb
146
+ - lib/neo4j.old/extensions/rest/stubs.rb
147
+ - lib/neo4j.old/extensions/graph_algo/neo4j-graph-algo-0.3.jar
148
+ - lib/neo4j.old/extensions/graph_algo/all_simple_paths.rb
149
+ - lib/neo4j.old/extensions/aggregate/node_aggregate.rb
150
+ - lib/neo4j.old/extensions/aggregate/node_aggregate_mixin.rb
151
+ - lib/neo4j.old/extensions/aggregate/props_aggregator.rb
152
+ - lib/neo4j.old/extensions/aggregate/prop_group.rb
153
+ - lib/neo4j.old/extensions/aggregate/node_aggregator.rb
154
+ - lib/neo4j.old/extensions/aggregate/props_aggregate.rb
155
+ - lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
156
+ - lib/neo4j.old/extensions/aggregate/property_enum.rb
157
+ - lib/neo4j.old/extensions/aggregate/aggregate_enum.rb
158
+ - lib/neo4j.old/extensions/aggregate/node_group.rb
159
+ - lib/neo4j.old/extensions/aggregate/ext/node_mixin.rb
160
+ - lib/neo4j/event_handler.rb
161
+ - lib/neo4j/node_traverser.rb
162
+ - lib/neo4j/relationship_traverser.rb
163
+ - lib/neo4j/config.rb
164
+ - lib/neo4j/transaction.rb
165
+ - lib/neo4j/neo4j.rb
166
+ - lib/neo4j/node.rb
167
+ - lib/neo4j/node_mixin.rb
168
+ - lib/neo4j/property.rb
169
+ - lib/neo4j/database.rb
170
+ - lib/neo4j/index.rb
171
+ - lib/neo4j/version.rb
172
+ - lib/neo4j/node_relationship.rb
173
+ - lib/neo4j/equal.rb
174
+ - lib/neo4j/relationship.rb
175
+ - lib/neo4j/to_java.rb
176
+ - lib/neo4j/rails/model.rb
177
+ - lib/neo4j/rails/railtie.rb
178
+ - lib/neo4j/rails/lucene_connection_closer.rb
179
+ - lib/neo4j/rails/transaction.rb
180
+ - lib/neo4j/rails/value.rb
181
+ - lib/neo4j/jars/neo4j-lucene-index-0.1-20100916.085626-67.jar
182
+ - lib/neo4j/jars/lucene-core-2.9.2.jar
183
+ - lib/neo4j/jars/neo4j-kernel-1.1.jar
184
+ - lib/neo4j/jars/lucene-core-3.0.1.jar
185
+ - lib/neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar
186
+ - lib/neo4j/jars/neo4j-kernel-1.1.1.jar
187
+ - lib/neo4j/jars/neo4j-index-1.1.jar
188
+ - lib/neo4j/mapping/decl_relationship_dsl.rb
189
+ - lib/neo4j/mapping/node_mixin.rb
190
+ - lib/neo4j/mapping/has_n.rb
191
+ - lib/neo4j/mapping/class_methods/rule.rb
192
+ - lib/neo4j/mapping/class_methods/property.rb
193
+ - lib/neo4j/mapping/class_methods/index.rb
194
+ - lib/neo4j/mapping/class_methods/relationship.rb
195
+ - README.rdoc
196
+ - CHANGELOG
197
+ - CONTRIBUTORS
198
+ - Gemfile
199
+ - neo4j.gemspec
200
+ has_rdoc: true
201
+ homepage: http://github.com/andreasronge/neo4j/tree
202
+ licenses: []
203
+
204
+ post_install_message:
205
+ rdoc_options:
206
+ - --quiet
207
+ - --title
208
+ - Neo4j.rb
209
+ - --opname
210
+ - index.html
211
+ - --line-numbers
212
+ - --main
213
+ - README.rdoc
214
+ - --inline-source
215
+ require_paths:
216
+ - lib
217
+ required_ruby_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ segments:
222
+ - 1
223
+ - 8
224
+ - 7
225
+ version: 1.8.7
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">"
229
+ - !ruby/object:Gem::Version
230
+ segments:
231
+ - 1
232
+ - 3
233
+ - 1
234
+ version: 1.3.1
235
+ requirements: []
236
+
237
+ rubyforge_project: neo4j
238
+ rubygems_version: 1.3.6
239
+ signing_key:
240
+ specification_version: 3
241
+ summary: A graph database for JRuby
242
+ test_files: []
243
+