Sha256: 639386ac18711f7ac4449710867904ed38f87480f7369e0e22e70ae77c226f30

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

module Neography
  class Rest
    module OtherNodeRelationships
      include Neography::Rest::Helpers
    
      def get_node_relationships_to(id, other_id, direction = "all", types = [nil] )
        
        body = case parse_direction(direction)
                 when "all"
                   "position.endNode().getId() == " + get_id(other_id)
                 when "in"
                   "position.length() > 0 && position.lastRelationship().getStartNode().getId() == " + get_id(other_id)
                 when "out"
                   "position.length() > 0 && position.lastRelationship().getEndNode().getId() == " + get_id(other_id) 
                end

        relationships = {:relationships => Array(types).map{|row| Hash[{:type => row}].merge({:direction => parse_direction(direction)})} }

        if Array(types).first.nil?
          relationships = {}
        end
                
        options = {
          :body => {:order      => "breadth_first",
                    :uniqueness => "relationship_global",
                    :max_depth  => 1,
                    :return_filter => {:language => "javascript",
                                       :body =>  body }
                    }.merge(relationships).to_json,
          :headers => json_content_type
        }

        @connection.post("/node/%{id}/traverse/relationship" % {:id => get_id(id)}, options) || []
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/neography-1.7.3/lib/neography/rest/other_node_relationships.rb
neography-down-1.6.4 lib/neography/rest/other_node_relationships.rb
neography-1.8.0 lib/neography/rest/other_node_relationships.rb
neography-1.7.3 lib/neography/rest/other_node_relationships.rb
neography-1.7.2 lib/neography/rest/other_node_relationships.rb
neography-1.7.1 lib/neography/rest/other_node_relationships.rb
neography-1.7.0 lib/neography/rest/other_node_relationships.rb
neography-1.6.0 lib/neography/rest/other_node_relationships.rb
neography-1.5.2 lib/neography/rest/other_node_relationships.rb
neography-1.5.1 lib/neography/rest/other_node_relationships.rb
neography-1.5.0 lib/neography/rest/other_node_relationships.rb
neography-1.4.1 lib/neography/rest/other_node_relationships.rb
neography-1.4.0 lib/neography/rest/other_node_relationships.rb