protected boolean isChildOfMultiInstanceExecution(DelegateExecution executionEntity, DelegateExecution multiInstanceExecution) { boolean isChild = false; DelegateExecution parentExecution = executionEntity.getParent(); if (parentExecution != null) { if (parentExecution.getId().equals(multiInstanceExecution.getId())) { isChild = true; } else { boolean isNestedChild = isChildOfMultiInstanceExecution(parentExecution, multiInstanceExecution); if (isNestedChild) { isChild = true; } } } return isChild; }
public void execute(IntegrationActivityBehavior receiveTaskActivityBehavior, DelegateExecution execution) { Map<String, Object> stringObjectMap = new HashMap<String, Object>(); stringObjectMap.put(executionId, execution.getId()); stringObjectMap.put(processInstanceId, execution.getProcessInstanceId()); stringObjectMap.put(processDefinitionId, execution.getProcessDefinitionId()); stringObjectMap.putAll(headerMapper.toHeaders(execution.getVariables())); MessageBuilder<?> mb = MessageBuilder.withPayload(execution).copyHeaders(stringObjectMap); Message<?> reply = sendAndReceiveMessage(mb.build()); if (null != reply) { Map<String, Object> vars = new HashMap<String, Object>(); headerMapper.fromHeaders(reply.getHeaders(), vars); for (String k : vars.keySet()) { processEngine.getRuntimeService().setVariable(execution.getId(), k, vars.get(k)); } receiveTaskActivityBehavior.leave(execution); } }
public void trigger(DelegateExecution execution, String signalName, Object signalData) { CommandContext commandContext = Context.getCommandContext(); TaskEntityManager taskEntityManager = commandContext.getTaskEntityManager(); List<TaskEntity> taskEntities = taskEntityManager.findTasksByExecutionId(execution.getId()); // Should be only one for (TaskEntity taskEntity : taskEntities) { if (!taskEntity.isDeleted()) { throw new ActivitiException("UserTask should not be signalled before complete"); } } leave(execution); }
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); } }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { JobEntityManager jobEntityManager = Context.getCommandContext().getJobEntityManager(); List<JobEntity> jobEntities = jobEntityManager.findJobsByExecutionId(execution.getId()); for (JobEntity jobEntity : jobEntities) { // Should be only one jobEntityManager.delete(jobEntity); } Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
protected void planTransactionDependentExecutionListener(ListenerFactory listenerFactory, DelegateExecution execution, TransactionDependentExecutionListener executionListener, ActivitiListener activitiListener) { Map<String, Object> executionVariablesToUse = execution.getVariables(); CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener); Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver); TransactionDependentExecutionListenerExecutionScope scope = new TransactionDependentExecutionListenerExecutionScope( execution.getProcessInstanceId(), execution.getId(), execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse); addTransactionListener(activitiListener, new ExecuteExecutionListenerTransactionListener(executionListener, scope)); }
protected void planTransactionDependentTaskListener(DelegateExecution execution, TransactionDependentTaskListener taskListener, ActivitiListener activitiListener) { Map<String, Object> executionVariablesToUse = execution.getVariables(); CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener); Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver); TransactionDependentTaskListenerExecutionScope scope = new TransactionDependentTaskListenerExecutionScope( execution.getProcessInstanceId(), execution.getId(), (Task) execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse); addTransactionListener(activitiListener, new ExecuteTaskListenerTransactionListener(taskListener, scope)); }
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); } }
if (!joinedExecution.getId().equals(execution.getId())) { executionEntityManager.deleteExecutionAndRelatedData(joinedExecution, null, false);
ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_COMPLETED, exclusiveGateway.getId(), exclusiveGateway.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), exclusiveGateway));
protected void dispatchActivityCancelled(DelegateExecution execution, FlowElement terminateEndEvent) { Context.getProcessEngineConfiguration() .getEventDispatcher() .dispatchEvent( ActivitiEventBuilder.createActivityCancelledEvent(execution.getCurrentFlowElement().getId(), execution.getCurrentFlowElement().getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), parseActivityType((FlowNode) execution.getCurrentFlowElement()), terminateEndEvent)); }
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); } } } }
protected void sendProcessInstanceCancelledEvent(DelegateExecution execution, FlowElement terminateEndEvent) { if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { if ((execution.isProcessInstanceType() && execution.getSuperExecutionId() == null) || (execution.getParentId() == null && execution.getSuperExecutionId() != null)) { Context.getProcessEngineConfiguration().getEventDispatcher() .dispatchEvent(ActivitiEventBuilder.createCancelledEvent(execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), execution.getCurrentFlowElement())); } } dispatchExecutionCancelled(execution, terminateEndEvent); }
handleException(execution, e.getMessage(), e, doIgnoreException, exceptionVariable); } catch (EmailException e) { handleException(execution, "Could not send e-mail in execution " + execution.getId(), e, doIgnoreException, exceptionVariable);
throw new ActivitiException("Process model (id = " + execution.getId() + ") could not be found");
event.setProcessDefinitionId(((Job) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof DelegateExecution) { event.setExecutionId(((DelegateExecution) persistedObject).getId()); event.setProcessInstanceId(((DelegateExecution) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((DelegateExecution) persistedObject).getProcessDefinitionId());
public void trigger(DelegateExecution execution, String signalName, Object signalData) { CommandContext commandContext = Context.getCommandContext(); TaskEntityManager taskEntityManager = commandContext.getTaskEntityManager(); List<TaskEntity> taskEntities = taskEntityManager.findTasksByExecutionId(execution.getId()); // Should be only one for (TaskEntity taskEntity : taskEntities) { if (!taskEntity.isDeleted()) { throw new ActivitiException("UserTask should not be signalled before complete"); } } leave(execution); }
@Override public void eventCancelledByEventGateway(DelegateExecution execution) { JobEntityManager jobEntityManager = Context.getCommandContext().getJobEntityManager(); List<JobEntity> jobEntities = jobEntityManager.findJobsByExecutionId(execution.getId()); for (JobEntity jobEntity : jobEntities) { // Should be only one jobEntityManager.delete(jobEntity); } Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false); }
protected void planTransactionDependentTaskListener(DelegateExecution execution, TransactionDependentTaskListener taskListener, ActivitiListener activitiListener) { Map<String, Object> executionVariablesToUse = execution.getVariables(); CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener); Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver); TransactionDependentTaskListenerExecutionScope scope = new TransactionDependentTaskListenerExecutionScope( execution.getProcessInstanceId(), execution.getId(), (Task) execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse); addTransactionListener(activitiListener, new ExecuteTaskListenerTransactionListener(taskListener, scope)); }
protected void planTransactionDependentExecutionListener(ListenerFactory listenerFactory, DelegateExecution execution, TransactionDependentExecutionListener executionListener, ActivitiListener activitiListener) { Map<String, Object> executionVariablesToUse = execution.getVariables(); CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener); Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver); TransactionDependentExecutionListenerExecutionScope scope = new TransactionDependentExecutionListenerExecutionScope( execution.getProcessInstanceId(), execution.getId(), execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse); addTransactionListener(activitiListener, new ExecuteExecutionListenerTransactionListener(executionListener, scope)); }