neo4j 1.0.0-java → 1.1.0.beta.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/CONTRIBUTORS +1 -0
  2. data/Gemfile +1 -0
  3. data/README.rdoc +1 -0
  4. data/lib/neo4j/algo/algo.rb +5 -5
  5. data/lib/neo4j/database.rb +1 -1
  6. data/lib/neo4j/has_n/class_methods.rb +5 -6
  7. data/lib/neo4j/has_n/decl_relationship_dsl.rb +32 -21
  8. data/lib/neo4j/has_n/mapping.rb +4 -5
  9. data/lib/neo4j/index/indexer.rb +21 -17
  10. data/lib/neo4j/index/indexer_registry.rb +1 -0
  11. data/lib/neo4j/index/lucene_query.rb +1 -1
  12. data/lib/neo4j/jars/core/neo4j-backup-1.3.jar +0 -0
  13. data/lib/neo4j/jars/core/{neo4j-graph-algo-1.3.M03.jar → neo4j-graph-algo-1.3.jar} +0 -0
  14. data/lib/neo4j/jars/core/neo4j-kernel-1.3.jar +0 -0
  15. data/lib/neo4j/jars/core/neo4j-lucene-index-1.3.jar +0 -0
  16. data/lib/neo4j/jars/ha/neo4j-com-1.3.jar +0 -0
  17. data/lib/neo4j/jars/ha/neo4j-ha-1.3.jar +0 -0
  18. data/lib/neo4j/jars/ha/neo4j-jmx-1.3.jar +0 -0
  19. data/lib/neo4j/jars/ha/neo4j-management-1.3.jar +0 -0
  20. data/lib/neo4j/jars/ha/{neo4j-shell-1.3.M03.jar → neo4j-shell-1.3.jar} +0 -0
  21. data/lib/neo4j/neo4j.rb +1 -1
  22. data/lib/neo4j/node.rb +2 -3
  23. data/lib/neo4j/node_mixin/node_mixin.rb +5 -0
  24. data/lib/neo4j/property/class_methods.rb +6 -10
  25. data/lib/neo4j/property/property.rb +0 -2
  26. data/lib/neo4j/rails/attributes.rb +10 -8
  27. data/lib/neo4j/rails/callbacks.rb +1 -1
  28. data/lib/neo4j/rails/finders.rb +1 -1
  29. data/lib/neo4j/rails/lucene_connection_closer.rb +1 -3
  30. data/lib/neo4j/rails/mapping/property.rb +112 -35
  31. data/lib/neo4j/rails/model.rb +10 -0
  32. data/lib/neo4j/rails/persistence.rb +10 -4
  33. data/lib/neo4j/rails/rails.rb +6 -2
  34. data/lib/neo4j/rails/rel_persistence.rb +231 -0
  35. data/lib/neo4j/rails/relationship.rb +126 -0
  36. data/lib/neo4j/rails/relationships/node_dsl.rb +91 -0
  37. data/lib/neo4j/rails/relationships/relationships.rb +47 -40
  38. data/lib/neo4j/rails/relationships/rels_dsl.rb +82 -0
  39. data/lib/neo4j/rails/relationships/storage.rb +161 -0
  40. data/lib/neo4j/rails/serialization.rb +1 -1
  41. data/lib/neo4j/rails/validations/associated.rb +53 -0
  42. data/lib/neo4j/rails/validations.rb +2 -3
  43. data/lib/neo4j/relationship.rb +3 -3
  44. data/lib/neo4j/relationship_mixin/relationship_mixin.rb +5 -1
  45. data/lib/neo4j/rels/traverser.rb +12 -12
  46. data/lib/neo4j/rule/rule_node.rb +2 -1
  47. data/lib/neo4j/to_java.rb +0 -4
  48. data/lib/neo4j/traversal/traverser.rb +24 -3
  49. data/lib/neo4j/type_converters/type_converters.rb +59 -6
  50. data/lib/neo4j/version.rb +1 -1
  51. data/lib/neo4j.rb +10 -8
  52. metadata +21 -16
  53. data/lib/neo4j/jars/core/neo4j-backup-1.3.M03.jar +0 -0
  54. data/lib/neo4j/jars/core/neo4j-kernel-1.3.M03.jar +0 -0
  55. data/lib/neo4j/jars/core/neo4j-lucene-index-1.3.M03.jar +0 -0
  56. data/lib/neo4j/jars/ha/neo4j-com-1.3.M03.jar +0 -0
  57. data/lib/neo4j/jars/ha/neo4j-ha-1.3.M03.jar +0 -0
  58. data/lib/neo4j/jars/ha/neo4j-management-1.3.M03.jar +0 -0
  59. data/lib/neo4j/rails/relationships/mapper.rb +0 -103
  60. data/lib/neo4j/rails/relationships/relationship.rb +0 -30
