Esempio n. 1
0
 public override void Accept(DbStructureVisitor visitor)
 {
     using (Transaction tx = _db.beginTx())
     {
         ShowStructure(_bridge.getKernelTransactionBoundToThisThread(true), visitor);
         tx.Success();
     }
 }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long makeNode(String label) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual long MakeNode(string label)
        {
            long result;

            try
            {
                using (Transaction tx = _graph.beginTransaction(KernelTransaction.Type.@explicit, AnonymousContext.write()))
                {
                    KernelTransaction ktx = _txBridge.getKernelTransactionBoundToThisThread(true);
                    long nodeId           = ktx.DataWrite().nodeCreate();
                    int  labelId          = ktx.TokenWrite().labelGetOrCreateForName(label);
                    ktx.DataWrite().nodeAddLabel(nodeId, labelId);
                    result = nodeId;
                    tx.Success();
                }
            }
            catch (Exception e)
            {
                _log.error("Failed to create node: " + e.Message);
                throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureCallFailed, "Failed to create node: " + e.Message, e);
            }
            return(result);
        }
Esempio n. 3
0
        private void SetUpMocks()
        {
            _queryService = mock(typeof(GraphDatabaseQueryService));
            DependencyResolver resolver = mock(typeof(DependencyResolver));

            _txBridge         = mock(typeof(ThreadToStatementContextBridge));
            _initialStatement = mock(typeof(KernelStatement));

            _statistics = new ConfiguredExecutionStatistics(this);
            QueryRegistryOperations queryRegistryOperations = mock(typeof(QueryRegistryOperations));
            InternalTransaction     internalTransaction     = mock(typeof(InternalTransaction));

            when(internalTransaction.TerminationReason()).thenReturn(null);

            when(_initialStatement.queryRegistration()).thenReturn(queryRegistryOperations);
            when(_queryService.DependencyResolver).thenReturn(resolver);
            when(resolver.ResolveDependency(typeof(ThreadToStatementContextBridge))).thenReturn(_txBridge);
            when(_queryService.beginTransaction(any(), any())).thenReturn(internalTransaction);

            KernelTransaction mockTransaction = mockTransaction(_initialStatement);

            when(_txBridge.get()).thenReturn(_initialStatement);
            when(_txBridge.getKernelTransactionBoundToThisThread(true)).thenReturn(mockTransaction);
        }
Esempio n. 4
0
 internal virtual void SuspendSinceTransactionsAreStillThreadBound()
 {
     Debug.Assert(_suspendedTransaction == null, "Can't suspend the transaction if it already is suspended.");
     _suspendedTransaction = _bridge.getKernelTransactionBoundToThisThread(true);
     _bridge.unbindTransactionFromCurrentThread();
 }