Esempio n. 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");
            }
        }
Esempio n. 2
0
        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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 7
0
        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());
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }