Ejemplo n.º 1
0
        protected internal virtual void DeleteChildExecutions(IExecutionEntity parentExecution, IExecutionEntity notToDeleteExecution, ICommandContext commandContext)
        {
            // TODO: would be good if this deleteChildExecutions could be removed and the one on the executionEntityManager is used
            // The problem however, is that the 'notToDeleteExecution' is passed here.
            // This could be solved by not reusing an execution, but creating a new

            // Delete all child executions
            IExecutionEntityManager        executionEntityManager = commandContext.ExecutionEntityManager;
            ICollection <IExecutionEntity> childExecutions        = executionEntityManager.FindChildExecutionsByParentExecutionId(parentExecution.Id);

            if (CollectionUtil.IsNotEmpty(childExecutions))
            {
                foreach (IExecutionEntity childExecution in childExecutions)
                {
                    if (childExecution.Id.Equals(notToDeleteExecution.Id) == false)
                    {
                        DeleteChildExecutions(childExecution, notToDeleteExecution, commandContext);
                    }
                }
            }

            string deleteReason = History.DeleteReasonFields.BOUNDARY_EVENT_INTERRUPTING + " (" + notToDeleteExecution.CurrentActivityId + ")";

            if (parentExecution.CurrentFlowElement is CallActivity)
            {
                IExecutionEntity subProcessExecution = executionEntityManager.FindSubProcessInstanceBySuperExecutionId(parentExecution.Id);
                if (subProcessExecution != null)
                {
                    executionEntityManager.DeleteProcessInstanceExecutionEntity(subProcessExecution.Id, subProcessExecution.CurrentActivityId, deleteReason, true, true);
                }
            }

            executionEntityManager.DeleteExecutionAndRelatedData(parentExecution, deleteReason, false);
        }