neo4j 2.2.3-java → 2.2.4-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +5 -0
  3. data/Gemfile +2 -3
  4. data/README.rdoc +19 -14
  5. data/lib/neo4j/rails/attributes.rb +2 -2
  6. data/lib/neo4j/rails/attributes.rb~ +530 -0
  7. data/lib/neo4j/rails/node_persistance.rb +9 -0
  8. data/lib/neo4j/rails/persistence.rb +2 -2
  9. data/lib/neo4j/rails/persistence.rb~ +186 -0
  10. data/lib/neo4j/rails/relationship_persistence.rb +9 -0
  11. data/lib/neo4j/version.rb +1 -1
  12. data/neo4j.gemspec +1 -1
  13. metadata +22 -66
  14. data/lib/db/active_tx_log +0 -1
  15. data/lib/db/index/lucene-store.db +0 -0
  16. data/lib/db/index/lucene.log.active +0 -0
  17. data/lib/db/index/lucene.log.v0 +0 -0
  18. data/lib/db/messages.log +0 -286
  19. data/lib/db/neostore +0 -0
  20. data/lib/db/neostore.id +0 -0
  21. data/lib/db/neostore.nodestore.db +0 -0
  22. data/lib/db/neostore.nodestore.db.id +0 -0
  23. data/lib/db/neostore.propertystore.db +0 -0
  24. data/lib/db/neostore.propertystore.db.arrays +0 -0
  25. data/lib/db/neostore.propertystore.db.arrays.id +0 -0
  26. data/lib/db/neostore.propertystore.db.id +0 -0
  27. data/lib/db/neostore.propertystore.db.index +0 -0
  28. data/lib/db/neostore.propertystore.db.index.id +0 -0
  29. data/lib/db/neostore.propertystore.db.index.keys +0 -0
  30. data/lib/db/neostore.propertystore.db.index.keys.id +0 -0
  31. data/lib/db/neostore.propertystore.db.strings +0 -0
  32. data/lib/db/neostore.propertystore.db.strings.id +0 -0
  33. data/lib/db/neostore.relationshipstore.db +0 -0
  34. data/lib/db/neostore.relationshipstore.db.id +0 -0
  35. data/lib/db/neostore.relationshiptypestore.db +0 -0
  36. data/lib/db/neostore.relationshiptypestore.db.id +0 -0
  37. data/lib/db/neostore.relationshiptypestore.db.names +0 -0
  38. data/lib/db/neostore.relationshiptypestore.db.names.id +0 -0
  39. data/lib/db/nioneo_logical.log.active +0 -0
  40. data/lib/db/nioneo_logical.log.v0 +0 -0
  41. data/lib/db/tm_tx_log.1 +0 -0
@@ -41,6 +41,15 @@ module Neo4j
41
41
  self
42
42
  end
43
43
 
44
+ def freeze_if_deleted
45
+ unless new_record?
46
+ Neo4j::IdentityMap.remove_node_by_id(neo_id)
47
+ unless self.class.load_entity(neo_id)
48
+ set_deleted_properties
49
+ freeze
50
+ end
51
+ end
52
+ end
44
53
 
45
54
  def reload_from_database
46
55
  Neo4j::IdentityMap.remove_node_by_id(neo_id)
@@ -74,7 +74,7 @@ module Neo4j
74
74
 
75
75
  # Returns +true+ if the properties hash has been frozen.
76
76
  def frozen?
77
- reload unless new_record?
77
+ freeze_if_deleted
78
78
  @_properties.frozen?
79
79
  end
80
80
 
@@ -117,7 +117,7 @@ module Neo4j
117
117
  props = args.first
118
118
  raise "Can't get or create entity since #{props.inspect} does not included unique key #{props[unique_factory_key]}'" unless props[unique_factory_key]
119
119
  index = index_for_type(_decl_props[unique_factory_key][:index])
120
- Neo4j::Core::Index::UniqueFactory.new(unique_factory_key, index) { |*| create!(*args) }.get_or_create(unique_factory_key, props[unique_factory_key])
120
+ Neo4j::Core::Index::UniqueFactory.new(unique_factory_key, index) { |*| create!(*args) }.get_or_create(unique_factory_key, props[unique_factory_key]).wrapper
121
121
  end
122
122
 
123
123
  # Same as #create, but raises an error if there is a problem during save.
