use of io.camunda.zeebe.util.buffer.BufferUtil 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.util.buffer.BufferUtil in project zeebe by zeebe-io.
the class CatchEventAnalyzer method findCatchEvent.
public Either<Failure, CatchEventTuple> findCatchEvent(final DirectBuffer errorCode, ElementInstance instance, final Optional<DirectBuffer> jobErrorMessage) {
// assuming that error events are used rarely
// - just walk through the scope hierarchy and look for a matching catch event
final ArrayList<DirectBuffer> availableCatchEvents = new ArrayList<>();
while (instance != null && instance.isActive()) {
final var instanceRecord = instance.getValue();
final var process = getProcess(instanceRecord.getProcessDefinitionKey());
final var found = findCatchEventInProcess(errorCode, process, instance);
if (found.isRight()) {
return Either.right(found.get());
} else {
availableCatchEvents.addAll(found.getLeft());
}
// find in parent process instance if exists
final var parentElementInstanceKey = instanceRecord.getParentElementInstanceKey();
instance = elementInstanceState.getInstance(parentElementInstanceKey);
}
final String incidentErrorMessage = String.format("Expected to throw an error event with the code '%s'%s, but it was not caught.%s", BufferUtil.bufferAsString(errorCode), jobErrorMessage.isPresent() && jobErrorMessage.get().capacity() > 0 ? String.format(" with message '%s'", BufferUtil.bufferAsString(jobErrorMessage.get())) : "", availableCatchEvents.isEmpty() ? " No error events are available in the scope." : String.format(" Available error events are [%s]", availableCatchEvents.stream().map(BufferUtil::bufferAsString).collect(Collectors.joining(", "))));
// no matching catch event found
return Either.left(new Failure(incidentErrorMessage, ErrorType.UNHANDLED_ERROR_EVENT));
}
use of io.camunda.zeebe.util.buffer.BufferUtil in project zeebe by camunda-cloud.
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.util.buffer.BufferUtil in project zeebe by zeebe-io.
the class CatchEventBehavior method evaluateMessageName.
private Either<Failure, DirectBuffer> evaluateMessageName(final ExecutableCatchEvent event, final BpmnElementContext context) {
if (!event.isMessage()) {
return Either.right(null);
}
final var scopeKey = context.getElementInstanceKey();
final ExecutableMessage message = event.getMessage();
final Expression messageNameExpression = message.getMessageNameExpression();
return expressionProcessor.evaluateStringExpression(messageNameExpression, scopeKey).map(BufferUtil::wrapString);
}
use of io.camunda.zeebe.util.buffer.BufferUtil in project zeebe by zeebe-io.
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);
}
Aggregations