neo4j-core 5.0.1 → 5.0.2
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/graph_json.rb +35 -0
- data/lib/neo4j-core/query.rb +3 -3
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-embedded/embedded_session.rb +1 -1
- data/lib/neo4j-server/cypher_session.rb +11 -13
- data/lib/neo4j/tasks/neo4j_server.rake +14 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b74f69f9b3d8758405b41493b43eb58c9d7113fb
|
4
|
+
data.tar.gz: bca8ba4bdf95e2caef2d07d396da5e47c5f7d41f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be6fa6687915b5ab2974d3f8089d21732cf58b5d75981e0b7a979fa3beff6e3d5f2ca23e84ce5527e6409df4cc5e2f21f3e5b295d7fcc2a81446f18afd50f419
|
7
|
+
data.tar.gz: d60a1cf05c0e317d61d468bc5e7641d1c48e57ba8a3f94214126430ba747458ef22f0962d645d03dc1b3b06ea1165f7f6be34ba5254ae60182ae872d881a83b0
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Core
|
3
|
+
module GraphJSON
|
4
|
+
def self.to_graph_json(objects)
|
5
|
+
nodes = {}
|
6
|
+
edges = {}
|
7
|
+
|
8
|
+
objects.each do |object|
|
9
|
+
case object
|
10
|
+
when Neo4j::ActiveNode, Neo4j::Server::CypherNode
|
11
|
+
nodes[object.neo_id] = {
|
12
|
+
id: object.neo_id,
|
13
|
+
labels: (object.is_a?(Neo4j::ActiveNode) ? [object.class.name] : object.labels),
|
14
|
+
properties: object.attributes
|
15
|
+
}
|
16
|
+
when Neo4j::ActiveRel, Neo4j::Server::CypherRelationship
|
17
|
+
edges[[object.start_node.neo_id, object.end_node.neo_id]] = {
|
18
|
+
source: object.start_node.neo_id,
|
19
|
+
target: object.end_node.neo_id,
|
20
|
+
type: object.rel_type,
|
21
|
+
properties: object.props
|
22
|
+
}
|
23
|
+
else
|
24
|
+
fail "Invalid value found: #{object.inspect}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
{
|
29
|
+
nodes: nodes.values,
|
30
|
+
edges: edges.values
|
31
|
+
}.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/neo4j-core/query.rb
CHANGED
@@ -174,9 +174,9 @@ module Neo4j
|
|
174
174
|
def response
|
175
175
|
return @response if @response
|
176
176
|
cypher = to_cypher
|
177
|
-
|
178
|
-
|
179
|
-
|
177
|
+
|
178
|
+
@response = @session._query(cypher, merge_params, context: @options[:context])
|
179
|
+
|
180
180
|
if !response.respond_to?(:error?) || !response.error?
|
181
181
|
response
|
182
182
|
else
|
data/lib/neo4j-core/version.rb
CHANGED
@@ -137,7 +137,7 @@ module Neo4j
|
|
137
137
|
# Remember that you should close the resource iterator.
|
138
138
|
# @param [String] q the cypher query as a String
|
139
139
|
# @return (see #query)
|
140
|
-
def _query(q, params = {})
|
140
|
+
def _query(q, params = {}, options = {})
|
141
141
|
@engine ||= Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(@graph_db)
|
142
142
|
@engine.execute(q, Neo4j::Core::HashWithIndifferentAccess.new(params))
|
143
143
|
rescue StandardError => e
|
@@ -195,26 +195,24 @@ module Neo4j
|
|
195
195
|
end
|
196
196
|
|
197
197
|
def _query_entity_data(query, id = nil, params = {})
|
198
|
-
_query_response(query, params).entity_data(id)
|
199
|
-
end
|
200
|
-
|
201
|
-
def _query_response(query, params = {})
|
202
198
|
_query(query, params).tap do |response|
|
203
199
|
response.raise_error if response.error?
|
204
|
-
end
|
200
|
+
end.entity_data(id)
|
205
201
|
end
|
206
202
|
|
207
|
-
def _query(query, params = {})
|
203
|
+
def _query(query, params = {}, options = {})
|
208
204
|
query, params = query_and_params(query, params)
|
209
205
|
|
210
206
|
curr_tx = Neo4j::Transaction.current
|
211
|
-
|
212
|
-
curr_tx
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
207
|
+
ActiveSupport::Notifications.instrument('neo4j.cypher_query', context: options[:context] || 'CYPHER', cypher: query, params: params) do
|
208
|
+
if curr_tx
|
209
|
+
curr_tx._query(query, params)
|
210
|
+
else
|
211
|
+
url = resource_url(:cypher)
|
212
|
+
query = params.nil? ? {'query' => query} : {'query' => query, 'params' => params}
|
213
|
+
response = @connection.post(url, query)
|
214
|
+
CypherResponse.create_with_no_tx(response)
|
215
|
+
end
|
218
216
|
end
|
219
217
|
end
|
220
218
|
|
@@ -78,9 +78,21 @@ namespace :neo4j do
|
|
78
78
|
system_or_fail("#{install_location(args)}/bin/neo4j #{command}")
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
def get_edition(args)
|
82
|
+
edition_string = args[:edition]
|
83
|
+
|
84
|
+
edition_string.gsub(/-latest$/) do
|
85
|
+
require 'open-uri'
|
86
|
+
puts 'Retrieving latest version...'
|
87
|
+
latest_version = JSON.parse(open('https://api.github.com/repos/neo4j/neo4j/releases/latest').read)['tag_name']
|
88
|
+
puts "Latest version is: #{latest_version}"
|
89
|
+
"-#{latest_version}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
desc 'Install Neo4j with auth disabled in v2.2+, example neo4j:install[community-latest,development]'
|
82
94
|
task :install, :edition, :environment do |_, args|
|
83
|
-
edition = args
|
95
|
+
edition = get_edition(args)
|
84
96
|
environment = get_environment(args)
|
85
97
|
puts "Installing Neo4j-#{edition} environment: #{environment}"
|
86
98
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Chris Grigg, Brian Underwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- lib/neo4j-core.rb
|
263
263
|
- lib/neo4j-core/active_entity.rb
|
264
264
|
- lib/neo4j-core/cypher_translator.rb
|
265
|
+
- lib/neo4j-core/graph_json.rb
|
265
266
|
- lib/neo4j-core/hash_with_indifferent_access.rb
|
266
267
|
- lib/neo4j-core/helpers.rb
|
267
268
|
- lib/neo4j-core/label.rb
|