@@ -0,0 +1,186 @@
1
+ module Neo4j
2
+ module Rails
3
+ # Defines the create, delete and update methods.
4
+ # @see ClassMethods class methods when including this module
5
+ module Persistence
6
+ extend ActiveSupport::Concern
7
+ extend TxMethods
8
+
9
+
10
+ # Persist the object to the database. Validations and Callbacks are included
11
+ # by default but validation can be disabled by passing <tt>:validate => false</tt>
12
+ # to <tt>save</tt>. Creates a new transaction.
13
+ # @param (see Neo4j::Rails::Validations#save)
14
+ # @return [Boolean] true if it was persisted
15
+ # @see Neo4j::Rails::Validations Neo4j::Rails::Validations - for the :validate parameter
16
+ # @see Neo4j::Rails::Callbacks Neo4j::Rails::Callbacks - for callbacks
17
+ def save(*)
18
+ create_or_update
19
+ end
20
+ tx_methods :save
21
+
22
+ # Persist the object to the database. Validations and Callbacks are included
23
+ # by default but validation can be disabled by passing :validate => false
24
+ # to #save! Creates a new transaction.
25
+ #
26
+ # @raise a RecordInvalidError if there is a problem during save.
27
+ # @param (see Neo4j::Rails::Validations#save)
28
+ # @return nil
29
+ # @see #save
30
+ # @see Neo4j::Rails::Validations Neo4j::Rails::Validations - for the :validate parameter
31
+ # @see Neo4j::Rails::Callbacks Neo4j::Rails::Callbacks - for callbacks
32
+ def save!(*args)
33
+ unless save(*args)
34
+ raise RecordInvalidError.new(self)
35
+ end
36
+ end
37
+
38
+ # Removes the node from Neo4j and freezes the object.
39
+ def destroy
40
+ delete
41
+ freeze
42
+ end
43
+
44
+ # Same as #destroy but doesn't run destroy callbacks and doesn't freeze
45
+ # the object. Creates a new transaction
46
+ def delete
47
+ del unless new_record? || destroyed?
48
+ set_deleted_properties
49
+ end
50
+ tx_methods :delete
51
+
52
+ # Returns +true+ if the object was destroyed.
53
+ def destroyed?
54
+ @_deleted || (!new_record? && !self.class.load_entity(neo_id))
55
+ end
56
+
57
+ # Returns +true+ if the record is persisted, i.e. it’s not a new record and it was not destroyed
58
+ def persisted?
59
+ !new_record? && !destroyed?
60
+ end
61
+
62
+ # Returns +true+ if the record hasn't been saved to Neo4j yet.
63
+ def new_record?
64
+ _java_entity.nil?
65
+ end
66
+
67
+ alias :new? :new_record?
68
+
69
+ # Freeze the properties hash.
70
+ def freeze
71
+ @_properties.freeze
72
+ self
73
+ end
74
+
75
+ # Returns +true+ if the properties hash has been frozen.
76
+ def frozen?
77
+ reload unless new_record?
78
+ @_properties.frozen?
79
+ end
80
+
81
+
82
+ module ClassMethods
83
+
84
+ def transaction(&block)
85
+ Neo4j::Rails::Transaction.run do |tx|
86
+ block.call(tx)
87
+ end
88
+ end
89
+
90
+ def new(*args, &block)
91
+ instance = orig_new(*args, &block)
92
+ instance.instance_eval(&block) if block
93
+ instance
94
+ end
95
+
96
+ # Initialize a model and set a bunch of attributes at the same time. Returns
97
+ # the object whether saved successfully or not.
98
+ def create(*args)
99
+ new(*args).tap do |o|
100
+ yield o if block_given?
101
+ o.save
102
+ end
103
+ end
104
+
105
+ # Get the indexed entity, creating it (exactly once) if no indexed entity exist.
106
+ #
107
+ # @example Creating a Unique node
108
+ #
109
+ # class MyNode < Neo4j::Rails::Model
110
+ # property :email, :index => :exact, :unique => true
111
+ # end
112
+ #
113
+ # node = MyNode.get_or_create(:email =>'jimmy@gmail.com', :name => 'jimmy')
114
+ #
115
+ # @see #put_if_absent
116
+ def get_or_create(*args)
117
+ props = args.first
118
+ raise "Can't get or create entity since #{props.inspect} does not included unique key #{props[unique_factory_key]}'" unless props[unique_factory_key]
119
+ index = index_for_type(_decl_props[unique_factory_key][:index])
120
+ Neo4j::Core::Index::UniqueFactory.new(unique_factory_key, index) { |*| create!(*args) }.get_or_create(unique_factory_key, props[unique_factory_key])
121
+ end
122
+
123
+ # Same as #create, but raises an error if there is a problem during save.
124
+ # @return [Neo4j::Rails::Model, Neo4j::Rails::Relationship]
125
+ def create!(*args)
126
+ new(*args).tap do |o|
127
+ yield o if block_given?
128
+ o.save!
129
+ end
130
+ end
131
+
132
+ # Destroy each node in turn. Runs the destroy callbacks for each node.
133
+ def destroy_all
134
+ all.each do |n|
135
+ n.destroy
136
+ end
137
+ end
138
+ end
139
+
140
+ # Returns if the entity is currently being updated or created
141
+ def create_or_updating?
142
+ !!@_create_or_updating
143
+ end
144
+
145
+ protected
146
+
147
+ def update
148
+ write_changed_attributes
149
+ clear_changes
150
+ true
151
+ end
152
+
153
+ def create_or_update
154
+ # since the same model can be created or updated twice from a relationship we have to have this guard
155
+ @_create_or_updating = true
156
+ result = persisted? ? update : create
157
+ unless result != false
158
+ Neo4j::Rails::Transaction.fail if Neo4j::Rails::Transaction.running?
159
+ false
160
+ else
161
+ true
162
+ end
163
+ rescue => e
164
+ Neo4j::Rails::Transaction.fail if Neo4j::Rails::Transaction.running?
165
+ raise e
166
+ ensure
167
+ @_create_or_updating = nil
168
+ end
169
+
170
+ def set_deleted_properties
171
+ @_deleted = true
172
+ end
173
+
174
+ public
175
+ class RecordInvalidError < RuntimeError
176
+ attr_reader :record
177
+
178
+ def initialize(record)
179
+ @record = record
180
+ super(@record.errors.full_messages.join(", "))
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
186
+
@@ -73,6 +73,15 @@ module Neo4j
73
73
  self
