Class: Neography::Rest

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Helpers
Defined in:
lib/neography/rest.rb,
lib/neography/rest/batch.rb,
lib/neography/rest/clean.rb,
lib/neography/rest/nodes.rb,
lib/neography/rest/paths.rb,
lib/neography/rest/cypher.rb,
lib/neography/rest/gremlin.rb,
lib/neography/rest/helpers.rb,
lib/neography/rest/indexes.rb,
lib/neography/rest/extensions.rb,
lib/neography/rest/node_paths.rb,
lib/neography/rest/properties.rb,
lib/neography/rest/auto_indexes.rb,
lib/neography/rest/node_indexes.rb,
lib/neography/rest/relationships.rb,
lib/neography/rest/node_traversal.rb,
lib/neography/rest/node_properties.rb,
lib/neography/rest/node_auto_indexes.rb,
lib/neography/rest/node_relationships.rb,
lib/neography/rest/relationship_indexes.rb,
lib/neography/rest/relationship_properties.rb,
lib/neography/rest/relationship_auto_indexes.rb

Defined Under Namespace

Modules: Helpers, Paths Classes: AutoIndexes, Batch, Clean, Cypher, Extensions, Gremlin, Indexes, NodeAutoIndexes, NodeIndexes, NodePaths, NodeProperties, NodeRelationships, NodeTraversal, Nodes, Properties, RelationshipAutoIndexes, RelationshipIndexes, RelationshipProperties, Relationships

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#get_id, #json_content_type

Constructor Details

#initialize(options = ENV['NEO4J_URL'] || {}) ⇒ Rest

Returns a new instance of Rest.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/neography/rest.rb', line 41

def initialize(options = ENV['NEO4J_URL'] || {})
  @connection = Connection.new(options)

  @nodes                     = Nodes.new(@connection)
  @node_properties           = NodeProperties.new(@connection)
  @node_relationships        = NodeRelationships.new(@connection)
  @node_indexes              = NodeIndexes.new(@connection)
  @node_auto_indexes         = NodeAutoIndexes.new(@connection)
  @node_traversal            = NodeTraversal.new(@connection)
  @node_paths                = NodePaths.new(@connection)

  @relationships             = Relationships.new(@connection)
  @relationship_properties   = RelationshipProperties.new(@connection)
  @relationship_indexes      = RelationshipIndexes.new(@connection)
  @relationship_auto_indexes = RelationshipAutoIndexes.new(@connection)

  @cypher                    = Cypher.new(@connection)
  @gremlin                   = Gremlin.new(@connection)
  @extensions                = Extensions.new(@connection)
  @batch                     = Batch.new(@connection)
  @clean                     = Clean.new(@connection)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



37
38
39
# File 'lib/neography/rest.rb', line 37

def connection
  @connection
end

Instance Method Details

#add_node_auto_index_property(property) ⇒ Object



234
235
236
# File 'lib/neography/rest.rb', line 234

def add_node_auto_index_property(property)
  @node_auto_indexes.add_property(property)
end

#add_node_to_index(index, key, value, id) ⇒ Object Also known as: add_to_index



193
194
195
# File 'lib/neography/rest.rb', line 193

def add_node_to_index(index, key, value, id)
  @node_indexes.add(index, key, value, id)
end

#add_relationship_auto_index_property(property) ⇒ Object



298
299
300
# File 'lib/neography/rest.rb', line 298

def add_relationship_auto_index_property(property)
  @relationship_auto_indexes.add_property(property)
end

#add_relationship_to_index(index, key, value, id) ⇒ Object



260
261
262
# File 'lib/neography/rest.rb', line 260

def add_relationship_to_index(index, key, value, id)
  @relationship_indexes.add(index, key, value, id)
end

#batch(*args) ⇒ Object

batch



350
351
352
# File 'lib/neography/rest.rb', line 350

def batch(*args)
  @batch.execute(*args)
end

#batch_not_streaming(*args) ⇒ Object



354
355
356
# File 'lib/neography/rest.rb', line 354

def batch_not_streaming(*args)
  @batch.not_streaming(*args)
end

#clean_database(sanity_check = "not_really") ⇒ Object

For testing (use a separate neo4j instance) call this before each test or spec



362
363
364
365
366
367
368
369
# File 'lib/neography/rest.rb', line 362

