private IGraphObject ParseJsonGraphObject(JObject jsonGraphObject, bool reloadProperties) { var selfArray = jsonGraphObject["self"].Value <string>().Split('/'); if (selfArray.Length < 2) { throw new Exception("Invalid response from batch"); } switch (selfArray[selfArray.Length - 2]) { case "node": var node = RestNodeStore.CreateNodeFromJson(jsonGraphObject); if (reloadProperties) { node.Properties = null; } return(node); case "relationship": var relationship = RestRelationshipStore.CreateRelationshipFromJson(jsonGraphObject); if (reloadProperties) { relationship.Properties = null; } return(relationship); default: throw new Exception("Invalid response from batch"); } }
public Node GetRootNode(ConnectionElement connection) { string response; var status = Neo4jRestApi.GetRoot(Connection.GetDatabaseEndpoint(connection.DbUrl).Data, out response); if (status != HttpStatusCode.OK) { throw new Exception(string.Format("Error getting root node (http response:{0})", status)); } JObject jo; try { jo = JObject.Parse(response); } catch (Exception e) { throw new Exception("Invalid json", e); } JToken referenceNode; if (!jo.TryGetValue("reference_node", out referenceNode)) { throw new NodeNotFoundException("Reference node not found"); } var graphStore = new RestNodeStore(referenceNode.Value <string>()); return(new Node(graphStore)); }
public static Node Initilize(Properties properties, string selfUri, INodeStore nodeStore = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } return(nodeStore.Initilize(selfUri, properties)); }
public static void SetProperty <T>(Node node, string key, T value, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } nodeStore.SetProperty(node, key, value); }
public static Node AddToIndex(Node node, string indexName, string key, object value, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.AddToIndex(connection, node, indexName, key, value)); }
public static IEnumerable <Node> GetNode(string indexName, string searchQuery, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.GetNode(connection, indexName, searchQuery)); }
public static IEnumerable <Node> GetNode(string indexName, string key, object value, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.GetNode(connection, indexName, key, value)); }
public static Node GetNode(long nodeId, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.GetNode(connection, nodeId)); }
public static Node Initilize(long id, Properties properties, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.Initilize(connection, id, properties)); }
public static bool RemoveFromIndex(Node node, string indexName, string key = null, object value = null, INodeStore nodeStore = null, ConnectionElement connection = null) { if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(key == null? nodeStore.RemoveFromIndex(connection, node, indexName) : value == null? nodeStore.RemoveFromIndex(connection, node, indexName, key) : nodeStore.RemoveFromIndex(connection, node, indexName, key, value)); }
public static Node CreateNode(Properties properties, INodeStore nodeStore, ConnectionElement connection = null) { if (properties == null) { properties = new Properties(); } if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.CreateNode(connection, properties)); }
public static Node Initilize(Properties properties = null, INodeStore nodeStore = null, ConnectionElement connection = null) { if (properties == null) { properties = new Properties(); } if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.Initilize(connection.DbUrl, properties)); }
public static Node CreateUniqueNode(string indexName, string key, object value, IndexUniqueness uniqueness, Properties properties = null, INodeStore nodeStore = null, ConnectionElement connection = null) { if (properties == null) { properties = new Properties(); } if (nodeStore == null) { nodeStore = new RestNodeStore(); } if (connection == null) { connection = DefaultConnection; } return(nodeStore.CreateUniqueNode(connection, properties, indexName, key, value, uniqueness)); }
public Node GetRootNode(ConnectionElement connection) { string response; var status = Neo4jRestApi.GetRoot(connection.DbUrl, out response); if (status != HttpStatusCode.OK) { throw new Exception(string.Format("Error getting root node (http response:{0})", status)); } JObject jo; try { jo = JObject.Parse(response); } catch (Exception e) { throw new Exception("Invalid json", e); } JToken referenceNode; if (!jo.TryGetValue("reference_node", out referenceNode)) { throw new NodeNotFoundException("Reference node not found"); } var graphStore = new RestNodeStore(referenceNode.Value<string>()); return new Node(graphStore); }