@@ -57,7 +57,7 @@ module Neo4j
57
57
  when org.neo4j.graphdb.Direction::OUTGOING
58
58
  @from.create_relationship_to(other_node, @type)
59
59
  when org.neo4j.graphdb.Direction::INCOMING
60
- other_node._java_node.create_relationship_to(@from, @type)
60
+ other_node.create_relationship_to(@from, @type)
61
61
  else
62
62
  raise "Only allowed to create outgoing or incoming relationships (not #@dir)"
63
63
  end
@@ -149,7 +149,7 @@ module Neo4j
149
149
  end
150
150
 
151
151
  def each
152
- iterator.each { |i| yield i.wrapper }
152
+ @traversal_result == :paths ? iterator.each { |i| yield i } : iterator.each { |i| yield i.wrapper }
153
153
  end
154
154
 
155
155
  # Same as #each but does not wrap each node in a Ruby class, yields the Java Neo4j Node instance instead.
@@ -157,6 +157,20 @@ module Neo4j
157
157
  iterator.each { |i| yield i }
158
158
  end
159
159
 
160
+ # Returns an enumerable of relationships instead of nodes
161
+ #
162
+ def rels
163
+ @traversal_result = :rels
164
+ self
165
+ end
166
+
167
+ # Returns an enumerable of relationships instead of nodes
168
+ #
169
+ def paths
170
+ @traversal_result = :paths
171
+ self
172
+ end
173
+
160
174
  def iterator
161
175
  unless @include_start_node
162
176
  if @filter_predicate
@@ -166,7 +180,14 @@ module Neo4j
166
180
  end
167
181
  end
168
182
  @td = @td.prune(org.neo4j.kernel.Traversal.pruneAfterDepth(@depth)) unless @depth == :all
169
- @td.traverse(@from).nodes
183
+ if @traversal_result == :rels
184
+ @td.traverse(@from._java_node).relationships
185
+ elsif @traversal_result == :paths
186
+ @td.traverse(@from._java_node).iterator
187
+ else
188
+ @td.traverse(@from._java_node).nodes
189
+ end
190
+
170
191
  end
171
192
  end
172
193
  end
@@ -50,12 +50,65 @@ module Neo4j
50
50
  end
51
51
  end
52
52
 
53
+
54
+ class BooleanConverter
55
+ class << self
56
+
57
+ def convert?(class_or_symbol)
58
+ :boolean == class_or_symbol
59
+ end
60
+
61
+ def to_java(value)
62
+ !!value && value != '0'
63
+ end
64
+
65
+ def to_ruby(value)
66
+ !!value && value != '0'
67
+ end
68
+ end
69
+ end
70
+
71
+
72
+ class FixnumConverter
73
+ class << self
74
+
75
+ def convert?(class_or_symbol)
76
+ Fixnum == class_or_symbol || :fixnum == class_or_symbol
77
+ end
78
+
79
+ def to_java(value)
80
+ value.to_i
81
+ end
82
+
83
+ def to_ruby(value)
84
+ value.to_i
85
+ end
86
+ end
87
+ end
88
+
89
+ class FloatConverter
90
+ class << self
91
+
92
+ def convert?(clazz_or_symbol)
93
+ Float == clazz_or_symbol || :float == clazz_or_symbol
94
+ end
95
+
96
+ def to_java(value)
97
+ value.to_f
98
+ end
99
+
100
+ def to_ruby(value)
101
+ value.to_f
102
+ end
103
+ end
104
+ end
105
+
53
106
  # Converts Date objects to Java long types. Must be timezone UTC.
