neography-down 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.project +12 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +939 -0
  7. data/CONTRIBUTORS +18 -0
  8. data/Gemfile +4 -0
  9. data/Guardfile +14 -0
  10. data/LICENSE +19 -0
  11. data/README.md +281 -0
  12. data/Rakefile +14 -0
  13. data/examples/facebook.rb +40 -0
  14. data/examples/facebook_v2.rb +25 -0
  15. data/examples/greatest.rb +43 -0
  16. data/examples/linkedin.rb +39 -0
  17. data/examples/linkedin_v2.rb +22 -0
  18. data/examples/traversal_example1.rb +65 -0
  19. data/examples/traversal_example2.rb +54 -0
  20. data/lib/neography.rb +45 -0
  21. data/lib/neography/config.rb +64 -0
  22. data/lib/neography/connection.rb +263 -0
  23. data/lib/neography/equal.rb +21 -0
  24. data/lib/neography/errors.rb +60 -0
  25. data/lib/neography/index.rb +52 -0
  26. data/lib/neography/multi_json_parser.rb +28 -0
  27. data/lib/neography/neography.rb +10 -0
  28. data/lib/neography/node.rb +63 -0
  29. data/lib/neography/node_path.rb +29 -0
  30. data/lib/neography/node_relationship.rb +37 -0
  31. data/lib/neography/node_traverser.rb +146 -0
  32. data/lib/neography/path_traverser.rb +100 -0
  33. data/lib/neography/property.rb +110 -0
  34. data/lib/neography/property_container.rb +28 -0
  35. data/lib/neography/railtie.rb +19 -0
  36. data/lib/neography/relationship.rb +78 -0
  37. data/lib/neography/relationship_traverser.rb +80 -0
  38. data/lib/neography/rest.rb +99 -0
  39. data/lib/neography/rest/batch.rb +414 -0
  40. data/lib/neography/rest/clean.rb +17 -0
  41. data/lib/neography/rest/constraints.rb +38 -0
  42. data/lib/neography/rest/cypher.rb +29 -0
  43. data/lib/neography/rest/extensions.rb +21 -0
  44. data/lib/neography/rest/gremlin.rb +20 -0
  45. data/lib/neography/rest/helpers.rb +96 -0
  46. data/lib/neography/rest/node_auto_indexes.rb +60 -0
  47. data/lib/neography/rest/node_indexes.rb +139 -0
  48. data/lib/neography/rest/node_labels.rb +49 -0
  49. data/lib/neography/rest/node_paths.rb +49 -0
  50. data/lib/neography/rest/node_properties.rb +52 -0
  51. data/lib/neography/rest/node_relationships.rb +33 -0
  52. data/lib/neography/rest/node_traversal.rb +25 -0
  53. data/lib/neography/rest/nodes.rb +94 -0
  54. data/lib/neography/rest/other_node_relationships.rb +38 -0
  55. data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
  56. data/lib/neography/rest/relationship_indexes.rb +142 -0
  57. data/lib/neography/rest/relationship_properties.rb +52 -0
  58. data/lib/neography/rest/relationship_types.rb +11 -0
  59. data/lib/neography/rest/relationships.rb +16 -0
  60. data/lib/neography/rest/schema_indexes.rb +26 -0
  61. data/lib/neography/rest/spatial.rb +137 -0
  62. data/lib/neography/rest/transactions.rb +101 -0
  63. data/lib/neography/tasks.rb +207 -0
  64. data/lib/neography/version.rb +3 -0
  65. data/neography.gemspec +39 -0
  66. data/spec/integration/authorization_spec.rb +40 -0
  67. data/spec/integration/broken_spatial_spec.rb +28 -0
  68. data/spec/integration/index_spec.rb +71 -0
  69. data/spec/integration/neography_spec.rb +10 -0
  70. data/spec/integration/node_encoding_spec.rb +71 -0
  71. data/spec/integration/node_path_spec.rb +222 -0
  72. data/spec/integration/node_relationship_spec.rb +381 -0
  73. data/spec/integration/node_spec.rb +260 -0
  74. data/spec/integration/parsing_spec.rb +13 -0
  75. data/spec/integration/performance_spec.rb +17 -0
  76. data/spec/integration/relationship_spec.rb +37 -0
  77. data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
  78. data/spec/integration/rest_batch_spec.rb +604 -0
  79. data/spec/integration/rest_batch_streaming_spec.rb +51 -0
  80. data/spec/integration/rest_bulk_spec.rb +106 -0
  81. data/spec/integration/rest_constraints_spec.rb +72 -0
  82. data/spec/integration/rest_experimental_spec.rb +22 -0
  83. data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
  84. data/spec/integration/rest_header_spec.rb +15 -0
  85. data/spec/integration/rest_index_spec.rb +481 -0
  86. data/spec/integration/rest_labels_spec.rb +128 -0
  87. data/spec/integration/rest_node_spec.rb +274 -0
  88. data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
  89. data/spec/integration/rest_path_spec.rb +231 -0
  90. data/spec/integration/rest_plugin_spec.rb +177 -0
  91. data/spec/integration/rest_relationship_spec.rb +354 -0
  92. data/spec/integration/rest_relationship_types_spec.rb +18 -0
  93. data/spec/integration/rest_schema_index_spec.rb +32 -0
  94. data/spec/integration/rest_spatial_spec.rb +166 -0
  95. data/spec/integration/rest_transaction_spec.rb +166 -0
  96. data/spec/integration/rest_traverse_spec.rb +149 -0
  97. data/spec/integration/unmanaged_spec.rb +27 -0
  98. data/spec/matchers.rb +33 -0
  99. data/spec/neography_spec.rb +23 -0
  100. data/spec/spec_helper.rb +44 -0
  101. data/spec/unit/config_spec.rb +135 -0
  102. data/spec/unit/connection_spec.rb +284 -0
  103. data/spec/unit/node_spec.rb +100 -0
  104. data/spec/unit/properties_spec.rb +285 -0
  105. data/spec/unit/relationship_spec.rb +118 -0
  106. data/spec/unit/rest/batch_spec.rb +262 -0
  107. data/spec/unit/rest/clean_spec.rb +16 -0
  108. data/spec/unit/rest/constraints_spec.rb +45 -0
  109. data/spec/unit/rest/cypher_spec.rb +20 -0
  110. data/spec/unit/rest/extensions_spec.rb +28 -0
  111. data/spec/unit/rest/gremlin_spec.rb +25 -0
  112. data/spec/unit/rest/helpers_spec.rb +124 -0
  113. data/spec/unit/rest/labels_spec.rb +77 -0
  114. data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
  115. data/spec/unit/rest/node_indexes_spec.rb +140 -0
  116. data/spec/unit/rest/node_paths_spec.rb +77 -0
  117. data/spec/unit/rest/node_properties_spec.rb +79 -0
  118. data/spec/unit/rest/node_relationships_spec.rb +57 -0
  119. data/spec/unit/rest/node_traversal_spec.rb +35 -0
  120. data/spec/unit/rest/nodes_spec.rb +187 -0
  121. data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
  122. data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
  123. data/spec/unit/rest/relationship_properties_spec.rb +79 -0
  124. data/spec/unit/rest/relationship_types_spec.rb +15 -0
  125. data/spec/unit/rest/relationships_spec.rb +21 -0
  126. data/spec/unit/rest/schema_index_spec.rb +30 -0
  127. data/spec/unit/rest/transactions_spec.rb +43 -0
  128. metadata +372 -0
