neo4j 1.0.0.beta.21-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +141 -0
- data/CONTRIBUTORS +17 -0
- data/Gemfile +16 -0
- data/README.rdoc +135 -0
- data/lib/generators/neo4j.rb +65 -0
- data/lib/generators/neo4j/model/model_generator.rb +39 -0
- data/lib/generators/neo4j/model/templates/model.erb +7 -0
- data/lib/neo4j.rb +77 -0
- data/lib/neo4j/config.rb +153 -0
- data/lib/neo4j/database.rb +56 -0
- data/lib/neo4j/equal.rb +21 -0
- data/lib/neo4j/event_handler.rb +116 -0
- data/lib/neo4j/index/class_methods.rb +62 -0
- data/lib/neo4j/index/index.rb +33 -0
- data/lib/neo4j/index/indexer.rb +312 -0
- data/lib/neo4j/index/indexer_registry.rb +68 -0
- data/lib/neo4j/index/lucene_query.rb +191 -0
- data/lib/neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
- data/lib/neo4j/jars/lucene-core-3.0.2.jar +0 -0
- data/lib/neo4j/jars/neo4j-index-1.2-1.2.M03.jar +0 -0
- data/lib/neo4j/jars/neo4j-kernel-1.2-1.2.M03.jar +0 -0
- data/lib/neo4j/jars/neo4j-lucene-index-0.2-1.2.M03.jar +0 -0
- data/lib/neo4j/load.rb +21 -0
- data/lib/neo4j/mapping/class_methods/init_node.rb +50 -0
- data/lib/neo4j/mapping/class_methods/init_rel.rb +35 -0
- data/lib/neo4j/mapping/class_methods/list.rb +13 -0
- data/lib/neo4j/mapping/class_methods/property.rb +82 -0
- data/lib/neo4j/mapping/class_methods/relationship.rb +91 -0
- data/lib/neo4j/mapping/class_methods/rule.rb +295 -0
- data/lib/neo4j/mapping/decl_relationship_dsl.rb +214 -0
- data/lib/neo4j/mapping/has_list.rb +134 -0
- data/lib/neo4j/mapping/has_n.rb +83 -0
- data/lib/neo4j/mapping/node_mixin.rb +112 -0
- data/lib/neo4j/mapping/relationship_mixin.rb +120 -0
- data/lib/neo4j/model.rb +4 -0
- data/lib/neo4j/neo4j.rb +95 -0
- data/lib/neo4j/node.rb +131 -0
- data/lib/neo4j/node_mixin.rb +4 -0
- data/lib/neo4j/node_relationship.rb +149 -0
- data/lib/neo4j/node_traverser.rb +157 -0
- data/lib/neo4j/property.rb +111 -0
- data/lib/neo4j/rails/attributes.rb +155 -0
- data/lib/neo4j/rails/callbacks.rb +34 -0
- data/lib/neo4j/rails/finders.rb +134 -0
- data/lib/neo4j/rails/lucene_connection_closer.rb +19 -0
- data/lib/neo4j/rails/mapping/property.rb +60 -0
- data/lib/neo4j/rails/model.rb +105 -0
- data/lib/neo4j/rails/persistence.rb +260 -0
- data/lib/neo4j/rails/railtie.rb +21 -0
- data/lib/neo4j/rails/relationships/mapper.rb +96 -0
- data/lib/neo4j/rails/relationships/relationship.rb +30 -0
- data/lib/neo4j/rails/relationships/relationships.rb +60 -0
- data/lib/neo4j/rails/serialization.rb +25 -0
- data/lib/neo4j/rails/timestamps.rb +65 -0
- data/lib/neo4j/rails/transaction.rb +67 -0
- data/lib/neo4j/rails/tx_methods.rb +15 -0
- data/lib/neo4j/rails/validations.rb +38 -0
- data/lib/neo4j/rails/validations/non_nil.rb +11 -0
- data/lib/neo4j/rails/validations/uniqueness.rb +37 -0
- data/lib/neo4j/relationship.rb +169 -0
- data/lib/neo4j/relationship_mixin.rb +4 -0
- data/lib/neo4j/relationship_traverser.rb +92 -0
- data/lib/neo4j/to_java.rb +31 -0
- data/lib/neo4j/transaction.rb +68 -0
- data/lib/neo4j/type_converters.rb +117 -0
- data/lib/neo4j/version.rb +3 -0
- data/lib/orm_adapter/adapters/neo4j.rb +55 -0
- data/lib/tmp/neo4j/active_tx_log +1 -0
- data/lib/tmp/neo4j/index/lucene-store.db +0 -0
- data/lib/tmp/neo4j/index/lucene.log.active +0 -0
- data/lib/tmp/neo4j/lucene-fulltext/lucene-store.db +0 -0
- data/lib/tmp/neo4j/lucene-fulltext/lucene.log.active +0 -0
- data/lib/tmp/neo4j/lucene/lucene-store.db +0 -0
- data/lib/tmp/neo4j/lucene/lucene.log.active +0 -0
- data/lib/tmp/neo4j/messages.log +85 -0
- data/lib/tmp/neo4j/neostore +0 -0
- data/lib/tmp/neo4j/neostore.id +0 -0
- data/lib/tmp/neo4j/neostore.nodestore.db +0 -0
- data/lib/tmp/neo4j/neostore.nodestore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.arrays +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.arrays.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.keys +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.keys.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.strings +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.strings.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshipstore.db +0 -0
- data/lib/tmp/neo4j/neostore.relationshipstore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names.id +0 -0
- data/lib/tmp/neo4j/nioneo_logical.log.active +0 -0
- data/lib/tmp/neo4j/tm_tx_log.1 +0 -0
- data/neo4j.gemspec +31 -0
- metadata +216 -0
data/lib/neo4j/config.rb
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
|
2
|
+
module Neo4j
|
3
|
+
|
4
|
+
|
5
|
+
# == Keeps configuration for neo4j
|
6
|
+
#
|
7
|
+
# The most important configuration is <tt>Neo4j::Config[:storage_path]</tt> which is used to
|
8
|
+
# locate where the neo4j database is stored on the filesystem.
|
9
|
+
# If this directory is empty then a new database will be created, otherwise it will use the
|
10
|
+
# database from that directory.
|
11
|
+
#
|
12
|
+
# ==== Default Configurations
|
13
|
+
# <tt>:storage_path</tt>:: default <tt>tmp/neo4j</tt> where the database is stored
|
14
|
+
# <tt>:timestamps</tt>:: default <tt>true</tt> for Rails Neo4j::Model - if timestamps should be used when saving the model
|
15
|
+
# <tt>:lucene</tt>:: default hash keys: <tt>:fulltext</tt>, <tt>:exact</tt> configuration how the lucene index is stored
|
16
|
+
# <tt>:converters</tt>:: defines which converters should be used before writing and reading to neo4j, see Neo4j::TypeConverters
|
17
|
+
#
|
18
|
+
class Config
|
19
|
+
# This code is copied from merb-core/config.rb.
|
20
|
+
class << self
|
21
|
+
# Returns the hash of default config values for neo4j
|
22
|
+
#
|
23
|
+
# ==== Returns
|
24
|
+
# Hash:: The defaults for the config.
|
25
|
+
def defaults
|
26
|
+
@defaults ||= {
|
27
|
+
:storage_path => 'tmp/neo4j',
|
28
|
+
:timestamps => true,
|
29
|
+
|
30
|
+
# TODO: Just pickup all converter classes that are in the Neo4j::TypeConverters module?
|
31
|
+
:converters => { Date => Neo4j::TypeConverters::DateConverter,
|
32
|
+
DateTime => Neo4j::TypeConverters::DateTimeConverter,
|
33
|
+
Time => Neo4j::TypeConverters::TimeConverter
|
34
|
+
},
|
35
|
+
|
36
|
+
:lucene => {
|
37
|
+
:fulltext => {"provider" => "lucene", "type" => "fulltext" },
|
38
|
+
:exact => {"provider" => "lucene", "type" => "exact" }}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# Yields the configuration.
|
44
|
+
#
|
45
|
+
# ==== Block parameters
|
46
|
+
# c :: The configuration parameters, a hash.
|
47
|
+
#
|
48
|
+
# ==== Examples
|
49
|
+
# Neo4j::Config.use do |config|
|
50
|
+
# config[:storage_path] = '/var/neo4j'
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# ==== Returns
|
54
|
+
# nil
|
55
|
+
def use
|
56
|
+
@configuration ||= {}
|
57
|
+
yield @configuration
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Set the value of a config entry.
|
63
|
+
#
|
64
|
+
# ==== Parameters
|
65
|
+
# key :: The key to set the parameter for.
|
66
|
+
# val :: The value of the parameter.
|
67
|
+
#
|
68
|
+
def []=(key, val)
|
69
|
+
(@configuration ||= setup)[key] = val
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
# Gets the the value of a config entry
|
74
|
+
#
|
75
|
+
# ==== Parameters
|
76
|
+
# key:: The key of the config entry value we want
|
77
|
+
#
|
78
|
+
def [](key)
|
79
|
+
(@configuration ||= setup)[key]
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# Remove the value of a config entry.
|
84
|
+
#
|
85
|
+
# ==== Parameters
|
86
|
+
# key<Object>:: The key of the parameter to delete.
|
87
|
+
#
|
88
|
+
# ==== Returns
|
89
|
+
# The value of the removed entry.
|
90
|
+
#
|
91
|
+
def delete(key)
|
92
|
+
@configuration.delete(key)
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# Remove all configuration. This can be useful for testing purpose.
|
97
|
+
#
|
98
|
+
#
|
99
|
+
# ==== Returns
|
100
|
+
# nil
|
101
|
+
#
|
102
|
+
def delete_all
|
103
|
+
@configuration = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
# Retrieve the value of a config entry, returning the provided default if the key is not present
|
108
|
+
#
|
109
|
+
# ==== Parameters
|
110
|
+
# key:: The key to retrieve the parameter for.
|
111
|
+
# default::The default value to return if the parameter is not set.
|
112
|
+
#
|
113
|
+
# ==== Returns
|
114
|
+
# The value of the configuration parameter or the default.
|
115
|
+
#
|
116
|
+
def fetch(key, default)
|
117
|
+
@configuration.fetch(key, default)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Sets up the configuration
|
121
|
+
#
|
122
|
+
# ==== Returns
|
123
|
+
# The configuration as a hash.
|
124
|
+
#
|
125
|
+
def setup()
|
126
|
+
@configuration = {}
|
127
|
+
@configuration.merge!(defaults)
|
128
|
+
@configuration
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
# Returns the configuration as a hash.
|
133
|
+
#
|
134
|
+
# ==== Returns
|
135
|
+
# The config as a hash.
|
136
|
+
#
|
137
|
+
def to_hash
|
138
|
+
@configuration
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns the config as YAML.
|
142
|
+
#
|
143
|
+
# ==== Returns
|
144
|
+
# The config as YAML.
|
145
|
+
#
|
146
|
+
def to_yaml
|
147
|
+
require "yaml"
|
148
|
+
@configuration.to_yaml
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Neo4j
|
2
|
+
class Database #:nodoc:
|
3
|
+
attr_reader :graph, :lucene, :event_handler
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
@event_handler = EventHandler.new
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def start
|
11
|
+
@graph = org.neo4j.kernel.EmbeddedGraphDatabase.new(Config[:storage_path])
|
12
|
+
@lucene = @graph.index #org.neo4j.index.impl.lucene.LuceneIndexProvider.new
|
13
|
+
@graph.register_transaction_event_handler(@event_handler)
|
14
|
+
@running = true
|
15
|
+
@event_handler.neo4j_started(self)
|
16
|
+
at_exit { shutdown }
|
17
|
+
end
|
18
|
+
|
19
|
+
def shutdown
|
20
|
+
if @running
|
21
|
+
@graph.unregister_transaction_event_handler(@event_handler)
|
22
|
+
@event_handler.neo4j_shutdown(self)
|
23
|
+
@graph.shutdown
|
24
|
+
@graph = nil
|
25
|
+
@lucene = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
@running = false
|
29
|
+
end
|
30
|
+
|
31
|
+
def running?
|
32
|
+
@running
|
33
|
+
end
|
34
|
+
|
35
|
+
def begin_tx
|
36
|
+
@graph.begin_tx
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def each_node
|
41
|
+
iter = @graph.all_nodes.iterator
|
42
|
+
while (iter.hasNext)
|
43
|
+
yield iter.next.wrapper
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def _each_node
|
48
|
+
iter = @graph.all_nodes.iterator
|
49
|
+
while (iter.hasNext)
|
50
|
+
yield iter.next
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/lib/neo4j/equal.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Neo4j
|
2
|
+
|
3
|
+
# == This mixin is used for both nodes and relationships to decide if two entities are equal or not.
|
4
|
+
#
|
5
|
+
module Equal
|
6
|
+
def equal?(o)
|
7
|
+
eql?(o)
|
8
|
+
end
|
9
|
+
|
10
|
+
def eql?(o)
|
11
|
+
return false unless o.respond_to?(:getId)
|
12
|
+
o.getId == getId
|
13
|
+
end
|
14
|
+
|
15
|
+
def ==(o)
|
16
|
+
eql?(o)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Neo4j
|
2
|
+
|
3
|
+
# == Handles Transactional Events
|
4
|
+
#
|
5
|
+
# You can use this to receive event before the transaction commits.
|
6
|
+
# The following events are supported:
|
7
|
+
# * <tt>on_neo4j_started</tt>
|
8
|
+
# * <tt>on_neo4j_shutdown</tt>
|
9
|
+
# * <tt>on_node_created</tt>
|
10
|
+
# * <tt>on_node_deleted</tt>
|
11
|
+
# * <tt>on_relationship_created</tt>
|
12
|
+
# * <tt>on_relationship_deleted</tt>
|
13
|
+
# * <tt>on_property_changed</tt>
|
14
|
+
# * <tt>on_rel_property_changed</tt>
|
15
|
+
#
|
16
|
+
# === Usage
|
17
|
+
#
|
18
|
+
# class MyListener
|
19
|
+
# def on_node_deleted(node, old_props, tx_data)
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# # to add an listener without starting neo4j:
|
24
|
+
# Neo4j.unstarted_db.event_handler.add(MyListener.new)
|
25
|
+
#
|
26
|
+
# You only need to implement the methods that you need.
|
27
|
+
#
|
28
|
+
class EventHandler
|
29
|
+
include org.neo4j.graphdb.event.TransactionEventHandler
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@listeners = []
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def after_commit(data, state)
|
37
|
+
end
|
38
|
+
|
39
|
+
def after_rollback(data, state)
|
40
|
+
end
|
41
|
+
|
42
|
+
def before_commit(data)
|
43
|
+
data.created_nodes.each{|node| node_created(node)}
|
44
|
+
data.assigned_node_properties.each { |tx_data| property_changed(tx_data.entity, tx_data.key, tx_data.previously_commited_value, tx_data.value) }
|
45
|
+
data.removed_node_properties.each { |tx_data| property_changed(tx_data.entity, tx_data.key, tx_data.previously_commited_value, nil) unless data.deleted_nodes.include?(tx_data.entity) }
|
46
|
+
data.deleted_nodes.each { |node| node_deleted(node, deleted_properties_for(node,data), data)}
|
47
|
+
data.created_relationships.each {|rel| relationship_created(rel, data)}
|
48
|
+
data.deleted_relationships.each {|rel| relationship_deleted(rel, deleted_rel_properties_for(rel, data), data)}
|
49
|
+
data.assigned_relationship_properties.each { |tx_data| rel_property_changed(tx_data.entity, tx_data.key, tx_data.previously_commited_value, tx_data.value) }
|
50
|
+
data.removed_relationship_properties.each {|tx_data| rel_property_changed(tx_data.entity, tx_data.key, tx_data.previously_commited_value, nil) unless data.deleted_relationships.include?(tx_data.entity) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def deleted_properties_for(node, data)
|
54
|
+
data.removed_node_properties.find_all{|tx_data| tx_data.entity == node}.inject({}) do |memo, tx_data|
|
55
|
+
memo[tx_data.key] = tx_data.previously_commited_value
|
56
|
+
memo
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def deleted_rel_properties_for(rel, data)
|
61
|
+
data.removed_relationship_properties.find_all{|tx_data| tx_data.entity == rel}.inject({}) do |memo, tx_data|
|
62
|
+
memo[tx_data.key] = tx_data.previously_commited_value
|
63
|
+
memo
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def add(listener)
|
68
|
+
@listeners << listener unless @listeners.include?(listener)
|
69
|
+
end
|
70
|
+
|
71
|
+
def remove(listener)
|
72
|
+
@listeners.delete(listener)
|
73
|
+
end
|
74
|
+
|
75
|
+
def remove_all
|
76
|
+
@listeners = []
|
77
|
+
end
|
78
|
+
|
79
|
+
def print
|
80
|
+
puts "Listeners #{@listeners.size}"
|
81
|
+
@listeners.each {|li| puts " Listener '#{li}'"}
|
82
|
+
end
|
83
|
+
|
84
|
+
def neo4j_started(db)
|
85
|
+
@listeners.each { |li| li.on_neo4j_started(db) if li.respond_to?(:on_neo4j_started) }
|
86
|
+
end
|
87
|
+
|
88
|
+
def neo4j_shutdown(db)
|
89
|
+
@listeners.each { |li| li.on_neo4j_shutdown(db) if li.respond_to?(:on_neo4j_shutdown) }
|
90
|
+
end
|
91
|
+
|
92
|
+
def node_created(node)
|
93
|
+
@listeners.each {|li| li.on_node_created(node) if li.respond_to?(:on_node_created)}
|
94
|
+
end
|
95
|
+
|
96
|
+
def node_deleted(node,old_properties, data)
|
97
|
+
@listeners.each {|li| li.on_node_deleted(node,old_properties, data) if li.respond_to?(:on_node_deleted)}
|
98
|
+
end
|
99
|
+
|
100
|
+
def relationship_created(relationship, tx_data)
|
101
|
+
@listeners.each {|li| li.on_relationship_created(relationship, tx_data) if li.respond_to?(:on_relationship_created)}
|
102
|
+
end
|
103
|
+
|
104
|
+
def relationship_deleted(relationship, old_props, data)
|
105
|
+
@listeners.each {|li| li.on_relationship_deleted(relationship, old_props, data) if li.respond_to?(:on_relationship_deleted)}
|
106
|
+
end
|
107
|
+
|
108
|
+
def property_changed(node, key, old_value, new_value)
|
109
|
+
@listeners.each {|li| li.on_property_changed(node, key, old_value, new_value) if li.respond_to?(:on_property_changed)}
|
110
|
+
end
|
111
|
+
|
112
|
+
def rel_property_changed(rel, key, old_value, new_value)
|
113
|
+
@listeners.each {|li| li.on_rel_property_changed(rel, key, old_value, new_value) if li.respond_to?(:on_rel_property_changed)}
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Index
|
3
|
+
module ClassMethods
|
4
|
+
attr_reader :_indexer
|
5
|
+
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
##
|
9
|
+
# See Neo4j::Index::Indexer#index
|
10
|
+
# Forwards to the indexer that should be used.
|
11
|
+
# It is possible to share the same index for several different classes, see #node_indexer.
|
12
|
+
# :singleton-method: index
|
13
|
+
|
14
|
+
##
|
15
|
+
# See Neo4j::Index::Indexer#find
|
16
|
+
# Forwards to the indexer that should be used.
|
17
|
+
# It is possible to share the same index for several different classes, see #node_indexer.
|
18
|
+
# :singleton-method: find
|
19
|
+
|
20
|
+
|
21
|
+
def_delegators :@_indexer, :index, :find, :index?, :index_type?, :delete_index_type, :rm_field_type, :add_index, :rm_index, :index_type_for, :index_name
|
22
|
+
|
23
|
+
|
24
|
+
# Sets which indexer should be used for the given node class.
|
25
|
+
# You can share an indexer between several different classes.
|
26
|
+
#
|
27
|
+
# ==== Example
|
28
|
+
# class Contact
|
29
|
+
# include Neo4j::NodeMixin
|
30
|
+
# index :name
|
31
|
+
# has_one :phone
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# class Phone
|
35
|
+
# include Neo4j::NodeMixin
|
36
|
+
# property :phone
|
37
|
+
# node_indexer Contact # put index on the Contact class instead
|
38
|
+
# index :phone
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# # Find an contact with a phone number, this works since they share the same index
|
42
|
+
# Contact.find('phone: 12345').first #=> a phone object !
|
43
|
+
#
|
44
|
+
# ==== Returns
|
45
|
+
# The indexer that should be used to index the given class
|
46
|
+
def node_indexer(clazz)
|
47
|
+
indexer(clazz, :node)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Sets which indexer should be used for the given relationship class
|
51
|
+
# Same as #node_indexer except that it indexes relationships instead of nodes.
|
52
|
+
#
|
53
|
+
def rel_indexer(clazz)
|
54
|
+
indexer(clazz, :rel)
|
55
|
+
end
|
56
|
+
|
57
|
+
def indexer(clazz, type) #:nodoc:
|
58
|
+
@_indexer = IndexerRegistry.create_for(self, clazz, type)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Neo4j
|
2
|
+
|
3
|
+
module Index
|
4
|
+
|
5
|
+
# Adds an index on the given property
|
6
|
+
# Notice that you normally don't have to do that since you simply can declare
|
7
|
+
# that the property and index should be updated automatically by using the class method #index.
|
8
|
+
#
|
9
|
+
# The index operation will take place immediately unlike when using the Neo4j::Index::ClassMethods::index
|
10
|
+
# method which instead will guarantee that the neo4j database and the lucene database will be consistent.
|
11
|
+
# It uses a two phase commit when the transaction is about to be committed.
|
12
|
+
#
|
13
|
+
# ==== See also
|
14
|
+
# Neo4j::Index::ClassMethods::index
|
15
|
+
#
|
16
|
+
def add_index(field, value=self[field])
|
17
|
+
self.class.add_index(wrapped_entity, field.to_s, value)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Removes an index on the given property.
|
21
|
+
# Just like #add_index this is normally not needed since you instead can declare it with the
|
22
|
+
# #index class method instead.
|
23
|
+
#
|
24
|
+
# ==== See also
|
25
|
+
# Neo4j::Index::ClassMethods::index
|
26
|
+
# Neo4j::Index#add_index
|
27
|
+
#
|
28
|
+
def rm_index(field, value=self[field])
|
29
|
+
self.class.rm_index(wrapped_entity, field.to_s, value)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|