Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void startDb()
        public virtual void StartDb()
        {
            _graphDb = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabaseBuilder().setConfig(new Dictionary <string, string>()).newGraphDatabase();

            using (Transaction tx = _graphDb.beginTx())
            {
                // Create the node and relationship auto-indexes
                _graphDb.index().NodeAutoIndexer.Enabled = true;
                _graphDb.index().NodeAutoIndexer.startAutoIndexingProperty("nodeProp");
                _graphDb.index().RelationshipAutoIndexer.Enabled = true;
                _graphDb.index().RelationshipAutoIndexer.startAutoIndexingProperty("type");

                tx.Success();
            }

            using (Transaction tx = _graphDb.beginTx())
            {
                Node node1 = _graphDb.createNode();
                Node node2 = _graphDb.createNode();
                Node node3 = _graphDb.createNode();
                _id1 = node1.Id;
                _id2 = node2.Id;
                _id3 = node3.Id;
                Relationship rel = node1.CreateRelationshipTo(node2, RelationshipType.withName("FOO"));
                rel.SetProperty("type", "FOO");

                tx.Success();
            }
        }
Example #2
0
 private void CreateLegacyIndex()
 {
     using (Transaction tx = _graphDb.beginTx())
     {
         Index <Node> nodeIndex = _graphDb.index().forNodes(INDEX);
         nodeIndex.Add(_graphDb.createNode(), "some-key", "som-value");
         tx.Success();
     }
 }
Example #3
0
            internal virtual void DeleteAllIndexes()
            {
                IndexManager indexManager = Db.index();

                foreach (string indexName in indexManager.NodeIndexNames())
                {
                    try
                    {
                        Db.index().forNodes(indexName).delete();
                    }
                    catch (System.NotSupportedException)
                    {
                        // Encountered a read-only index.
                    }
                }

                foreach (string indexName in indexManager.RelationshipIndexNames())
                {
                    try
                    {
                        Db.index().forRelationships(indexName).delete();
                    }
                    catch (System.NotSupportedException)
                    {
                        // Encountered a read-only index.
                    }
                }

                foreach (string k in indexManager.NodeAutoIndexer.AutoIndexedProperties)
                {
                    indexManager.NodeAutoIndexer.stopAutoIndexingProperty(k);
                }
                indexManager.NodeAutoIndexer.Enabled = false;

                foreach (string k in indexManager.RelationshipAutoIndexer.AutoIndexedProperties)
                {
                    indexManager.RelationshipAutoIndexer.stopAutoIndexingProperty(k);
                }
                indexManager.RelationshipAutoIndexer.Enabled = false;
            }
Example #4
0
 private ReadableRelationshipIndex RelationShipAutoIndex()
 {
     return(_graphDb.index().RelationshipAutoIndexer.AutoIndex);
 }
Example #5
0
 public override IndexManager Index()
 {
     return(GraphDatabaseAPI.index());
 }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNodeAutoIndexFromAPISanity()
        public virtual void TestNodeAutoIndexFromAPISanity()
        {
            NewTransaction();
            AutoIndexer <Node> autoIndexer = _graphDb.index().NodeAutoIndexer;

            autoIndexer.StartAutoIndexingProperty("test_uuid");
            autoIndexer.Enabled = true;
            assertEquals(1, autoIndexer.AutoIndexedProperties.Count);
            assertTrue(autoIndexer.AutoIndexedProperties.Contains("test_uuid"));

            Node node1 = _graphDb.createNode();

            node1.SetProperty("test_uuid", "node1");
            Node node2 = _graphDb.createNode();

            node2.SetProperty("test_uuid", "node2");

            NewTransaction();

            assertEquals(node1, autoIndexer.AutoIndex.get("test_uuid", "node1").Single);
            assertEquals(node2, autoIndexer.AutoIndex.get("test_uuid", "node2").Single);
        }