neo4j 1.0.0-java → 1.1.0.beta.1-java
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.
- data/CONTRIBUTORS +1 -0
- data/Gemfile +1 -0
- data/README.rdoc +1 -0
- data/lib/neo4j/algo/algo.rb +5 -5
- data/lib/neo4j/database.rb +1 -1
- data/lib/neo4j/has_n/class_methods.rb +5 -6
- data/lib/neo4j/has_n/decl_relationship_dsl.rb +32 -21
- data/lib/neo4j/has_n/mapping.rb +4 -5
- data/lib/neo4j/index/indexer.rb +21 -17
- data/lib/neo4j/index/indexer_registry.rb +1 -0
- data/lib/neo4j/index/lucene_query.rb +1 -1
- data/lib/neo4j/jars/core/neo4j-backup-1.3.jar +0 -0
- data/lib/neo4j/jars/core/{neo4j-graph-algo-1.3.M03.jar → neo4j-graph-algo-1.3.jar} +0 -0
- data/lib/neo4j/jars/core/neo4j-kernel-1.3.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-lucene-index-1.3.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-com-1.3.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-ha-1.3.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-jmx-1.3.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-management-1.3.jar +0 -0
- data/lib/neo4j/jars/ha/{neo4j-shell-1.3.M03.jar → neo4j-shell-1.3.jar} +0 -0
- data/lib/neo4j/neo4j.rb +1 -1
- data/lib/neo4j/node.rb +2 -3
- data/lib/neo4j/node_mixin/node_mixin.rb +5 -0
- data/lib/neo4j/property/class_methods.rb +6 -10
- data/lib/neo4j/property/property.rb +0 -2
- data/lib/neo4j/rails/attributes.rb +10 -8
- data/lib/neo4j/rails/callbacks.rb +1 -1
- data/lib/neo4j/rails/finders.rb +1 -1
- data/lib/neo4j/rails/lucene_connection_closer.rb +1 -3
- data/lib/neo4j/rails/mapping/property.rb +112 -35
- data/lib/neo4j/rails/model.rb +10 -0
- data/lib/neo4j/rails/persistence.rb +10 -4
- data/lib/neo4j/rails/rails.rb +6 -2
- data/lib/neo4j/rails/rel_persistence.rb +231 -0
- data/lib/neo4j/rails/relationship.rb +126 -0
- data/lib/neo4j/rails/relationships/node_dsl.rb +91 -0
- data/lib/neo4j/rails/relationships/relationships.rb +47 -40
- data/lib/neo4j/rails/relationships/rels_dsl.rb +82 -0
- data/lib/neo4j/rails/relationships/storage.rb +161 -0
- data/lib/neo4j/rails/serialization.rb +1 -1
- data/lib/neo4j/rails/validations/associated.rb +53 -0
- data/lib/neo4j/rails/validations.rb +2 -3
- data/lib/neo4j/relationship.rb +3 -3
- data/lib/neo4j/relationship_mixin/relationship_mixin.rb +5 -1
- data/lib/neo4j/rels/traverser.rb +12 -12
- data/lib/neo4j/rule/rule_node.rb +2 -1
- data/lib/neo4j/to_java.rb +0 -4
- data/lib/neo4j/traversal/traverser.rb +24 -3
- data/lib/neo4j/type_converters/type_converters.rb +59 -6
- data/lib/neo4j/version.rb +1 -1
- data/lib/neo4j.rb +10 -8
- metadata +21 -16
- data/lib/neo4j/jars/core/neo4j-backup-1.3.M03.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-kernel-1.3.M03.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-lucene-index-1.3.M03.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-com-1.3.M03.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-ha-1.3.M03.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-management-1.3.M03.jar +0 -0
- data/lib/neo4j/rails/relationships/mapper.rb +0 -103
- data/lib/neo4j/rails/relationships/relationship.rb +0 -30
data/CONTRIBUTORS
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -12,6 +12,7 @@ It uses two powerful and mature Java libraries:
|
|
12
12
|
=== Documentation
|
13
13
|
|
14
14
|
* {Guides and API}[http://neo4j.rubyforge.org/guides/index.html]
|
15
|
+
* {Blog: Neo4j and Rails 3}[http://blog.jayway.com/2011/03/02/neo4j-rb-1-0-0-and-rails-3/]
|
15
16
|
|
16
17
|
=== Why Neo4j.rb or a Graph Database ?
|
17
18
|
|
data/lib/neo4j/algo/algo.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# external neo4j dependencies
|
2
2
|
require 'neo4j/to_java'
|
3
|
-
require 'neo4j/jars/core/neo4j-graph-algo-1.3.
|
3
|
+
require 'neo4j/jars/core/neo4j-graph-algo-1.3.jar'
|
4
4
|
|
5
5
|
module Neo4j
|
6
6
|
|
@@ -162,14 +162,14 @@ module Neo4j
|
|
162
162
|
self
|
163
163
|
end
|
164
164
|
|
165
|
-
# Specifies that nodes should be returned from as result
|
165
|
+
# Specifies that nodes should be returned from as result
|
166
166
|
# See also #rels
|
167
167
|
def nodes
|
168
168
|
@path_finder_method = :nodes
|
169
169
|
self
|
170
170
|
end
|
171
171
|
|
172
|
-
# Specifies that relationships should be returned from as result
|
172
|
+
# Specifies that relationships should be returned from as result
|
173
173
|
# See also #nodes
|
174
174
|
#
|
175
175
|
def rels
|
@@ -184,8 +184,8 @@ module Neo4j
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def each(&block) #:nodoc:
|
187
|
-
if @single
|
188
|
-
execute_algo.send(@path_finder_method
|
187
|
+
if @single && @path_finder_method
|
188
|
+
execute_algo.send(@path_finder_method).each &block
|
189
189
|
else
|
190
190
|
execute_algo.each &block
|
191
191
|
end
|
data/lib/neo4j/database.rb
CHANGED
@@ -110,7 +110,7 @@ module Neo4j
|
|
110
110
|
|
111
111
|
|
112
112
|
def management(jmx_clazz) #:nodoc:
|
113
|
-
@neo4j_manager ||= org.neo4j.management.Neo4jManager.new(@graph.get_management_bean(org.neo4j.
|
113
|
+
@neo4j_manager ||= org.neo4j.management.Neo4jManager.new(@graph.get_management_bean(org.neo4j.jmx.Kernel.java_class))
|
114
114
|
@neo4j_manager.getBean(jmx_clazz.java_class)
|
115
115
|
end
|
116
116
|
|
@@ -47,7 +47,7 @@ module Neo4j
|
|
47
47
|
# * This method returns Neo4j::HasN::DeclRelationshipDsl
|
48
48
|
# * The generated has_n method returns a Neo4j::HasN::Mapping object
|
49
49
|
#
|
50
|
-
def has_n(rel_type
|
50
|
+
def has_n(rel_type)
|
51
51
|
clazz = self
|
52
52
|
module_eval(%Q{
|
53
53
|
def #{rel_type}
|
@@ -67,7 +67,7 @@ module Neo4j
|
|
67
67
|
_decl_rels[:#{rel_type}].rel_type.to_s
|
68
68
|
end}, __FILE__, __LINE__)
|
69
69
|
|
70
|
-
_decl_rels[rel_type.to_sym] = DeclRelationshipDsl.new(rel_type, false, clazz
|
70
|
+
_decl_rels[rel_type.to_sym] = DeclRelationshipDsl.new(rel_type, false, clazz)
|
71
71
|
end
|
72
72
|
|
73
73
|
|
@@ -92,7 +92,7 @@ module Neo4j
|
|
92
92
|
#
|
93
93
|
# Neo4j::HasN::DeclRelationshipDsl
|
94
94
|
#
|
95
|
-
def has_one(rel_type
|
95
|
+
def has_one(rel_type)
|
96
96
|
clazz = self
|
97
97
|
module_eval(%Q{def #{rel_type}=(value)
|
98
98
|
dsl = _decl_rels_for(:#{rel_type})
|
@@ -107,12 +107,11 @@ module Neo4j
|
|
107
107
|
end}, __FILE__, __LINE__)
|
108
108
|
|
109
109
|
module_eval(%Q{def #{rel_type}_rel
|
110
|
-
|
111
|
-
dsl = #{clazz}._decl_rels[:'#{rel_type.to_s}']
|
110
|
+
dsl = _decl_rels_for(:#{rel_type})
|
112
111
|
dsl.single_relationship(self)
|
113
112
|
end}, __FILE__, __LINE__)
|
114
113
|
|
115
|
-
_decl_rels[rel_type.to_sym] = DeclRelationshipDsl.new(rel_type, true, clazz
|
114
|
+
_decl_rels[rel_type.to_sym] = DeclRelationshipDsl.new(rel_type, true, clazz)
|
116
115
|
end
|
117
116
|
|
118
117
|
end
|
@@ -34,10 +34,10 @@ module Neo4j
|
|
34
34
|
class DeclRelationshipDsl
|
35
35
|
include Neo4j::ToJava
|
36
36
|
|
37
|
-
attr_reader :target_class, :
|
37
|
+
attr_reader :target_class, :dir, :rel_type
|
38
38
|
|
39
|
-
def initialize(method_id, has_one, target_class
|
40
|
-
@
|
39
|
+
def initialize(method_id, has_one, target_class)
|
40
|
+
@dir = :outgoing
|
41
41
|
@method_id = method_id
|
42
42
|
@has_one = has_one
|
43
43
|
@rel_type = method_id
|
@@ -45,24 +45,39 @@ module Neo4j
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def to_s
|
48
|
-
"DeclRelationshipDsl #{object_id} dir: #{@
|
48
|
+
"DeclRelationshipDsl #{object_id} dir: #{@dir} rel_id: #{@method_id}, rel_type: #{@rel_type}, target_class:#{@target_class} rel_class:#{@relationship}"
|
49
49
|
end
|
50
50
|
|
51
51
|
def has_one?
|
52
52
|
@has_one
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
def has_n?
|
56
|
+
!@has_one
|
57
|
+
end
|
58
|
+
|
59
|
+
def java_rel_type
|
60
|
+
type_to_java(@rel_type)
|
61
|
+
end
|
62
|
+
|
63
|
+
def java_dir
|
64
|
+
dir_to_java(@dir)
|
65
|
+
end
|
66
|
+
|
67
|
+
def each_node(node, &block) #:nodoc:
|
68
|
+
node._java_node.getRelationships(java_rel_type, java_dir).each do |rel|
|
69
|
+
block.call(rel.getOtherNode(node).wrapper)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def _each_node(node, &block) #:nodoc:
|
74
|
+
node._java_node.getRelationships(java_rel_type, java_dir).each do |rel|
|
75
|
+
block.call rel.getOtherNode(node)
|
61
76
|
end
|
62
77
|
end
|
63
78
|
|
64
79
|
def incoming? #:nodoc:
|
65
|
-
@
|
80
|
+
@dir == :incoming
|
66
81
|
end
|
67
82
|
|
68
83
|
def single_node(node) #:nodoc:
|
@@ -71,24 +86,20 @@ module Neo4j
|
|
71
86
|
end
|
72
87
|
|
73
88
|
def single_relationship(node) #:nodoc:
|
74
|
-
node._java_node.rel(
|
89
|
+
node._java_node.rel(dir, rel_type)
|
75
90
|
end
|
76
91
|
|
77
92
|
def _all_relationships(node) #:nodoc:
|
78
|
-
|
79
|
-
dir = dir_to_java(direction)
|
80
|
-
node._java_node.getRelationships(type, dir)
|
93
|
+
node._java_node.getRelationships(java_rel_type, java_dir)
|
81
94
|
end
|
82
95
|
|
83
96
|
def all_relationships(node) #:nodoc:
|
84
|
-
Neo4j::Rels::Traverser.new(node._java_node, [rel_type],
|
97
|
+
Neo4j::Rels::Traverser.new(node._java_node, [rel_type], dir)
|
85
98
|
end
|
86
99
|
|
87
100
|
def create_relationship_to(node, other) # :nodoc:
|
88
101
|
from, to = incoming? ? [other, node] : [node, other]
|
89
|
-
|
90
|
-
|
91
|
-
rel = from._java_node.create_relationship_to(to._java_node, java_type)
|
102
|
+
rel = from._java_node.create_relationship_to(to._java_node, java_rel_type)
|
92
103
|
rel[:_classname] = relationship_class.to_s if relationship_class
|
93
104
|
rel.wrapper
|
94
105
|
end
|
@@ -122,7 +133,7 @@ module Neo4j
|
|
122
133
|
# folder.files << FolderNode.new
|
123
134
|
#
|
124
135
|
def to(target)
|
125
|
-
@
|
136
|
+
@dir = :outgoing
|
126
137
|
|
127
138
|
if (Class === target)
|
128
139
|
# handle e.g. has_n(:friends).to(class)
|
@@ -174,7 +185,7 @@ module Neo4j
|
|
174
185
|
#
|
175
186
|
#
|
176
187
|
def from(*args)
|
177
|
-
@
|
188
|
+
@dir = :incoming
|
178
189
|
|
179
190
|
if (args.size > 1)
|
180
191
|
# handle specified (prefixed) relationship, e.g. has_n(:known_by).from(clazz, :type)
|
data/lib/neo4j/has_n/mapping.rb
CHANGED
@@ -22,12 +22,11 @@ module Neo4j
|
|
22
22
|
|
23
23
|
def initialize(node, dsl) # :nodoc:
|
24
24
|
@node = node
|
25
|
-
@direction = dsl.direction
|
26
25
|
@dsl = dsl
|
27
26
|
end
|
28
27
|
|
29
28
|
def to_s
|
30
|
-
"HasN::Mapping [
|
29
|
+
"HasN::Mapping [#{@dsl.dir}, id: #{@node.neo_id} type: #{@dsl && @dsl.rel_type} dsl:#{@dsl}]"
|
31
30
|
end
|
32
31
|
|
33
32
|
def size
|
@@ -43,7 +42,7 @@ module Neo4j
|
|
43
42
|
nil # out of index
|
44
43
|
end
|
45
44
|
|
46
|
-
# Pretend we are an array - this is
|
45
|
+
# Pretend we are an array - this is necessarily for Rails actionpack/actionview/formhelper to work with this
|
47
46
|
def is_a?(type)
|
48
47
|
# ActionView requires this for nested attributes to work
|
49
48
|
return true if Array == type
|
@@ -52,12 +51,12 @@ module Neo4j
|
|
52
51
|
|
53
52
|
# Required by the Enumerable mixin.
|
54
53
|
def each(&block)
|
55
|
-
@dsl.each_node(@node,
|
54
|
+
@dsl.each_node(@node, &block)
|
56
55
|
end
|
57
56
|
|
58
57
|
# returns none wrapped nodes, you may get better performance using this method
|
59
58
|
def _each(&block)
|
60
|
-
@dsl.
|
59
|
+
@dsl._each_node(@node, &block)
|
61
60
|
end
|
62
61
|
|
63
62
|
# Returns an real ruby array.
|
data/lib/neo4j/index/indexer.rb
CHANGED
@@ -68,8 +68,8 @@ module Neo4j
|
|
68
68
|
# Example:
|
69
69
|
# class Person
|
70
70
|
# include Neo4j::NodeMixin
|
71
|
-
# property :weight, :type => Float
|
72
|
-
# index :weight
|
71
|
+
# property :height, :weight, :type => Float
|
72
|
+
# index :height, :weight
|
73
73
|
# end
|
74
74
|
#
|
75
75
|
# Supported values for <tt>:type</tt> is <tt>String</tt>, <tt>Float</tt>, <tt>Date</tt>, <tt>DateTime</tt> and <tt>Fixnum</tt>
|
@@ -78,19 +78,23 @@ module Neo4j
|
|
78
78
|
# * See Neo4j::Index::LuceneQuery
|
79
79
|
# * See #find
|
80
80
|
#
|
81
|
-
def index(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
81
|
+
def index(*args)
|
82
|
+
conf = args.last.kind_of?(Hash) ? args.pop : {}
|
83
|
+
conf_no_via = conf.reject { |k,v| k == :via } # avoid endless recursion
|
84
|
+
|
85
|
+
args.uniq.each do | field |
|
86
|
+
if conf[:via]
|
87
|
+
rel_dsl = @indexer_for._decl_rels[conf[:via]]
|
88
|
+
raise "No relationship defined for '#{conf[:via]}'. Check class '#{@indexer_for}': index :#{field}, via=>:#{conf[:via]} <-- error. Define it with a has_one or has_n" unless rel_dsl
|
89
|
+
raise "Only incoming relationship are possible to define index on. Check class '#{@indexer_for}': index :#{field}, via=>:#{conf[:via]}" unless rel_dsl.incoming?
|
90
|
+
via_indexer = rel_dsl.target_class._indexer
|
91
|
+
|
92
|
+
field = field.to_s
|
93
|
+
@via_relationships[field] = rel_dsl
|
94
|
+
via_indexer.index(field, conf_no_via)
|
95
|
+
else
|
96
|
+
@field_types[field.to_s] = conf[:type] || :exact
|
97
|
+
end
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
@@ -197,9 +201,9 @@ module Neo4j
|
|
197
201
|
return value unless type
|
198
202
|
|
199
203
|
if String != type
|
200
|
-
org.neo4j.index.
|
204
|
+
org.neo4j.index.lucene.ValueContext.new(value).indexNumeric
|
201
205
|
else
|
202
|
-
org.neo4j.index.
|
206
|
+
org.neo4j.index.lucene.ValueContext.new(value)
|
203
207
|
end
|
204
208
|
end
|
205
209
|
|
@@ -196,7 +196,7 @@ module Neo4j
|
|
196
196
|
memo << org.apache.lucene.search.SortField.new(field.to_s, type, @order[field])
|
197
197
|
end
|
198
198
|
sort = org.apache.lucene.search.Sort.new(*java_sort_fields)
|
199
|
-
org.neo4j.index.
|
199
|
+
org.neo4j.index.lucene.QueryContext.new(query).sort(sort)
|
200
200
|
end
|
201
201
|
|
202
202
|
def build_hash_query(query) #:nodoc:
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/neo4j/neo4j.rb
CHANGED
@@ -147,7 +147,7 @@ module Neo4j
|
|
147
147
|
# jmx_clazz :: http://api.neo4j.org/current/org/neo4j/management/package-summary.html
|
148
148
|
# this_db :: default currently runnig instance or a newly started neo4j db instance
|
149
149
|
#
|
150
|
-
def management(jmx_clazz = org.neo4j.
|
150
|
+
def management(jmx_clazz = org.neo4j.jmx.Primitives, this_db = self.started_db)
|
151
151
|
this_db.management(jmx_clazz)
|
152
152
|
end
|
153
153
|
|
data/lib/neo4j/node.rb
CHANGED
@@ -151,13 +151,12 @@ module Neo4j
|
|
151
151
|
#
|
152
152
|
def load(node_id, db = Neo4j.started_db)
|
153
153
|
node = _load(node_id, db)
|
154
|
-
|
155
|
-
node.wrapper
|
154
|
+
node && node.wrapper
|
156
155
|
end
|
157
156
|
|
158
157
|
# Same as load but does not return the node as a wrapped Ruby object.
|
159
158
|
#
|
160
|
-
def _load(node_id, db)
|
159
|
+
def _load(node_id, db = Neo4j.started_db)
|
161
160
|
return nil if node_id.nil?
|
162
161
|
db.graph.get_node_by_id(node_id.to_i)
|
163
162
|
rescue java.lang.IllegalStateException
|
@@ -76,6 +76,11 @@ module Neo4j
|
|
76
76
|
@_java_node
|
77
77
|
end
|
78
78
|
|
79
|
+
# same as _java_node - so that we can use the same method for both relationships and nodes
|
80
|
+
def _java_entity
|
81
|
+
@_java_node
|
82
|
+
end
|
83
|
+
|
79
84
|
# Trigger rules.
|
80
85
|
# You don't normally need to call this method (except in Migration) since
|
81
86
|
# it will be triggered automatically by the Neo4j::Rule::Rule
|
@@ -40,18 +40,14 @@ module Neo4j
|
|
40
40
|
# :to_java in the Neo4j::TypeConverters module.
|
41
41
|
#
|
42
42
|
def property(*props)
|
43
|
-
|
44
|
-
props[1].each_pair do |key, value|
|
45
|
-
pname = props[0].to_sym
|
46
|
-
_decl_props[pname] ||= {}
|
47
|
-
_decl_props[pname][key] = value
|
48
|
-
end
|
49
|
-
props = props[0..0]
|
50
|
-
end
|
43
|
+
options = props.last.kind_of?(Hash) ? props.pop : {}
|
51
44
|
|
52
|
-
props.each do |prop|
|
45
|
+
props.uniq.each do |prop|
|
53
46
|
pname = prop.to_sym
|
54
47
|
_decl_props[pname] ||= {}
|
48
|
+
options.each do |key, value|
|
49
|
+
_decl_props[pname][key] = value
|
50
|
+
end
|
55
51
|
|
56
52
|
define_method(pname) do
|
57
53
|
Neo4j::TypeConverters.to_ruby(self.class, pname, self[pname])
|
@@ -80,4 +76,4 @@ module Neo4j
|
|
80
76
|
end
|
81
77
|
end
|
82
78
|
end
|
83
|
-
end
|
79
|
+
end
|
@@ -99,8 +99,6 @@ module Neo4j
|
|
99
99
|
set_property(k, value.to_java(:boolean))
|
100
100
|
when Fixnum
|
101
101
|
set_property(k, value.to_java(:long))
|
102
|
-
when Boolean
|
103
|
-
set_property(k, value.to_java(:boolean))
|
104
102
|
else
|
105
103
|
raise "Not allowed to store array with value #{value[0]} type #{value[0].class}"
|
106
104
|
end
|
@@ -50,7 +50,7 @@ module Neo4j
|
|
50
50
|
if @properties.has_key?(key)
|
51
51
|
@properties[key]
|
52
52
|
else
|
53
|
-
@properties[key] = (persisted? &&
|
53
|
+
@properties[key] = (persisted? && _java_entity.has_property?(key)) ? read_attribute(key) : attribute_defaults[key]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -88,8 +88,8 @@ module Neo4j
|
|
88
88
|
callstack.each do |name, values_with_empty_parameters|
|
89
89
|
begin
|
90
90
|
# (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
|
91
|
-
|
92
|
-
raise "Not a multiparameter attribute, missing :type on property #{name} for #{self.class}" unless
|
91
|
+
decl_type = self.class._decl_props[name.to_sym][:type]
|
92
|
+
raise "Not a multiparameter attribute, missing :type on property #{name} for #{self.class}" unless decl_type
|
93
93
|
|
94
94
|
# in order to allow a date to be set without a year, we must keep the empty values.
|
95
95
|
values = values_with_empty_parameters.reject { |v| v.nil? }
|
@@ -98,17 +98,19 @@ module Neo4j
|
|
98
98
|
send(name + "=", nil)
|
99
99
|
else
|
100
100
|
|
101
|
-
value = if
|
101
|
+
value = if :time == decl_type
|
102
102
|
instantiate_time_object(name, values)
|
103
|
-
elsif
|
103
|
+
elsif :date == decl_type
|
104
104
|
begin
|
105
105
|
values = values_with_empty_parameters.collect do |v| v.nil? ? 1 : v end
|
106
106
|
Date.new(*values)
|
107
107
|
rescue ArgumentError => ex # if Date.new raises an exception on an invalid date
|
108
108
|
instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
|
109
109
|
end
|
110
|
+
elsif :datetime == decl_type
|
111
|
+
DateTime.new(*values)
|
110
112
|
else
|
111
|
-
|
113
|
+
raise "Unknown type #{decl_type}"
|
112
114
|
end
|
113
115
|
|
114
116
|
send(name + "=", value)
|
@@ -185,7 +187,7 @@ module Neo4j
|
|
185
187
|
# attributes or the property keys for the persisted node.
|
186
188
|
def property_names
|
187
189
|
keys = @properties.keys + self.class._decl_props.keys.map { |k| k.to_s }
|
188
|
-
keys +=
|
190
|
+
keys += _java_entity.property_keys.to_a if persisted?
|
189
191
|
keys.flatten.uniq
|
190
192
|
end
|
191
193
|
|
@@ -202,7 +204,7 @@ module Neo4j
|
|
202
204
|
@properties.keys.include?(name) ||
|
203
205
|
self.class._decl_props.map { |k| k.to_s }.include?(name) ||
|
204
206
|
begin
|
205
|
-
super
|
207
|
+
persisted? && super
|
206
208
|
rescue org.neo4j.graphdb.NotFoundException
|
207
209
|
set_deleted_properties
|
208
210
|
nil
|
data/lib/neo4j/rails/finders.rb
CHANGED