use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class TakeOutgoingSequenceFlowsOperation method handleAdhocSubProcess.
protected void handleAdhocSubProcess(FlowNode flowNode) {
boolean completeAdhocSubProcess = false;
AdhocSubProcess adhocSubProcess = (AdhocSubProcess) flowNode.getParentContainer();
if (adhocSubProcess.getCompletionCondition() != null) {
Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(adhocSubProcess.getCompletionCondition());
Condition condition = new UelExpressionCondition(expression);
if (condition.evaluate(adhocSubProcess.getId(), execution)) {
completeAdhocSubProcess = true;
}
}
if (flowNode.getOutgoingFlows().size() > 0) {
leaveFlowNode(flowNode);
} else {
commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(execution, null);
}
if (completeAdhocSubProcess) {
boolean endAdhocSubProcess = true;
if (!adhocSubProcess.isCancelRemainingInstances()) {
List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByParentExecutionId(execution.getParentId());
for (ExecutionEntity executionEntity : childExecutions) {
if (!executionEntity.getId().equals(execution.getId())) {
endAdhocSubProcess = false;
break;
}
}
}
if (endAdhocSubProcess) {
Context.getAgenda().planEndExecutionOperation(execution.getParent());
}
}
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ProcessInstanceHelper method getMessageName.
protected String getMessageName(CommandContext commandContext, MessageEventDefinition messageEventDefinition, DelegateExecution execution) {
ExpressionManager expressionManager = commandContext.getProcessEngineConfiguration().getExpressionManager();
String messageName = Optional.ofNullable(messageEventDefinition.getMessageRef()).orElse(messageEventDefinition.getMessageExpression());
Expression expression = expressionManager.createExpression(messageName);
return expression.getValue(execution).toString();
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ConditionUtil method hasTrueCondition.
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;
}
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class TestExecutionListener method notify.
@Override
public void notify(DelegateExecution execution) {
Expression inputExpression = DelegateHelper.getFieldExpression(execution, "input");
Number input = (Number) inputExpression.getValue(execution);
int result = input.intValue() * 100;
Expression resultVarExpression = DelegateHelper.getFieldExpression(execution, "resultVar");
execution.setVariable(resultVarExpression.getValue(execution).toString(), result);
}
use of org.activiti.engine.delegate.Expression in project Activiti by Activiti.
the class ExpressionResolverTest method resolveExpressionsMap_should_replaceExpressionByValue_when_MapContainsAnExpression.
@Test
public void resolveExpressionsMap_should_replaceExpressionByValue_when_MapContainsAnExpression() {
// given
Expression playerExpression = buildExpression("${player}");
given(expressionEvaluator.evaluate(playerExpression, expressionManager, delegateInterceptor)).willReturn("Agatha");
// when
Map<String, Object> result = expressionResolver.resolveExpressionsMap(expressionEvaluator, singletonMap("players", map("Red", "John", "Green", "Peter", "Blue", "Mary", "Yellow", "${player}")));
// then
assertThat(result).containsEntry("players", map("Red", "John", "Green", "Peter", "Blue", "Mary", "Yellow", "Agatha"));
}
Aggregations