def clean_database(sanity_check = "not_really")
  if sanity_check == "yes_i_really_want_to_clean_the_database"
    @clean.execute
    true
  else
    false
  end
end

#create_node(*args) ⇒ Object



78
79
80
# File 'lib/neography/rest.rb', line 78

def create_node(*args)
  @nodes.create(*args)
end

#create_node_auto_index(type = "exact", provider = "lucene") ⇒ Object



185
186
187
# File 'lib/neography/rest.rb', line 185

def create_node_auto_index(type = "exact", provider = "lucene")
  @node_indexes.create_auto(type, provider)
end

#create_node_index(name, type = "exact", provider = "lucene") ⇒ Object



181
182
183
# File 'lib/neography/rest.rb', line 181

def create_node_index(name, type = "exact", provider = "lucene")
  @node_indexes.create(name, type, provider)
end

#create_nodes(args) ⇒ Object



82
83
84
# File 'lib/neography/rest.rb', line 82

def create_nodes(args)
  @nodes.create_multiple(args)
end

#create_nodes_threaded(args) ⇒ Object



86
87
88
# File 'lib/neography/rest.rb', line 86

def create_nodes_threaded(args)
  @nodes.create_multiple_threaded(args)
end

#create_relationship(type, from, to, props = nil) ⇒ Object



170
171
172
# File 'lib/neography/rest.rb', line 170

def create_relationship(type, from, to, props = nil)
  @node_relationships.create(type, from, to, props)
end

#create_relationship_auto_index(type = "exact", provider = "lucene") ⇒ Object



252
253
254
# File 'lib/neography/rest.rb', line 252

def create_relationship_auto_index(type = "exact", provider = "lucene")
  @relationship_indexes.create_auto(type, provider)
end

#create_relationship_index(name, type = "exact", provider = "lucene") ⇒ Object



248
249
250
# File 'lib/neography/rest.rb', line 248

def create_relationship_index(name, type = "exact", provider = "lucene")
  @relationship_indexes.create(name, type, provider)
end

#create_unique_node(index, key, value, props = {}) ⇒ Object



189
190
191
# File 'lib/neography/rest.rb', line 189

def create_unique_node(index, key, value, props={})
  @node_indexes.create_unique(index, key, value, props)
end

#create_unique_relationship(index, key, value, type, from, to) ⇒ Object



256
257
258
# File 'lib/neography/rest.rb', line 256

def create_unique_relationship(index, key, value, type, from, to)
  @relationship_indexes.create_unique(index, key, value, type, from, to)
end

#delete_node(id) ⇒ Object



90
91
92
# File 'lib/neography/rest.rb', line 90

def delete_node(id)
  @nodes.delete(id)
end

#delete_node!(id) ⇒ Object



94
95
96
97
98
99
100
101
# File 'lib/neography/rest.rb', line 94

def delete_node!(id)
  relationships = get_node_relationships(get_id(id))
  relationships.each do |relationship|
    delete_relationship(relationship["self"].split('/').last)
  end unless relationships.nil?

  delete_node(id)
end

#delete_relationship(id) ⇒ Object



134
135
136
# File 'lib/neography/rest.rb', line 134

def delete_relationship(id)
  @relationships.delete(id)
end

#execute_query(query, params = {}) ⇒ Object

cypher query



328
329
330
# File 'lib/neography/rest.rb', line 328

def execute_query(query, params = {})
  @cypher.query(query, params)
end

#execute_script(script, params = {}) ⇒ Object

gremlin script



334
335
336
# File 'lib/neography/rest.rb', line 334

def execute_script(script, params = {})
  @gremlin.execute(script, params)
end

#find_node_auto_index(key_or_query, value = nil) ⇒ Object



218
219
220
# File 'lib/neography/rest.rb', line 218

def find_node_auto_index(key_or_query, value = nil)
  @node_auto_indexes.find_or_query(key_or_query, value)
end

#find_node_index(index, key_or_query, value = nil) ⇒ Object



208
209
210
# File 'lib/neography/rest.rb', line 208

def find_node_index(index, key_or_query, value = nil)
  @node_indexes.find(index, key_or_query, value)
end

#find_relationship_auto_index(key_or_query, value = nil) ⇒ Object



282
283
284
# File 'lib/neography/rest.rb', line 282

def find_relationship_auto_index(key_or_query, value = nil)
  @relationship_auto_indexes.find_or_query(key_or_query, value)
