use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class BoundaryEventActivityBehavior method deleteChildExecutions.
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.cancelExecutionAndRelatedData(parentExecution, deleteReason);
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class ParallelMultiInstanceBehavior 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 TerminateEndEventActivityBehavior method dispatchExecutionCancelled.
protected void dispatchExecutionCancelled(DelegateExecution execution, FlowElement terminateEndEvent) {
ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
// subprocesses
for (DelegateExecution subExecution : executionEntityManager.findChildExecutionsByParentExecutionId(execution.getId())) {
dispatchExecutionCancelled(subExecution, terminateEndEvent);
}
// call activities
ExecutionEntity subProcessInstance = Context.getCommandContext().getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
if (subProcessInstance != null) {
dispatchExecutionCancelled(subProcessInstance, terminateEndEvent);
}
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class AddIdentityLinkForProcessInstanceCmd method execute.
public Void execute(CommandContext commandContext) {
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
ExecutionEntity processInstance = executionEntityManager.findById(processInstanceId);
if (processInstance == null) {
throw new ActivitiObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
}
IdentityLinkEntityManager identityLinkEntityManager = commandContext.getIdentityLinkEntityManager();
identityLinkEntityManager.addIdentityLink(processInstance, userId, groupId, type);
commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, true);
return null;
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityManager in project Activiti by Activiti.
the class CompleteAdhocSubProcessCmd method execute.
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);
Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true);
return null;
}
Aggregations