54
107
  class DateConverter
55
108
  class << self
56
109
 
57
- def convert?(clazz)
58
- Date == clazz
110
+ def convert?(clazz_or_symbol)
111
+ Date == clazz_or_symbol || :date == clazz_or_symbol
59
112
  end
60
113
 
61
114
  def to_java(value)
@@ -74,8 +127,8 @@ module Neo4j
74
127
  class DateTimeConverter
75
128
  class << self
76
129
 
77
- def convert?(clazz)
78
- DateTime == clazz
130
+ def convert?(clazz_or_symbol)
131
+ DateTime == clazz_or_symbol || :datetime == clazz_or_symbol
79
132
  end
80
133
 
81
134
  # Converts the given DateTime (UTC) value to an Fixnum.
@@ -96,8 +149,8 @@ module Neo4j
96
149
  class TimeConverter
97
150
  class << self
98
151
 
99
- def convert?(clazz)
100
- Time == clazz
152
+ def convert?(clazz_or_symbol)
153
+ Time == clazz_or_symbol || :time == clazz_or_symbol
101
154
  end
102
155
 
103
156
  # Converts the given DateTime (UTC) value to an Fixnum.
data/lib/neo4j/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0.beta.1"
3
3
  end
data/lib/neo4j.rb CHANGED
@@ -13,9 +13,10 @@ require 'will_paginate/finders/base'
13
13
 
14
14
  require 'neo4j/jars/core/geronimo-jta_1.1_spec-1.1.1.jar'
15
15
  require 'neo4j/jars/core/lucene-core-3.0.3.jar'
16
- require 'neo4j/jars/core/neo4j-lucene-index-1.3.M03.jar'
17
- require 'neo4j/jars/core/neo4j-kernel-1.3.M03.jar'
18
- require 'neo4j/jars/ha/neo4j-management-1.3.M03.jar'
16
+ require 'neo4j/jars/core/neo4j-lucene-index-1.3.jar'
17
+ require 'neo4j/jars/core/neo4j-kernel-1.3.jar'
18
+ require 'neo4j/jars/ha/neo4j-management-1.3.jar'
19
+ require 'neo4j/jars/ha/neo4j-jmx-1.3.jar'
19
20
 
20
21
  module Neo4j
21
22
 
@@ -31,20 +32,21 @@ module Neo4j
31
32
  end
32
33
 
33
34
  def self.load_shell_jars
34
- require 'neo4j/jars/ha/neo4j-shell-1.3.M03.jar'
35
+ require 'neo4j/jars/ha/neo4j-shell-1.3.jar'
35
36
  end
36
37
 
37
38
  def self.load_online_backup
38
- require 'neo4j/jars/ha/neo4j-com-1.3.M03.jar'
39
- require 'neo4j/jars/core/neo4j-backup-1.3.M03.jar'
39
+ require 'neo4j/jars/ha/neo4j-com-1.3.jar'
40
+ require 'neo4j/jars/core/neo4j-backup-1.3.jar'
40
41
  require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
41
42
  Neo4j.send(:const_set, :OnlineBackup, org.neo4j.backup.OnlineBackup)
42
43
  end
43
44
 
44
45
  def self.load_ha_jars
46
+ require 'neo4j/jars/core/neo4j-backup-1.3.jar'
45
47
  require 'neo4j/jars/ha/log4j-1.2.16.jar'
46
- require 'neo4j/jars/ha/neo4j-ha-1.3.M03.jar'
47
- require 'neo4j/jars/ha/neo4j-com-1.3.M03.jar'
48
+ require 'neo4j/jars/ha/neo4j-ha-1.3.jar'
49
+ require 'neo4j/jars/ha/neo4j-com-1.3.jar'
48
50
  require 'neo4j/jars/ha/netty-3.2.1.Final.jar'
