Esempio n. 1
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. 2
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. 3
0
 public static Relationship AddToIndex(Relationship relationship, Enum indexName, Enum key, object value, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(AddToIndex(relationship, indexName.ToString(), key.ToString(), value, relationshipStore, connection));
 }
Esempio n. 4
0
 public Relationship(IRelationshipStore relationshipStore, Properties properties = null)
 {
     _properties             = properties ?? new Properties();
     _relationshipGraphStore = relationshipStore;
 }
Esempio n. 5
0
 public static List <Path> ParseJson(JArray jsonPaths, IRelationshipStore relationshipGraphStore)
 {
     return(ParseJson(jsonPaths, new RestNodeStore(), relationshipGraphStore));
 }
Esempio n. 6
0
 public static List<Path> ParseJson(JArray jsonPaths, IRelationshipStore relationshipGraphStore)
 {
     return ParseJson(jsonPaths, new RestNodeStore(), relationshipGraphStore);
 }
Esempio n. 7
0
        private Path(JObject path, INodeStore nodeGraphStore, IRelationshipStore relationshipGraphStore)
        {
            JToken startNode;
            if (!path.TryGetValue("start", out startNode))
            {
                throw new Exception("Invalid path json");
            }

            switch (startNode.Type)
            {
                case JTokenType.String:
                    StartNode = nodeGraphStore.Initilize(startNode.Value<string>(), null);
                    break;

                //case JTokenType.Object:
                //    StartNode = nodeGraphStore.CreateNodeFromJson((JObject)startNode);
                //    break;

                default:
                    throw new Exception("Invalid path json");
            }

            JToken endNode;
            if (!path.TryGetValue("end", out endNode))
            {
                throw new Exception("Invalid path json");
            }

            switch (endNode.Type)
            {
                case JTokenType.String:
                    EndNode = nodeGraphStore.Initilize(endNode.Value<string>(), null);
                    break;

                //case JTokenType.Object:
                //    EndNode = nodeGraphStore.CreateNodeFromJson((JObject)endNode);
                //    break;

                default:
                    throw new Exception("Invalid path json");
            }

            Nodes = new List<Node>();
            JToken nodes;
            if (!path.TryGetValue("nodes", out nodes) || nodes.Type != JTokenType.Array)
            {
                throw new Exception("Invalid path json");
            }

            foreach (JToken node in nodes)
            {
                switch (node.Type)
                {
                    case JTokenType.String:
                        Nodes.Add(nodeGraphStore.Initilize(node.Value<string>(), null));
                        break;

                    //case JTokenType.Object:
                    //    Nodes.Add(nodeGraphStore.CreateNodeFromJson((JObject)node));
                    //    break;

                    default:
                        throw new Exception("Invalid path json");
                }
            }

            Relationships = new List<Relationship>();
            JToken relationships;
            if (!path.TryGetValue("relationships", out relationships) || relationships.Type != JTokenType.Array)
            {
                throw new Exception("Invalid path json");
            }

            foreach (JToken relationship in relationships)
            {
                switch (relationship.Type)
                {
                    case JTokenType.String:
                        Relationships.Add(relationshipGraphStore.Initilize(relationship.Value<string>(), null));
                        break;

                    //case JTokenType.Object:
                    //    Relationships.Add(relationshipGraphStore.CreateRelationshipFromJson((JObject)relationship));
                    //    break;

                    default:
                        throw new Exception("Invalid path json");
                }
            }

            OriginalPathJson = path.ToString(Formatting.None);
        }
Esempio n. 8
0
 public static Relationship CreateRelationship(Node startNode, Node endNode, Enum name, Properties properties = null, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(CreateRelationship(startNode, endNode, name.ToString(), properties, relationshipStore, connection));
 }
Esempio n. 9
0
 private Relationship(Properties properties = null)
 {
     _properties             = properties ?? new Properties();
     _relationshipGraphStore = new RestRelationshipStore();
 }
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));
        }
Esempio n. 11
0
 public static Relationship GetRelationship(EncryptId relationshipId, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(GetRelationship((long)relationshipId, relationshipStore, connection));
 }
Esempio n. 12
0
 public static Relationship CreateUniqueRelationship(Node startNode, Node endNode, Enum name, Enum indexName, Enum key, object value, IndexUniqueness uniqueness, Properties properties = null, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(CreateUniqueRelationship(startNode, endNode, name.ToString(), indexName.ToString(), key.ToString(), value, uniqueness, properties, relationshipStore, connection));
 }