74
74
  end
75
75
 
76
+ def freeze_if_deleted
77
+ unless new_record?
78
+ Neo4j::IdentityMap.remove_rel_by_id(neo_id)
79
+ unless self.class.load_entity(neo_id)
80
+ set_deleted_properties
81
+ freeze
82
+ end
83
+ end
84
+ end
76
85
 
77
86
  def reload_from_database
78
87
  Neo4j::IdentityMap.remove_rel_by_id(id) if persisted?
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.4"
3
3
  end
@@ -32,5 +32,5 @@ It comes included with the Apache Lucene document database.
32
32
  s.add_dependency('orm_adapter', ">= 0.0.3")
33
33
  s.add_dependency("activemodel", ">= 3.0.0", "< 3.3")
34
34
  s.add_dependency("railties", ">= 3.0.0", "< 3.3")
35
- s.add_dependency("neo4j-wrapper", '2.2.3')
35
+ s.add_dependency("neo4j-wrapper", '2.2.4')
36
36
  end
metadata CHANGED
@@ -1,78 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
5
- prerelease:
4
+ version: 2.2.4
6
5
  platform: java
7
6
  authors:
8
7
  - Andreas Ronge
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-28 00:00:00.000000000 Z
11
+ date: 2013-05-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: orm_adapter
16
15
  version_requirements: !ruby/object:Gem::Requirement
17
16
  requirements:
18
- - - ! '>='
17
+ - - '>='
19
18
  - !ruby/object:Gem::Version
20
19
  version: 0.0.3
21
- none: false
22
20
  requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - ! '>='
22
+ - - '>='
25
23
  - !ruby/object:Gem::Version
26
24
  version: 0.0.3
27
- none: false
28
25
  prerelease: false
29
26
  type: :runtime
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activemodel
32
29
  version_requirements: !ruby/object:Gem::Requirement
33
30
  requirements:
34
- - - ! '>='
31
+ - - '>='
35
32
  - !ruby/object:Gem::Version
36
33
  version: 3.0.0
37
- - - !binary |-
38
- PA==
34
+ - - <
39
35
  - !ruby/object:Gem::Version
40
36
  version: '3.3'
41
- none: false
42
37
  requirement: !ruby/object:Gem::Requirement
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: 3.0.0
47
- - - !binary |-
48
- PA==
42
+ - - <
49
43
  - !ruby/object:Gem::Version
50
44
  version: '3.3'
51
- none: false
52
45
  prerelease: false
53
46
  type: :runtime
54
47
  - !ruby/object:Gem::Dependency
55
48
  name: railties
56
49
  version_requirements: !ruby/object:Gem::Requirement
57
50
  requirements:
58
- - - ! '>='
51
+ - - '>='
59
52
  - !ruby/object:Gem::Version
60
53
  version: 3.0.0
61
- - - !binary |-
62
- PA==
54
+ - - <
63
55
  - !ruby/object:Gem::Version
64
56
  version: '3.3'
65
- none: false
66
57
  requirement: !ruby/object:Gem::Requirement
67
58
  requirements:
68
- - - ! '>='
59
+ - - '>='
69
60
  - !ruby/object:Gem::Version
70
61
  version: 3.0.0
71
- - - !binary |-
72
- PA==
62
+ - - <
73
63
  - !ruby/object:Gem::Version
74
64
  version: '3.3'
75
- none: false
76
65
  prerelease: false
77
66
  type: :runtime
78
67
  - !ruby/object:Gem::Dependency
@@ -81,14 +70,12 @@ dependencies:
81
70
  requirements:
