1. Peter Wilhelmsson
  2. Neo4RestNet

Wiki

Clone wiki

Neo4RestNet / Home

Project status

Functions ported from java api

These functions are done & verified

  • IGraphDatabaseService.CreateNode(string json)
  • IGraphDatabaseService.CreateNode()
  • IGraphDatabaseService.GetNode(long id)
  • INode.Delete()
  • INode.GetRelationships(...)
  • INode.GetSingleRelationship(string name, Direction direction)
  • INode.CreateRelationshipTo(INode to, string name);
  • INode.Id {get; }
  • INode.Self {get; } (not part of the java api, but useful in this impl)
  • INode.TraverseNodes(TraversalOrder, StopEvaluator, ... relationships) (and combinations of these)
  • INode.TraverseNodes(string json)
  • Functions for setting/removing properties on node
  • IRelationship.Delete()
  • IRelationship.EndNode
  • IRelationship.StartNode
  • IRelationship.Name
  • IIndexService.AddIndex<T>(INode node, string key, T value)
  • IIndexService.RemoveIndex<T>(INode node, string key, T value)
  • IIndexService.GetNodes<T>(string key, T value)
  • IIndexService.GetSingleNode<T>(string key, T value)

These functions are implemented but not yet verified:

  • INode.HasRelationship(...) (they all depend on the INode.GetRelationships(...) functions right now)
  • IRelationship.Nodes

These functions are done but with limitations:

  • IGraphDatabaseService.GetReferenceNode() (always returns node 0)

Known limitations

  • Setting properties where the value is an array, like array of ints or strings doesn't seem to work. More debugging on this is needed. Missing support on rest server?
  • Traversal with ReturnableEvaluator.AllButStartNode does not work. Need to investigate the actual name of this in the rest api.
  • Traversal with ReturnableEvaluator.All does not include the start node, but works as you would expect AllButStartNode would! Maybe som mismatch in the java api and the rest api?

In progress

  • Generation of javascript from .net code to be able to write stop evaluators and returnable evaluators in .net code. .net expressions like r => r.Depth < 4 && r.Node.GetProperty<string>("Name") == "Whatever" will be translated to the corresponding javascript: position.depth() < 4 && position.node().getProperty('Name') == 'Whatever'

Todo:s

  • Consistent errorhandling. Check java api documentation for the correct exception to throw. More unit tests needed to verify error conditions
  • move unit tests to separate project
  • Example project

Code example

public void function main()
{
    // Connect to the database
    var graphDb = new RestGraphDatabaseService("http://localhost:9999/");

    // Create a node with no properties
    var node = graphDb.CreateNode();
    // Get the same node again by its native id
    node = graphDb.GetNode(node.Id);

    // Create another node
    var anotherNode = graphDb.CreateNode();
    // Set a property on the node
    anotherNode.SetProperty("property", "val");

    // Add a relation between them
    var relationship = node.CreateRelationshipTo(anotherNode, "WeKnowEachOther");
    // Set a property on the relationship
    relationship.SetProperty("relprop", 1);

    // Get the relations from the first node
    var relation = node.GetSingleRelationship("WeKnowEachOther", Direction.Outgoing);
    // Get the property value on the relation
    var relVal = relation.GetProperty<int>("relprop");

    // Traverse from the first node
    // So far only traversal through json & js impl
    var traversedNodes = 
          node.TraverseNodes(TraversalOrder.DepthFirst, StopEvaluator.EndOfGraph,    
                                 ReturnableEvaluator.All, "WeKnowEachOther", Direction.All);
    // ok, get rid of the nodes
    anotherNode.Delete();
    node.Delete();
}

Updated