end

#find_relationship_index(index, key_or_query, value = nil) ⇒ Object



272
273
274
# File 'lib/neography/rest.rb', line 272

def find_relationship_index(index, key_or_query, value = nil)
  @relationship_indexes.find(index, key_or_query, value)
end

#get_extension(path) ⇒ Object



344
345
346
# File 'lib/neography/rest.rb', line 344

def get_extension(path)
  @extensions.get(path)
end

#get_node(id) ⇒ Object



70
71
72
# File 'lib/neography/rest.rb', line 70

def get_node(id)
  @nodes.get(id)
end

#get_node_auto_index(key, value) ⇒ Object

auto node indexes



214
215
216
# File 'lib/neography/rest.rb', line 214

def get_node_auto_index(key, value)
  @node_auto_indexes.get(key, value)
end

#get_node_auto_index_propertiesObject



230
231
232
# File 'lib/neography/rest.rb', line 230

def get_node_auto_index_properties
  @node_auto_indexes.properties
end

#get_node_auto_index_statusObject



222
223
224
# File 'lib/neography/rest.rb', line 222

def get_node_auto_index_status
  @node_auto_indexes.status
end

#get_node_index(index, key, value) ⇒ Object Also known as: get_index



203
204
205
# File 'lib/neography/rest.rb', line 203

def get_node_index(index, key, value)
  @node_indexes.get(index, key, value)
end

#get_node_properties(id, *properties) ⇒ Object

node properties



112
113
114
# File 'lib/neography/rest.rb', line 112

def get_node_properties(id, *properties)
  @node_properties.get(id, *properties.flatten)
end

#get_node_relationships(id, dir = nil, types = nil) ⇒ Object

node relationships



166
167
168
# File 'lib/neography/rest.rb', line 166

def get_node_relationships(id, dir = nil, types = nil)
  @node_relationships.get(id, dir, types)
end

#get_nodes(*args) ⇒ Object



74
75
76
# File 'lib/neography/rest.rb', line 74

def get_nodes(*args)
  @nodes.get_each(*args)
end

#get_path(from, to, relationships, depth = 1, algorithm = "shortestPath") ⇒ Object

paths



314
315
316
# File 'lib/neography/rest.rb', line 314

def get_path(from, to, relationships, depth = 1, algorithm = "shortestPath")
  @node_paths.get(from, to, relationships, depth, algorithm)
end

#get_paths(from, to, relationships, depth = 1, algorithm = "allPaths") ⇒ Object



318
319
320
# File 'lib/neography/rest.rb', line 318

def get_paths(from, to, relationships, depth = 1, algorithm = "allPaths")
  @node_paths.get_all(from, to, relationships, depth, algorithm)
end

#get_relationship(id) ⇒ Object

relationships



130
131
132
# File 'lib/neography/rest.rb', line 130

def get_relationship(id)
  @relationships.get(id)
end

#get_relationship_auto_index(key, value) ⇒ Object

relationship auto indexes



278
279
280
# File 'lib/neography/rest.rb', line 278

def get_relationship_auto_index(key, value)
  @relationship_auto_indexes.get(key, value)
end

#get_relationship_auto_index_propertiesObject



294
295
296
# File 'lib/neography/rest.rb', line 294

def get_relationship_auto_index_properties
  @relationship_auto_indexes.properties
end

#get_relationship_auto_index_statusObject



286
287
288
# File 'lib/neography/rest.rb', line 286

def get_relationship_auto_index_status
  @relationship_auto_indexes.status
end

#get_relationship_end_node(rel) ⇒ Object



142
143
144
# File 'lib/neography/rest.rb', line 142

def get_relationship_end_node(rel)
  get_node(rel["end"])
end

#get_relationship_index(index, key, value) ⇒ Object



268
269
270
# File 'lib/neography/rest.rb', line 268

def get_relationship_index(index, key, value)
  @relationship_indexes.get(index, key, value)
end

#get_relationship_properties(id, *properties) ⇒ Object

relationship properties



148
149
150
# File 'lib/neography/rest.rb', line 148

def get_relationship_properties(id, *properties)
  @relationship_properties.get(id, *properties.flatten)
end

#get_relationship_start_node(rel) ⇒ Object



138
139
140
# File 'lib/neography/rest.rb', line 138

