示例#1
0
        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 IEnumerable <Relationship> GetRelationships(RelationshipDirection direction, IEnumerable <string> relationshipTypes)
        {
            string response;
            var    status = Neo4jRestApi.GetRelationshipsOnNode(DbUrl, Id, direction, relationshipTypes, out response);

            if (status != HttpStatusCode.OK)
            {
                throw new Exception(string.Format("Error retrieving relationships on node (node id:{0} http response:{1})", Id, status));
            }

            return(RestRelationshipStore.ParseRelationshipJson(response));
        }
示例#3
0
        public static Relationship AddToIndex(Relationship relationship, string indexName, string key, object value, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(relationshipStore.AddToIndex(connection, relationship, indexName, key, value));
        }
示例#4
0
        public static IEnumerable <Relationship> GetRelationship(string indexName, string searchQuery, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(relationshipStore.GetRelationship(connection, indexName, searchQuery));
        }
示例#5
0
        public static IEnumerable <Relationship> GetRelationship(string indexName, string key, object value, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(relationshipStore.GetRelationship(connection, indexName, key, value));
        }
示例#6
0
        public static Relationship GetRelationship(long relationshipId, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(relationshipStore.GetRelationship(connection, relationshipId));
        }
        public Relationship CreateRelationship(Node startNode, Node endNode, string relationshipType, Properties properties)
        {
            string response;
            var    status = Neo4jRestApi.CreateRelationship(DbUrl,
                                                            startNode.Id,
                                                            endNode.Id,
                                                            relationshipType,
                                                            properties == null ? null : properties.ToString(),
                                                            out response);

            if (status != HttpStatusCode.Created)
            {
                throw new Exception(string.Format("Error creationg relationship on node (node id:{0} http response:{1})", Id, status));
            }

            return(RestRelationshipStore.ParseRelationshipJson(response).First());
        }
示例#8
0
        public static bool RemoveFromIndex(Relationship relationship, string indexName, string key = null, object value = null, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(key == null?
                   relationshipStore.RemoveFromIndex(connection, relationship, indexName)
                       : value == null?
                       relationshipStore.RemoveFromIndex(connection, relationship, indexName, key)
                           : relationshipStore.RemoveFromIndex(connection, relationship, indexName, key, value));
        }
示例#9
0
        public static Relationship CreateRelationship(Node startNode, Node endNode, string name, Properties properties = null, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (properties == null)
            {
                properties = new Properties();
            }

            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(relationshipStore.CreateRelationship(connection, startNode, endNode, name, properties));
        }
示例#10
0
        public static Relationship CreateUniqueRelationship(Node startNode, Node endNode, string name, string indexName, string key, object value, IndexUniqueness uniqueness, Properties properties = null, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
        {
            if (properties == null)
            {
                properties = new Properties();
            }

            if (relationshipStore == null)
            {
                relationshipStore = new RestRelationshipStore();
            }

            if (connection == null)
            {
                connection = DefaultConnection;
            }

            return(relationshipStore.CreateUniqueRelationship(connection, startNode, endNode, name, properties, indexName, key, value, uniqueness));
        }