49
51
  require 'neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar'
50
52
  require 'neo4j/jars/ha/org.apache.servicemix.bundles.lucene-3.0.1_2.jar'
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.0
4
+ prerelease: 6
5
+ version: 1.1.0.beta.1
6
6
  platform: java
7
7
  authors:
8
8
  - Andreas Ronge
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-02 00:00:00 +01:00
13
+ date: 2011-04-28 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -128,29 +128,34 @@ files:
128
128
  - lib/neo4j/rails/timestamps.rb
129
129
  - lib/neo4j/rails/callbacks.rb
130
130
  - lib/neo4j/rails/tx_methods.rb
131
+ - lib/neo4j/rails/rel_persistence.rb
131
132
  - lib/neo4j/rails/finders.rb
132
- - lib/neo4j/rails/relationships/mapper.rb
133
+ - lib/neo4j/rails/relationship.rb
134
+ - lib/neo4j/rails/relationships/rels_dsl.rb
135
+ - lib/neo4j/rails/relationships/node_dsl.rb
133
136
  - lib/neo4j/rails/relationships/relationships.rb
134
- - lib/neo4j/rails/relationships/relationship.rb
137
+ - lib/neo4j/rails/relationships/storage.rb
135
138
  - lib/neo4j/rails/mapping/property.rb
139
+ - lib/neo4j/rails/validations/associated.rb
136
140
  - lib/neo4j/rails/validations/uniqueness.rb
137
141
  - lib/neo4j/rails/validations/non_nil.rb
138
142
  - lib/neo4j/jars/core/lucene-core-3.0.3.jar
139
- - lib/neo4j/jars/core/neo4j-backup-1.3.M03.jar
140
- - lib/neo4j/jars/core/neo4j-kernel-1.3.M03.jar
143
+ - lib/neo4j/jars/core/neo4j-backup-1.3.jar
141
144
  - lib/neo4j/jars/core/geronimo-jta_1.1_spec-1.1.1.jar
142
- - lib/neo4j/jars/core/neo4j-graph-algo-1.3.M03.jar
143
- - lib/neo4j/jars/core/neo4j-lucene-index-1.3.M03.jar
145
+ - lib/neo4j/jars/core/neo4j-lucene-index-1.3.jar
146
+ - lib/neo4j/jars/core/neo4j-graph-algo-1.3.jar
147
+ - lib/neo4j/jars/core/neo4j-kernel-1.3.jar
144
148
  - lib/neo4j/jars/core/neo4j-index-1.3-1.3.M01.jar
145
- - lib/neo4j/jars/ha/neo4j-shell-1.3.M03.jar
146
149
  - lib/neo4j/jars/ha/org.apache.servicemix.bundles.lucene-3.0.1_2.jar
147
150
  - lib/neo4j/jars/ha/zookeeper-3.3.2.jar
148
151
  - lib/neo4j/jars/ha/netty-3.2.1.Final.jar
149
152
  - lib/neo4j/jars/ha/log4j-1.2.16.jar
150
- - lib/neo4j/jars/ha/neo4j-com-1.3.M03.jar
151
- - lib/neo4j/jars/ha/neo4j-management-1.3.M03.jar
153
+ - lib/neo4j/jars/ha/neo4j-ha-1.3.jar
154
+ - lib/neo4j/jars/ha/neo4j-com-1.3.jar
155
+ - lib/neo4j/jars/ha/neo4j-management-1.3.jar
156
+ - lib/neo4j/jars/ha/neo4j-shell-1.3.jar
157
+ - lib/neo4j/jars/ha/neo4j-jmx-1.3.jar
152
158
  - lib/neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar
153
- - lib/neo4j/jars/ha/neo4j-ha-1.3.M03.jar
154
159
  - lib/neo4j/index/indexer.rb
155
160
  - lib/neo4j/index/lucene_query.rb
156
161
  - lib/neo4j/index/indexer_registry.rb
@@ -206,13 +211,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
211
  required_rubygems_version: !ruby/object:Gem::Requirement