def get_relationship_start_node(rel)
  get_node(rel["start"])
end

#get_rootObject

nodes



66
67
68
# File 'lib/neography/rest.rb', line 66

def get_root
  @nodes.root
end

#get_shortest_weighted_path(from, to, relationships, weight_attr = "weight", depth = 1, algorithm = "dijkstra") ⇒ Object



322
323
324
# File 'lib/neography/rest.rb', line 322

def get_shortest_weighted_path(from, to, relationships, weight_attr = "weight", depth = 1, algorithm = "dijkstra")
  @node_paths.shortest_weighted(from, to, relationships, weight_attr, depth, algorithm)
end

#list_node_indexesObject Also known as: list_indexes

node indexes



176
177
178
# File 'lib/neography/rest.rb', line 176

def list_node_indexes
  @node_indexes.list
end

#list_relationship_indexesObject

relationship indexes



244
245
246
# File 'lib/neography/rest.rb', line 244

def list_relationship_indexes
  @relationship_indexes.list
end

#post_extension(path, params = {}) ⇒ Object

unmanaged extensions



340
341
342
# File 'lib/neography/rest.rb', line 340

def post_extension(path, params = {})
  @extensions.post(path, params)
end

#remove_node_auto_index_property(property) ⇒ Object



238
239
240
# File 'lib/neography/rest.rb', line 238

def remove_node_auto_index_property(property)
  @node_auto_indexes.remove_property(property)
end

#remove_node_from_index(index, id_or_key, id_or_value = nil, id = nil) ⇒ Object Also known as: remove_from_index



198
199
200
# File 'lib/neography/rest.rb', line 198

def remove_node_from_index(index, id_or_key, id_or_value = nil, id = nil)
  @node_indexes.remove(index, id_or_key, id_or_value, id)
end

#remove_node_properties(id, *properties) ⇒ Object



124
125
126
# File 'lib/neography/rest.rb', line 124

def remove_node_properties(id, *properties)
  @node_properties.remove(id, *properties.flatten)
end

#remove_relationship_auto_index_property(property) ⇒ Object



302
303
304
# File 'lib/neography/rest.rb', line 302

def remove_relationship_auto_index_property(property)
  @relationship_auto_indexes.remove_property(property)
end

#remove_relationship_from_index(index, id_or_key, id_or_value = nil, id = nil) ⇒ Object



264
265
266
# File 'lib/neography/rest.rb', line 264

def remove_relationship_from_index(index, id_or_key, id_or_value = nil, id = nil)
  @relationship_indexes.remove(index, id_or_key, id_or_value, id)
end

#remove_relationship_properties(id, *properties) ⇒ Object



160
161
162
# File 'lib/neography/rest.rb', line 160

def remove_relationship_properties(id, *properties)
  @relationship_properties.remove(id, *properties.flatten)
end

#reset_node_properties(id, properties) ⇒ Object



120
121
122
# File 'lib/neography/rest.rb', line 120

def reset_node_properties(id, properties)
  @node_properties.reset(id, properties)
end

#reset_relationship_properties(id, properties) ⇒ Object



156
157
158
# File 'lib/neography/rest.rb', line 156

def reset_relationship_properties(id, properties)
  @relationship_properties.reset(id, properties)
end

#set_node_auto_index_status(change_to = true) ⇒ Object



226
227
228
# File 'lib/neography/rest.rb', line 226

def set_node_auto_index_status(change_to = true)
  @node_auto_indexes.status = change_to
end

#set_node_properties(id, properties) ⇒ Object



116
117
118
# File 'lib/neography/rest.rb', line 116

def set_node_properties(id, properties)
  @node_properties.set(id, properties)
end

#set_relationship_auto_index_status(change_to = true) ⇒ Object



290
291
292
# File 'lib/neography/rest.rb', line 290

def set_relationship_auto_index_status(change_to = true)
  @relationship_auto_indexes.status = change_to
end

#set_relationship_properties(id, properties) ⇒ Object



152
153
154
# File 'lib/neography/rest.rb', line 152

def set_relationship_properties(id, properties)
  @relationship_properties.set(id, properties)
end

#traverse(id, return_type, description) ⇒ Object

traversal



308
309
310
# File 'lib/neography/rest.rb', line 308

def traverse(id, return_type, description)
  @node_traversal.traverse(id, return_type, description)
end