neo4j 1.2.6-java → 2.0.0.alpha.3-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +30 -0
- data/CONTRIBUTORS +1 -0
- data/Gemfile +16 -4
- data/README.rdoc +25 -3
- data/bin/neo4j-jars +15 -8
- data/bin/neo4j-shell +0 -1
- data/bin/neo4j-upgrade +72 -0
- data/config/neo4j/config.yml +5 -4
- data/lib/neo4j/algo/algo.rb +0 -1
- data/lib/neo4j/batch/inserter.rb +5 -0
- data/lib/neo4j/database.rb +18 -12
- data/lib/neo4j/event_handler.rb +76 -9
- data/lib/neo4j/has_list/class_methods.rb +1 -1
- data/lib/neo4j/has_list/mapping.rb +13 -33
- data/lib/neo4j/has_n/decl_relationship_dsl.rb +17 -13
- data/lib/neo4j/has_n/mapping.rb +6 -23
- data/lib/neo4j/identity_map.rb +0 -3
- data/lib/neo4j/index/class_methods.rb +9 -3
- data/lib/neo4j/index/index.rb +2 -1
- data/lib/neo4j/index/indexer.rb +3 -2
- data/lib/neo4j/index/indexer_registry.rb +1 -1
- data/lib/neo4j/index/lucene_query.rb +52 -33
- data/lib/neo4j/neo4j.rb +19 -0
- data/lib/neo4j/node.rb +42 -36
- data/lib/neo4j/node_mixin/node_mixin.rb +9 -5
- data/lib/neo4j/paginated.rb +23 -0
- data/lib/neo4j/rails/accept_id.rb +66 -0
- data/lib/neo4j/rails/attributes.rb +14 -9
- data/lib/neo4j/rails/compositions.rb +9 -1
- data/lib/neo4j/rails/finders.rb +5 -1
- data/lib/neo4j/rails/mapping/property.rb +41 -28
- data/lib/neo4j/rails/model.rb +2 -0
- data/lib/neo4j/rails/observer.rb +61 -2
- data/lib/neo4j/rails/persistence.rb +57 -57
- data/lib/neo4j/rails/rails.rb +1 -0
- data/lib/neo4j/rails/railtie.rb +4 -1
- data/lib/neo4j/rails/rel_persistence.rb +11 -12
- data/lib/neo4j/rails/relationship.rb +9 -4
- data/lib/neo4j/rails/relationships/node_dsl.rb +15 -5
- data/lib/neo4j/rails/relationships/relationships.rb +42 -2
- data/lib/neo4j/rails/relationships/rels_dsl.rb +60 -3
- data/lib/neo4j/rails/relationships/storage.rb +43 -5
- data/lib/neo4j/rails/validations/uniqueness.rb +1 -0
- data/lib/neo4j/rails/versioning/versioning.rb +64 -9
- data/lib/neo4j/relationship.rb +79 -73
- data/lib/neo4j/rule/event_listener.rb +7 -1
- data/lib/neo4j/rule/functions/count.rb +6 -0
- data/lib/neo4j/rule/rule.rb +20 -5
- data/lib/neo4j/rule/rule_node.rb +33 -20
- data/lib/neo4j/to_java.rb +5 -0
- data/lib/neo4j/traversal/traverser.rb +38 -1
- data/lib/neo4j/type_converters/type_converters.rb +56 -5
- data/lib/neo4j/version.rb +1 -1
- data/lib/neo4j.rb +3 -49
- data/neo4j.gemspec +2 -2
- metadata +191 -216
- data/bin/neo4j-shell~ +0 -108
- data/lib/Gemfile~ +0 -3
- data/lib/config2.yml~ +0 -86
- data/lib/neo4j/jars/core/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
- data/lib/neo4j/jars/core/lucene-core-3.1.0.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-backup-1.4.1.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-graph-algo-1.4.1.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-kernel-1.4.1.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-lucene-index-1.4.1.jar +0 -0
- data/lib/neo4j/jars/ha/log4j-1.2.16.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-com-1.4.1.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-ha-1.4.1.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-jmx-1.4.1.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-management-1.4.1.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-shell-1.4.1.jar +0 -0
- data/lib/neo4j/jars/ha/netty-3.2.1.Final.jar +0 -0
- data/lib/neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar +0 -0
- data/lib/neo4j/jars/ha/zookeeper-3.3.2.jar +0 -0
- data/lib/neo4j/paginate.rb +0 -25
- data/lib/perf.rb~ +0 -36
- data/lib/test.rb~ +0 -2
data/lib/neo4j/to_java.rb
CHANGED
@@ -31,7 +31,6 @@ module Neo4j
|
|
31
31
|
class Traverser
|
32
32
|
include Enumerable
|
33
33
|
include ToJava
|
34
|
-
include Neo4j::Paginate
|
35
34
|
|
36
35
|
|
37
36
|
def initialize(from, type = nil, dir=nil)
|
@@ -46,6 +45,44 @@ module Neo4j
|
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
48
|
+
|
49
|
+
# Sets traversing depth first.
|
50
|
+
#
|
51
|
+
# The <tt>pre_or_post</tt> parameter parameter can have two values: :pre or :post
|
52
|
+
# * :pre - Traversing depth first, visiting each node before visiting its child nodes (default)
|
53
|
+
# * :post - Traversing depth first, visiting each node after visiting its child nodes.
|
54
|
+
#
|
55
|
+
def depth_first(pre_or_post = :pre)
|
56
|
+
case pre_or_post
|
57
|
+
when :pre then @td = @td.order(org.neo4j.kernel.Traversal.preorderDepthFirst())
|
58
|
+
when :post then @td = @td.order(org.neo4j.kernel.Traversal.postorderDepthFirst())
|
59
|
+
else raise "Unknown type #{pre_or_post}, should be :pre or :post"
|
60
|
+
end
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# Sets traversing breadth first (default).
|
66
|
+
#
|
67
|
+
# This is the default ordering if none is defined.
|
68
|
+
# The <tt>pre_or_post</tt> parameter parameter can have two values: :pre or :post
|
69
|
+
# * :pre - Traversing breadth first, visiting each node before visiting its child nodes (default)
|
70
|
+
# * :post - Traversing breadth first, visiting each node after visiting its child nodes.
|
71
|
+
#
|
72
|
+
# ==== Note
|
73
|
+
# Please note that breadth first traversals have a higher memory overhead than depth first traversals.
|
74
|
+
# BranchSelectors carries state and hence needs to be uniquely instantiated for each traversal. Therefore it is supplied to the TraversalDescription through a BranchOrderingPolicy interface, which is a factory of BranchSelector instances.
|
75
|
+
#
|
76
|
+
def breadth_first(pre_or_post = :pre)
|
77
|
+
case pre_or_post
|
78
|
+
when :pre then @td = @td.order(org.neo4j.kernel.Traversal.preorderBreadthFirst())
|
79
|
+
when :post then @td = @td.order(org.neo4j.kernel.Traversal.postorderBreadthFirst())
|
80
|
+
else raise "Unknown type #{pre_or_post}, should be :pre or :post"
|
81
|
+
end
|
82
|
+
self
|
83
|
+
end
|
84
|
+
|
85
|
+
|
49
86
|
def eval_paths(&eval_path_block)
|
50
87
|
@td = @td.evaluator(Evaluator.new(&eval_path_block))
|
51
88
|
self
|
@@ -59,28 +59,72 @@ module Neo4j
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def to_java(value)
|
62
|
+
return nil if value.nil?
|
62
63
|
!!value && value != '0'
|
63
64
|
end
|
64
65
|
|
65
66
|
def to_ruby(value)
|
67
|
+
return nil if value.nil?
|
66
68
|
!!value && value != '0'
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
73
|
+
class SymbolConverter
|
74
|
+
class << self
|
75
|
+
|
76
|
+
def convert?(class_or_symbol)
|
77
|
+
:symbol == class_or_symbol || Symbol == class_or_symbol
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_java(value)
|
81
|
+
return nil if value.nil?
|
82
|
+
value.to_s
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_ruby(value)
|
86
|
+
return nil if value.nil?
|
87
|
+
value.to_sym
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
class StringConverter
|
94
|
+
class << self
|
95
|
+
|
96
|
+
def convert?(class_or_symbol)
|
97
|
+
[String, :string, :text].include? class_or_symbol
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_java(value)
|
101
|
+
return nil if value.nil?
|
102
|
+
value.to_s
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_ruby(value)
|
106
|
+
return nil if value.nil?
|
107
|
+
value.to_s
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
71
113
|
|
72
114
|
class FixnumConverter
|
73
115
|
class << self
|
74
116
|
|
75
117
|
def convert?(class_or_symbol)
|
76
|
-
Fixnum == class_or_symbol || :fixnum == class_or_symbol
|
118
|
+
Fixnum == class_or_symbol || :fixnum == class_or_symbol || :numeric == class_or_symbol
|
77
119
|
end
|
78
120
|
|
79
121
|
def to_java(value)
|
122
|
+
return nil if value.nil?
|
80
123
|
value.to_i
|
81
124
|
end
|
82
125
|
|
83
126
|
def to_ruby(value)
|
127
|
+
return nil if value.nil?
|
84
128
|
value.to_i
|
85
129
|
end
|
86
130
|
end
|
@@ -94,10 +138,12 @@ module Neo4j
|
|
94
138
|
end
|
95
139
|
|
96
140
|
def to_java(value)
|
141
|
+
return nil if value.nil?
|
97
142
|
value.to_f
|
98
143
|
end
|
99
144
|
|
100
145
|
def to_ruby(value)
|
146
|
+
return nil if value.nil?
|
101
147
|
value.to_f
|
102
148
|
end
|
103
149
|
end
|
@@ -184,7 +230,10 @@ module Neo4j
|
|
184
230
|
end
|
185
231
|
|
186
232
|
# Always returns a converter that handles to_ruby or to_java
|
187
|
-
|
233
|
+
# if +enforce_type+ is set to false then it will raise in case of unknown type
|
234
|
+
# otherwise it will return the DevaultConverter.
|
235
|
+
def converter(type = nil, enforce_type = true)
|
236
|
+
return DefaultConverter unless type
|
188
237
|
@converters ||= begin
|
189
238
|
Neo4j::TypeConverters.constants.find_all do |c|
|
190
239
|
Neo4j::TypeConverters.const_get(c).respond_to?(:convert?)
|
@@ -192,14 +241,16 @@ module Neo4j
|
|
192
241
|
Neo4j::TypeConverters.const_get(c)
|
193
242
|
end
|
194
243
|
end
|
195
|
-
|
244
|
+
found = @converters.find {|c| c.convert?(type) }
|
245
|
+
raise "The type #{type.inspect} is unknown. Use one of #{@converters.map{|c| c.name.demodulize.sub('Converter','') }.join(", ")} or create a custom type converter." if !found && enforce_type
|
246
|
+
found or DefaultConverter
|
196
247
|
end
|
197
248
|
|
198
249
|
# Converts the given value to a Java type by using the registered converters.
|
199
250
|
# It just looks at the class of the given value unless an attribute name is given.
|
200
251
|
# It will convert it if there is a converter registered (in Neo4j::Config) for this value.
|
201
|
-
def convert(value, attribute = nil, klass = nil)
|
202
|
-
converter(attribute_type(value, attribute, klass)).to_java(value)
|
252
|
+
def convert(value, attribute = nil, klass = nil, enforce_type = true)
|
253
|
+
converter(attribute_type(value, attribute, klass), enforce_type).to_java(value)
|
203
254
|
end
|
204
255
|
|
205
256
|
# Converts the given property (key, value) to Java if there is a type converter for given type.
|
data/lib/neo4j/version.rb
CHANGED
data/lib/neo4j.rb
CHANGED
@@ -10,56 +10,9 @@ require 'active_support/core_ext/class/inheritable_attributes'
|
|
10
10
|
require 'active_support/core_ext/hash/indifferent_access'
|
11
11
|
require 'active_model'
|
12
12
|
|
13
|
-
require 'will_paginate/collection'
|
14
|
-
require 'will_paginate/finders/base'
|
15
|
-
|
16
13
|
# core extensions
|
17
14
|
require 'neo4j/core_ext/class/inheritable_attributes'
|
18
15
|
|
19
|
-
# Jars
|
20
|
-
|
21
|
-
require 'neo4j/jars/core/geronimo-jta_1.1_spec-1.1.1.jar'
|
22
|
-
require 'neo4j/jars/core/lucene-core-3.1.0.jar'
|
23
|
-
require 'neo4j/jars/core/neo4j-lucene-index-1.4.1.jar'
|
24
|
-
require 'neo4j/jars/core/neo4j-kernel-1.4.1.jar'
|
25
|
-
require 'neo4j/jars/ha/neo4j-management-1.4.1.jar'
|
26
|
-
require 'neo4j/jars/ha/neo4j-jmx-1.4.1.jar'
|
27
|
-
|
28
|
-
module Neo4j
|
29
|
-
|
30
|
-
def self.load_local_jars
|
31
|
-
# This is a temporary fix since the HA does not yet work with this JAR
|
32
|
-
# It will be solved in a future version of the Java Neo4j library.
|
33
|
-
if Neo4j.config[:online_backup_enabled]
|
34
|
-
Neo4j.load_online_backup
|
35
|
-
else
|
36
|
-
# backup and HA does not work with this JAR FILE
|
37
|
-
require 'neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.load_shell_jars
|
42
|
-
require 'neo4j/jars/ha/neo4j-shell-1.4.1.jar'
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.load_online_backup
|
46
|
-
require 'neo4j/jars/ha/neo4j-com-1.4.1.jar'
|
47
|
-
require 'neo4j/jars/core/neo4j-backup-1.4.1.jar'
|
48
|
-
require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
|
49
|
-
Neo4j.send(:const_set, :OnlineBackup, org.neo4j.backup.OnlineBackup)
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.load_ha_jars
|
53
|
-
require 'neo4j/jars/core/neo4j-backup-1.4.1.jar'
|
54
|
-
require 'neo4j/jars/ha/log4j-1.2.16.jar'
|
55
|
-
require 'neo4j/jars/ha/neo4j-ha-1.4.1.jar'
|
56
|
-
require 'neo4j/jars/ha/neo4j-com-1.4.1.jar'
|
57
|
-
require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
|
58
|
-
require 'neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar'
|
59
|
-
# require 'neo4j/jars/ha/org.apache.servicemix.bundles.lucene-3.0.1_2.jar' # TODO IS THIS NEEDED ?
|
60
|
-
require 'neo4j/jars/ha/zookeeper-3.3.2.jar'
|
61
|
-
end
|
62
|
-
end
|
63
16
|
|
64
17
|
module Neo4j
|
65
18
|
include Java
|
@@ -68,9 +21,10 @@ module Neo4j
|
|
68
21
|
Enumerator = Enumerable::Enumerator unless defined? Enumerator
|
69
22
|
end
|
70
23
|
|
24
|
+
require 'neo4j-community'
|
71
25
|
require 'neo4j/version'
|
72
26
|
require 'neo4j/neo4j'
|
73
|
-
require 'neo4j/
|
27
|
+
require 'neo4j/paginated'
|
74
28
|
require 'neo4j/node'
|
75
29
|
require 'neo4j/relationship'
|
76
30
|
require 'neo4j/relationship_set'
|
@@ -105,4 +59,4 @@ require 'neo4j/batch/batch'
|
|
105
59
|
|
106
60
|
require 'orm_adapter/adapters/neo4j'
|
107
61
|
|
108
|
-
require 'neo4j/identity_map'
|
62
|
+
require 'neo4j/identity_map'
|
data/neo4j.gemspec
CHANGED
@@ -24,13 +24,13 @@ It comes included with the Apache Lucene document database.
|
|
24
24
|
|
25
25
|
s.require_path = 'lib'
|
26
26
|
s.files = Dir.glob("{bin,lib,config}/**/*") + %w(README.rdoc CHANGELOG CONTRIBUTORS Gemfile neo4j.gemspec)
|
27
|
-
s.executables = ['neo4j-shell', 'neo4j-jars']
|
27
|
+
s.executables = ['neo4j-shell', 'neo4j-jars', 'neo4j-upgrade']
|
28
28
|
s.has_rdoc = true
|
29
29
|
s.extra_rdoc_files = %w( README.rdoc )
|
30
30
|
s.rdoc_options = ["--quiet", "--title", "Neo4j.rb", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
|
31
31
|
|
32
32
|
s.add_dependency('orm_adapter', ">= 0.0.3")
|
33
33
|
s.add_dependency("activemodel", ">= 3.0.0")
|
34
|
-
s.add_dependency("will_paginate", ["3.0.pre4"]) # should be ~>3.0 but it's API has changed '
|
35
34
|
s.add_dependency("railties", ">= 3.0.0")
|
35
|
+
s.add_dependency("neo4j-community", "1.6.0.alpha.6")
|
36
36
|
end
|