Search in sources :

Example 21 with ExecutionEntityManager

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);
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) CallActivity(org.activiti.bpmn.model.CallActivity) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 22 with ExecutionEntityManager

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();
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 23 with ExecutionEntityManager

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);
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 24 with ExecutionEntityManager

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;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) IdentityLinkEntityManager(org.activiti.engine.impl.persistence.entity.IdentityLinkEntityManager) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 25 with ExecutionEntityManager

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;
}
Also used : AdhocSubProcess(org.activiti.bpmn.model.AdhocSubProcess) ActivitiException(org.activiti.engine.ActivitiException) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Aggregations

ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)30 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)29 ActivitiException (org.activiti.engine.ActivitiException)11 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)6 SubProcess (org.activiti.bpmn.model.SubProcess)5 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)5 FlowElement (org.activiti.bpmn.model.FlowElement)4 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 DelegateExecution (org.activiti.engine.delegate.DelegateExecution)4 ArrayList (java.util.ArrayList)3 Activity (org.activiti.bpmn.model.Activity)3 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 CallActivity (org.activiti.bpmn.model.CallActivity)3 Process (org.activiti.bpmn.model.Process)2 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)2 CompensateEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity)2 EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)2 EventSubscriptionEntityManager (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntityManager)2 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)2 HashMap (java.util.HashMap)1