protected void deleteExecutionEntities(ExecutionEntityManager executionEntityManager, ExecutionEntity rootExecutionEntity, String deleteReason) { List<ExecutionEntity> childExecutions = executionEntityManager.collectChildren(rootExecutionEntity); for (int i=childExecutions.size()-1; i>=0; i--) { executionEntityManager.deleteExecutionAndRelatedData(childExecutions.get(i), deleteReason, false); } executionEntityManager.deleteExecutionAndRelatedData(rootExecutionEntity, deleteReason, false); }
/** * Should be subclassed by the more specific types. * For an intermediate catch without type, it's simply leaving the event. */ public void eventCancelledByEventGateway(DelegateExecution execution) { Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
private ExecutionEntityManager deleteAllChildExecutions(ExecutionEntityManager executionEntityManager, ExecutionEntity scopeExecution) { // Delete all child executions Collection<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(scopeExecution.getId()); for (ExecutionEntity childExecution : childExecutions) { executionEntityManager.deleteExecutionAndRelatedData(childExecution, execution.getDeleteReason(), false); } return executionEntityManager; } }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { deleteMessageEventSubScription(execution); Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { deleteSignalEventSubscription(execution); Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
protected boolean isAllEventScopeExecutions(ExecutionEntityManager executionEntityManager, ExecutionEntity parentExecution) { boolean allEventScopeExecutions = true; List<ExecutionEntity> executions = executionEntityManager.findChildExecutionsByParentExecutionId(parentExecution.getId()); for (ExecutionEntity childExecution : executions) { if (childExecution.isEventScope()) { executionEntityManager.deleteExecutionAndRelatedData(childExecution, null, false); } else { allEventScopeExecutions = false; break; } } return allEventScopeExecutions; }
protected void deleteChildExecutions(ExecutionEntity parentExecution, boolean deleteExecution, CommandContext commandContext) { // Delete all child executions ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); Collection<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(parentExecution.getId()); if (CollectionUtil.isNotEmpty(childExecutions)) { for (ExecutionEntity childExecution : childExecutions) { deleteChildExecutions(childExecution, true, commandContext); } } if (deleteExecution) { executionEntityManager.deleteExecutionAndRelatedData(parentExecution, null, false); } }
protected void deleteChildExecutions(ExecutionEntity parentExecution, ExecutionEntity notToDeleteExecution, CommandContext commandContext, String deleteReason) { // Delete all child executions ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); Collection<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(parentExecution.getId()); if (CollectionUtil.isNotEmpty(childExecutions)) { for (ExecutionEntity childExecution : childExecutions) { if (!(childExecution.getId().equals(notToDeleteExecution.getId()))) { deleteChildExecutions(childExecution, notToDeleteExecution, commandContext, deleteReason); } } } executionEntityManager.deleteExecutionAndRelatedData(parentExecution, deleteReason, false); }
protected void createChildExecutionForSubProcess(SubProcess subProcess) { ExecutionEntity parentScopeExecution = findFirstParentScopeExecution(execution); // Create the sub process execution that can be used to set variables // We create a new execution and delete the incoming one to have a proper scope that // does not conflict anything with any existing scopes ExecutionEntity subProcessExecution = commandContext.getExecutionEntityManager().createChildExecution(parentScopeExecution); subProcessExecution.setCurrentFlowElement(subProcess); subProcessExecution.setScope(true); commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(execution, null, false); execution = subProcessExecution; }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { JobEntityManager jobEntityManager = Context.getCommandContext().getJobEntityManager(); List<JobEntity> jobEntities = jobEntityManager.findJobsByExecutionId(execution.getId()); for (JobEntity jobEntity : jobEntities) { // Should be only one jobEntityManager.delete(jobEntity); } Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
if (!executionEntityInGateway.getId().equals(execution.getId())) { commandContext.getHistoryManager().recordActivityEnd(executionEntityInGateway, null); executionEntityManager.deleteExecutionAndRelatedData(executionEntityInGateway, null, false);
protected void cleanupExecutions(FlowElement currentFlowElement) { if (execution.getParentId() != null && execution.isScope()) { // If the execution is a scope (and not a process instance), the scope must first be // destroyed before we can continue and follow the sequence flow Context.getAgenda().planDestroyScopeOperation(execution); } else if (currentFlowElement instanceof Activity) { // If the current activity is an activity, we need to remove any currently active boundary events Activity activity = (Activity) currentFlowElement; if (CollectionUtil.isNotEmpty(activity.getBoundaryEvents())) { // Cancel events are not removed List<String> notToDeleteEvents = new ArrayList<String>(); for (BoundaryEvent event : activity.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(event.getEventDefinitions()) && event.getEventDefinitions().get(0) instanceof CancelEventDefinition) { notToDeleteEvents.add(event.getId()); } } // Delete all child executions Collection<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByParentExecutionId(execution.getId()); for (ExecutionEntity childExecution : childExecutions) { if (childExecution.getCurrentFlowElement() == null || !notToDeleteEvents.contains(childExecution.getCurrentFlowElement().getId())) { commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(childExecution, null, false); } } } } }
public Void execute(CommandContext commandContext) { ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); ExecutionEntity execution = executionEntityManager.findById(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class); } if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) { throw new ActivitiException("The current flow element of the requested execution is not an ad-hoc sub process"); } List<? extends ExecutionEntity> childExecutions = execution.getExecutions(); if (childExecutions.size() > 0) { throw new ActivitiException("Ad-hoc sub process has running child executions that need to be completed first"); } ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(execution.getParent()); outgoingFlowExecution.setCurrentFlowElement(execution.getCurrentFlowElement()); executionEntityManager.deleteExecutionAndRelatedData(execution, null, false); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true); return null; }
protected void deleteChildExecutions(ExecutionEntity parentExecution, ExecutionEntity notToDeleteExecution, CommandContext 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 ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); Collection<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(parentExecution.getId()); if (CollectionUtil.isNotEmpty(childExecutions)) { for (ExecutionEntity childExecution : childExecutions) { if (childExecution.getId().equals(notToDeleteExecution.getId()) == false) { deleteChildExecutions(childExecution, notToDeleteExecution, commandContext); } } } String deleteReason = DeleteReason.BOUNDARY_EVENT_INTERRUPTING + " (" + notToDeleteExecution.getCurrentActivityId() + ")"; if (parentExecution.getCurrentFlowElement() instanceof CallActivity) { ExecutionEntity subProcessExecution = executionEntityManager.findSubProcessInstanceBySuperExecutionId(parentExecution.getId()); if (subProcessExecution != null) { executionEntityManager.deleteProcessInstanceExecutionEntity(subProcessExecution.getId(), subProcessExecution.getCurrentActivityId(), deleteReason, true, true); } } executionEntityManager.deleteExecutionAndRelatedData(parentExecution, deleteReason, false); }
null, false); executionEntityManager.deleteExecutionAndRelatedData(parentExecution, null, false);
for (ExecutionEntity childExecution : childExecutions) { if (!childExecution.getId().equals(executionEntity.getId())) { executionEntityManager.deleteExecutionAndRelatedData(childExecution, DeleteReason.EVENT_SUBPROCESS_INTERRUPTING + "(" + startEvent.getId() + ")", false);
leaveFlowNode(flowNode); } else { commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(execution, null, false);
Context.getAgenda().planDestroyScopeOperation(currentExecution); } else { executionEntityManager.deleteExecutionAndRelatedData(currentExecution, null, false);
protected void cleanupCompensation() { // The compensation is at the end here. Simply stop the execution. commandContext.getHistoryManager().recordActivityEnd(execution, null); commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(execution, null, false); ExecutionEntity parentExecutionEntity = execution.getParent(); if (parentExecutionEntity.isScope() && !parentExecutionEntity.isProcessInstanceType()) { if (allChildExecutionsEnded(parentExecutionEntity, null)) { // Go up the hierarchy to check if the next scope is ended too. // This could happen if only the compensation activity is still active, but the // main process is already finished. ExecutionEntity executionEntityToEnd = parentExecutionEntity; ExecutionEntity scopeExecutionEntity = findNextParentScopeExecutionWithAllEndedChildExecutions(parentExecutionEntity, parentExecutionEntity); while (scopeExecutionEntity != null) { executionEntityToEnd = scopeExecutionEntity; scopeExecutionEntity = findNextParentScopeExecutionWithAllEndedChildExecutions(scopeExecutionEntity, parentExecutionEntity); } if (executionEntityToEnd.isProcessInstanceType()) { Context.getAgenda().planEndExecutionOperation(executionEntityToEnd); } else { Context.getAgenda().planDestroyScopeOperation(executionEntityToEnd); } } } }
null, false); executionEntityManager.deleteExecutionAndRelatedData(parentExecution, null, false);