org.activiti.engine.impl.persistence.entity.ExecutionEntityManager Java Examples
The following examples show how to use
org.activiti.engine.impl.persistence.entity.ExecutionEntityManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessInstanceDiagramCmd.java From activiti-basic with Apache License 2.0 | 6 votes |
public InputStream execute(CommandContext commandContext) { ExecutionEntityManager executionEntityManager = commandContext .getExecutionEntityManager(); ExecutionEntity executionEntity = executionEntityManager .findExecutionById(processInstanceId); List<String> activiityIds = executionEntity.findActiveActivityIds(); String processDefinitionId = executionEntity.getProcessDefinitionId(); GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd( processDefinitionId); BpmnModel bpmnModel = getBpmnModelCmd.execute(commandContext); InputStream is = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", activiityIds); return is; }
Example #2
Source File: GatewayActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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(); }
Example #3
Source File: SetProcessInstanceBusinessKeyCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public Void execute(CommandContext commandContext) { ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager(); ExecutionEntity processInstance = executionManager.findById(processInstanceId); if (processInstance == null) { throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class); } else if (!processInstance.isProcessInstanceType()) { throw new ActivitiIllegalArgumentException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id."); } if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, processInstance.getProcessDefinitionId())) { commandContext.getProcessEngineConfiguration().getActiviti5CompatibilityHandler().updateBusinessKey(processInstanceId, businessKey); return null; } executionManager.updateProcessInstanceBusinessKey(processInstance, businessKey); return null; }
Example #4
Source File: CompleteAdhocSubProcessCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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 == false) { 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; }
Example #5
Source File: AddIdentityLinkForProcessInstanceCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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); } if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, processInstance.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.addIdentityLinkForProcessInstance(processInstanceId, userId, groupId, type); return null; } IdentityLinkEntityManager identityLinkEntityManager = commandContext.getIdentityLinkEntityManager(); identityLinkEntityManager.addIdentityLink(processInstance, userId, groupId, type); commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, true); return null; }
Example #6
Source File: TerminateEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void terminateMultiInstanceRoot(DelegateExecution execution, CommandContext commandContext, ExecutionEntityManager executionEntityManager) { // When terminateMultiInstance is 'true', we look for the multi instance root and delete it from there. ExecutionEntity miRootExecutionEntity = executionEntityManager.findFirstMultiInstanceRoot((ExecutionEntity) execution); if (miRootExecutionEntity != null) { // Create sibling execution to continue process instance execution before deletion ExecutionEntity siblingExecution = executionEntityManager.createChildExecution(miRootExecutionEntity.getParent()); siblingExecution.setCurrentFlowElement(miRootExecutionEntity.getCurrentFlowElement()); deleteExecutionEntities(executionEntityManager, miRootExecutionEntity, createDeleteReason(miRootExecutionEntity.getActivityId())); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(siblingExecution, true); } else { defaultTerminateEndEventBehaviour(execution, commandContext, executionEntityManager); } }
Example #7
Source File: TerminateEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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); } // activity with message/signal boundary events FlowElement currentFlowElement = execution.getCurrentFlowElement(); if (currentFlowElement instanceof FlowNode) { dispatchActivityCancelled(execution, terminateEndEvent); } }
Example #8
Source File: ParallelMultiInstanceBehavior.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
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(); }
Example #9
Source File: EndExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void handleMultiInstanceSubProcess(ExecutionEntityManager executionEntityManager, ExecutionEntity parentExecution) { List<ExecutionEntity> activeChildExecutions = getActiveChildExecutionsForExecution(executionEntityManager, parentExecution.getId()); boolean containsOtherChildExecutions = false; for (ExecutionEntity activeExecution : activeChildExecutions) { if (activeExecution.getId().equals(execution.getId()) == false) { containsOtherChildExecutions = true; } } if (!containsOtherChildExecutions) { // Destroy the current scope (subprocess) and leave via the subprocess ScopeUtil.createCopyOfSubProcessExecutionForCompensation(parentExecution); Context.getAgenda().planDestroyScopeOperation(parentExecution); SubProcess subProcess = execution.getCurrentFlowElement().getSubProcess(); MultiInstanceActivityBehavior multiInstanceBehavior = (MultiInstanceActivityBehavior) subProcess.getBehavior(); parentExecution.setCurrentFlowElement(subProcess); multiInstanceBehavior.leave(parentExecution); } }
Example #10
Source File: SetProcessInstanceBusinessKeyCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public Void execute(CommandContext commandContext) { ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager(); ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId); if (processInstance == null) { throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class); } else if (!processInstance.isProcessInstanceType()) { throw new ActivitiIllegalArgumentException( "A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id."); } processInstance.updateProcessBusinessKey(businessKey); return null; }
Example #11
Source File: TerminateEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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); }
Example #12
Source File: TerminateEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void terminateAllBehaviour(DelegateExecution execution, CommandContext commandContext, ExecutionEntityManager executionEntityManager) { ExecutionEntity rootExecutionEntity = executionEntityManager.findByRootProcessInstanceId(execution.getRootProcessInstanceId()); String deleteReason = createDeleteReason(execution.getCurrentActivityId()); deleteExecutionEntities(executionEntityManager, rootExecutionEntity, deleteReason); endAllHistoricActivities(rootExecutionEntity.getId(), deleteReason); commandContext.getHistoryManager().recordProcessInstanceEnd(rootExecutionEntity.getId(), deleteReason, execution.getCurrentActivityId()); }
Example #13
Source File: ParallelMultiInstanceBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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); } }
Example #14
Source File: CancelEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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()) == false) { deleteChildExecutions(childExecution, notToDeleteExecution, commandContext, deleteReason); } } } executionEntityManager.deleteExecutionAndRelatedData(parentExecution, deleteReason, false); }
Example #15
Source File: TerminateEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void execute(DelegateExecution execution) { CommandContext commandContext = Context.getCommandContext(); ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); if (terminateAll) { terminateAllBehaviour(execution, commandContext, executionEntityManager); } else if (terminateMultiInstance) { terminateMultiInstanceRoot(execution, commandContext, executionEntityManager); } else { defaultTerminateEndEventBehaviour(execution, commandContext, executionEntityManager); } }
Example #16
Source File: EventSubProcessMessageStartEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void trigger(DelegateExecution execution, String triggerName, Object triggerData) { CommandContext commandContext = Context.getCommandContext(); ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); ExecutionEntity executionEntity = (ExecutionEntity) execution; StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement(); if (startEvent.isInterrupting()) { List<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(executionEntity.getParentId()); for (ExecutionEntity childExecution : childExecutions) { if (childExecution.getId().equals(executionEntity.getId()) == false) { executionEntityManager.deleteExecutionAndRelatedData(childExecution, DeleteReason.EVENT_SUBPROCESS_INTERRUPTING + "(" + startEvent.getId() + ")", false); } } } EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager(); List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions(); for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageEventDefinition.getMessageRef())) { eventSubscriptionEntityManager.delete(eventSubscription); } } executionEntity.setCurrentFlowElement((SubProcess) executionEntity.getCurrentFlowElement().getParentContainer()); executionEntity.setScope(true); ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(executionEntity); outgoingFlowExecution.setCurrentFlowElement(startEvent); leave(outgoingFlowExecution); }
Example #17
Source File: BoundaryEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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); }
Example #18
Source File: BoundaryEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void executeNonInterruptingBehavior(ExecutionEntity executionEntity, CommandContext commandContext) { // Non-interrupting: the current execution is given the first parent // scope (which isn't its direct parent) // // Why? Because this execution does NOT have anything to do with // the current parent execution (the one where the boundary event is on): when it is deleted or whatever, // this does not impact this new execution at all, it is completely independent in that regard. // Note: if the parent of the parent does not exists, this becomes a concurrent execution in the process instance! ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); ExecutionEntity parentExecutionEntity = executionEntityManager.findById(executionEntity.getParentId()); ExecutionEntity scopeExecution = null; ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(parentExecutionEntity.getParentId()); while (currentlyExaminedExecution != null && scopeExecution == null) { if (currentlyExaminedExecution.isScope()) { scopeExecution = currentlyExaminedExecution; } else { currentlyExaminedExecution = executionEntityManager.findById(currentlyExaminedExecution.getParentId()); } } if (scopeExecution == null) { throw new ActivitiException("Programmatic error: no parent scope execution found for boundary event"); } ExecutionEntity nonInterruptingExecution = executionEntityManager.createChildExecution(scopeExecution); nonInterruptingExecution.setCurrentFlowElement(executionEntity.getCurrentFlowElement()); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(nonInterruptingExecution, true); }
Example #19
Source File: BoundaryEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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); }
Example #20
Source File: IntermediateCatchEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void deleteOtherEventsRelatedToEventBasedGateway(DelegateExecution execution, EventGateway eventGateway) { // To clean up the other events behind the event based gateway, we must gather the // activity ids of said events and check the _sibling_ executions of the incoming execution. // Note that it can happen that there are multiple such execution in those activity ids, // (for example a parallel gw going twice to the event based gateway, kinda silly, but valid) // so we only take _one_ result of such a query for deletion. // Gather all activity ids for the events after the event based gateway that need to be destroyed List<SequenceFlow> outgoingSequenceFlows = eventGateway.getOutgoingFlows(); Set<String> eventActivityIds = new HashSet<String>(outgoingSequenceFlows.size() - 1); // -1, the event being triggered does not need to be deleted for (SequenceFlow outgoingSequenceFlow : outgoingSequenceFlows) { if (outgoingSequenceFlow.getTargetFlowElement() != null && !outgoingSequenceFlow.getTargetFlowElement().getId().equals(execution.getCurrentActivityId())) { eventActivityIds.add(outgoingSequenceFlow.getTargetFlowElement().getId()); } } CommandContext commandContext = Context.getCommandContext(); ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); // Find the executions List<ExecutionEntity> executionEntities = executionEntityManager .findExecutionsByParentExecutionAndActivityIds(execution.getParentId(), eventActivityIds); // Execute the cancel behaviour of the IntermediateCatchEvent for (ExecutionEntity executionEntity : executionEntities) { if (eventActivityIds.contains(executionEntity.getActivityId()) && execution.getCurrentFlowElement() instanceof IntermediateCatchEvent) { IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) execution.getCurrentFlowElement(); if (intermediateCatchEvent.getBehavior() instanceof IntermediateCatchEventActivityBehavior) { ((IntermediateCatchEventActivityBehavior) intermediateCatchEvent.getBehavior()).eventCancelledByEventGateway(executionEntity); eventActivityIds.remove(executionEntity.getActivityId()); // We only need to delete ONE execution at the event. } } } }
Example #21
Source File: EndExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<ExecutionEntity> getActiveChildExecutionsForExecution(ExecutionEntityManager executionEntityManager, String executionId) { List<ExecutionEntity> activeChildExecutions = new ArrayList<ExecutionEntity>(); List<ExecutionEntity> executions = executionEntityManager.findChildExecutionsByParentExecutionId(executionId); for (ExecutionEntity activeExecution : executions) { if (!(activeExecution.getCurrentFlowElement() instanceof BoundaryEvent)) { activeChildExecutions.add(activeExecution); } } return activeChildExecutions; }
Example #22
Source File: AbstractOperation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * 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; }
Example #23
Source File: EndExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected ExecutionEntity handleRegularExecutionEnd(ExecutionEntityManager executionEntityManager, ExecutionEntity parentExecution) { ExecutionEntity executionToContinue = null; if (!parentExecution.isProcessInstanceType() && !(parentExecution.getCurrentFlowElement() instanceof SubProcess)) { parentExecution.setCurrentFlowElement(execution.getCurrentFlowElement()); } if (execution.getCurrentFlowElement() instanceof SubProcess) { SubProcess currentSubProcess = (SubProcess) execution.getCurrentFlowElement(); if (currentSubProcess.getOutgoingFlows().size() > 0) { // create a new execution to take the outgoing sequence flows executionToContinue = executionEntityManager.createChildExecution(parentExecution); executionToContinue.setCurrentFlowElement(execution.getCurrentFlowElement()); } else { if (parentExecution.getId().equals(parentExecution.getProcessInstanceId()) == false) { // create a new execution to take the outgoing sequence flows executionToContinue = executionEntityManager.createChildExecution(parentExecution.getParent()); executionToContinue.setCurrentFlowElement(parentExecution.getCurrentFlowElement()); executionEntityManager.deleteChildExecutions(parentExecution, null, false); executionEntityManager.deleteExecutionAndRelatedData(parentExecution, null, false); } else { executionToContinue = parentExecution; } } } else { executionToContinue = parentExecution; } return executionToContinue; }
Example #24
Source File: EndExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected int getNumberOfActiveChildExecutionsForProcessInstance(ExecutionEntityManager executionEntityManager, String processInstanceId) { Collection<ExecutionEntity> executions = executionEntityManager.findChildExecutionsByProcessInstanceId(processInstanceId); int activeExecutions = 0; for (ExecutionEntity execution : executions) { if (execution.isActive() && !processInstanceId.equals(execution.getId())) { activeExecutions++; } } return activeExecutions; }
Example #25
Source File: EndExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected int getNumberOfActiveChildExecutionsForExecution(ExecutionEntityManager executionEntityManager, String executionId) { List<ExecutionEntity> executions = executionEntityManager.findChildExecutionsByParentExecutionId(executionId); int activeExecutions = 0; // Filter out the boundary events for (ExecutionEntity activeExecution : executions) { if (!(activeExecution.getCurrentFlowElement() instanceof BoundaryEvent)) { activeExecutions++; } } return activeExecutions; }
Example #26
Source File: EndExecutionOperation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
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; }
Example #27
Source File: FindActiveActivityIdsCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public List<String> execute(CommandContext commandContext) { if (executionId == null) { throw new ActivitiIllegalArgumentException("executionId is null"); } ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager(); ExecutionEntity execution = executionEntityManager.findById(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class); } return findActiveActivityIds(execution); }
Example #28
Source File: SetProcessDefinitionVersionCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public Void execute(CommandContext commandContext) { // check that the new process definition is just another version of the same // process definition that the process instance is using ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager(); ExecutionEntity processInstance = executionManager.findById(processInstanceId); if (processInstance == null) { throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class); } else if (!processInstance.isProcessInstanceType()) { throw new ActivitiIllegalArgumentException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id."); } DeploymentManager deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentManager(); ProcessDefinition currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(processInstance.getProcessDefinitionId()); ProcessDefinition newProcessDefinition = deploymentCache .findDeployedProcessDefinitionByKeyAndVersionAndTenantId(currentProcessDefinition.getKey(), processDefinitionVersion, currentProcessDefinition.getTenantId()); validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition); // switch the historic process instance to the new process definition version commandContext.getHistoryManager().recordProcessDefinitionChange(processInstanceId, newProcessDefinition.getId()); // switch all sub-executions of the process instance to the new process definition version Collection<ExecutionEntity> childExecutions = executionManager.findChildExecutionsByProcessInstanceId(processInstanceId); for (ExecutionEntity executionEntity : childExecutions) { validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition); } return null; }
Example #29
Source File: ScopeUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * we create a separate execution for each compensation handler invocation. */ public static void throwCompensationEvent(List<CompensateEventSubscriptionEntity> eventSubscriptions, DelegateExecution execution, boolean async) { ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager(); // first spawn the compensating executions for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { ExecutionEntity compensatingExecution = null; // check whether compensating execution is already created (which is the case when compensating an embedded subprocess, // where the compensating execution is created when leaving the subprocess and holds snapshot data). if (eventSubscription.getConfiguration() != null) { compensatingExecution = executionEntityManager.findById(eventSubscription.getConfiguration()); compensatingExecution.setParent(compensatingExecution.getProcessInstance()); compensatingExecution.setEventScope(false); } else { compensatingExecution = executionEntityManager.createChildExecution((ExecutionEntity) execution); eventSubscription.setConfiguration(compensatingExecution.getId()); } } // signal compensation events in reverse order of their 'created' timestamp Collections.sort(eventSubscriptions, new Comparator<EventSubscriptionEntity>() { public int compare(EventSubscriptionEntity o1, EventSubscriptionEntity o2) { return o2.getCreated().compareTo(o1.getCreated()); } }); for (CompensateEventSubscriptionEntity compensateEventSubscriptionEntity : eventSubscriptions) { Context.getCommandContext().getEventSubscriptionEntityManager().eventReceived(compensateEventSubscriptionEntity, null, async); } }
Example #30
Source File: AbstractManager.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected ExecutionEntityManager getExecutionEntityManager() { return getProcessEngineConfiguration().getExecutionEntityManager(); }