private RestNodeStore(ConnectionElement connection, long id, string nodeJson = null) { DbUrl = connection.DbUrl; Id = id; Self = string.Concat(connection, "/node/", Id); OriginalNodeJson = nodeJson; }
private RestRelationshipStore(ConnectionElement connection, long id, string relationshipJson = null) { DbUrl = connection.DbUrl; Id = id; Self = string.Concat(Connection.GetServiceRoot(DbUrl).Relationship, "/", Id); OriginalRelationshipJson = relationshipJson; }
public IEnumerable<Relationship> GetRelationship(ConnectionElement connection, string indexName, string key, object value) { throw new NotImplementedException(); }
public IEnumerable<Relationship> GetRelationship(ConnectionElement connection, string indexName, string searchQuery) { string response; var status = Neo4jRestApi.GetRelationship(connection.DbUrl, indexName, searchQuery, out response); if (status != HttpStatusCode.OK) { throw new Exception(string.Format("Index not found in (index:{0})", indexName)); } return ParseRelationshipJson(response); }
public HttpStatusCode DeleteRelationship(ConnectionElement connection) { var status = Neo4jRestApi.DeleteRelationship(connection.DbUrl, Id); if (status != HttpStatusCode.NoContent) { throw new Exception(string.Format("Error deleting relationship (relationship id:{0} http response:{1})", Id, status)); } return status; }
public Relationship CreateRelationship(ConnectionElement connection, Node startNode, Node endNode, string name, Properties properties) { string response; var status = Neo4jRestApi.CreateRelationship(connection.DbUrl, startNode.Id, endNode.Id, name, properties.ToString(), out response); if (status != HttpStatusCode.Created) { throw new Exception(string.Format("Error creating relationship (http response:{0})", status)); } return ParseRelationshipJson(response).First(); }
public DataTable Execute(ConnectionElement connection) { var joScript = new JObject { { "query", Query } }; string response; Rest.HttpRest.Post(connection.CypherUrl, joScript.ToString(Formatting.None), out response); var joResponse = JObject.Parse(response); var jaColumns = (JArray)joResponse["columns"]; var jaData = (JArray)joResponse["data"]; var returnTypes = GetReturnTypes; var dt = new DataTable(); if(jaData == null) { return dt; } var initColumns = true; foreach (JArray jRow in jaData) { var colIndex = 0; var row = new List<object>(); foreach (var jCol in jRow) { if (initColumns) { // NOTE: DataTable does NOT support nullable data types dt.Columns.Add(jaColumns[colIndex].ToString(), returnTypes[colIndex]); } if (returnTypes[colIndex] == typeof(Node)) { row.Add(jCol.Type == JTokenType.Null ? null : RestNodeStore.CreateNodeFromJson((JObject)jCol)); } else if (returnTypes[colIndex] == typeof(Relationship)) { row.Add(jCol.Type == JTokenType.Null ? null : RestRelationshipStore.CreateRelationshipFromJson((JObject)jCol)); } else if (returnTypes[colIndex] == typeof(Path)) { row.Add(jCol.Type == JTokenType.Null ? null : Path.ParseJson((JArray)jCol)); } // Handle the Null case for all Types else if (jCol.Type == JTokenType.Null) { row.Add(DBNull.Value); } // Explicitly cast to correct data type else if (returnTypes[colIndex] == typeof(DateTime)) { row.Add(jCol.Value<DateTime>()); } else if (returnTypes[colIndex] == typeof(double)) { row.Add(jCol.Value<double>()); } else if (returnTypes[colIndex] == typeof(int)) { row.Add(jCol.Value<int>()); } else if (returnTypes[colIndex] == typeof(long)) { row.Add(jCol.Value<long>()); } else if (returnTypes[colIndex] == typeof(string)) { row.Add(jCol.Value<string>()); } else { throw new NotSupportedException(string.Format("Return Type of {0} is not supported", returnTypes[colIndex].Name)); } colIndex++; } initColumns = false; var dtRow = dt.NewRow(); dtRow.ItemArray = row.ToArray(); dt.Rows.Add(dtRow); } return dt; }
public Node Initilize(ConnectionElement connection, long id, Properties properties) { return new Node(new RestNodeStore(connection, id), properties); }
public Node GetNode(ConnectionElement connection, long nodeId) { throw new NotImplementedException(); }
public Node CreateUniqueNode(ConnectionElement connection, Properties properties, string indexName, string key, object value) { return _batchStore.CreateUniqueNode(connection, properties, indexName, key, value); }
public Node CreateNode(ConnectionElement connection, Properties properties) { throw new NotImplementedException(); }
public Node AddToIndex(ConnectionElement connection, Node node, string indexName, string key, object value, bool unique = false) { return _batchStore.AddToIndex(connection, node, indexName, key, value, unique); }
public bool RemoveFromIndex(ConnectionElement connection, Node node, string indexName, string key, object value) { throw new BatchRemoveFromIndexNotSupportedException(); }
public Node Initilize(ConnectionElement connection, long id, Properties properties) { Id = id; return new Node(this, properties); }
public Node GetRootNode(ConnectionElement connection) { throw new NotImplementedException(); }
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); }
public IEnumerable<Node> GetNode(ConnectionElement connection, string indexName, string key, object value) { throw new NotImplementedException(); }
public IEnumerable<Node> GetNode(ConnectionElement connection, string indexName, string searchQuery) { throw new NotImplementedException(); }
public bool RemoveFromIndex(ConnectionElement connection, Node node, string indexName, string key) { var status = Neo4jRestApi.RemoveNodeFromIndex(connection.DbUrl, node.Id, indexName, key); if (status != HttpStatusCode.NoContent) { throw new Exception(string.Format("Error remove node from index (node id:{0} index name:{1} key:{2} http response:{3})", node.Id, indexName, key, status)); } return true; }
public Node AddToIndex(ConnectionElement connection, Node node, string indexName, string key, object value, bool unique = false) { string response; var status = Neo4jRestApi.AddNodeToIndex(connection.DbUrl, node.Id, indexName, key, value, out response, unique); if (status == HttpStatusCode.Created) { return ParseNodeJson(response).First(); } // Add a node to an index but mapping already exists if(unique && status == HttpStatusCode.OK) { return null; } throw new Exception(string.Format("Error adding node to index (http response:{0})", status)); }
public Relationship AddToIndex(ConnectionElement connection, Relationship relationship, string indexName, string key, object value) { string response; var status = Neo4jRestApi.AddRelationshipToIndex(connection.DbUrl, relationship.Id, indexName, key, value, out response); if (status == HttpStatusCode.Created || status == HttpStatusCode.OK) { return ParseRelationshipJson(response).First(); } //// Add a relationship to an index but mapping already exists //if (unique && status == HttpStatusCode.OK) //{ // return null; //} throw new Exception(string.Format("Error adding relationship to index (http response:{0})", status)); }
public Node CreateNode(ConnectionElement connection, Properties properties) { string response; var status = Neo4jRestApi.CreateNode(connection.DbUrl, properties.ToString(), out response); if (status != HttpStatusCode.Created) { throw new Exception(string.Format("Error creating node (http response:{0})", status)); } return ParseNodeJson(response).First(); }
public Relationship CreateUniqueRelationship(ConnectionElement connection, Node startNode, Node endNode, string name, Properties properties, string indexName, string key, object value, IndexUniqueness uniqueness) { string response; var status = Neo4jRestApi.CreateUniqueRelationship(connection.DbUrl, startNode.Id, endNode.Id, name, properties.ToString(), indexName, key, value, uniqueness, out response); if (status == HttpStatusCode.Created) { return ParseRelationshipJson(response).First(); } // Create unique relationship but index mapping already exists if (status == HttpStatusCode.OK) { return null; } throw new Exception(string.Format("Error creating relationship (http response:{0})", status)); }
public Node CreateUniqueNode(ConnectionElement connection, Properties properties, string indexName, string key, object value) { string response; var status = Neo4jRestApi.CreateUniqueNode(connection.DbUrl, properties.ToString(), indexName, key, value, out response); if (status == HttpStatusCode.Created) { return ParseNodeJson(response).First(); } // Create unique node but index mapping already exists if(status == HttpStatusCode.OK) { return null; } throw new Exception(string.Format("Error creating node (http response:{0})", status)); }
public Relationship GetRelationship(ConnectionElement connection, long relationshipId) { string response; var status = Neo4jRestApi.GetRelationship(connection.DbUrl, relationshipId, out response); if (status == HttpStatusCode.NotFound) { throw new RelationshipNotFoundException(string.Format("Relationship({0})", relationshipId)); } return CreateRelationshipFromJson(response); }
public Node GetNode(ConnectionElement connection, long nodeId) { string response; var status = Neo4jRestApi.GetNode(connection.DbUrl, nodeId, out response); if (status == HttpStatusCode.NotFound) { throw new NodeNotFoundException(string.Format("Node({0})",nodeId)); } return CreateNodeFromJson(response); }
public Relationship Initilize(ConnectionElement connection, long id, Properties properties) { return new Relationship(new RestRelationshipStore(connection, id), properties); }
public IEnumerable<Node> GetNode(ConnectionElement connection, string indexName, string key, object value) { string response; var status = Neo4jRestApi.GetNode(connection.DbUrl, indexName, key, value, out response); if(status == HttpStatusCode.OK) { return ParseNodeJson(response); } if(status == HttpStatusCode.NotFound) { return new List<Node>(); } throw new Exception(string.Format("Index not found in (index:{0})", indexName)); }
public bool RemoveFromIndex(ConnectionElement connection, Relationship relationship, string indexName, string key, object value) { var status = Neo4jRestApi.RemoveRelationshipFromIndex(connection.DbUrl, relationship.Id, indexName, key, value); if (status != HttpStatusCode.NoContent) { throw new Exception(string.Format("Error remove relationship from index (relationship id:{0} index name:{1} key:{2} http response:{3})", relationship.Id, indexName, key, status)); } return true; }
public Relationship GetRelationship(ConnectionElement connection, long relationshipId) { throw new NotImplementedException(); }