//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddRelationshipToExplicitIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddRelationshipToExplicitIndex()
        {
            long relId;

            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                relId = graphDb.createNode().createRelationshipTo(graphDb.createNode(), RelationshipType.withName("R")).Id;
                ctx.Success();
            }

            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.RelationshipAddToExplicitIndex(INDEX_NAME, relId, KEY, VALUE);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Relationship> hits = graphDb.index().forRelationships(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertThat(hits.next().Id, equalTo(relId));
                hits.Close();
                ctx.Success();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveNonExistingRelationshipFromExplicitIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRemoveNonExistingRelationshipFromExplicitIndex()
        {
            // Given
            long relId = AddRelationshipToExplicitIndex();

            // When
            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.RelationshipRemoveFromExplicitIndex(INDEX_NAME, relId + 1);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Relationship> hits = graphDb.index().forRelationships(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertThat(hits.next().Id, equalTo(relId));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertFalse(hits.hasNext());
                hits.Close();
                ctx.Success();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateExplicitIndexTwice() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateExplicitIndexTwice()
        {
            // Given
            Dictionary <string, string> config = new Dictionary <string, string>();

            config["type"]     = "exact";
            config["provider"] = "lucene";

            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeExplicitIndexCreateLazily(INDEX_NAME, config);
                tx.Success();
            }

            // When
            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeExplicitIndexCreateLazily(INDEX_NAME, config);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                assertTrue(graphDb.index().existsForNodes(INDEX_NAME));
                ctx.Success();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleRemoveNodeFromExplicitIndexTwice() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleRemoveNodeFromExplicitIndexTwice()
        {
            // Given
            long nodeId = AddNodeToExplicitIndex();

            // When
            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeRemoveFromExplicitIndex(INDEX_NAME, nodeId);
                tx.Success();
            }

            using (Transaction tx = beginTransaction())
            {
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeRemoveFromExplicitIndex(INDEX_NAME, nodeId);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Node> hits = graphDb.index().forNodes(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertFalse(hits.hasNext());
                hits.Close();
                ctx.Success();
            }
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void propertyRemoved(org.neo4j.internal.kernel.api.ExplicitIndexWrite ops, long entityId, int propertyKey) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.AutoIndexingKernelException
        public override void PropertyRemoved(ExplicitIndexWrite ops, long entityId, int propertyKey)
        {
            if (_enabled)
            {
                try
                {
                    string name = _propertyKeyLookup.getTokenById(propertyKey).name();
                    if (_propertyKeysToInclude.get().contains(name))
                    {
                        EnsureIndexExists(ops);
                        _type.remove(ops, entityId, name);
                    }
                }
                catch (KernelException e)
                {
                    throw new AutoIndexingKernelException(e);
                }
                catch (TokenNotFoundException e)
                {
                    // TODO: TokenNotFoundException was added before there was a kernel. It should be converted to a
                    // KernelException now
                    throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(propertyKey, e));
                }
            }
        }
Example #6
0
 private void EnsureIndexExists(ExplicitIndexWrite ops)
 {
     // Known racy, but this is safe because ensureIndexExists is concurrency safe, we just want to avoid calling it
     // for every single write we make.
     if (!_indexCreated)
     {
         _type.ensureIndexExists(ops);
         _indexCreated = true;
     }
 }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void entityRemoved(org.neo4j.internal.kernel.api.ExplicitIndexWrite ops, long entityId) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.AutoIndexingKernelException
        public override void EntityRemoved(ExplicitIndexWrite ops, long entityId)
        {
            if (_enabled)
            {
                try
                {
                    EnsureIndexExists(ops);
                    _type.remove(ops, entityId);
                }
                catch (KernelException e)
                {
                    throw new AutoIndexingKernelException(e);
                }
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long addNodeToExplicitIndex() throws Exception
        private long AddNodeToExplicitIndex()
        {
            long nodeId;

            using (Transaction tx = beginTransaction())
            {
                nodeId = tx.DataWrite().nodeCreate();
                ExplicitIndexWrite          indexWrite = tx.IndexWrite();
                Dictionary <string, string> config     = new Dictionary <string, string>();
                config["type"]     = "exact";
                config["provider"] = "lucene";
                indexWrite.NodeExplicitIndexCreateLazily(INDEX_NAME, config);
                indexWrite.NodeAddToExplicitIndex(INDEX_NAME, nodeId, KEY, VALUE);
                tx.Success();
            }
            return(nodeId);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddNodeToExplicitIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddNodeToExplicitIndex()
        {
            long nodeId;

            using (Transaction tx = beginTransaction())
            {
                nodeId = tx.DataWrite().nodeCreate();
                ExplicitIndexWrite indexWrite = tx.IndexWrite();
                indexWrite.NodeAddToExplicitIndex(INDEX_NAME, nodeId, KEY, VALUE);
                tx.Success();
            }

            // Then
            using (Org.Neo4j.Graphdb.Transaction ctx = graphDb.beginTx())
            {
                IndexHits <Node> hits = graphDb.index().forNodes(INDEX_NAME).get(KEY, VALUE);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertThat(hits.next().Id, equalTo(nodeId));
                hits.Close();
                ctx.Success();
            }
        }
Example #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void add(org.neo4j.internal.kernel.api.ExplicitIndexWrite operations, String name, long id, String key, Object value) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public void add(ExplicitIndexWrite operations, string name, long id, string key, object value)
            {
                operations.NodeAddToExplicitIndex(name, id, key, value);
            }
Example #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void drop(org.neo4j.internal.kernel.api.ExplicitIndexWrite operations, String name) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public void drop(ExplicitIndexWrite operations, string name)
            {
                operations.RelationshipExplicitIndexDrop(name);
            }
Example #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void remove(org.neo4j.internal.kernel.api.ExplicitIndexWrite operations, String name, long id) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public void remove(ExplicitIndexWrite operations, string name, long id)
            {
                operations.RelationshipRemoveFromExplicitIndex(name, id);
            }
Example #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void remove(org.neo4j.internal.kernel.api.ExplicitIndexWrite operations, String name, long id, String key, Object value) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public void remove(ExplicitIndexWrite operations, string name, long id, string key, object value)
            {
                operations.RelationshipRemoveFromExplicitIndex(name, id, key, value);
            }
Example #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void drop(org.neo4j.internal.kernel.api.ExplicitIndexWrite operations, String name) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public void drop(ExplicitIndexWrite operations, string name)
            {
                operations.NodeExplicitIndexDrop(name);
            }
Example #15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void remove(org.neo4j.internal.kernel.api.ExplicitIndexWrite operations, String name, long id, String key) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public void remove(ExplicitIndexWrite operations, string name, long id, string key)
            {
                operations.NodeRemoveFromExplicitIndex(name, id, key);
            }