private String getCurrentActivityId(DelegateExecution context) { List<Execution> processExecutions = processEngineConfiguration.getRuntimeService() .createExecutionQuery() .processInstanceId(context.getProcessInstanceId()) .list(); List<Execution> processExecutionsWithActivityIds = processExecutions.stream() .filter(e -> e.getActivityId() != null) .collect(Collectors.toList()); if (processExecutionsWithActivityIds.isEmpty()) { // if this happen then there is a really big problem with Flowable :) throw new SLException("There are no executions for process with id: " + context.getProcessInstanceId()); } return processExecutionsWithActivityIds.get(0) .getActivityId(); }
@Override public void processIsInActivity(final String processInstanceId, final String activityId) { // Assert there is a running process instance processIsActive(processInstanceId); // Assert there is at least one execution in the activity callback.trace(LogMessage.PROCESS_14, processInstanceId, activityId); final List<Execution> executions = getRuntimeService().createExecutionQuery().processInstanceId(processInstanceId).activityId(activityId).list(); Assert.assertThat(executions.isEmpty(), is(false)); }
private List<Execution> getExecutionsByProcessId(String processInstanceId) { return processEngine.getRuntimeService() .createExecutionQuery() .rootProcessInstanceId(processInstanceId) .list(); }
.executionId(executionId) .activityId(activity) .singleResult(); .processDefinitionKey(processKey) .processInstanceId(processInstanceId) .activityId(activity) .singleResult();
private Execution findCurrentExecution(FlowableEngineEvent flowableEngineEvent) { try { // This is needed because when there are parallel CallActivity, the query will return multiple results for just one Execution List<Execution> currentExecutionsForProcess = Context.getProcessEngineConfiguration() .getRuntimeService() .createExecutionQuery() .executionId(flowableEngineEvent.getExecutionId()) .processInstanceId(flowableEngineEvent.getProcessInstanceId()) .list(); // Based on the above comment, one of the executions will have null activityId(because it will be the monitoring one) and thus // should be excluded from the list of executions Execution currentExecutionForProces = CommonUtil.isNullOrEmpty(currentExecutionsForProcess) ? null : findCurrentExecution(currentExecutionsForProcess); return currentExecutionForProces; } catch (Throwable e) { return null; } }
@Override protected void notifyInternal(DelegateExecution context) throws Exception { boolean isServiceUpdated = StepsUtil.getIsServiceUpdated(context); String serviceName = StepsUtil.getServiceToProcessName(context); if(serviceName == null) { throw new IllegalStateException("Not able to determine service update status."); } String exportedVariableName = Constants.VAR_IS_SERVICE_UPDATED_VAR_PREFIX + serviceName; RuntimeService runtimeService = Context.getProcessEngineConfiguration().getRuntimeService(); String superExecutionId = context.getParentId(); Execution superExecutionResult = runtimeService.createExecutionQuery().executionId(superExecutionId).singleResult(); superExecutionId = superExecutionResult.getSuperExecutionId(); runtimeService.setVariable(superExecutionId, exportedVariableName, isServiceUpdated); }
private Execution findCurrentExecution(FlowableEngineEvent flowableEngineEvent) { try { // This is needed because when there are parallel CallActivity, the query will return multiple results for just one Execution List<Execution> currentExecutionsForProcess = Context.getProcessEngineConfiguration() .getRuntimeService() .createExecutionQuery() .executionId(flowableEngineEvent.getExecutionId()) .processInstanceId(flowableEngineEvent.getProcessInstanceId()) .list(); // Based on the above comment, one of the executions will have null activityId(because it will be the monitoring one) and thus // should be excluded from the list of executions Execution currentExecutionForProces = CommonUtil.isNullOrEmpty(currentExecutionsForProcess) ? null : findCurrentExecution(currentExecutionsForProcess); return currentExecutionForProces; } catch (Throwable e) { return null; } }
@Override protected void notifyInternal(DelegateExecution context) throws Exception { boolean isServiceUpdated = StepsUtil.getIsServiceUpdated(context); String serviceName = StepsUtil.getServiceToProcessName(context); if(serviceName == null) { throw new IllegalStateException("Not able to determine service update status."); } String exportedVariableName = Constants.VAR_IS_SERVICE_UPDATED_VAR_PREFIX + serviceName; RuntimeService runtimeService = Context.getProcessEngineConfiguration().getRuntimeService(); String superExecutionId = context.getParentId(); Execution superExecutionResult = runtimeService.createExecutionQuery().executionId(superExecutionId).singleResult(); superExecutionId = superExecutionResult.getSuperExecutionId(); runtimeService.setVariable(superExecutionId, exportedVariableName, isServiceUpdated); }
private List<Execution> getAllProcessExecutions(String processInstanceId) { return processEngine.getRuntimeService() .createExecutionQuery() .rootProcessInstanceId(processInstanceId) .list(); }
private String getCurrentActivityId(DelegateExecution context) { List<Execution> processExecutions = processEngineConfiguration.getRuntimeService() .createExecutionQuery() .processInstanceId(context.getProcessInstanceId()) .list(); List<Execution> processExecutionsWithActivityIds = processExecutions.stream() .filter(e -> e.getActivityId() != null) .collect(Collectors.toList()); if (processExecutionsWithActivityIds.isEmpty()) { // if this happen then there is a really big problem with Flowable :) throw new SLException("There are no executions for process with id: " + context.getProcessInstanceId()); } return processExecutionsWithActivityIds.get(0) .getActivityId(); }
@Override public Void execute(CommandContext commandContext) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); ExecutionEntity execution = (ExecutionEntity) processEngineConfiguration.getRuntimeService().createExecutionQuery().executionId(executionId).singleResult(); if (execution == null) { throw new FlowableException("No execution could be found for id " + executionId); } FlowElement flowElement = execution.getCurrentFlowElement(); if (!(flowElement instanceof CaseServiceTask)) { throw new FlowableException("No execution could be found with a case service task for id " + executionId); } CaseServiceTask caseServiceTask = (CaseServiceTask) flowElement; CaseTaskActivityBehavior caseTaskActivityBehavior = (CaseTaskActivityBehavior) caseServiceTask.getBehavior(); caseTaskActivityBehavior.triggerCaseTask(execution, variables); return null; } }
List<Execution> executions = runtimeService .createExecutionQuery() .processInstanceId(InstanceId) .list();
@Override public List<IOParameter> getOutputParametersOfCaseTask(String executionId) { ExecutionEntity execution = (ExecutionEntity) processEngineConfiguration.getRuntimeService().createExecutionQuery().executionId(executionId).singleResult(); if (execution == null) { throw new FlowableException("No execution could be found for id " + executionId); } FlowElement flowElement = execution.getCurrentFlowElement(); if (!(flowElement instanceof CaseServiceTask)) { throw new FlowableException("No execution could be found with a case service task for id " + executionId); } List<IOParameter> cmmnParameters = new ArrayList<>(); CaseServiceTask caseServiceTask = (CaseServiceTask) flowElement; List<org.flowable.bpmn.model.IOParameter> parameters = caseServiceTask.getOutParameters(); for (org.flowable.bpmn.model.IOParameter ioParameter : parameters) { IOParameter parameter = new IOParameter(); parameter.setSource(ioParameter.getSource()); parameter.setSourceExpression(ioParameter.getSourceExpression()); parameter.setTarget(ioParameter.getTarget()); parameter.setTargetExpression(ioParameter.getTargetExpression()); cmmnParameters.add(parameter); } return cmmnParameters; }
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).list(); Map<String, Execution> executionMap = new HashMap<>(); for (Execution execution : executions) {