@@ -0,0 +1,52 @@
1
+ module Neography
2
+ class Rest
3
+ module RelationshipProperties
4
+
5
+ def set_relationship_properties(id, properties)
6
+ properties.each do |property, value|
7
+ options = { :body => value.to_json, :headers => json_content_type }
8
+ @connection.put("/relationship/%{id}/properties/%{property}" % {:id => get_id(id), :property => property}, options)
9
+ end
10
+ end
11
+
12
+ def reset_relationship_properties(id, properties)
13
+ options = { :body => properties.to_json, :headers => json_content_type }
14
+ @connection.put("/relationship/%{id}/properties" % {:id => get_id(id)}, options)
15
+ end
16
+
17
+ def get_relationship_properties(id, *properties)
18
+ if properties.none?
19
+ @connection.get("/relationship/%{id}/properties" % {:id => get_id(id)})
20
+ else
21
+ get_each_relationship_properties(id, *properties)
22
+ end
23
+ end
24
+
25
+ def get_each_relationship_properties(id, *properties)
26
+ retrieved_properties = properties.flatten.inject({}) do |memo, property|
27
+ value = @connection.get("/relationship/%{id}/properties/%{property}" % {:id => get_id(id), :property => property})
28
+ memo[property] = value unless value.nil?
29
+ memo
30
+ end
31
+ return nil if retrieved_properties.empty?
32
+ retrieved_properties
33
+ end
34
+
35
+ def remove_relationship_properties(id, *properties)
36
+ if properties.none?
37
+ @connection.delete("/relationship/%{id}/properties" % {:id => get_id(id)})
38
+ else
39
+ remove_each_relationship_properties(id, *properties)
40
+ end
41
+ end
42
+
43
+ def remove_each_relationship_properties(id, *properties)
44
+ properties.flatten.each do |property|
45
+ @connection.delete("/relationship/%{id}/properties/%{property}" % {:id => get_id(id), :property => property})
46
+ end
47
+ end
48
+
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,11 @@
1
+ module Neography
2
+ class Rest
3
+ module RelationshipTypes
4
+
5
+ def list_relationship_types
6
+ @connection.get("/relationship/types")
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module Neography
2
+ class Rest
3
+ module Relationships
4
+ include Neography::Rest::Helpers
5
+
6
+ def get_relationship(id)
7
+ @connection.get("/relationship/%{id}" % {:id => get_id(id)})
8
+ end
9
+
10
+ def delete_relationship(id)
11
+ @connection.delete("/relationship/%{id}" % {:id => get_id(id)})
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ module Neography
2
+ class Rest
3
+ module SchemaIndexes
4
+ include Neography::Rest::Helpers
5
+
6
+ def get_schema_index(label)
7
+ @connection.get("/schema/index/%{label}" % {:label => label})
8
+ end
9
+
10
+ def delete_schema_index(label, index)
11
+ @connection.delete("/schema/index/%{label}/%{index}" % {:label => label, :index => index})
12
+ end
13
+
14
+ def create_schema_index(label, keys = [])
15
+ options = {
16
+ :body => (
17
+ { :property_keys => keys
18
+ }
19
+ ).to_json,
20
+ :headers => json_content_type
21
+ }
22
+ @connection.post("/schema/index/%{label}" % {:label => label}, options)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,137 @@
1
+ module Neography
2
+ class Rest
3
+ module Spatial
4
+ include Neography::Rest::Helpers
5
+
6
+ def get_spatial
7
+ @connection.get("/ext/SpatialPlugin")
8
+ end
9
+
10
+ def add_point_layer(layer, lat = nil, lon = nil)
11
+ options = {
12
+ :body => {
13
+ :layer => layer,
14
+ :lat => lat || "lat",
15
+ :lon => lon || "lon"
16
+ }.to_json,
17
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
18
+ }
19
+
20
+ @connection.post("/ext/SpatialPlugin/graphdb/addSimplePointLayer", options)
21
+ end
22
+
23
+ def add_editable_layer(layer, format = "WKT", node_property_name = "wkt")
24
+ options = {
25
+ :body => {
26
+ :layer => layer,
27
+ :format => format,
28
+ :nodePropertyName => node_property_name
29
+ }.to_json,
30
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
31
+ }
32
+
33
+ @connection.post("/ext/SpatialPlugin/graphdb/addEditableLayer", options)
34
+ end
35
+
36
+ def get_layer(layer)
37
+ options = {
38
+ :body => {
39
+ :layer => layer
40
+ }.to_json,
41
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
42
+ }
43
+ @connection.post("/ext/SpatialPlugin/graphdb/getLayer", options)
44
+ end
45
+
46
+ def add_geometry_to_layer(layer, geometry)
47
+ options = {
48
+ :body => {
49
+ :layer => layer,
50
+ :geometry => geometry
51
+ }.to_json,
52
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
53
+ }
54
+ @connection.post("/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer", options)
55
+ end
56
+
57
+ def edit_geometry_from_layer(layer, geometry, node)
58
+ options = {
59
+ :body => {
60
+ :layer => layer,
61
+ :geometry => geometry,
62
+ :geometryNodeId => get_id(node)
63
+ }.to_json,
64
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
65
+ }
66
+ @connection.post("/ext/SpatialPlugin/graphdb/updateGeometryFromWKT", options)
67
+ end
68
+
69
+ def add_node_to_layer(layer, node)
70
+ options = {
71
+ :body => {
72
+ :layer => layer,
73
+ :node => get_id(node)
74
+ }.to_json,
75
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
76
+ }
77
+ @connection.post("/ext/SpatialPlugin/graphdb/addNodeToLayer", options)
78
+ end
79
+
80
+ def find_geometries_in_bbox(layer, minx, maxx, miny, maxy)
81
+ options = {
82
+ :body => {
83
+ :layer => layer,
84
+ :minx => minx,
85
+ :maxx => maxx,
86
+ :miny => miny,
87
+ :maxy => maxy
88
+ }.to_json,
89
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
90
+ }
91
+ @connection.post("/ext/SpatialPlugin/graphdb/findGeometriesInBBox", options)
92
+ end
93
+
94
+ def find_geometries_within_distance(layer, pointx, pointy, distance)
95
+ options = {
96
+ :body => {
97
+ :layer => layer,
98
+ :pointX => pointx,
99
+ :pointY => pointy,
100
+ :distanceInKm => distance
101
+ }.to_json,
102
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
103
+ }
104
+ @connection.post("/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance", options)
105
+ end
106
+
107
+ def create_spatial_index(name, type = nil, lat = nil, lon = nil)
108
+ options = {
109
+ :body => {
110
+ :name => name,
111
+ :config => {
112
+ :provider => "spatial",
113
+ :geometry_type => type || "point",
114
+ :lat => lat || "lat",
115
+ :lon => lon || "lon"
116
+ }
117
+ }.to_json,
118
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
119
+ }
120
+ @connection.post("/index/node", options)
121
+ end
122
+
123
+ def add_node_to_spatial_index(index, id)
124
+ options = {
125
+ :body => {
126
+ :uri => @connection.configuration + "/node/#{get_id(id)}",
127
+ :key => "k",
128
+ :value => "v"
129
+ }.to_json,
130
+ :headers => json_content_type.merge({'Accept' => 'application/json;charset=UTF-8'})
131
+ }
132
+ @connection.post("/index/node/%{index}" % {:index => index}, options)
133
+ end
134
+
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,101 @@
1
+ module Neography
2
+ class Rest
3
+ module Transactions
4
+ include Neography::Rest::Helpers
5
+
6
+ def begin_transaction(statements = [], commit = "")
7
+ options = {
8
+ :body => (
9
+ convert_cypher(statements)
10
+ ).to_json,
11
+ :headers => json_content_type
12
+ }
13
+ @connection.post("/transaction" + commit, options)
14
+ end
15
+
16
+ def in_transaction(tx, statements = [])
17
+ options = {
18
+ :body => (
19
+ convert_cypher(statements)
20
+ ).to_json,
21
+ :headers => json_content_type
22
+ }
23
+ @connection.post("/transaction/%{id}" % {:id => get_tx_id(tx)}, options)
24
+ end
25
+
26
+ def keep_transaction(tx)
27
+ in_transaction(tx)
28
+ end
29
+
30
+ def commit_transaction(tx, statements = [])
31
+ if (tx.is_a?(Hash) || tx.is_a?(Integer))
32
+ options = {
33
+ :body => (
34
+ convert_cypher(statements)
35
+ ).to_json,
36
+ :headers => json_content_type
37
+ }
38
+ @connection.post("/transaction/%{id}/commit" % {:id => get_tx_id(tx)}, options)
39
+ else
40
+ begin_transaction(tx, "/commit")
41
+ end
42
+ end
43
+
44
+ def rollback_transaction(tx)
45
+ @connection.delete("/transaction/%{id}" % {:id => get_tx_id(tx)})
46
+ end
47
+
48
+ private
49
+
50
+ def get_tx_id(tx)
51
+ return tx if tx.is_a?(Integer)
52
+ return tx.split("/")[-2] if tx.is_a?(String)
53
+ return tx["commit"].split("/")[-2] if tx["commit"]
54
+ raise NeographyError.new("Could not determine transaction id", nil, tx)
55
+ end
56
+
57
+ def convert_cypher(statements)
58
+ array = []
59
+ query = nil
60
+ parameters = nil
61
+ Array(statements).each do |statement|
62
+ case
63
+ when query && parameters && statement.is_a?(Array)
64
+ then
65
+ array << {:statement => query, :parameters => parameters, :resultDataContents => statement }
66
+ query = nil
67
+ parameters = nil
68
+ when query && parameters && statement.is_a?(String)
69
+ then
70
+ array << {:statement => query, :parameters => parameters}
71
+ query = statement
72
+ parameters = nil
73
+ when query && statement.is_a?(Hash)
74
+ then
75
+ parameters = statement
76
+ when query && statement.is_a?(Array)
77
+ then
78
+ array << {:statement => query, :resultDataContents => statement }
79
+ query = nil
80
+ parameters = nil
81
+ else
82
+ query = statement
83
+ end
84
+
85
+ end
86
+
87
+ if query && parameters
88
+ array << {:statement => query, :parameters => parameters}
89
+ query = nil
90
+ end
91
+
92
+ if query
93
+ array << {:statement => query}
94
+ end
95
+
96
+ { :statements => array }
97
+ end
98
+
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,207 @@
1
+ # borrowed from architect4r
2
+ require 'os'
3
+ # require 'zip'
4
+ require 'net/http'
5
+
6
+ namespace :neo4j do
7
+ # desc "Install Neo4j"
8
+ # task :install, :edition, :version do |t, args|
9
+ # args.with_defaults(:edition => "community", :version => "2.0.3")
10
+ # puts "Installing Neo4j-#{args[:edition]}-#{args[:version]}"
11
+ #
12
+ # if OS::Underlying.windows?
13
+ # # Download Neo4j
14
+ # unless File.exist?('neo4j.zip')
15
+ # df = File.open('neo4j.zip', 'wb')
16
+ # begin
17
+ # Net::HTTP.start("dist.neo4j.org") do |http|
18
+ # http.request_get("/neo4j-#{args[:edition]}-#{args[:version]}-windows.zip") do |resp|
19
+ # resp.read_body do |segment|
20
+ # df.write(segment)
21
+ # end
22
+ # end
23
+ # end
24
+ # ensure
25
+ # df.close()
26
+ # end
27
+ # end
28
+ #
29
+ # # Extract and move to neo4j directory
30
+ # unless File.exist?('neo4j')
31
+ # Zip::File.open('neo4j.zip') do |zip_file|
32
+ # zip_file.each do |f|
33
+ # f_path=File.join(".", f.name)
34
+ # FileUtils.mkdir_p(File.dirname(f_path))
35
+ # begin
36
+ # zip_file.extract(f, f_path) unless File.exist?(f_path)
37
+ # rescue
38
+ # puts f.name + " failed to extract."
39
+ # end
40
+ # end
41
+ # end
42
+ # FileUtils.mv "neo4j-#{args[:edition]}-#{args[:version]}", "neo4j"
43
+ # end
44
+ #
45
+ # # Install if running with Admin Privileges
46
+ # if %x[reg query "HKU\\S-1-5-19"].size > 0
47
+ # %x[neo4j/bin/neo4j install]
48
+ # puts "Neo4j Installed as a service."
49
+ # end
50
+ #
51
+ # else
52
+ # %x[curl -O http://dist.neo4j.org/neo4j-#{args[:edition]}-#{args[:version]}-unix.tar.gz]
53
+ # %x[tar -xvzf neo4j-#{args[:edition]}-#{args[:version]}-unix.tar.gz]
54
+ # %x[mv neo4j-#{args[:edition]}-#{args[:version]} neo4j]
55
+ # %x[rm neo4j-#{args[:edition]}-#{args[:version]}-unix.tar.gz]
56
+ # puts "Neo4j Installed in to neo4j directory."
57
+ # end
58
+ # puts "Type 'rake neo4j:start' to start it"
59
+ # end
60
+
61
+ desc "Start the Neo4j Server"
62
+ task :start do
63
+ puts "Starting Neo4j..."
64
+ if OS::Underlying.windows?
65
+ if %x[reg query "HKU\\S-1-5-19"].size > 0
66
+ value = %x[neo4j/bin/Neo4j.bat start] #start service
67
+ else
68
+ puts "Starting Neo4j directly, not as a service."
69
+ value = %x[neo4j/bin/Neo4j.bat]
70
+ end
71
+ else
72
+ value = %x[neo4j/bin/neo4j start]
73
+ end
74
+ puts value
75
+ end
76
+
77
+ desc "Start the Neo4j Server in the background"
78
+ task :start_no_wait do
79
+ puts "Starting Neo4j in the background..."
80
+ if OS::Underlying.windows?
81
+ if %x[reg query "HKU\\S-1-5-19"].size > 0
82
+ value = %x[neo4j/bin/Neo4j.bat start-no-wait] #start service
83
+ else
84
+ puts "Starting Neo4j directly, not as a service."
85
+ value = %x[neo4j/bin/Neo4j.bat start-no-wait]
86
+ end
87
+ else
88
+ value = %x[neo4j/bin/neo4j start-no-wait]
89
+ end
90
+ puts value
91
+ end
92
+
93
+ desc "Stop the Neo4j Server"
94
+ task :stop do
95
+ puts "Stopping Neo4j..."
96
+ if OS::Underlying.windows?
97
+ if %x[reg query "HKU\\S-1-5-19"].size > 0
98
+ value = %x[neo4j/bin/Neo4j.bat stop] #stop service
99
+ else
100
+ puts "You do not have administrative rights to stop the Neo4j Service"
101
+ end
102
+ else
103
+ value = %x[neo4j/bin/neo4j stop]
104
+ end
105
+ puts value
106
+ end
107
+
108
+ desc "Restart the Neo4j Server"
109
+ task :restart do
110
+ puts "Restarting Neo4j..."
111
+ if OS::Underlying.windows?
112
+ if %x[reg query "HKU\\S-1-5-19"].size > 0
113
+ %x[neo4j/bin/Neo4j.bat restart]
114
+ else
115
+ puts "You do not have administrative rights to restart the Neo4j Service"
116
+ end
117
+ else
118
+ %x[neo4j/bin/neo4j restart]
119
+ end
120
+ end
121
+
122
+ desc "Reset the Neo4j Server"
123
+ task :reset_yes_i_am_sure do
124
+ # Stop the server
125
+ if OS::Underlying.windows?
126
+ if %x[reg query "HKU\\S-1-5-19"].size > 0
127
+ %x[neo4j/bin/Neo4j.bat stop]
128
+
129
+ # Reset the database
130
+ FileUtils.rm_rf("neo4j/data/graph.db")
131
+ FileUtils.mkdir("neo4j/data/graph.db")
132
+
133
+ # Remove log files
134
+ FileUtils.rm_rf("neo4j/data/log")
135
+ FileUtils.mkdir("neo4j/data/log")
136
+
137
+ %x[neo4j/bin/Neo4j.bat start]
138
+ else
139
+ puts "You do not have administrative rights to reset the Neo4j Service"
140
+ end
141
+ else
142
+ %x[neo4j/bin/neo4j stop]
143
+
144
+ # Reset the database
145
+ FileUtils.rm_rf("neo4j/data/graph.db")
146
+ FileUtils.mkdir("neo4j/data/graph.db")
147
+
148
+ # Remove log files
149
+ FileUtils.rm_rf("neo4j/data/log")
150
+ FileUtils.mkdir("neo4j/data/log")
151
+
152
+ # Start the server
153
+ %x[neo4j/bin/neo4j start]
154
+ end
155
+ end
156
+
157
+ # task :get_spatial, :version do |t, args|
158
+ # args.with_defaults(:version => "2.0.1")
159
+ # puts "Installing Neo4j-Spatial #{args[:version]}"
160
+ #
161
+ # unless File.exist?('neo4j-spatial.zip')
162
+ # df = File.open('neo4j-spatial.zip', 'wb')
163
+ # case args[:version]
164
+ # when "2.0.1"
165
+ # dist = "m2.neo4j.org"
166
+ # request = "/content/repositories/releases/org/neo4j/neo4j-spatial/0.13-neo4j-2.0.1/neo4j-spatial-0.13-neo4j-2.0.1-server-plugin.zip"
167
+ # when "2.0.0"
168
+ # dist = "dist.neo4j.org"
169
+ # request = "/spatial/neo4j-spatial-0.12-neo4j-2.0.0-server-plugin.zip"
170
+ # when "1.9"
171
+ # dist = "dist.neo4j.org.s3.amazonaws.com"
172
+ # request = "/spatial/neo4j-spatial-0.11-neo4j-1.9-server-plugin.zip"
173
+ # when "1.8.2"
174
+ # dist = "dist.neo4j.org.s3.amazonaws.com"
175
+ # request = "/spatial/neo4j-spatial-0.9.1-neo4j-1.8.2-server-plugin.zip"
176
+ # else
177
+ # abort("I don't know that version of the neo4j spatial plugin")
178
+ # end
179
+ #
180
+ # begin
181
+ # Net::HTTP.start(dist) do |http|
182
+ # http.request_get(request) do |resp|
183
+ # resp.read_body do |segment|
184
+ # df.write(segment)
185
+ # end
186
+ # end
187
+ # end
188
+ # ensure
189
+ # df.close()
190
+ # end
191
+ # end
192
+ #
193
+ # # Extract to neo4j plugins directory
194
+ # Zip::File.open('neo4j-spatial.zip') do |zip_file|
195
+ # zip_file.each do |f|
196
+ # f_path=File.join("neo4j/plugins/", f.name)
197
+ # FileUtils.mkdir_p(File.dirname(f_path))
198
+ # begin
199
+ # zip_file.extract(f, f_path) unless File.exist?(f_path)
200
+ # rescue
201
+ # puts f.name + " failed to extract."
202
+ # end
203
+ # end
204
+ # end
205
+ #
206
+ # end
207
+ # end