/// <summary> /// Creates the index on the master server /// </summary> /// <param name="indexName">Name of the index.</param> /// <param name="dropIfExists">if set to <c>true</c> [drop if exists].</param> public void CreateIndex(string indexName, bool dropIfExists) { if (dropIfExists) { DeleteIndex(indexName); } var indexConfiguration = new IndexConfiguration { Provider = IndexProvider.lucene, Type = IndexType.fulltext }; GraphPoolableClient client = null; try { client = GetClient(); client.GetClient().CreateIndex(indexName, indexConfiguration, IndexFor.Node); } catch (Exception e) { LogException("CreateIndex", e); InformAboutHostProblems(client, e); throw; } }
/// <summary> /// Deletes the index on the master server /// </summary> /// <param name="indexName">Name of the index.</param> public void DeleteIndex(string indexName) { GraphPoolableClient client = null; try { client = GetClient(); if (client.GetClient().CheckIndexExists(indexName, IndexFor.Node)) { client.GetClient().DeleteIndex(indexName, IndexFor.Node); } } catch (Exception e) { LogException("DeleteIndex", e); InformAboutHostProblems(client, e); throw; } }
/// <summary> /// Inserts the specified node on the master server /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node">The node.</param> /// <param name="relationships">The relationships.</param> /// <returns></returns> public NodeResult <T> Insert <T>(T node, IEnumerable <IRelationshipAllowingParticipantNode <T> > relationships) where T : class { GraphPoolableClient client = GetClient(); try { return(new NodeResult <T>(client.GetClient().Create(node, relationships.ToArray(), Enumerable.Empty <IndexEntry>()), node)); } catch (Exception e) { LogException("Insert", e); InformAboutHostProblems(client, e); throw; } }
/// <summary> /// Creates the relationship on the master server /// </summary> /// <typeparam name="TNode">The type of the node.</typeparam> /// <typeparam name="TRelationship">The type of the relationship.</typeparam> /// <param name="nodeReference">The node reference.</param> /// <param name="relationshipAllowingParticipantNode">The relationship allowing participant node.</param> public void CreateRelationship <TNode, TRelationship>(NodeReference <TNode> nodeReference, TRelationship relationshipAllowingParticipantNode) where TRelationship : Relationship, IRelationshipAllowingSourceNode <TNode> { GraphPoolableClient client = null; try { client = GetClient(); client.GetClient().CreateRelationship(nodeReference, relationshipAllowingParticipantNode); } catch (Exception e) { LogException("CreateRelationship", e); InformAboutHostProblems(client, e); throw; } }
/// <summary> /// Inserts the specified node on the master server /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node">The node.</param> /// <param name="indexEntries">The index entries.</param> /// <returns></returns> public NodeResult <T> Insert <T>(T node, IEnumerable <IndexEntry> indexEntries) where T : class { GraphPoolableClient client = null; try { client = GetClient(); return(new NodeResult <T>(client.GetClient().Create(node, null, indexEntries), node)); } catch (Exception e) { LogException("Insert", e); InformAboutHostProblems(client, e); throw; } }
/// <summary> /// Gets the specified node references on the slave server /// </summary> /// <typeparam name="T"></typeparam> /// <param name="query">The query.</param> /// <returns></returns> public IEnumerable <NodeReference <T> > GetNodeReferences <T>(string query) { GraphPoolableClient client = null; try { client = GetClient(); return(((IRawGraphClient)client.GetClient()) .ExecuteGetCypherResults <Node <T> >(new CypherQuery(query, null, CypherResultMode.Set)) .Select(t => t.Reference)); } catch (Exception e) { LogException("GetNodeReferences", e); InformAboutHostProblems(client, e); throw; } }
/// <summary> /// Deletes the specified node reference on the master server /// </summary> /// <param name="nodeReference">The node reference.</param> /// <returns></returns> public bool Delete(long nodeReference) { GraphPoolableClient client = null; try { client = GetClient(); client.GetClient() .Cypher .Start(new { n = nodeReference }) .Match("n-[r?]-()") .Delete("n, r") .ExecuteWithoutResults(); return(true); } catch (Exception e) { LogException("Delete", e); InformAboutHostProblems(client, e); throw; } }