Permalink
Browse files

Merge remote-tracking branch 'promontis/master'

BREAKING CHANGES
update Node AddToIndex to AddNodeToIndex
update Node Delete to DeleteNode
update Relationship AddToIndex to AddRelationshipToIndex
update Relationship Delete to DeleteRelationship
  • Loading branch information...
SepiaGroup committed Dec 9, 2011
2 parents ddf8f04 + 3f1a1e9 commit 46e1f6bde4dae5c1f0f713c1e68b4c2a0af8ec83
View
@@ -7,6 +7,8 @@ bin
Obj
Bin
TestResults
+_ReSharper
+*.vs10x
*.csproj.user
*.suo
*.scc
@@ -27,4 +29,4 @@ obj/
*.scc
*.ilk
*.ncb
-_ReSharper*
+_ReSharper*
@@ -0,0 +1,16 @@
+using System.Configuration;
+using System.Net;
+
+namespace Neo4jRestNet.CleanDbPlugin
+{
+ public class CleanDbPlugin
+ {
+ private static readonly string _defaultDbUrl = ConfigurationManager.ConnectionStrings["neo4j"].ConnectionString.TrimEnd('/');
+ private static readonly string _cleanDbPluginPath = ConfigurationManager.ConnectionStrings["cleandb"].ConnectionString.TrimEnd('/');
+
+ public static HttpStatusCode CleanDb()
+ {
+ return Rest.HttpRest.Delete(string.Concat(_defaultDbUrl, _cleanDbPluginPath));
+ }
+ }
+}
View
@@ -16,7 +16,7 @@ private enum NodeProperty
NodeType
}
- private static readonly string DefaultDbUrl = ConfigurationManager.ConnectionStrings["neo4j"].ConnectionString.TrimEnd('/');
+ private static readonly string _defaultDbUrl = ConfigurationManager.ConnectionStrings["neo4j"].ConnectionString.TrimEnd('/');
private string _dbUrl;
private string _self;
@@ -32,7 +32,7 @@ private enum NodeProperty
public static Node GetRootNode()
{
- return GetRootNode(DefaultDbUrl);
+ return GetRootNode(_defaultDbUrl);
}
public static Node GetRootNode(string dbUrl)
@@ -71,7 +71,7 @@ public static Node GetRootNode(string dbUrl)
public static Node GetNode(EncryptId nodeId)
{
- return GetNode(DefaultDbUrl, nodeId);
+ return GetNode(_defaultDbUrl, nodeId);
}
public static Node GetNode(string dbUrl, EncryptId nodeId)
@@ -88,22 +88,22 @@ public static Node GetNode(string dbUrl, EncryptId nodeId)
public static IEnumerable<Node> GetNode(string indexName, string key, object value)
{
- return GetNode(DefaultDbUrl, indexName, key, value);
+ return GetNode(_defaultDbUrl, indexName, key, value);
}
public static IEnumerable<Node> GetNode(Enum indexName, string key, object value)
{
- return GetNode(DefaultDbUrl, indexName.ToString(), key, value);
+ return GetNode(_defaultDbUrl, indexName.ToString(), key, value);
}
public static IEnumerable<Node> GetNode(string indexName, Enum key, object value)
{
- return GetNode(DefaultDbUrl, indexName, key.ToString(), value);
+ return GetNode(_defaultDbUrl, indexName, key.ToString(), value);
}
public static IEnumerable<Node> GetNode(Enum indexName, Enum key, object value)
{
- return GetNode(DefaultDbUrl, indexName.ToString(), key.ToString(), value);
+ return GetNode(_defaultDbUrl, indexName.ToString(), key.ToString(), value);
}
public static IEnumerable<Node> GetNode(string dbUrl, string indexName, string key, object value)
@@ -135,12 +135,12 @@ public static IEnumerable<Node> GetNode(string dbUrl, Enum indexName, Enum key,
public static IEnumerable<Node> GetNode(string indexName, string searchQuery)
{
- return GetNode(DefaultDbUrl, indexName, searchQuery);
+ return GetNode(_defaultDbUrl, indexName, searchQuery);
}
public static IEnumerable<Node> GetNode(Enum indexName, string searchQuery)
{
- return GetNode(DefaultDbUrl, indexName.ToString(), searchQuery);
+ return GetNode(_defaultDbUrl, indexName.ToString(), searchQuery);
}
public static IEnumerable<Node> GetNode(string dbUrl, string indexName, string searchQuery)
@@ -168,7 +168,7 @@ public static Node CreateNode(string nodeType)
{
var properties = new Properties();
properties.SetProperty(NodeProperty.NodeType.ToString(), nodeType);
- return CreateNodeFromJson(DefaultDbUrl, properties.ToString());
+ return CreateNodeFromJson(_defaultDbUrl, properties.ToString());
}
public static Node CreateNode(Enum nodeType)
@@ -190,7 +190,7 @@ public static Node CreateNode(string dbUrl, Enum nodeType)
public static Node CreateNode(string nodeType, Properties properties)
{
properties.SetProperty(NodeProperty.NodeType.ToString(), nodeType);
- return CreateNodeFromJson(DefaultDbUrl, properties.ToString());
+ return CreateNodeFromJson(_defaultDbUrl, properties.ToString());
}
public static Node CreateNode(Enum nodeType, Properties properties)
@@ -212,7 +212,7 @@ public static Node CreateNode(string dbUrl, Enum nodeType, Properties properties
public static Node CreateNode(string nodeType, IDictionary<string, object> properties)
{
properties.Add(NodeProperty.NodeType.ToString(), nodeType);
- return CreateNodeFromJson(DefaultDbUrl, JObject.FromObject(properties).ToString(Formatting.None));
+ return CreateNodeFromJson(_defaultDbUrl, JObject.FromObject(properties).ToString(Formatting.None));
}
public static Node CreateNode(Enum nodeType, IDictionary<string, object> properties)
@@ -247,7 +247,7 @@ private static Node CreateNodeFromJson(string dbUrl, string jsonProperties)
#region Delete
- public HttpStatusCode Delete()
+ public HttpStatusCode DeleteNode()
{
HttpStatusCode status = Neo4jRestApi.DeleteNode(_dbUrl, Id);
if (status != HttpStatusCode.NoContent)
@@ -537,35 +537,35 @@ public IEnumerable<IGraphObject> Traverse(Order order, Uniqueness uniqueness, IE
#region Index
- public static Node AddToIndex(long nodeId, string indexName, string key, object value)
+ public static Node AddNodeToIndex(long nodeId, string indexName, string key, object value)
{
- return AddToIndex(DefaultDbUrl, nodeId, indexName, key, value);
+ return AddNodeToIndex(_defaultDbUrl, nodeId, indexName, key, value);
}
- public static Node AddToIndex(long nodeId, Enum indexName, string key, object value)
+ public static Node AddNodeToIndex(long nodeId, Enum indexName, string key, object value)
{
- return AddToIndex(DefaultDbUrl, nodeId, indexName.ToString(), key, value);
+ return AddNodeToIndex(_defaultDbUrl, nodeId, indexName.ToString(), key, value);
}
- public static Node AddToIndex(long nodeId, string indexName, Enum key, object value)
+ public static Node AddNodeToIndex(long nodeId, string indexName, Enum key, object value)
{
- return AddToIndex(DefaultDbUrl, nodeId, indexName, key.ToString(), value);
+ return AddNodeToIndex(_defaultDbUrl, nodeId, indexName, key.ToString(), value);
}
- public static Node AddToIndex(long nodeId, Enum indexName, Enum key, object value)
+ public static Node AddNodeToIndex(long nodeId, Enum indexName, Enum key, object value)
{
- return AddToIndex(DefaultDbUrl, nodeId, indexName.ToString(), key.ToString(), value);
+ return AddNodeToIndex(_defaultDbUrl, nodeId, indexName.ToString(), key.ToString(), value);
}
- public static Node AddToIndex(string dbUrl, long nodeId, Enum indexName, Enum key, object value)
+ public static Node AddNodeToIndex(string dbUrl, long nodeId, Enum indexName, Enum key, object value)
{
- return AddToIndex(dbUrl, nodeId, indexName.ToString(), key.ToString(), value);
+ return AddNodeToIndex(dbUrl, nodeId, indexName.ToString(), key.ToString(), value);
}
- public static Node AddToIndex(string dbUrl, long nodeId, string indexName, string key, object value)
+ public static Node AddNodeToIndex(string dbUrl, long nodeId, string indexName, string key, object value)
{
string response;
- HttpStatusCode status = Neo4jRestApi.AddNodeToIndex(dbUrl, nodeId, indexName, key, value, out response);
+ var status = Neo4jRestApi.AddNodeToIndex(dbUrl, nodeId, indexName, key, value, out response);
if (status != HttpStatusCode.Created)
{
throw new Exception(string.Format("Error creating index for node (http response:{0})", status));
@@ -574,24 +574,24 @@ public static Node AddToIndex(string dbUrl, long nodeId, string indexName, strin
return InitializeFromNodeJson(response);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, string indexName)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, string indexName)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, Enum indexName)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, Enum indexName)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName.ToString());
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName.ToString());
}
- public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, Enum indexName)
+ public static HttpStatusCode RemoveNodeFromIndex(string dbUrl, long nodeId, Enum indexName)
{
- return RemoveFromIndex(dbUrl, nodeId, indexName.ToString());
+ return RemoveNodeFromIndex(dbUrl, nodeId, indexName.ToString());
}
- public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, string indexName)
+ public static HttpStatusCode RemoveNodeFromIndex(string dbUrl, long nodeId, string indexName)
{
- HttpStatusCode status = Neo4jRestApi.RemoveNodeFromIndex(dbUrl, nodeId, indexName);
+ var status = Neo4jRestApi.RemoveNodeFromIndex(dbUrl, nodeId, indexName);
if (status != HttpStatusCode.NoContent)
{
throw new Exception(string.Format("Error remove node from index (node id:{0} index name:{1} http response:{2})", nodeId, indexName, status));
@@ -600,34 +600,34 @@ public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, string i
return status;
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, string indexName, string key)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, string indexName, string key)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName, key);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName, key);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, Enum indexName, string key)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, Enum indexName, string key)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName.ToString(), key);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName.ToString(), key);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, string indexName, Enum key)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, string indexName, Enum key)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName, key.ToString());
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName, key.ToString());
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, Enum indexName, Enum key)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, Enum indexName, Enum key)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName.ToString(), key.ToString());
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName.ToString(), key.ToString());
}
- public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, Enum indexName, Enum key)
+ public static HttpStatusCode RemoveNodeFromIndex(string dbUrl, long nodeId, Enum indexName, Enum key)
{
- return RemoveFromIndex(dbUrl, nodeId, indexName.ToString(), key.ToString());
+ return RemoveNodeFromIndex(dbUrl, nodeId, indexName.ToString(), key.ToString());
}
- public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, string indexName, string key)
+ public static HttpStatusCode RemoveNodeFromIndex(string dbUrl, long nodeId, string indexName, string key)
{
- HttpStatusCode status = Neo4jRestApi.RemoveNodeFromIndex(dbUrl, nodeId, indexName, key);
+ var status = Neo4jRestApi.RemoveNodeFromIndex(dbUrl, nodeId, indexName, key);
if (status != HttpStatusCode.NoContent)
{
throw new Exception(string.Format("Error remove node from index (node id:{0} index name:{1} http response:{2})", nodeId, indexName, status));
@@ -636,29 +636,29 @@ public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, string i
return status;
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, string indexName, string key, object value)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, string indexName, string key, object value)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName, key, value);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName, key, value);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, Enum indexName, string key, object value)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, Enum indexName, string key, object value)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName.ToString(), key, value);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName.ToString(), key, value);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, string indexName, Enum key, object value)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, string indexName, Enum key, object value)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName, key.ToString(), value);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName, key.ToString(), value);
}
- public static HttpStatusCode RemoveFromIndex(long nodeId, Enum indexName, Enum key, object value)
+ public static HttpStatusCode RemoveNodeFromIndex(long nodeId, Enum indexName, Enum key, object value)
{
- return RemoveFromIndex(DefaultDbUrl, nodeId, indexName.ToString(), key.ToString(), value);
+ return RemoveNodeFromIndex(_defaultDbUrl, nodeId, indexName.ToString(), key.ToString(), value);
}
- public static HttpStatusCode RemoveFromIndex(string dbUrl, long nodeId, string indexName, string key, object value)
+ public static HttpStatusCode RemoveNodeFromIndex(string dbUrl, long nodeId, string indexName, string key, object value)
{
- HttpStatusCode status = Neo4jRestApi.RemoveNodeFromIndex(dbUrl, nodeId, indexName, key, value);
+ var status = Neo4jRestApi.RemoveNodeFromIndex(dbUrl, nodeId, indexName, key, value);
if (status != HttpStatusCode.NoContent)
{
throw new Exception(string.Format("Error remove node from index (node id:{0} index name:{1} http response:{2})", nodeId, indexName, status));
@@ -766,4 +766,4 @@ public override int GetHashCode()
#endregion
}
-}
+}
Oops, something went wrong.

0 comments on commit 46e1f6b

Please sign in to comment.