Permalink
Browse files

release 1.2.4 - multitenancy bug fixes and #eval_paths/unique traversals

  • Loading branch information...
1 parent 3f3ace4 commit 978d335334051229886567ce54d34ae847d386c6 @andreasronge andreasronge committed Oct 7, 2011
Showing with 182 additions and 22 deletions.
  1. +6 −0 CHANGELOG
  2. +1 −1 README.rdoc
  3. +1 −1 Rakefile
  4. +87 −1 lib/neo4j/node.rb
  5. +1 −1 lib/neo4j/node_mixin/node_mixin.rb
  6. +58 −0 lib/neo4j/rails/model.rb
  7. +27 −17 lib/neo4j/traversal/traversal.rb
  8. +1 −1 lib/neo4j/version.rb
View
@@ -1,3 +1,9 @@
+ == 1.2.4 / 2011-10-07
+* Support for traversing with Neo4j::Node#eval_paths and setting uniqueness on traversals [#187]
+* Removed unnecessary node creation on database start up (class nodes attached to reference node) (Vivek Prahlad)
+* Safer multitenancy - automatically reset the reference node in thread local context after each request using rack middleware
+* Bugfixes for multitenancy (Deepak N and Vivek Prahlad)
+
== 1.2.3 / 2011-10-01
* Multitenancy support by namespaced-indices & changeable reference node (Vivek Prahlad, pull 41)
* Added a Neo4j::Rails::Model#columns which returns all defined properties [#186]
View
@@ -45,7 +45,7 @@ Example of creating a Neo4j::Node
node.outgoing(:friends).each {|node| puts "name #{node[:name]}"}
end
-==== Neo4j::Mapping::NodeMixin
+==== Neo4j::NodeMixin
Example of mapping a ruby class to a node and delaring properties and relationships and lucene index.
View
@@ -40,7 +40,7 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.title = "Neo4j.rb #{Neo4j::VERSION}"
rdoc.options << '--webcvs=http://github.com/andreasronge/neo4j/tree/master/'
- rdoc.options << '-f' << 'horo'
+# rdoc.options << '-f' << 'horo'
rdoc.options << '-c' << 'utf-8'
rdoc.options << '-m' << 'README.rdoc'
rdoc.rdoc_files.include('README.rdoc')
View
@@ -113,7 +113,93 @@ class Node
# :method: _java_node
# Returns the java node/relationship object representing this object unless it is already the java object.
# This method is defined in the org.neo4j.kernel.impl.core.NodeProxy which is return by Neo4j::Node.new
-
+
+
+ ##
+ # :method: expand
+ # See Neo4j::Traversal#expand
+
+ ##
+ # :method: outgoing
+ # See Neo4j::Traversal#outgoing
+
+
+ ##
+ # :method: incoming
+ # See Neo4j::Traversal#incoming
+
+ ##
+ # :method: both
+ # See Neo4j::Traversal#both
+
+ ##
+ # :method: eval_paths
+ # See Neo4j::Traversal#eval_paths
+
+ ##
+ # :method: unique
+ # See Neo4j::Traversal#unique
+
+ ##
+ # :method: node
+ # See Neo4j::Rels#node or Neo4j::Rels
+
+ ##
+ # :method: _node
+ # See Neo4j::Rels#_node or Neo4j::Rels
+
+ ##
+ # :method: rels
+ # See Neo4j::Rels#rels or Neo4j::Rels
+
+ ##
+ # :method: _rels
+ # See Neo4j::Rels#_rels or Neo4j::Rels
+
+ ##
+ # :method: rel
+ # See Neo4j::Rels#rel
+
+ ##
+ # :method: _rel
+ # See Neo4j::Rels#_rel
+
+ ##
+ # :method: rel?
+ # See Neo4j::Rels#rel?
+
+ ##
+ # :method: props
+ # See Neo4j::Property#props
+
+ ##
+ # :method: neo_id
+ # See Neo4j::Property#neo_id
+
+ ##
+ # :method: attributes
+ # See Neo4j::Property#attributes
+
+ ##
+ # :method: property?
+ # See Neo4j::Property#property?
+
+ ##
+ # :method: update
+ # See Neo4j::Property#update
+
+ ##
+ # :method: []
+ # See Neo4j::Property#[]
+
+ ##
+ # :method: []=
+ # See Neo4j::Property#[]=
+
+ ##
+ # :method: []=
+ # See Neo4j::Property#[]=
+
class << self
# Returns a new neo4j Node.
@@ -15,7 +15,7 @@
module Neo4j
# This Mixin is used to wrap Neo4j Java Nodes in Ruby objects.
#
- # It includes a number of mixins and forwards some methods to the raw Java node which in term includes a number of mixins, see below.
+ # It includes a number of mixins and forwards some methods to the raw Java node (Neo4j::Node) which includes the mixins below:
#
# === Instance Methods
#
View
@@ -96,6 +96,64 @@ def reachable_from_ref_node?
end
##
+ # :method: outgoing
+ #
+ # Similar to Neo4j::Traversal#outgoing but returns depth one only outgoing relationship
+ # which may not all be persisted.
+ # For only traversing persisted outgoing relationship of any depth or more advanced traversals, use
+ # the wrapped Java node instead.
+ #
+ # ==== Examples
+ #
+ # person.outgoing(:friends) << other_person
+ # person.save!
+ #
+ # person.outgoing(:friends).map{|f| f.outgoing(:knows).to_a}.flatten
+ #
+ # ==== Examples
+ #
+ # Neo4j::Transaction.run do
+ # person._java_node.outgoing(:friends) << other_person
+ # end
+ #
+ # person._java_node.outgoing(:friends).outgoing(:knows).depth(4)
+ #
+ # Notice you can also declare outgoing relationships with the #has_n and #has_one class method.
+ #
+ # See Neo4j::Rails::Relationships#outgoing
+ # See Neo4j::Traversal#outgoing (when using it from the _java_node)
+
+
+ ##
+ # :method: incoming
+ #
+ # Returns incoming relationship of depth one which may not all be persisted.
+ # See #outgoing
+
+
+ ##
+ # :method: rels
+ #
+ # Returns both incoming and outgoing relationships which may not all be persisted.
+ # If you only want to find persisted relationships: @node._java_node.rels@
+ #
+ # See Neo4j::Rails::Relationships#rels
+ # See Neo4j::Rels#rels or Neo4j::Rels
+ #
+
+ ##
+ # :method: []
+ #
+ # Returns a property of this node, which may or may not have been declared with the class property method.
+ # Similar to Neo4j::Property#[] but can return not persisted properties as well.
+
+ ##
+ # :method: []=
+ #
+ # Sets any property on the node.
+ # Similar to Neo4j::Property#[]= but you must call the #save method to persist the property.
+
+ ##
# :singleton-method: property
#
# See Neo4j::Rails::Mapping::Property::ClassMethods#property
@@ -4,6 +4,11 @@
require 'neo4j/traversal/traverser'
module Neo4j
+
+ # Contains methods that are mixin for Neo4j::Node
+ # They all return Neo4j::Traversal::Traverser
+ # See the {Neo4j.rb Guide: Traversing Relationships and Nodes}[http://neo4j.rubyforge.org/guides/traverser.html]
+ #
module Traversal
include ToJava
@@ -16,6 +21,8 @@ module Traversal
#
# The above traverse all relationships with a property of age > 5
#
+ # See http://neo4j.rubyforge.org/guides/traverser.html
+ #
def expand(&expander)
Traverser.new(self).expander(&expander)
end
@@ -49,7 +56,9 @@ def expand(&expander)
# # Find all my friends and work colleges
# me.outgoing(:friends).outgoing(:work).each {...}
#
- # Of course all the methods <tt>outgoing</tt>, <tt>incoming</tt>, <tt>both</tt>, <tt>depth</tt>, <tt>include_start_node</tt>, <tt>filter</tt>, and <tt>prune</tt> can be combined.
+ # Of course all the methods <tt>outgoing</tt>, <tt>incoming</tt>, <tt>both</tt>, <tt>depth</tt>, <tt>include_start_node</tt>, <tt>filter</tt>, and <tt>prune</tt>, <tt>eval_paths</tt>, <tt>unique</tt> can be combined.
+ #
+ # See the {Neo4j.rb Guides}[http://neo4j.rubyforge.org/guides/traverser.html]
#
def outgoing(type)
if type
@@ -62,7 +71,7 @@ def outgoing(type)
# Returns the incoming nodes of given type(s).
#
- # See #outgoing
+ # See #outgoing and http://neo4j.rubyforge.org/guides/traverser.html
#
def incoming(type)
if type
@@ -76,7 +85,7 @@ def incoming(type)
#
# If a type is not given then it will return all types of relationships.
#
- # See #outgoing
+ # See #outgoing and http://neo4j.rubyforge.org/guides/traverser.html
#
def both(type=nil)
if type
@@ -88,11 +97,11 @@ def both(type=nil)
# Traverse using a block. The block is expected to return one of the following values:
- # * :exclude_and_continue
- # * :exclude_and_prune
- # * :include_and_continue
- # * :include_and_prune
- # in order to decide if it should continue to traverse and if it should include the node in the traversal result.
+ # * <tt>:exclude_and_continue</tt>
+ # * <tt>:exclude_and_prune</tt>
+ # * <tt>:include_and_continue</tt>
+ # * <tt>:include_and_prune</tt>
+ # This value decides if it should continue to traverse and if it should include the node in the traversal result.
# The block will receive a path argument.
#
# ==== Example
@@ -101,8 +110,9 @@ def both(type=nil)
#
# ==== See also
#
+ # * How to use - http://neo4j.rubyforge.org/guides/traverser.html
# * the path parameter - http://api.neo4j.org/1.4/org/neo4j/graphdb/Path.html
- # * the #unique - if paths should be visit more the once, etc...
+ # * the #unique method - if paths should be visit more the once, etc...
#
def eval_paths(&eval_block)
Traverser.new(self).eval_paths(&eval_block)
@@ -111,16 +121,16 @@ def eval_paths(&eval_block)
# Sets uniqueness of nodes or relationships to visit during a traversals.
#
# Allowed values
- # * :node_global :: A node cannot be traversed more than once (default)
- # * :node_path :: For each returned node there 's a unique path from the start node to it.
- # * :node_recent :: This is like :node_global, but only guarantees uniqueness among the most recent visited nodes, with a configurable count.
- # * :none :: No restriction (the user will have to manage it).
- # * :rel_global :: A relationship cannot be traversed more than once, whereas nodes can.
- # * :rel_path :: No restriction (the user will have to manage it).
- # * :rel_recent :: Same as for :node_recent, but for relationships.
+ # * <tt>:node_global</tt> A node cannot be traversed more than once (default)
+ # * <tt>:node_path</tt> For each returned node there 's a unique path from the start node to it.
+ # * <tt>:node_recent</tt> This is like :node_global, but only guarantees uniqueness among the most recent visited nodes, with a configurable count.
+ # * <tt>:none</tt> No restriction (the user will have to manage it).
+ # * <tt>:rel_global</tt> A relationship cannot be traversed more than once, whereas nodes can.
+ # * <tt>:rel_path</tt> :: No restriction (the user will have to manage it).
+ # * <tt>:rel_recent</tt> Same as for :node_recent, but for relationships.
#
# See example in #eval_paths
- # See http://api.neo4j.org/1.4/org/neo4j/kernel/Uniqueness.html
+ # See http://api.neo4j.org/1.4/org/neo4j/kernel/Uniqueness.html and http://neo4j.rubyforge.org/guides/traverser.html
def unique(u)
Traverser.new(self).unique(u)
end
View
@@ -1,3 +1,3 @@
module Neo4j
- VERSION = "1.2.3"
+ VERSION = "1.2.4"
end

0 comments on commit 978d335

Please sign in to comment.