Esempio n. 13
0
        private Path(JObject path, INodeStore nodeGraphStore, IRelationshipStore relationshipGraphStore)
        {
            JToken startNode;

            if (!path.TryGetValue("start", out startNode))
            {
                throw new Exception("Invalid path json");
            }

            switch (startNode.Type)
            {
            case JTokenType.String:
                StartNode = nodeGraphStore.Initilize(startNode.Value <string>(), null);
                break;

            //case JTokenType.Object:
            //    StartNode = nodeGraphStore.CreateNodeFromJson((JObject)startNode);
            //    break;

            default:
                throw new Exception("Invalid path json");
            }

            JToken endNode;

            if (!path.TryGetValue("end", out endNode))
            {
                throw new Exception("Invalid path json");
            }

            switch (endNode.Type)
            {
            case JTokenType.String:
                EndNode = nodeGraphStore.Initilize(endNode.Value <string>(), null);
                break;

            //case JTokenType.Object:
            //    EndNode = nodeGraphStore.CreateNodeFromJson((JObject)endNode);
            //    break;

            default:
                throw new Exception("Invalid path json");
            }

            Nodes = new List <Node>();
            JToken nodes;

            if (!path.TryGetValue("nodes", out nodes) || nodes.Type != JTokenType.Array)
            {
                throw new Exception("Invalid path json");
            }

            foreach (JToken node in nodes)
            {
                switch (node.Type)
                {
                case JTokenType.String:
                    Nodes.Add(nodeGraphStore.Initilize(node.Value <string>(), null));
                    break;

                //case JTokenType.Object:
                //    Nodes.Add(nodeGraphStore.CreateNodeFromJson((JObject)node));
                //    break;

                default:
                    throw new Exception("Invalid path json");
                }
            }

            Relationships = new List <Relationship>();
            JToken relationships;

            if (!path.TryGetValue("relationships", out relationships) || relationships.Type != JTokenType.Array)
            {
                throw new Exception("Invalid path json");
            }

            foreach (JToken relationship in relationships)
            {
                switch (relationship.Type)
                {
                case JTokenType.String:
                    Relationships.Add(relationshipGraphStore.Initilize(relationship.Value <string>(), null));
                    break;

                //case JTokenType.Object:
                //    Relationships.Add(relationshipGraphStore.CreateRelationshipFromJson((JObject)relationship));
                //    break;

                default:
                    throw new Exception("Invalid path json");
                }
            }

            OriginalPathJson = path.ToString(Formatting.None);
        }
Esempio n. 14
0
        public static List <Path> ParseJson(JArray jsonPaths, INodeStore nodeGraphStore, IRelationshipStore relationshipGraphStore)
        {
            if (jsonPaths == null)
            {
                return(null);
            }

            var jaPaths = jsonPaths;

            return((from JObject joPath in jaPaths select new Path(joPath, nodeGraphStore, relationshipGraphStore)).ToList());
        }
Esempio n. 15
0
 public static bool RemoveFromIndex(Relationship relationship, Enum indexName, Enum key = null, object value = null, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(RemoveFromIndex(relationship, indexName.ToString(), key == null ? null : key.ToString(), value, relationshipStore, connection));
 }
Esempio n. 16
0
 public static IEnumerable <Relationship> GetRelationship(Enum indexName, Enum key, object value, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(GetRelationship(indexName.ToString(), key.ToString(), value, relationshipStore, connection));
 }
Esempio n. 17
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. 18
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. 19
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. 20
0
 public static IEnumerable <Relationship> GetRelationship(Enum indexName, string searchQuery, IRelationshipStore relationshipStore = null, ConnectionElement connection = null)
 {
     return(GetRelationship(indexName.ToString(), searchQuery, relationshipStore, connection));
 }
Esempio n. 21
0
        public static List<Path> ParseJson(string jsonPaths, INodeStore nodeGraphStore, IRelationshipStore relationshipGraphStore)
        {
            if (String.IsNullOrEmpty(jsonPaths))
            {
                return null;
            }

            var jaPaths = JArray.Parse(jsonPaths);
            return ParseJson(jaPaths);
        }
Esempio n. 22
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. 23
0
        public static List<Path> ParseJson(JArray jsonPaths, INodeStore nodeGraphStore, IRelationshipStore relationshipGraphStore)
        {
            if (jsonPaths == null)
            {
                return null;
            }

            var jaPaths = jsonPaths;

            return (from JObject joPath in jaPaths select new Path(joPath, nodeGraphStore, relationshipGraphStore)).ToList();
        }
Esempio n. 24
0
        public static List <Path> ParseJson(string jsonPaths, INodeStore nodeGraphStore, IRelationshipStore relationshipGraphStore)
        {
            if (String.IsNullOrEmpty(jsonPaths))
            {
                return(null);
            }

            var jaPaths = JArray.Parse(jsonPaths);

            return(ParseJson(jaPaths));
        }