@Override public FlowElement getFlowElement(String flowElementId) { return getFlowElement(flowElementId, false); }
@Override public FlowElement getFlowElement(String flowElementId) { return getFlowElement(flowElementId, false); }
protected FlowNode getFlowNodeFromScope(String elementId, BaseElement scope) { FlowNode flowNode = null; if (StringUtils.isNotEmpty(elementId)) { if (scope instanceof Process) { flowNode = (FlowNode) ((Process) scope).getFlowElement(elementId); } else if (scope instanceof SubProcess) { flowNode = (FlowNode) ((SubProcess) scope).getFlowElement(elementId); } } return flowNode; }
protected void handleCompensationEventDefinition(BpmnModel bpmnModel, Process process, Event event, EventDefinition eventDefinition, List<ValidationError> errors) { CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) eventDefinition; // Check activityRef if ((StringUtils.isNotEmpty(compensateEventDefinition.getActivityRef()) && process.getFlowElement(compensateEventDefinition.getActivityRef(), true) == null)) { addError(errors, Problems.COMPENSATE_EVENT_INVALID_ACTIVITY_REF, process, event, "Invalid attribute value for 'activityRef': no activity with the given id"); } }
@Override protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) { org.flowable.bpmn.model.Process process = bpmnParse.getCurrentProcess(); sequenceFlow.setSourceFlowElement(process.getFlowElement(sequenceFlow.getSourceRef(), true)); sequenceFlow.setTargetFlowElement(process.getFlowElement(sequenceFlow.getTargetRef(), true)); }
public FlowElement getFlowElement(String id) { FlowElement foundFlowElement = null; for (Process process : processes) { foundFlowElement = process.getFlowElement(id); if (foundFlowElement != null) { break; } } if (foundFlowElement == null) { for (Process process : processes) { for (FlowElement flowElement : process.findFlowElementsOfType(SubProcess.class)) { foundFlowElement = getFlowElementInSubProcess(id, (SubProcess) flowElement); if (foundFlowElement != null) { break; } } if (foundFlowElement != null) { break; } } } return foundFlowElement; }
public FlowElement getFlowElement(String id) { FlowElement foundFlowElement = null; for (Process process : processes) { foundFlowElement = process.getFlowElement(id); if (foundFlowElement != null) { break; } } if (foundFlowElement == null) { for (Process process : processes) { for (FlowElement flowElement : process.findFlowElementsOfType(SubProcess.class)) { foundFlowElement = getFlowElementInSubProcess(id, (SubProcess) flowElement); if (foundFlowElement != null) { break; } } if (foundFlowElement != null) { break; } } } return foundFlowElement; }
@Override public FlowElement getCurrentFlowElement() { if (currentFlowElement == null) { String processDefinitionId = getProcessDefinitionId(); if (processDefinitionId != null) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); currentFlowElement = process.getFlowElement(getCurrentActivityId(), true); } } return currentFlowElement; }
@Override public FlowElement getCurrentFlowElement() { if (currentFlowElement == null) { String processDefinitionId = getProcessDefinitionId(); if (processDefinitionId != null) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); currentFlowElement = process.getFlowElement(getCurrentActivityId(), true); } } return currentFlowElement; }
@Override public FlowElement getCurrentFlowElement() { if (currentFlowElement == null) { String processDefinitionId = getProcessDefinitionId(); if (processDefinitionId != null) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); currentFlowElement = process.getFlowElement(getCurrentActivityId(), true); } } return currentFlowElement; }
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<EventGateway> eventGateways = process.findFlowElementsOfType(EventGateway.class); for (EventGateway eventGateway : eventGateways) { for (SequenceFlow sequenceFlow : eventGateway.getOutgoingFlows()) { FlowElement flowElement = process.getFlowElement(sequenceFlow.getTargetRef(), true); if (flowElement != null && !(flowElement instanceof IntermediateCatchEvent)) { addError(errors, Problems.EVENT_GATEWAY_ONLY_CONNECTED_TO_INTERMEDIATE_EVENTS, process, eventGateway, "Event based gateway can only be connected to elements of type intermediateCatchEvent"); } } } }
public void executeTaskListeners(TaskEntity taskEntity, String eventType) { if (taskEntity.getProcessDefinitionId() != null) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(taskEntity.getProcessDefinitionId()); FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; executeTaskListeners(userTask, taskEntity, eventType); } } }
protected int getMaxIterations(org.flowable.bpmn.model.Process process, String activityId) { FlowElement flowElement = process.getFlowElement(activityId, true); if (flowElement != null) { if (flowElement instanceof Event) { Event event = (Event) flowElement; List<EventDefinition> eventDefinitions = event.getEventDefinitions(); if (eventDefinitions != null) { for (EventDefinition eventDefinition : eventDefinitions) { if (eventDefinition instanceof TimerEventDefinition) { TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; if (timerEventDefinition.getTimeCycle() != null) { return calculateMaxIterationsValue(timerEventDefinition.getTimeCycle()); } } } } } } return -1; }
/** * To be used in an {@link ActivityBehavior} or {@link JavaDelegate}: leaves the current activity via one specific sequenceflow. */ public static void leaveDelegate(DelegateExecution delegateExecution, String sequenceFlowId) { String processDefinitionId = delegateExecution.getProcessDefinitionId(); org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); FlowElement flowElement = process.getFlowElement(sequenceFlowId); if (flowElement instanceof SequenceFlow) { delegateExecution.setCurrentFlowElement(flowElement); CommandContextUtil.getAgenda().planTakeOutgoingSequenceFlowsOperation((ExecutionEntity) delegateExecution, false); } else { throw new FlowableException(sequenceFlowId + " does not match a sequence flow"); } }
&& !inactiveExecution.isDeleted()) { FlowNode flowNode = (FlowNode) process.getFlowElement(inactiveExecution.getActivityId(), true); InactiveActivityBehavior inactiveActivityBehavior = ((InactiveActivityBehavior) flowNode.getBehavior()); LOGGER.debug("Found InactiveActivityBehavior instance of class {} that can be executed on activity '{}'", inactiveActivityBehavior.getClass(), flowNode.getId());
/** * Helper method to match the activityId of an execution with a FlowElement of the process definition referenced by the execution. */ protected FlowElement getCurrentFlowElement(final ExecutionEntity execution) { if (execution.getCurrentFlowElement() != null) { return execution.getCurrentFlowElement(); } else if (execution.getCurrentActivityId() != null) { String processDefinitionId = execution.getProcessDefinitionId(); org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); String activityId = execution.getCurrentActivityId(); FlowElement currentFlowElement = process.getFlowElement(activityId, true); return currentFlowElement; } return null; }
@Override protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance, List<ExecutionEntity> childExecutions) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); ExecutionEntity execution = executionEntityManager.createChildExecution(processInstance); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionEntity.getId()); UserTask userTask = (UserTask) bpmnModel.getProcessById(processDefinitionEntity.getKey()).getFlowElement(dynamicUserTaskBuilder.getDynamicTaskId()); execution.setCurrentFlowElement(userTask); Context.getAgenda().planContinueProcessOperation(execution); }
public TaskFormHandler getTaskFormHandlder(String processDefinitionId, String taskId) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); FlowElement flowElement = process.getFlowElement(taskId, true); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; ProcessDefinition processDefinitionEntity = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId); DeploymentEntity deploymentEntity = CommandContextUtil.getProcessEngineConfiguration() .getDeploymentEntityManager().findById(processDefinitionEntity.getDeploymentId()); TaskFormHandler taskFormHandler = new DefaultTaskFormHandler(); taskFormHandler.parseConfiguration(userTask.getFormProperties(), userTask.getFormKey(), deploymentEntity, processDefinitionEntity); return taskFormHandler; } return null; }
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinition newProcessDefinition) { // check that the new process definition version contains the current activity org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(newProcessDefinition.getId()); if (execution.getActivityId() != null && process.getFlowElement(execution.getActivityId(), true) == null) { throw new FlowableException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + execution.getActivityId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // switch the process instance to the new process definition version execution.setProcessDefinitionId(newProcessDefinition.getId()); execution.setProcessDefinitionName(newProcessDefinition.getName()); execution.setProcessDefinitionKey(newProcessDefinition.getKey()); // and change possible existing tasks (as the process definition id is stored there too) List<TaskEntity> tasks = CommandContextUtil.getTaskService(commandContext).findTasksByExecutionId(execution.getId()); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordTaskInfoChange(taskEntity); } }
@Override protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance, List<ExecutionEntity> childExecutions) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); TaskEntity taskEntity = CommandContextUtil.getTaskService().getTask(taskId); ExecutionEntity executionAtTask = executionEntityManager.findById(taskEntity.getExecutionId()); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionEntity.getId()); FlowElement taskElement = bpmnModel.getFlowElement(executionAtTask.getCurrentActivityId()); FlowElement subProcessElement = bpmnModel.getFlowElement(((SubProcess) taskElement.getParentContainer()).getId()); ExecutionEntity subProcessExecution = executionEntityManager.createChildExecution(executionAtTask.getParent()); subProcessExecution.setScope(true); subProcessExecution.setCurrentFlowElement(subProcessElement); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(subProcessExecution); executionAtTask.setParent(subProcessExecution); ExecutionEntity execution = executionEntityManager.createChildExecution(subProcessExecution); FlowElement newSubProcess = bpmnModel.getMainProcess().getFlowElement(dynamicEmbeddedSubProcessBuilder.getDynamicSubProcessId(), true); execution.setCurrentFlowElement(newSubProcess); CommandContextUtil.getAgenda().planContinueProcessOperation(execution); }