use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class GatewayActivityBehavior method lockFirstParentScope.
protected void lockFirstParentScope(DelegateExecution execution) {
ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
boolean found = false;
ExecutionEntity parentScopeExecution = null;
ExecutionEntity currentExecution = (ExecutionEntity) execution;
while (!found && currentExecution != null && currentExecution.getParentId() != null) {
parentScopeExecution = executionEntityManager.findById(currentExecution.getParentId());
if (parentScopeExecution != null && parentScopeExecution.isScope()) {
found = true;
}
currentExecution = parentScopeExecution;
}
parentScopeExecution.forceUpdate();
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class AbstractOperation method findFirstParentScopeExecution.
/**
* Returns the first parent execution of the provided execution that is a scope.
*/
protected ExecutionEntity findFirstParentScopeExecution(ExecutionEntity executionEntity) {
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
ExecutionEntity parentScopeExecution = null;
ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(executionEntity.getParentId());
while (currentlyExaminedExecution != null && parentScopeExecution == null) {
if (currentlyExaminedExecution.isScope()) {
parentScopeExecution = currentlyExaminedExecution;
} else {
currentlyExaminedExecution = executionEntityManager.findById(currentlyExaminedExecution.getParentId());
}
}
return parentScopeExecution;
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class BoundaryEventActivityBehavior method executeInterruptingBehavior.
protected void executeInterruptingBehavior(ExecutionEntity executionEntity, CommandContext commandContext) {
// The destroy scope operation will look for the parent execution and
// destroy the whole scope, and leave the boundary event using this parent execution.
//
// The take outgoing seq flows operation below (the non-interrupting else clause) on the other hand uses the
// child execution to leave, which keeps the scope alive.
// Which is what we need here.
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
ExecutionEntity attachedRefScopeExecution = executionEntityManager.findById(executionEntity.getParentId());
ExecutionEntity parentScopeExecution = null;
ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(attachedRefScopeExecution.getParentId());
while (currentlyExaminedExecution != null && parentScopeExecution == null) {
if (currentlyExaminedExecution.isScope()) {
parentScopeExecution = currentlyExaminedExecution;
} else {
currentlyExaminedExecution = executionEntityManager.findById(currentlyExaminedExecution.getParentId());
}
}
if (parentScopeExecution == null) {
throw new ActivitiException("Programmatic error: no parent scope execution found for boundary event");
}
deleteChildExecutions(attachedRefScopeExecution, executionEntity, commandContext);
// set new parent for boundary event execution
executionEntity.setParent(parentScopeExecution);
Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(executionEntity, true);
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class CancelEndEventActivityBehavior method deleteChildExecutions.
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);
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class EndExecutionOperation method handleRegularExecution.
protected void handleRegularExecution() {
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
// There will be a parent execution (or else we would be in the process instance handling method)
ExecutionEntity parentExecution = executionEntityManager.findById(execution.getParentId());
// If the execution is a scope, all the child executions must be deleted first.
if (execution.isScope()) {
executionEntityManager.deleteChildExecutions(execution, null);
}
// Delete current execution
logger.debug("Ending execution {}", execution.getId());
executionEntityManager.deleteExecutionAndRelatedData(execution, null);
logger.debug("Parent execution found. Continuing process using execution {}", parentExecution.getId());
// When ending an execution in a multi instance subprocess , special care is needed
if (isEndEventInMultiInstanceSubprocess(execution)) {
handleMultiInstanceSubProcess(executionEntityManager, parentExecution);
return;
}
SubProcess subProcess = execution.getCurrentFlowElement().getSubProcess();
// If not (eg an embedded subprocess still has active elements, we cannot continue)
if (getNumberOfActiveChildExecutionsForExecution(executionEntityManager, parentExecution.getId()) == 0 || isAllEventScopeExecutions(executionEntityManager, parentExecution)) {
ExecutionEntity executionToContinue = null;
if (subProcess != null) {
if (subProcess.isForCompensation()) {
Context.getAgenda().planEndExecutionOperation(parentExecution);
} else {
executionToContinue = handleSubProcessEnd(executionEntityManager, parentExecution, subProcess);
}
} else {
// In the 'regular' case (not being in a subprocess), we use the parent execution to
// continue process instance execution
executionToContinue = handleRegularExecutionEnd(executionEntityManager, parentExecution);
}
if (executionToContinue != null) {
// not the process instance root execution (otherwise the process instance is finished)
if (executionToContinue.isProcessInstanceType()) {
handleProcessInstanceExecution(executionToContinue);
} else {
Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(executionToContinue, true);
}
}
}
}
Aggregations