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; }
protected void executeBoundaryEvents(Collection<BoundaryEvent> boundaryEvents, ExecutionEntity execution) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions()) || (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition)) { continue; } // A Child execution of the current execution is created to represent the boundary event being active ExecutionEntity childExecutionEntity = commandContext.getExecutionEntityManager().createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); logger.debug("Executing boundary event activityBehavior {} with execution {}", boundaryEventBehavior.getClass(), childExecutionEntity.getId()); boundaryEventBehavior.execute(childExecutionEntity); } } }
if (currentSubProcess.getOutgoingFlows().size() > 0) { executionToContinue = executionEntityManager.createChildExecution(parentExecution); executionToContinue.setCurrentFlowElement(execution.getCurrentFlowElement()); } else { if (!parentExecution.getId().equals(parentExecution.getProcessInstanceId())) { executionToContinue = executionEntityManager.createChildExecution(parentExecution.getParent()); executionToContinue.setCurrentFlowElement(parentExecution.getCurrentFlowElement());
protected void executeCompensateBoundaryEvents(Collection<BoundaryEvent> boundaryEvents, DelegateExecution execution) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) { continue; } if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition == false) { continue; } ExecutionEntity childExecutionEntity = Context.getCommandContext().getExecutionEntityManager().createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); boundaryEventBehavior.execute(childExecutionEntity); } }
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); } }
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; }
ExecutionEntity activityExecution = Context.getCommandContext().getExecutionEntityManager().createChildExecution(execution); activityExecution.setCurrentFlowElement(foundNode); Context.getAgenda().planContinueProcessOperation(activityExecution);
protected void executeCompensationBoundaryEvents(FlowElement flowElement, DelegateExecution execution) { //Execute compensation boundary events Collection<BoundaryEvent> boundaryEvents = findBoundaryEventsForFlowNode(execution.getProcessDefinitionId(), flowElement); if (CollectionUtil.isNotEmpty(boundaryEvents)) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) { continue; } if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) { ExecutionEntity childExecutionEntity = Context.getCommandContext().getExecutionEntityManager() .createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); boundaryEventBehavior.execute(childExecutionEntity); } } } }
compensatingExecution.setEventScope(false); } else { compensatingExecution = executionEntityManager.createChildExecution((ExecutionEntity) execution); eventSubscription.setConfiguration(compensatingExecution.getId());
public void execute(DelegateExecution execution) { StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement(); EventSubProcess eventSubProcess = (EventSubProcess) startEvent.getSubProcess(); execution.setCurrentFlowElement(eventSubProcess); execution.setScope(true); // initialize the template-defined data objects as variables Map<String, Object> dataObjectVars = processDataObjects(eventSubProcess.getDataObjects()); if (dataObjectVars != null) { execution.setVariablesLocal(dataObjectVars); } ExecutionEntity startSubProcessExecution = Context.getCommandContext() .getExecutionEntityManager().createChildExecution((ExecutionEntity) execution); startSubProcessExecution.setCurrentFlowElement(startEvent); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(startSubProcessExecution, true); }
executionEntity.setScope(true); ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(executionEntity); outgoingFlowExecution.setCurrentFlowElement(startEvent);
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); }
ExecutionEntity eventSubProcessExecution = executionEntityManager.createChildExecution(parentExecution); eventSubProcessExecution.setCurrentFlowElement(event); Context.getAgenda().planContinueProcessOperation(eventSubProcessExecution);
/** * Handles the sequential case of spawning the instances. Will only create one instance, since at most one instance can be active. */ protected int createInstances(DelegateExecution multiInstanceExecution) { int nrOfInstances = resolveNrOfInstances(multiInstanceExecution); if (nrOfInstances == 0) { return nrOfInstances; } else if (nrOfInstances < 0) { throw new ActivitiIllegalArgumentException("Invalid number of instances: must be a non-negative integer value" + ", but was " + nrOfInstances); } // Create child execution that will execute the inner behavior ExecutionEntity childExecution = Context.getCommandContext().getExecutionEntityManager() .createChildExecution((ExecutionEntity) multiInstanceExecution); childExecution.setCurrentFlowElement(multiInstanceExecution.getCurrentFlowElement()); multiInstanceExecution.setMultiInstanceRoot(true); multiInstanceExecution.setActive(false); // Set Multi-instance variables setLoopVariable(multiInstanceExecution, NUMBER_OF_INSTANCES, nrOfInstances); setLoopVariable(multiInstanceExecution, NUMBER_OF_COMPLETED_INSTANCES, 0); setLoopVariable(multiInstanceExecution, NUMBER_OF_ACTIVE_INSTANCES, 1); setLoopVariable(childExecution, getCollectionElementIndexVariable(), 0); logLoopDetails(multiInstanceExecution, "initialized", 0, 0, 1, nrOfInstances); if (nrOfInstances > 0) { executeOriginalBehavior(childExecution, 0); } return nrOfInstances; }
ExecutionEntity eventScopeExecution = Context.getCommandContext().getExecutionEntityManager().createChildExecution(processInstanceExecutionEntity); eventScopeExecution.setActive(false); eventScopeExecution.setEventScope(true);
messageEventDefinition.setMessageRef(bpmnModel.getMessage(messageEventDefinition.getMessageRef()).getName()); ExecutionEntity messageExecution = commandContext.getExecutionEntityManager().createChildExecution(processInstance); messageExecution.setCurrentFlowElement(startEvent); messageExecution.setEventScope(true);
executionToContinue = executionEntityManager.createChildExecution(parentExecution.getParent()); executionToContinue.setCurrentFlowElement(subProcess);
public void execute(DelegateExecution execution) { SubProcess subProcess = getSubProcessFromExecution(execution); FlowElement startElement = null; if (CollectionUtil.isNotEmpty(subProcess.getFlowElements())) { for (FlowElement subElement : subProcess.getFlowElements()) { if (subElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) subElement; // start none event if (CollectionUtil.isEmpty(startEvent.getEventDefinitions())) { startElement = startEvent; break; } } } } if (startElement == null) { throw new ActivitiException("No initial activity found for subprocess " + subProcess.getId()); } ExecutionEntity executionEntity = (ExecutionEntity) execution; executionEntity.setScope(true); // initialize the template-defined data objects as variables Map<String, Object> dataObjectVars = processDataObjects(subProcess.getDataObjects()); if (dataObjectVars != null) { executionEntity.setVariablesLocal(dataObjectVars); } ExecutionEntity startSubProcessExecution = Context.getCommandContext().getExecutionEntityManager() .createChildExecution(executionEntity); startSubProcessExecution.setCurrentFlowElement(startElement); Context.getAgenda().planContinueProcessOperation(startSubProcessExecution); }
ExecutionEntity executionToContinue = executionEntityManager.createChildExecution((ExecutionEntity) multiInstanceRootExecution); executionToContinue.setCurrentFlowElement(childExecution.getCurrentFlowElement()); executionToContinue.setScope(true);
ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(scopeExecutionEntity.getParent()); outgoingFlowExecution.setCurrentFlowElement(scopeExecutionEntity.getCurrentFlowElement()); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true);