neo4j 1.0.0.beta.12 → 1.0.0.beta.13
Sign up to get free protection for your applications and to get access to all the features.
@@ -64,14 +64,18 @@ module Neo4j::Mapping
|
|
64
64
|
clazz = self
|
65
65
|
module_eval(%Q{def #{rel_type}=(value)
|
66
66
|
dsl = #{clazz}._decl_rels[:'#{rel_type.to_s}']
|
67
|
-
|
67
|
+
dir = dsl.direction
|
68
|
+
dsl = dsl.incoming? ? dsl.incoming_dsl(self) : dsl
|
69
|
+
rel = dsl.single_relationship(self, dir)
|
68
70
|
rel.del unless rel.nil?
|
69
71
|
dsl.create_relationship_to(self, value)
|
70
72
|
end}, __FILE__, __LINE__)
|
71
73
|
|
72
74
|
module_eval(%Q{def #{rel_type}
|
73
75
|
dsl = #{clazz}._decl_rels[:'#{rel_type.to_s}']
|
74
|
-
dsl.
|
76
|
+
dir = dsl.direction
|
77
|
+
dsl = dsl.incoming? ? dsl.incoming_dsl(self) : dsl
|
78
|
+
dsl.single_relationship(self, dir)
|
75
79
|
end}, __FILE__, __LINE__)
|
76
80
|
|
77
81
|
# TODO
|
@@ -85,11 +85,23 @@ module Neo4j::Mapping
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
88
|
+
def incoming?
|
89
|
+
@direction == :incoming
|
90
|
+
end
|
91
|
+
|
92
|
+
def incoming_dsl(node)
|
93
|
+
# which class specifies the incoming DSL ?
|
94
|
+
clazz = to_class || node.class
|
95
|
+
dsl = clazz._decl_rels[to_type]
|
96
|
+
raise "Unspecified outgoing relationship '#{to_type}' for incoming relationship '#{rel_id}' on class #{clazz}" if dsl.nil?
|
97
|
+
dsl
|
98
|
+
end
|
99
|
+
|
100
|
+
def single_relationship(node, dir)
|
89
101
|
type = type_to_java(namespace_type)
|
90
|
-
dir = dir_to_java(
|
102
|
+
dir = dir_to_java(dir)
|
91
103
|
rel = node._java_node.getSingleRelationship(type, dir)
|
92
|
-
rel.nil? ? nil : rel.
|
104
|
+
rel.nil? ? nil : rel.other_node(node).wrapper
|
93
105
|
end
|
94
106
|
|
95
107
|
def create_relationship_to(node, other)
|
data/lib/neo4j/mapping/has_n.rb
CHANGED
@@ -11,15 +11,7 @@ module Neo4j
|
|
11
11
|
def initialize(node, dsl) # :nodoc:
|
12
12
|
@node = node
|
13
13
|
@direction = dsl.direction
|
14
|
-
|
15
|
-
if @direction == :outgoing
|
16
|
-
@dsl = dsl
|
17
|
-
else
|
18
|
-
# which class specifies the incoming DSL ?
|
19
|
-
clazz = dsl.to_class || node.class
|
20
|
-
@dsl = clazz._decl_rels[dsl.to_type]
|
21
|
-
raise "Unspecified outgoing relationship '#{dsl.to_type}' for incoming relationship '#{dsl.rel_id}' on class #{clazz}" if @dsl.nil?
|
22
|
-
end
|
14
|
+
@dsl = @direction == :outgoing ? dsl : dsl.incoming_dsl(node)
|
23
15
|
end
|
24
16
|
|
25
17
|
def to_s
|
data/lib/neo4j/rails/model.rb
CHANGED
data/lib/neo4j/rails/value.rb
CHANGED
@@ -67,7 +67,6 @@ module Neo4j::Rails
|
|
67
67
|
rel.each do |new_node|
|
68
68
|
wrapper = new_node.respond_to?(:wrapper) ? new_node.wrapper : new_node
|
69
69
|
if wrapper.save
|
70
|
-
puts "NEW RELATIONSHIP OF TYPE #{type} from #{root_node} to #{new_node}"
|
71
70
|
root_node.outgoing(type) << wrapper
|
72
71
|
else
|
73
72
|
valid = false
|
@@ -90,9 +89,11 @@ module Neo4j::Rails
|
|
90
89
|
self
|
91
90
|
end
|
92
91
|
|
93
|
-
def
|
92
|
+
def other_node(other)
|
94
93
|
other == @end_node ? @start_node : @end_node
|
95
94
|
end
|
95
|
+
|
96
|
+
alias_method :getOtherNode, :other_node
|
96
97
|
end
|
97
98
|
|
98
99
|
|
data/lib/neo4j/version.rb
CHANGED