Exemple #1
0
        public Node CreateUniqueNode(ConnectionElement connection, Properties properties, string indexName, string key, object value, IndexUniqueness uniqueness)
        {
            var body = new JObject
            {
                { "value", JToken.FromObject(value) },
                { "properties", properties.ToJObject() },
                { "key", key }
            };

            var index = _jobs.Count();

            _jobs.Add(new BatchJob
            {
                Method = HttpRest.Method.Post,
                To     = string.Format("/index/node/{0}?uniqueness={1}", indexName, uniqueness),
                Id     = index,
                Body   = body
            });

            _jobs[index].GraphObject = new BatchNodeStore(this).Initilize(null, index, null);

            return((Node)_jobs[index].GraphObject);
        }
Exemple #2
0
        public Relationship CreateUniqueRelationship(ConnectionElement connection, Node startNode, Node endNode, string name, Properties properties, string indexName, string key, object value, IndexUniqueness uniqueness)
        {
            var startFormat = IsBatchObject(endNode) ? "{{{0}}}" : "/node/{0}";
            var endFormat   = IsBatchObject(startNode) ? "{{{0}}}" : "/node/{0}";

            var body = new JObject
            {
                { "value", JToken.FromObject(value) },
                { "properties", properties.ToJObject() },
                { "key", key },
                { "start", string.Format(startFormat, startNode.Id) },
                { "end", string.Format(endFormat, endNode.Id) },
                { "type", name }
            };

            var index = _jobs.Count();

            _jobs.Add(new BatchJob
            {
                Method = HttpRest.Method.Post,
                To     = string.Format("/index/relationship/{0}?uniqueness={1}", indexName, uniqueness),
                Id     = index,
                Body   = body
            });

            _jobs[index].GraphObject = new BatchRelationshipStore(this).Initilize(null, index, null);

            return((Relationship)_jobs[index].GraphObject);
        }
        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 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, IndexUniqueness uniqueness)
 {
     return(_batchStore.CreateUniqueNode(connection, properties, indexName, key, value, uniqueness));
 }
Exemple #6
0
 public Relationship CreateUniqueRelationship(ConnectionElement connection, Node startNode, Node endNode, string name, Properties properties, string indexName, string key, object value, IndexUniqueness uniqueness)
 {
     return(_batchStore.CreateUniqueRelationship(connection, startNode, endNode, name, properties, indexName, key, value, uniqueness));
 }
Exemple #7
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));
 }
Exemple #8
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));
        }
        public static HttpStatusCode CreateUniqueNode(string dbUrl, string jsonProperties, string indexName, string key, object value, IndexUniqueness uniqueness, out string response)
        {
            var jo = new JObject
                     	{
                     		{"key", key},
                            {"value", JToken.FromObject(value)},
                            {"properties", JToken.Parse(string.IsNullOrWhiteSpace(jsonProperties) ? "{}" : jsonProperties)}
                     	};

            return HttpRest.Post(string.Concat(Connection.GetServiceRoot(dbUrl).NodeIndex, "/", indexName, "?uniqueness=", uniqueness), jo.ToString(Formatting.None, new IsoDateTimeConverter()), out response);
        }
        public static HttpStatusCode CreateUniqueRelationship(string dbUrl, long startNodeId, long endNodeId, string name, string jsonProperties, string indexName, string key, object value, IndexUniqueness uniqueness, out string response)
        {
            var jo = new JObject
                         {
                             {"key", key},
                             {"value", JToken.FromObject(value)},
                             {"start", string.Concat(Connection.GetServiceRoot(dbUrl).Node, "/", startNodeId)},
                             {"end", string.Concat(Connection.GetServiceRoot(dbUrl).Node, "/", endNodeId)},
                             {"properties", JToken.Parse(string.IsNullOrWhiteSpace(jsonProperties) ? "{}" : jsonProperties)},
                             {"type", name}
                         };

            return HttpRest.Post(string.Concat(Connection.GetServiceRoot(dbUrl).RelationshipIndex, "/", indexName, "?uniqueness=", uniqueness), jo.ToString(), out response);
        }
Exemple #11
0
 public static Node CreateUniqueNode(Enum indexName, Enum key, object value, IndexUniqueness uniqueness, Properties properties = null, INodeStore nodeStore = null, ConnectionElement connection = null)
 {
     return(CreateUniqueNode(indexName.ToString(), key.ToString(), value, uniqueness, properties, nodeStore, connection));
 }
Exemple #12
0
        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 Relationship CreateUniqueRelationship(ConnectionElement connection, Node startNode, Node endNode, string name, Properties properties, string indexName, string key, object value, IndexUniqueness uniqueness)
 {
     return _batchStore.CreateUniqueRelationship(connection, startNode, endNode, name, properties, indexName, key, value, uniqueness);
 }