neo4j-core 3.0.0.alpha.17 → 3.0.0.alpha.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/neo4j-core/query.rb +13 -3
- data/lib/neo4j-core/query_clauses.rb +3 -1
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-embedded/property.rb +52 -10
- data/lib/neo4j-server/cypher_response.rb +1 -1
- metadata +2 -50
- data/lib/mydb/active_tx_log +0 -1
- data/lib/mydb/index/lucene-store.db +0 -0
- data/lib/mydb/index/lucene.log.active +0 -0
- data/lib/mydb/index/lucene.log.v0 +0 -0
- data/lib/mydb/messages.log +0 -684
- data/lib/mydb/neostore +0 -0
- data/lib/mydb/neostore.id +0 -0
- data/lib/mydb/neostore.labeltokenstore.db +0 -0
- data/lib/mydb/neostore.labeltokenstore.db.id +0 -0
- data/lib/mydb/neostore.labeltokenstore.db.names +0 -0
- data/lib/mydb/neostore.labeltokenstore.db.names.id +0 -0
- data/lib/mydb/neostore.nodestore.db +0 -0
- data/lib/mydb/neostore.nodestore.db.id +0 -0
- data/lib/mydb/neostore.nodestore.db.labels +0 -0
- data/lib/mydb/neostore.nodestore.db.labels.id +0 -0
- data/lib/mydb/neostore.propertystore.db +0 -0
- data/lib/mydb/neostore.propertystore.db.arrays +0 -0
- data/lib/mydb/neostore.propertystore.db.arrays.id +0 -0
- data/lib/mydb/neostore.propertystore.db.id +0 -0
- data/lib/mydb/neostore.propertystore.db.index +0 -0
- data/lib/mydb/neostore.propertystore.db.index.id +0 -0
- data/lib/mydb/neostore.propertystore.db.index.keys +0 -0
- data/lib/mydb/neostore.propertystore.db.index.keys.id +0 -0
- data/lib/mydb/neostore.propertystore.db.strings +0 -0
- data/lib/mydb/neostore.propertystore.db.strings.id +0 -0
- data/lib/mydb/neostore.relationshipgroupstore.db +0 -0
- data/lib/mydb/neostore.relationshipgroupstore.db.id +0 -0
- data/lib/mydb/neostore.relationshipstore.db +0 -0
- data/lib/mydb/neostore.relationshipstore.db.id +0 -0
- data/lib/mydb/neostore.relationshiptypestore.db +0 -1
- data/lib/mydb/neostore.relationshiptypestore.db.id +0 -0
- data/lib/mydb/neostore.relationshiptypestore.db.names +0 -0
- data/lib/mydb/neostore.relationshiptypestore.db.names.id +0 -0
- data/lib/mydb/neostore.schemastore.db +0 -0
- data/lib/mydb/neostore.schemastore.db.id +0 -0
- data/lib/mydb/nioneo_logical.log.active +0 -0
- data/lib/mydb/nioneo_logical.log.v0 +0 -0
- data/lib/mydb/schema/label/lucene/segments.gen +0 -0
- data/lib/mydb/schema/label/lucene/segments_1 +0 -0
- data/lib/mydb/store_lock +0 -0
- data/lib/mydb/tm_tx_log.1 +0 -0
- data/lib/neo4j/session.rb~ +0 -202
- data/lib/neo4j-core/version.rb~ +0 -5
- data/lib/neo4j-embedded/cypher_response.rb~ +0 -85
- data/lib/neo4j-embedded/embedded_node.rb~ +0 -201
- data/lib/neo4j-embedded/embedded_relationship.rb~ +0 -62
- data/lib/neo4j-embedded/embedded_session.rb~ +0 -145
- data/lib/neo4j-server/cypher_response.rb~ +0 -155
data/lib/mydb/neostore
DELETED
Binary file
|
data/lib/mydb/neostore.id
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
RelationshipTypeStore v0.A.3
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/mydb/store_lock
DELETED
File without changes
|
data/lib/mydb/tm_tx_log.1
DELETED
Binary file
|
data/lib/neo4j/session.rb~
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
module Neo4j
|
2
|
-
class Session
|
3
|
-
|
4
|
-
@@current_session = nil
|
5
|
-
@@all_sessions = {}
|
6
|
-
@@factories = {}
|
7
|
-
|
8
|
-
# @abstract
|
9
|
-
def close
|
10
|
-
self.class.unregister(self)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Only for embedded database
|
14
|
-
# @abstract
|
15
|
-
def start
|
16
|
-
raise "not impl."
|
17
|
-
end
|
18
|
-
|
19
|
-
# Only for embedded database
|
20
|
-
# @abstract
|
21
|
-
def shutdown
|
22
|
-
raise "not impl."
|
23
|
-
end
|
24
|
-
|
25
|
-
# Only for embedded database
|
26
|
-
# @abstract
|
27
|
-
def running
|
28
|
-
raise "not impl."
|
29
|
-
end
|
30
|
-
|
31
|
-
def auto_commit?
|
32
|
-
true # TODO
|
33
|
-
end
|
34
|
-
|
35
|
-
# @abstract
|
36
|
-
def begin_tx
|
37
|
-
raise "not impl."
|
38
|
-
end
|
39
|
-
|
40
|
-
class CypherError < StandardError
|
41
|
-
attr_reader :error_msg, :error_status, :error_code
|
42
|
-
def initialize(error_msg, error_code, error_status)
|
43
|
-
super(error_msg)
|
44
|
-
@error_msg = error_msg
|
45
|
-
@error_status = error_status
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Executes a Cypher Query.
|
50
|
-
# Returns an enumerable of hash values where each hash corresponds to a row unless +return+ or +map_return+
|
51
|
-
# is not an array. The search result can be mapped to Neo4j::Node or Neo4j::Relationship is your own Ruby wrapper class
|
52
|
-
# by specifying a map_return parameter.
|
53
|
-
#
|
54
|
-
# @param [Hash, String] q the cypher query, as a pure string query or a hash which will generate a cypher string.
|
55
|
-
# @option q [Hash] :params cypher parameters
|
56
|
-
# @option q [Symbol,Hash] :label the label to match. You can specify several labels by using a hash of variable names and labels.
|
57
|
-
# @option q [Symbol] :conditions key and value of properties which the label nodes must match
|
58
|
-
# @option q [Hash] :conditions key and value of properties which the label nodes must match
|
59
|
-
# @option q [String, Array] :match the cypher match clause
|
60
|
-
# @option q [String, Array] :where the cypher where clause
|
61
|
-
# @option q [String, Array, Symbol] :return the cypher where clause
|
62
|
-
# @option q [String, Hash, Symbol] :map_return mapping of the returned values, e.g. :id_to_node, :id_to_rel, or :value
|
63
|
-
# @option q [Hash<Symbol, Proc>] :map_return_procs custom mapping functions of :map_return types
|
64
|
-
# @option q [String,Symbol,Array<Hash>] :order the order
|
65
|
-
# @option q [Fixnum] :limit enables the return of only subsets of the total result.
|
66
|
-
# @option q [Fixnum] :skip enables the return of only subsets of the total result.
|
67
|
-
# @return [Enumerable] the result, an enumerable of Neo4j::Node objects unless a pure cypher string is given or return/map_returns is specified, see examples.
|
68
|
-
# @raise CypherError if invalid cypher
|
69
|
-
# @example Cypher String and parameters
|
70
|
-
# Neo4j::Session.query("START n=node({p}) RETURN ID(n)", params: {p: 42})
|
71
|
-
#
|
72
|
-
# @example label
|
73
|
-
# # If there is no :return parameter it will try to return Neo4j::Node objects
|
74
|
-
# # Default parameter is :n in the generated cypher
|
75
|
-
# Neo4j::Session.query(label: :person) # => MATCH (n:`person`) RETURN ID(n) # or RETURN n for embedded
|
76
|
-
#
|
77
|
-
# @example to_s
|
78
|
-
# # What Cypher is returned ? check with to_s
|
79
|
-
# Neo4j::Session.query(label: :person).to_s # =>
|
80
|
-
#
|
81
|
-
# @example return
|
82
|
-
# Neo4j::Session.query(label: :person, return: :age) # returns age properties
|
83
|
-
# Neo4j::Session.query(label: :person, return: [:name, :age]) # returns a hash of name and age properties
|
84
|
-
# Neo4j::Session.query(label: :person, return: 'count(n) AS c')
|
85
|
-
#
|
86
|
-
# @example map_return - an Enumerable of names (String)
|
87
|
-
# Neo4j::Session.query("START n=node(42) RETURN n.name", map_return: :value)
|
88
|
-
#
|
89
|
-
# @example map_return - Enumerable of an Hash with name property, Neo4j::Relationship and Neo4j::Node as values
|
90
|
-
# Neo4j::Session.query("START n=node(42) MATCH n-[r]->[x] RETURN n.name as N, ID(r) as R, ID(x) as X",
|
91
|
-
# map_return: {N: :value, R: :id_to_rel, X: :id_to_node})
|
92
|
-
#
|
93
|
-
# @example map_return, only for embedded_db, to_rel, and to_node allows direct mapping to Neo4j::Node and Neo4j::Relationship without ID(n)
|
94
|
-
# Neo4j::Session.query("START n=node(42) MATCH n-[r]->[x] RETURN n.name as N, r, x", map_return: {N: :value, r: :to_rel, x: :to_node})
|
95
|
-
#
|
96
|
-
# @example map_return_procs, custom mapping function
|
97
|
-
# Neo4j::Session.query(label: :person, map_return: :age_times_two, map_return_procs: {age_times_two: ->(row){(row[:age] || 0) * 2}})
|
98
|
-
#
|
99
|
-
# @example match
|
100
|
-
# Neo4j::Session.query(label: :person, match: 'n--m')
|
101
|
-
#
|
102
|
-
# @example where
|
103
|
-
# Neo4j::Session.query(label: :person, where: 'n.age > 40')
|
104
|
-
# Neo4j::Session.query(label: :person, where: 'n.age > {age}', params: {age: 40})
|
105
|
-
#
|
106
|
-
# @example condition
|
107
|
-
# Neo4j::Session.query(label: :person, conditions: {age: 42})
|
108
|
-
# Neo4j::Session.query(label: :person, conditions: {name: /foo?bar.*/})
|
109
|
-
#
|
110
|
-
# @see http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html The Cypher Query Language Documentation
|
111
|
-
# @note Returns a read-once only forward iterable for the embedded database.
|
112
|
-
#
|
113
|
-
def query(q)
|
114
|
-
raise 'not implemented, abstract'
|
115
|
-
end
|
116
|
-
|
117
|
-
# Same as #query but does not accept an DSL and returns the raw result from the database.
|
118
|
-
# Notice, it might return different values depending on which database is used, embedded or server.
|
119
|
-
# @abstract
|
120
|
-
def _query(*params)
|
121
|
-
raise 'not implemented'
|
122
|
-
end
|
123
|
-
|
124
|
-
class << self
|
125
|
-
# Creates a new session to Neo4j
|
126
|
-
# @see also Neo4j::Server::CypherSession#open for :server_db params
|
127
|
-
# @param db_type the type of database, e.g. :embedded_db, or :server_db
|
128
|
-
def open(db_type=:server_db, *params)
|
129
|
-
register(create_session(db_type, params))
|
130
|
-
end
|
131
|
-
|
132
|
-
def open_named(db_type, name, default = nil, *params)
|
133
|
-
raise "Multiple sessions is currently only supported for Neo4j Server connections." unless db_type == :server_db
|
134
|
-
register(create_session(db_type, params), name, default)
|
135
|
-
end
|
136
|
-
|
137
|
-
def create_session(db_type, params = {})
|
138
|
-
unless (@@factories[db_type])
|
139
|
-
raise "Can't connect to database '#{db_type}', available #{@@factories.keys.join(',')}"
|
140
|
-
end
|
141
|
-
@@factories[db_type].call(*params)
|
142
|
-
end
|
143
|
-
|
144
|
-
def current
|
145
|
-
@@current_session
|
146
|
-
end
|
147
|
-
|
148
|
-
# @see Neo4j::Session#query
|
149
|
-
def query(*params)
|
150
|
-
current.query(*params)
|
151
|
-
end
|
152
|
-
|
153
|
-
def named(name)
|
154
|
-
@@all_sessions[name] || raise("No session named #{name}.")
|
155
|
-
end
|
156
|
-
|
157
|
-
def set_current(session)
|
158
|
-
@@current_session = session
|
159
|
-
end
|
160
|
-
|
161
|
-
def add_listener(&listener)
|
162
|
-
self._listeners << listener
|
163
|
-
end
|
164
|
-
|
165
|
-
def _listeners
|
166
|
-
@@listeners ||= []
|
167
|
-
@@listeners
|
168
|
-
end
|
169
|
-
|
170
|
-
def _notify_listeners(event, data)
|
171
|
-
_listeners.each {|li| li.call(event, data)}
|
172
|
-
end
|
173
|
-
|
174
|
-
def register(session, name = nil, default = nil)
|
175
|
-
if default == true
|
176
|
-
set_current(session)
|
177
|
-
elsif default.nil?
|
178
|
-
set_current(session) unless @@current_session
|
179
|
-
end
|
180
|
-
@@all_sessions[name] = session if name
|
181
|
-
@@current_session
|
182
|
-
end
|
183
|
-
|
184
|
-
def unregister(session)
|
185
|
-
@@current_session = nil if @@current_session == session
|
186
|
-
end
|
187
|
-
|
188
|
-
def all_sessions
|
189
|
-
@@all_sessions
|
190
|
-
end
|
191
|
-
|
192
|
-
def inspect
|
193
|
-
"Neo4j::Session available: #{@@factories && @@factories.keys}"
|
194
|
-
end
|
195
|
-
|
196
|
-
def register_db(db, &session_factory)
|
197
|
-
puts "replace factory for #{db}" if @@factories[db]
|
198
|
-
@@factories[db] = session_factory
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
data/lib/neo4j-core/version.rb~
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
module Neo4j::Embedded
|
2
|
-
|
3
|
-
# Wraps the Cypher query result.
|
4
|
-
# Loads the node and relationships wrapper if possible and use symbol as column keys.
|
5
|
-
# This is typically used in the native neo4j bindings since result does is not a Ruby enumerable with symbols as keys.
|
6
|
-
# @note The result is a once forward read only Enumerable, work if you need to read the result twice - use #to_a
|
7
|
-
#
|
8
|
-
class ResultWrapper
|
9
|
-
class ResultsAlreadyConsumedException < Exception;
|
10
|
-
end
|
11
|
-
|
12
|
-
include Enumerable
|
13
|
-
|
14
|
-
# @return the original result from the Neo4j Cypher Engine, once forward read only !
|
15
|
-
attr_reader :source
|
16
|
-
|
17
|
-
def initialize(source, map_return_procs, query)
|
18
|
-
@source = source
|
19
|
-
@unread = true
|
20
|
-
@map_return_procs = map_return_procs
|
21
|
-
@query = query
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_s
|
25
|
-
@query
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [Array<Symbol>] the columns in the query result
|
29
|
-
def columns
|
30
|
-
@source.columns.map { |x| x.to_sym }
|
31
|
-
end
|
32
|
-
|
33
|
-
# for the Enumerable contract
|
34
|
-
def each(&block)
|
35
|
-
raise ResultsAlreadyConsumedException unless @unread
|
36
|
-
|
37
|
-
if (block)
|
38
|
-
case @map_return_procs
|
39
|
-
when NilClass then
|
40
|
-
each_no_mapping &block
|
41
|
-
when Hash then
|
42
|
-
each_multi_column_mapping &block
|
43
|
-
else
|
44
|
-
each_single_column_mapping &block
|
45
|
-
end
|
46
|
-
else
|
47
|
-
Enumerator.new(self)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def each_no_mapping
|
55
|
-
@source.each do |row|
|
56
|
-
hash = {}
|
57
|
-
row.each do |key, value|
|
58
|
-
out[key.to_sym] = value
|
59
|
-
end
|
60
|
-
yield hash
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def each_multi_column_mapping
|
65
|
-
@source.each do |row|
|
66
|
-
hash = {}
|
67
|
-
row.each do |key, value|
|
68
|
-
k = key.to_sym
|
69
|
-
proc = @map_return_procs[k]
|
70
|
-
hash[k] = proc ? proc.call(value) : value
|
71
|
-
end
|
72
|
-
yield hash
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def each_single_column_mapping
|
77
|
-
@source.each do |row|
|
78
|
-
result = @map_return_procs.call(row.values.first)
|
79
|
-
yield result
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
@@ -1,201 +0,0 @@
|
|
1
|
-
module Neo4j::Embedded
|
2
|
-
class RelsIterator
|
3
|
-
include Enumerable
|
4
|
-
extend Neo4j::Core::TxMethods
|
5
|
-
|
6
|
-
def initialize(node, match)
|
7
|
-
@node = node
|
8
|
-
@match = match
|
9
|
-
end
|
10
|
-
|
11
|
-
def inspect
|
12
|
-
"Enumerable<Neo4j::Relationship>"
|
13
|
-
end
|
14
|
-
|
15
|
-
def each(&block)
|
16
|
-
@node._rels(@match).each {|r| block.call(r.wrapper)}
|
17
|
-
end
|
18
|
-
tx_methods :each
|
19
|
-
|
20
|
-
def empty?
|
21
|
-
first == nil
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
class NodesIterator
|
27
|
-
include Enumerable
|
28
|
-
extend Neo4j::Core::TxMethods
|
29
|
-
|
30
|
-
def initialize(node, match)
|
31
|
-
@node = node
|
32
|
-
@match = match
|
33
|
-
end
|
34
|
-
|
35
|
-
def each(&block)
|
36
|
-
@node._rels(@match).each {|r| block.call(r.other_node(@node))}
|
37
|
-
end
|
38
|
-
tx_methods :each
|
39
|
-
|
40
|
-
def empty?
|
41
|
-
first == nil
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
class EmbeddedNode
|
47
|
-
class << self
|
48
|
-
# This method is used to extend a Java Neo4j class so that it includes the same mixins as this class.
|
49
|
-
def extend_java_class(java_clazz)
|
50
|
-
java_clazz.class_eval do
|
51
|
-
include Neo4j::Embedded::Property
|
52
|
-
include Neo4j::EntityEquality
|
53
|
-
extend Neo4j::Core::TxMethods
|
54
|
-
|
55
|
-
def inspect
|
56
|
-
"EmbeddedNode neo_id: #{neo_id}"
|
57
|
-
end
|
58
|
-
|
59
|
-
def exist?
|
60
|
-
!!graph_database.get_node_by_id(neo_id)
|
61
|
-
rescue Java::OrgNeo4jGraphdb.NotFoundException
|
62
|
-
nil
|
63
|
-
end
|
64
|
-
tx_methods :exist?
|
65
|
-
|
66
|
-
def labels
|
67
|
-
_labels.iterator.map{|x| x.name.to_sym}
|
68
|
-
end
|
69
|
-
tx_methods :labels
|
70
|
-
|
71
|
-
alias_method :_labels, :getLabels
|
72
|
-
|
73
|
-
def _java_label(label_name)
|
74
|
-
Java::OrgNeo4jGraphdb.DynamicLabel.label(label_name)
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
def _add_label(*label_name)
|
79
|
-
label_name.each do |name|
|
80
|
-
addLabel(_java_label(name))
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
alias_method :add_label, :_add_label
|
85
|
-
tx_methods :add_label
|
86
|
-
|
87
|
-
def _remove_label(*label_name)
|
88
|
-
label_name.each do |name|
|
89
|
-
removeLabel(_java_label(name))
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
alias_method :remove_label, :_remove_label
|
94
|
-
tx_methods :remove_label
|
95
|
-
|
96
|
-
def set_label(*label_names)
|
97
|
-
label_as_symbols = label_names.map(&:to_sym)
|
98
|
-
to_keep = labels & label_as_symbols
|
99
|
-
to_remove = labels - to_keep
|
100
|
-
_remove_label(*to_remove)
|
101
|
-
to_add = label_as_symbols - to_keep
|
102
|
-
_add_label(*to_add)
|
103
|
-
end
|
104
|
-
tx_methods :set_label
|
105
|
-
|
106
|
-
def del
|
107
|
-
_rels.each { |r| r.del }
|
108
|
-
delete
|
109
|
-
nil
|
110
|
-
end
|
111
|
-
tx_methods :del
|
112
|
-
|
113
|
-
def create_rel(type, other_node, props = nil)
|
114
|
-
rel = create_relationship_to(other_node.neo4j_obj, ToJava.type_to_java(type))
|
115
|
-
props.each_pair { |k, v| rel[k] = v } if props
|
116
|
-
rel
|
117
|
-
end
|
118
|
-
tx_methods :create_rel
|
119
|
-
|
120
|
-
|
121
|
-
def rels(match={})
|
122
|
-
RelsIterator.new(self, match)
|
123
|
-
end
|
124
|
-
|
125
|
-
def nodes(match={})
|
126
|
-
NodesIterator.new(self, match)
|
127
|
-
end
|
128
|
-
|
129
|
-
def node(match={})
|
130
|
-
rel = _rel(match)
|
131
|
-
rel && rel.other_node(self).wrapper
|
132
|
-
end
|
133
|
-
tx_methods :node
|
134
|
-
|
135
|
-
def rel?(match={})
|
136
|
-
_rels(match).has_next
|
137
|
-
end
|
138
|
-
tx_methods :rel?
|
139
|
-
|
140
|
-
def rel(match={})
|
141
|
-
_rel(match)
|
142
|
-
end
|
143
|
-
tx_methods :rel
|
144
|
-
|
145
|
-
def _rel(match={})
|
146
|
-
dir = match[:dir] || :both
|
147
|
-
rel_type = match[:type]
|
148
|
-
|
149
|
-
rel = if rel_type
|
150
|
-
get_single_relationship(ToJava.type_to_java(rel_type), ToJava.dir_to_java(dir))
|
151
|
-
else
|
152
|
-
iter = get_relationships(ToJava.dir_to_java(dir)).iterator
|
153
|
-
if (iter.has_next)
|
154
|
-
first = iter.next
|
155
|
-
raise "Expected to only find one relationship from node #{neo_id} matching #{match.inspect}" if iter.has_next
|
156
|
-
first
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
between_id = match[:between] && match[:between].neo_id
|
161
|
-
|
162
|
-
if (rel && between_id)
|
163
|
-
rel.other_node(self).neo_id == between_id ? rel : nil
|
164
|
-
else
|
165
|
-
rel
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def _rels(match={})
|
170
|
-
dir = match[:dir] || :both
|
171
|
-
rel_type = match[:type]
|
172
|
-
|
173
|
-
rels = if rel_type
|
174
|
-
get_relationships(ToJava.type_to_java(rel_type), ToJava.dir_to_java(dir)).iterator
|
175
|
-
else
|
176
|
-
get_relationships(ToJava.dir_to_java(dir)).iterator
|
177
|
-
end
|
178
|
-
|
179
|
-
between_id = match[:between] && match[:between].neo_id
|
180
|
-
|
181
|
-
if (between_id)
|
182
|
-
rels.find_all{|r| r.end_node.neo_id == between_id || r.start_node.neo_id == between_id}
|
183
|
-
else
|
184
|
-
rels
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
def class
|
190
|
-
Neo4j::Node
|
191
|
-
end
|
192
|
-
|
193
|
-
include Neo4j::Node::Wrapper
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
extend_java_class(Java::OrgNeo4jKernelImplCore::NodeProxy)
|
199
|
-
end
|
200
|
-
|
201
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
module Neo4j::Embedded
|
2
|
-
class EmbeddedRelationship
|
3
|
-
class << self
|
4
|
-
# This method is used to extend a Java Neo4j class so that it includes the same mixins as this class.
|
5
|
-
def extend_java_class(java_clazz)
|
6
|
-
java_clazz.class_eval do
|
7
|
-
include Neo4j::Embedded::Property
|
8
|
-
include Neo4j::EntityEquality
|
9
|
-
include Neo4j::Relationship::Wrapper
|
10
|
-
extend Neo4j::Core::TxMethods
|
11
|
-
|
12
|
-
alias_method :_other_node, :getOtherNode
|
13
|
-
|
14
|
-
def exist?
|
15
|
-
!!graph_database.get_relationship_by_id(neo_id)
|
16
|
-
rescue Java::OrgNeo4jGraphdb.NotFoundException
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
tx_methods :exist?
|
20
|
-
|
21
|
-
def start_node
|
22
|
-
_start_node.wrapper
|
23
|
-
end
|
24
|
-
tx_methods :start_node
|
25
|
-
|
26
|
-
def _start_node
|
27
|
-
getStartNode
|
28
|
-
end
|
29
|
-
|
30
|
-
def rel_type
|
31
|
-
getType().name().to_sym
|
32
|
-
end
|
33
|
-
|
34
|
-
def del
|
35
|
-
delete
|
36
|
-
end
|
37
|
-
tx_methods :del
|
38
|
-
|
39
|
-
def other_node(n)
|
40
|
-
_other_node(n.neo4j_obj).wrapper
|
41
|
-
end
|
42
|
-
tx_methods :other_node
|
43
|
-
|
44
|
-
def end_node
|
45
|
-
_end_node.wrapper
|
46
|
-
end
|
47
|
-
tx_methods :end_node
|
48
|
-
|
49
|
-
def _end_node
|
50
|
-
getEndNode
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
extend_java_class(Java::OrgNeo4jKernelImplCore::RelationshipProxy)
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
end
|