use of io.camunda.zeebe.el.Expression in project zeebe by camunda.
the class MultiInstanceActivityTransformer method transformLoopCharacteristics.
private ExecutableLoopCharacteristics transformLoopCharacteristics(final TransformContext context, final MultiInstanceLoopCharacteristics elementLoopCharacteristics) {
final boolean isSequential = elementLoopCharacteristics.isSequential();
final Optional<Expression> completionCondition = Optional.ofNullable(elementLoopCharacteristics.getCompletionCondition()).map(CompletionCondition::getTextContent).filter(e -> !e.isEmpty()).map(context.getExpressionLanguage()::parseExpression);
final ZeebeLoopCharacteristics zeebeLoopCharacteristics = elementLoopCharacteristics.getSingleExtensionElement(ZeebeLoopCharacteristics.class);
final Expression inputCollection = context.getExpressionLanguage().parseExpression(zeebeLoopCharacteristics.getInputCollection());
final Optional<DirectBuffer> inputElement = Optional.ofNullable(zeebeLoopCharacteristics.getInputElement()).filter(e -> !e.isEmpty()).map(BufferUtil::wrapString);
final Optional<DirectBuffer> outputCollection = Optional.ofNullable(zeebeLoopCharacteristics.getOutputCollection()).filter(e -> !e.isEmpty()).map(BufferUtil::wrapString);
final Optional<Expression> outputElement = Optional.ofNullable(zeebeLoopCharacteristics.getOutputElement()).filter(e -> !e.isEmpty()).map(e -> context.getExpressionLanguage().parseExpression(e));
return new ExecutableLoopCharacteristics(isSequential, completionCondition, inputCollection, inputElement, outputCollection, outputElement);
}
use of io.camunda.zeebe.el.Expression in project zeebe by camunda.
the class BpmnVariableMappingBehavior method applyOutputMappings.
/**
* Apply the output mappings for a BPMN element. Generally called on completing of the element.
*
* @param context The current bpmn element context
* @param element The current bpmn element
* @return either void if successful, otherwise a failure
*/
public Either<Failure, Void> applyOutputMappings(final BpmnElementContext context, final ExecutableFlowNode element) {
final ProcessInstanceRecord record = context.getRecordValue();
final long elementInstanceKey = context.getElementInstanceKey();
final long processDefinitionKey = record.getProcessDefinitionKey();
final long processInstanceKey = record.getProcessInstanceKey();
final DirectBuffer bpmnProcessId = context.getBpmnProcessId();
final long scopeKey = getVariableScopeKey(context);
final Optional<Expression> outputMappingExpression = element.getOutputMappings();
final EventTrigger eventTrigger = eventScopeInstanceState.peekEventTrigger(elementInstanceKey);
boolean hasVariables = false;
DirectBuffer variables = null;
if (eventTrigger != null) {
variables = eventTrigger.getVariables();
hasVariables = variables.capacity() > 0;
}
if (outputMappingExpression.isPresent()) {
// set as local variables
if (hasVariables) {
variableBehavior.mergeLocalDocument(elementInstanceKey, processDefinitionKey, processInstanceKey, bpmnProcessId, variables);
}
// apply the output mappings
return expressionProcessor.evaluateVariableMappingExpression(outputMappingExpression.get(), elementInstanceKey).map(result -> {
variableBehavior.mergeDocument(scopeKey, processDefinitionKey, processInstanceKey, bpmnProcessId, result);
return null;
});
} else if (hasVariables) {
// merge/propagate the event variables by default
variableBehavior.mergeDocument(elementInstanceKey, processDefinitionKey, processInstanceKey, bpmnProcessId, variables);
} else if (isConnectedToEventBasedGateway(element) || element.getElementType() == BpmnElementType.BOUNDARY_EVENT || element.getElementType() == BpmnElementType.START_EVENT) {
// event variables are set local variables instead of temporary variables
final var localVariables = variablesState.getVariablesLocalAsDocument(elementInstanceKey);
variableBehavior.mergeDocument(scopeKey, processDefinitionKey, processInstanceKey, bpmnProcessId, localVariables);
}
return Either.right(null);
}
use of io.camunda.zeebe.el.Expression in project zeebe by camunda.
the class BpmnVariableMappingBehavior method applyInputMappings.
/**
* Apply the input mappings for a BPMN element. Generally called on activating of the element.
*
* @param context The current bpmn element context
* @param element The current bpmn element
* @return either void if successful, otherwise a failure
*/
public Either<Failure, Void> applyInputMappings(final BpmnElementContext context, final ExecutableFlowNode element) {
final long scopeKey = context.getElementInstanceKey();
final long processDefinitionKey = context.getProcessDefinitionKey();
final long processInstanceKey = context.getProcessInstanceKey();
final DirectBuffer bpmnProcessId = context.getBpmnProcessId();
final Optional<Expression> inputMappingExpression = element.getInputMappings();
if (inputMappingExpression.isPresent()) {
return expressionProcessor.evaluateVariableMappingExpression(inputMappingExpression.get(), scopeKey).map(result -> {
variableBehavior.mergeLocalDocument(scopeKey, processDefinitionKey, processInstanceKey, bpmnProcessId, result);
return null;
});
}
return Either.right(null);
}
use of io.camunda.zeebe.el.Expression in project zeebe by zeebe-io.
the class MessageTransformer method transform.
@Override
public void transform(final Message element, final TransformContext context) {
final String id = element.getId();
final ExpressionLanguage expressionLanguage = context.getExpressionLanguage();
final ExecutableMessage executableElement = new ExecutableMessage(id);
final ExtensionElements extensionElements = element.getExtensionElements();
if (extensionElements != null) {
final ZeebeSubscription subscription = extensionElements.getElementsQuery().filterByType(ZeebeSubscription.class).singleResult();
final Expression correlationKeyExpression = expressionLanguage.parseExpression(subscription.getCorrelationKey());
executableElement.setCorrelationKeyExpression(correlationKeyExpression);
}
if (element.getName() != null) {
final Expression messageNameExpression = expressionLanguage.parseExpression(element.getName());
executableElement.setMessageNameExpression(messageNameExpression);
if (messageNameExpression.isStatic()) {
final EvaluationResult messageNameResult = expressionLanguage.evaluateExpression(messageNameExpression, variable -> null);
if (messageNameResult.getType() == ResultType.STRING) {
final String messageName = messageNameResult.getString();
executableElement.setMessageName(messageName);
}
}
context.addMessage(executableElement);
}
}
use of io.camunda.zeebe.el.Expression in project zeebe by zeebe-io.
the class SequenceFlowTransformer method parseCondition.
private void parseCondition(final SequenceFlow element, final ExecutableSequenceFlow sequenceFlow, final ExpressionLanguage expressionLanguage) {
final ConditionExpression conditionExpression = element.getConditionExpression();
if (conditionExpression != null) {
final String condition = conditionExpression.getTextContent();
final Expression parsedCondition = expressionLanguage.parseExpression(condition);
sequenceFlow.setCondition(parsedCondition);
}
}
Aggregations