@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); }
@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); }
@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; } }
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; } }
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 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; }
.executionId(executionId) .activityId(activity) .singleResult();