Java Code Examples for org.activiti.engine.impl.context.Context#getBpmnOverrideElementProperties()
The following examples show how to use
org.activiti.engine.impl.context.Context#getBpmnOverrideElementProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConditionUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static boolean hasTrueCondition(SequenceFlow sequenceFlow, DelegateExecution execution) { String conditionExpression = null; if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode elementProperties = Context.getBpmnOverrideElementProperties(sequenceFlow.getId(), execution.getProcessDefinitionId()); conditionExpression = getActiveValue(sequenceFlow.getConditionExpression(), DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties); } else { conditionExpression = sequenceFlow.getConditionExpression(); } if (StringUtils.isNotEmpty(conditionExpression)) { Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(conditionExpression); Condition condition = new UelExpressionCondition(expression); if (condition.evaluate(sequenceFlow.getId(), execution)) { return true; } return false; } else { return true; } }
Example 2
Source File: ScriptCondition.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public boolean evaluate(String sequenceFlowId, DelegateExecution execution) { String conditionExpression = null; if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode elementProperties = Context.getBpmnOverrideElementProperties(sequenceFlowId, execution.getProcessDefinitionId()); conditionExpression = getActiveValue(expression, DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties); } else { conditionExpression = expression; } ScriptingEngines scriptingEngines = Context .getProcessEngineConfiguration() .getScriptingEngines(); Object result = scriptingEngines.evaluate(conditionExpression, language, execution); if (result == null) { throw new ActivitiException("condition script returns null: " + expression); } if (!(result instanceof Boolean)) { throw new ActivitiException("condition script returns non-Boolean: " + result + " (" + result.getClass().getName() + ")"); } return (Boolean) result; }
Example 3
Source File: UelExpressionCondition.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public boolean evaluate(String sequenceFlowId, DelegateExecution execution) { String conditionExpression = null; if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode elementProperties = Context.getBpmnOverrideElementProperties(sequenceFlowId, execution.getProcessDefinitionId()); conditionExpression = getActiveValue(initialConditionExpression, DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties); } else { conditionExpression = initialConditionExpression; } Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(conditionExpression); Object result = expression.getValue(execution); if (result == null) { throw new ActivitiException("condition expression returns null (sequenceFlowId: " + sequenceFlowId + ")" ); } if (!(result instanceof Boolean)) { throw new ActivitiException("condition expression returns non-Boolean (sequenceFlowId: " + sequenceFlowId + "): " + result + " (" + result.getClass().getName() + ")"); } return (Boolean) result; }
Example 4
Source File: ClassDelegate.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void execute(DelegateExecution execution) { boolean isSkipExpressionEnabled = SkipExpressionUtil.isSkipExpressionEnabled(execution, skipExpression); if (!isSkipExpressionEnabled || (isSkipExpressionEnabled && !SkipExpressionUtil.shouldSkipFlowElement(execution, skipExpression))) { if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(serviceTaskId, execution.getProcessDefinitionId()); if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME)) { String overrideClassName = taskElementProperties.get(DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME).asText(); if (StringUtils.isNotEmpty(overrideClassName) && overrideClassName.equals(className) == false) { className = overrideClassName; activityBehaviorInstance = null; } } } if (activityBehaviorInstance == null) { activityBehaviorInstance = getActivityBehaviorInstance(); } try { activityBehaviorInstance.execute(execution); } catch (BpmnError error) { ErrorPropagation.propagateError(error, execution); } catch (RuntimeException e) { if (!ErrorPropagation.mapException(e, (ExecutionEntity) execution, mapExceptions)) throw e; } } }
Example 5
Source File: ScriptTaskActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void execute(DelegateExecution execution) { ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines(); if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(scriptTaskId, execution.getProcessDefinitionId()); if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT)) { String overrideScript = taskElementProperties.get(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT).asText(); if (StringUtils.isNotEmpty(overrideScript) && overrideScript.equals(script) == false) { script = overrideScript; } } } boolean noErrors = true; try { Object result = scriptingEngines.evaluate(script, language, execution, storeScriptVariables); if (resultVariable != null) { execution.setVariable(resultVariable, result); } } catch (ActivitiException e) { LOGGER.warn("Exception while executing " + execution.getCurrentFlowElement().getId() + " : " + e.getMessage()); noErrors = false; Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof BpmnError) { ErrorPropagation.propagateError((BpmnError) rootCause, execution); } else { throw e; } } if (noErrors) { leave(execution); } }
Example 6
Source File: SecureJavascriptTaskActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void execute(DelegateExecution execution) { ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) Context.getProcessEngineConfiguration(); if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(scriptTaskId, execution.getProcessDefinitionId()); if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT)) { String overrideScript = taskElementProperties.get(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT).asText(); if (StringUtils.isNotEmpty(overrideScript) && overrideScript.equals(script) == false) { script = overrideScript; } } } boolean noErrors = true; try { Object result = SecureJavascriptUtil.evaluateScript(execution, script, config.getBeans()); if (resultVariable != null) { execution.setVariable(resultVariable, result); } } catch (ActivitiException e) { LOGGER.warn("Exception while executing " + execution.getCurrentActivityId() + " : " + e.getMessage()); noErrors = false; Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof BpmnError) { ErrorPropagation.propagateError((BpmnError) rootCause, execution); } else { throw e; } } if (noErrors) { leave(execution); } }
Example 7
Source File: ClassDelegate.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void execute(DelegateExecution execution) { ActivityExecution activityExecution = (ActivityExecution) execution; if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(serviceTaskId, execution.getProcessDefinitionId()); if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME)) { String overrideClassName = taskElementProperties.get(DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME).asText(); if (StringUtils.isNotEmpty(overrideClassName) && !overrideClassName.equals(className)) { className = overrideClassName; activityBehaviorInstance = null; } } } if (activityBehaviorInstance == null) { activityBehaviorInstance = getActivityBehaviorInstance(activityExecution); } try { activityBehaviorInstance.execute(execution); } catch (BpmnError error) { ErrorPropagation.propagateError(error, activityExecution); } catch (RuntimeException e) { if (!ErrorPropagation.mapException(e, activityExecution, mapExceptions)) throw e; } }
Example 8
Source File: ScriptTaskActivityBehavior.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void execute(DelegateExecution execution) { ActivityExecution activityExecution = (ActivityExecution) execution; ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines(); if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(scriptTaskId, execution.getProcessDefinitionId()); if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT)) { String overrideScript = taskElementProperties.get(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT).asText(); if (StringUtils.isNotEmpty(overrideScript) && !overrideScript.equals(script)) { script = overrideScript; } } } boolean noErrors = true; try { Object result = scriptingEngines.evaluate(script, language, execution, storeScriptVariables); if (resultVariable != null) { execution.setVariable(resultVariable, result); } } catch (ActivitiException e) { LOGGER.warn("Exception while executing {} : {}", activityExecution.getActivity().getId(), e.getMessage()); noErrors = false; Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause instanceof BpmnError) { ErrorPropagation.propagateError((BpmnError) rootCause, activityExecution); } else { throw e; } } if (noErrors) { leave(activityExecution); } }
Example 9
Source File: DmnActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void execute(DelegateExecution execution) { FieldExtension fieldExtension = DelegateHelper.getFlowElementField(execution, EXPRESSION_DECISION_TABLE_REFERENCE_KEY); if (fieldExtension == null || ((fieldExtension.getStringValue() == null || fieldExtension.getStringValue().length() == 0) && (fieldExtension.getExpression() == null || fieldExtension.getExpression().length() == 0))) { throw new ActivitiException("decisionTableReferenceKey is a required field extension for the dmn task " + task.getId()); } String activeDecisionTableKey = null; if (fieldExtension.getExpression() != null && fieldExtension.getExpression().length() > 0) { activeDecisionTableKey = fieldExtension.getExpression(); } else { activeDecisionTableKey = fieldExtension.getStringValue(); } ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager(); if (processEngineConfiguration.isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(task.getId(), execution.getProcessDefinitionId()); activeDecisionTableKey = getActiveValue(activeDecisionTableKey, DynamicBpmnConstants.DMN_TASK_DECISION_TABLE_KEY, taskElementProperties); } String finaldecisionTableKeyValue = null; Object decisionTableKeyValue = expressionManager.createExpression(activeDecisionTableKey).getValue(execution); if (decisionTableKeyValue != null) { if (decisionTableKeyValue instanceof String) { finaldecisionTableKeyValue = (String) decisionTableKeyValue; } else { throw new ActivitiIllegalArgumentException("decisionTableReferenceKey expression does not resolve to a string: " + decisionTableKeyValue); } } if (finaldecisionTableKeyValue == null || finaldecisionTableKeyValue.length() == 0) { throw new ActivitiIllegalArgumentException("decisionTableReferenceKey expression resolves to an empty value: " + decisionTableKeyValue); } ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(execution.getProcessDefinitionId()); DmnRuleService ruleService = processEngineConfiguration.getDmnEngineRuleService(); RuleEngineExecutionResult executionResult = ruleService.executeDecisionByKeyParentDeploymentIdAndTenantId(finaldecisionTableKeyValue, processDefinition.getDeploymentId(), execution.getVariables(), execution.getTenantId()); execution.setVariables(executionResult.getResultVariables()); leave(execution); }