Search in sources :

Example 1 with ExecutableFlowElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement in project zeebe by camunda.

the class BpmnStreamProcessor method processRecord.

@Override
public void processRecord(final TypedRecord<ProcessInstanceRecord> record, final TypedResponseWriter responseWriter, final TypedStreamWriter streamWriter, final Consumer<SideEffectProducer> sideEffect) {
    // initialize
    sideEffectQueue.clear();
    sideEffect.accept(sideEffectQueue);
    final var intent = (ProcessInstanceIntent) record.getIntent();
    final var recordValue = record.getValue();
    context.init(record.getKey(), recordValue, intent);
    final var bpmnElementType = recordValue.getBpmnElementType();
    final var processor = processors.getProcessor(bpmnElementType);
    final ExecutableFlowElement element = getElement(recordValue, processor);
    stateTransitionGuard.isValidStateTransition(context).ifRightOrLeft(ok -> {
        LOGGER.trace("Process process instance event [context: {}]", context);
        processEvent(intent, processor, element);
    }, violation -> rejectionWriter.appendRejection(record, RejectionType.INVALID_STATE, violation.getMessage()));
}
Also used : ExecutableFlowElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)

Example 2 with ExecutableFlowElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement in project zeebe by zeebe-io.

the class BpmnStateTransitionBehavior method invokeElementContainerIfPresent.

private Either<Failure, ?> invokeElementContainerIfPresent(final ExecutableFlowElement childElement, final BpmnElementContext childContext, final ElementContainerProcessorFunction containerFunction) {
    final ExecutableFlowElement containerScope;
    final BpmnElementContext containerContext;
    final var flowScope = childElement.getFlowScope();
    if (flowScope != null) {
        containerContext = stateBehavior.getFlowScopeContext(childContext);
        containerScope = flowScope;
    } else if (childContext.getParentElementInstanceKey() > 0) {
        // no flow scope, it is called from a parent process
        containerContext = stateBehavior.getParentElementInstanceContext(childContext);
        containerScope = getParentProcessScope(containerContext, childContext);
    } else {
        // no flow scope or no parent process
        return Either.right(null);
    }
    final var containerProcessor = processorLookUp.apply(containerScope.getElementType());
    return containerFunction.apply(containerProcessor, containerScope, containerContext);
}
Also used : ExecutableFlowElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement) BpmnElementContext(io.camunda.zeebe.engine.processing.bpmn.BpmnElementContext)

Example 3 with ExecutableFlowElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement in project zeebe by zeebe-io.

the class BpmnStreamProcessor method processRecord.

@Override
public void processRecord(final TypedRecord<ProcessInstanceRecord> record, final TypedResponseWriter responseWriter, final TypedStreamWriter streamWriter, final Consumer<SideEffectProducer> sideEffect) {
    // initialize
    sideEffectQueue.clear();
    sideEffect.accept(sideEffectQueue);
    final var intent = (ProcessInstanceIntent) record.getIntent();
    final var recordValue = record.getValue();
    context.init(record.getKey(), recordValue, intent);
    final var bpmnElementType = recordValue.getBpmnElementType();
    final var processor = processors.getProcessor(bpmnElementType);
    final ExecutableFlowElement element = getElement(recordValue, processor);
    stateTransitionGuard.isValidStateTransition(context).ifRightOrLeft(ok -> {
        LOGGER.trace("Process process instance event [context: {}]", context);
        processEvent(intent, processor, element);
    }, violation -> rejectionWriter.appendRejection(record, RejectionType.INVALID_STATE, violation.getMessage()));
}
Also used : ExecutableFlowElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)

Example 4 with ExecutableFlowElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement in project zeebe by camunda-cloud.

the class BpmnStateTransitionBehavior method invokeElementContainerIfPresent.

private Either<Failure, ?> invokeElementContainerIfPresent(final ExecutableFlowElement childElement, final BpmnElementContext childContext, final ElementContainerProcessorFunction containerFunction) {
    final ExecutableFlowElement containerScope;
    final BpmnElementContext containerContext;
    final var flowScope = childElement.getFlowScope();
    if (flowScope != null) {
        containerContext = stateBehavior.getFlowScopeContext(childContext);
        containerScope = flowScope;
    } else if (childContext.getParentElementInstanceKey() > 0) {
        // no flow scope, it is called from a parent process
        containerContext = stateBehavior.getParentElementInstanceContext(childContext);
        containerScope = getParentProcessScope(containerContext, childContext);
    } else {
        // no flow scope or no parent process
        return Either.right(null);
    }
    final var containerProcessor = processorLookUp.apply(containerScope.getElementType());
    return containerFunction.apply(containerProcessor, containerScope, containerContext);
}
Also used : ExecutableFlowElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement) BpmnElementContext(io.camunda.zeebe.engine.processing.bpmn.BpmnElementContext)

Example 5 with ExecutableFlowElement

use of io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement in project zeebe by camunda-cloud.

the class BpmnStreamProcessor method processRecord.

@Override
public void processRecord(final TypedRecord<ProcessInstanceRecord> record, final TypedResponseWriter responseWriter, final TypedStreamWriter streamWriter, final Consumer<SideEffectProducer> sideEffect) {
    // initialize
    sideEffectQueue.clear();
    sideEffect.accept(sideEffectQueue);
    final var intent = (ProcessInstanceIntent) record.getIntent();
    final var recordValue = record.getValue();
    context.init(record.getKey(), recordValue, intent);
    final var bpmnElementType = recordValue.getBpmnElementType();
    final var processor = processors.getProcessor(bpmnElementType);
    final ExecutableFlowElement element = getElement(recordValue, processor);
    stateTransitionGuard.isValidStateTransition(context).ifRightOrLeft(ok -> {
        LOGGER.trace("Process process instance event [context: {}]", context);
        processEvent(intent, processor, element);
    }, violation -> rejectionWriter.appendRejection(record, RejectionType.INVALID_STATE, violation.getMessage()));
}
Also used : ExecutableFlowElement(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)

Aggregations

ExecutableFlowElement (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElement)6 BpmnElementContext (io.camunda.zeebe.engine.processing.bpmn.BpmnElementContext)3 ProcessInstanceIntent (io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)3