//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private String getOrCreateSchemaState(String key, final String maybeSetThisState) private string GetOrCreateSchemaState(string key, string maybeSetThisState) { using (Transaction tx = Db.beginTx()) { KernelTransaction ktx = StatementContextSupplier.getKernelTransactionBoundToThisThread(true); string state = ktx.SchemaRead().schemaStateGetOrCreate(key, s => maybeSetThisState); tx.Success(); return(state); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { KernelTransaction transaction = mock(typeof(KernelTransaction)); _tokenRead = mock(typeof(TokenRead)); _schemaRead = mock(typeof(SchemaRead)); _procedure = new IndexProcedures(transaction, null); when(transaction.TokenRead()).thenReturn(_tokenRead); when(transaction.SchemaRead()).thenReturn(_schemaRead); _indexingService = mock(typeof(IndexingService)); _procedure = new IndexProcedures(transaction, _indexingService); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void lockNodeUsingUniqueIndexSeek(org.neo4j.kernel.internal.GraphDatabaseAPI database, org.neo4j.graphdb.Label label, String nameProperty) throws org.neo4j.internal.kernel.api.exceptions.KernelException private static void LockNodeUsingUniqueIndexSeek(GraphDatabaseAPI database, Label label, string nameProperty) { using (Transaction transaction = database.BeginTx()) { ThreadToStatementContextBridge contextBridge = database.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)); KernelTransaction kernelTransaction = contextBridge.GetKernelTransactionBoundToThisThread(true); TokenRead tokenRead = kernelTransaction.TokenRead(); Read dataRead = kernelTransaction.DataRead(); int labelId = tokenRead.NodeLabel(label.Name()); int propertyId = tokenRead.PropertyKey(nameProperty); IndexReference indexReference = kernelTransaction.SchemaRead().index(labelId, propertyId); dataRead.LockingNodeUniqueIndexSeek(indexReference, IndexQuery.ExactPredicate.exact(propertyId, "value")); transaction.Success(); } }
private bool SchemaStateContains(string key) { using (Transaction tx = Db.beginTx()) { KernelTransaction ktx = StatementContextSupplier.getKernelTransactionBoundToThisThread(true); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean result = new java.util.concurrent.atomic.AtomicBoolean(true); AtomicBoolean result = new AtomicBoolean(true); ktx.SchemaRead().schemaStateGetOrCreate(key, s => { result.set(false); return(null); }); tx.Success(); return(result.get()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAllowConcurrentViolationOfConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAllowConcurrentViolationOfConstraint() { // Given GraphDatabaseAPI graphDb = Db.GraphDatabaseAPI; System.Func <KernelTransaction> ktxSupplier = () => graphDb.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); Label label = label("Foo"); string propertyKey = "bar"; string conflictingValue = "baz"; // a constraint using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create(); tx.Success(); } // When using (Transaction tx = graphDb.BeginTx()) { KernelTransaction ktx = ktxSupplier(); int labelId = ktx.TokenRead().nodeLabel(label.Name()); int propertyKeyId = ktx.TokenRead().propertyKey(propertyKey); IndexDescriptor index = TestIndexDescriptorFactory.uniqueForLabel(labelId, propertyKeyId); Read read = ktx.DataRead(); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { read.NodeIndexSeek(ktx.SchemaRead().index(labelId, propertyKeyId), cursor, IndexOrder.NONE, false, IndexQuery.exact(index.Schema().PropertyId, "The value is irrelevant, we just want to perform some sort of lookup against this " + "index")); } // then let another thread come in and create a node Threads.execute(Db => { using (Transaction transaction = Db.beginTx()) { Db.createNode(label).setProperty(propertyKey, conflictingValue); transaction.success(); } return(null); }, graphDb).get(); // before we create a node with the same property ourselves - using the same statement that we have // already used for lookup against that very same index long node = ktx.DataWrite().nodeCreate(); ktx.DataWrite().nodeAddLabel(node, labelId); try { ktx.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of(conflictingValue)); fail("exception expected"); } // Then catch (UniquePropertyValueValidationException e) { assertEquals(ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyId), e.Constraint()); IndexEntryConflictException conflict = Iterators.single(e.Conflicts().GetEnumerator()); assertEquals(Values.stringValue(conflictingValue), conflict.SinglePropertyValue); } tx.Success(); } }