207
212
  none: false
208
213
  requirements:
209
- - - ">="
214
+ - - ">"
210
215
  - !ruby/object:Gem::Version
211
- version: "0"
216
+ version: 1.3.1
212
217
  requirements: []
213
218
 
214
219
  rubyforge_project: neo4j
215
- rubygems_version: 1.5.0
220
+ rubygems_version: 1.5.1
216
221
  signing_key:
217
222
  specification_version: 3
218
223
  summary: A graph database for JRuby
Binary file
@@ -1,103 +0,0 @@
1
- module Neo4j
2
- module Rails
3
- module Relationships
4
-
5
- class Mapper #:nodoc:
6
- attr_reader :dsl
7
-
8
- def initialize(rel_type, dsl, node)
9
- @rel_type = rel_type
10
- @relationships = []
11
- @dsl = dsl
12
- @node = node
13
- end
14
-
15
- def rel_type
16
- (@dsl && @dsl.rel_type) || @rel_type
17
- end
18
-
19
- def direction
20
- (@dsl && @dsl.direction) || :outgoing
21
- end
22
-
23
- def to_s #:nodoc:
24
- "#{self.class} #{object_id} dir: #{direction} rel_type: #{@rel_type} wrapped #{@dsl}"
25
- end
26
-
27
- def single_relationship(*)
28
- use_persisted_rels? ? @dsl.single_relationship(@node) : @relationships.first
29
- end
30
-
31
- def all_relationships(*)
32
- if use_persisted_rels?
33
- @dsl.all_relationships(@node)
34
- else
35
- @relationships
36
- end
37
- end
38
-
39
- def each_node(node, direction, &block)
40
- if use_persisted_rels?
41
- @dsl.each_node(node, direction, &block)
42
- else
43
- # TODO direction
44
- @relationships.each do |rel|
45
- block.call rel.end_node
46
- end
47
- end
48
- end
49
-
50
- def use_persisted_rels?
51
- @relationships.empty? && @node.persisted?
52
- end
53
-
54
- def del_rel(rel)
55
- @relationships.delete(rel)
56
- end
57
-
58
- def create_relationship_to(from, to)
59
- @relationships << Relationship.new(@rel_type, from, to, self)
60
- end
61
-
62
-
63
- def single_node(from)
64
- if !@relationships.empty?
65
- @relationships.first.end_node
66
- else
67
- @dsl.single_node(from) if @dsl && from.persisted?
68
- end
69
- end
70
-
71
- def valid?
72
- all_valid = true
73
- !@relationships.each do |rel|
74
- start_node = rel.start_node
75
- end_node = rel.end_node
76
-
77
- if !end_node.valid?
78
- all_valid = false
79
- start_node.errors[@rel_type.to_sym] ||= []
80
- start_node.errors[@rel_type.to_sym] << end_node.errors
81
- end
82
- end
83
- all_valid
84
- end
85
-
86
- def persist
87
- @relationships.each do |rel|
88
- if @dsl
89
- start_node = rel.start_node
90
- end_node = rel.end_node
91
-
92
- end_node.save!
93
- @dsl.create_relationship_to(start_node, end_node)
94
- else
95
- rel.end_node.save!
96
- rel.start_node.outgoing(@rel_type) << rel.end_node
97
- end
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
@@ -1,30 +0,0 @@
1
- module Neo4j
2
- module Rails
3
- module Relationships
4
-
5
- class Relationship
6
- attr_reader :rel_type, :start_node, :end_node
7
-
8
-
9
- def initialize(rel_type, start_node, end_node, decl)
10
- @rel_type = rel_type
11
- @start_node = start_node
12
- @end_node = end_node
13
- @decl = decl
14
- end
15
-
16
- def del
17
- @decl.del_rel(self)
18
- end
19
-
20
- def persist
21
- @start_node._java
22
- end
23
-
24
- def to_s
25
- "Rel [#{rel_type} start #{start_node} end #{end_node}]"
26
- end
27
- end
28
- end
29
- end
30
- end