82
71
  - - '='
83
72
  - !ruby/object:Gem::Version
84
- version: 2.2.3
85
- none: false
73
+ version: 2.2.4
86
74
  requirement: !ruby/object:Gem::Requirement
87
75
  requirements:
88
76
  - - '='
89
77
  - !ruby/object:Gem::Version
90
- version: 2.2.3
91
- none: false
78
+ version: 2.2.4
92
79
  prerelease: false
93
80
  type: :runtime
94
81
  description: "You can think of Neo4j as a high-performance graph engine with all the\
@@ -109,34 +96,6 @@ files:
109
96
  - bin/neo4j-shell
110
97
  - bin/neo4j-upgrade
111
98
  - lib/neo4j.rb
112
- - lib/db/active_tx_log
113
- - lib/db/messages.log
114
- - lib/db/neostore
115
- - lib/db/neostore.id
116
- - lib/db/neostore.nodestore.db
117
- - lib/db/neostore.nodestore.db.id
118
- - lib/db/neostore.propertystore.db
119
- - lib/db/neostore.propertystore.db.arrays
120
- - lib/db/neostore.propertystore.db.arrays.id
121
- - lib/db/neostore.propertystore.db.id
122
- - lib/db/neostore.propertystore.db.index
123
- - lib/db/neostore.propertystore.db.index.id
124
- - lib/db/neostore.propertystore.db.index.keys
125
- - lib/db/neostore.propertystore.db.index.keys.id
126
- - lib/db/neostore.propertystore.db.strings
127
- - lib/db/neostore.propertystore.db.strings.id
128
- - lib/db/neostore.relationshipstore.db
129
- - lib/db/neostore.relationshipstore.db.id
130
- - lib/db/neostore.relationshiptypestore.db
131
- - lib/db/neostore.relationshiptypestore.db.id
132
- - lib/db/neostore.relationshiptypestore.db.names
133
- - lib/db/neostore.relationshiptypestore.db.names.id
134
- - lib/db/nioneo_logical.log.active
135
- - lib/db/nioneo_logical.log.v0
136
- - lib/db/tm_tx_log.1
137
- - lib/db/index/lucene-store.db
138
- - lib/db/index/lucene.log.active
139
- - lib/db/index/lucene.log.v0
140
99
  - lib/generators/neo4j.rb
141
100
  - lib/generators/neo4j/model/model_generator.rb
142
101
  - lib/generators/neo4j/model/templates/model.erb
@@ -145,6 +104,7 @@ files:
145
104
  - lib/neo4j/version.rb~
146
105
  - lib/neo4j/rails/accept_id.rb
147
106
  - lib/neo4j/rails/attributes.rb
107
+ - lib/neo4j/rails/attributes.rb~
148
108
  - lib/neo4j/rails/callbacks.rb
149
109
  - lib/neo4j/rails/column.rb
150
110
  - lib/neo4j/rails/compositions.rb
@@ -156,6 +116,7 @@ files:
156
116
  - lib/neo4j/rails/node_persistance.rb
157
117
  - lib/neo4j/rails/observer.rb
158
118
  - lib/neo4j/rails/persistence.rb
119
+ - lib/neo4j/rails/persistence.rb~
159
120
  - lib/neo4j/rails/rack_middleware.rb
160
121
  - lib/neo4j/rails/rails.rb
161
122
  - lib/neo4j/rails/railtie.rb
@@ -189,6 +150,7 @@ files:
189
150
  - neo4j.gemspec
190
151
  homepage: http://github.com/andreasronge/neo4j/tree
191
152
  licenses: []
153
+ metadata: {}
192
154
  post_install_message:
193
155
  rdoc_options:
194
156
  - --quiet
@@ -202,24 +164,18 @@ require_paths:
202
164
  - lib
203
165
  required_ruby_version: !ruby/object:Gem::Requirement
204
166
  requirements:
205
- - - ! '>='
167
+ - - '>='
206
168
  - !ruby/object:Gem::Version
207
169
  version: 1.8.7
208
- none: false
209
170
  required_rubygems_version: !ruby/object:Gem::Requirement
210
171
  requirements:
211
- - - ! '>='
172
+ - - '>='
212
173
  - !ruby/object:Gem::Version
213
- segments:
214
- - 0
215
- version: !binary |-
216
- MA==
217
- hash: 2
218
- none: false
174
+ version: '0'
219
175
  requirements: []
220
176
  rubyforge_project: neo4j
221
- rubygems_version: 1.8.24
177
+ rubygems_version: 2.0.3
222
178
  signing_key:
223
- specification_version: 3
179
+ specification_version: 4
224
180
  summary: A graph database for JRuby
225
181
  test_files: []
@@ -1 +0,0 @@
1
- tm_tx_log.1
Binary file