Search in sources :

Example 1 with ExecutableMultiInstanceBody

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

the class MultiInstanceActivityTransformer method transform.

@Override
public void transform(final Activity element, final TransformContext context) {
    final ExecutableProcess process = context.getCurrentProcess();
    final ExecutableActivity innerActivity = process.getElementById(element.getId(), ExecutableActivity.class);
    final LoopCharacteristics loopCharacteristics = element.getLoopCharacteristics();
    if (loopCharacteristics instanceof MultiInstanceLoopCharacteristics) {
        final ExecutableLoopCharacteristics miLoopCharacteristics = transformLoopCharacteristics(context, (MultiInstanceLoopCharacteristics) loopCharacteristics);
        final ExecutableMultiInstanceBody multiInstanceBody = new ExecutableMultiInstanceBody(element.getId(), miLoopCharacteristics, innerActivity);
        multiInstanceBody.setElementType(BpmnElementType.MULTI_INSTANCE_BODY);
        multiInstanceBody.setFlowScope(innerActivity.getFlowScope());
        innerActivity.setFlowScope(multiInstanceBody);
        // attach boundary events to the multi-instance body
        innerActivity.getBoundaryEvents().forEach(multiInstanceBody::attach);
        innerActivity.getEventSubprocesses().forEach(multiInstanceBody::attach);
        innerActivity.getEvents().removeAll(innerActivity.getBoundaryEvents());
        innerActivity.getEventSubprocesses().stream().map(ExecutableFlowElementContainer::getStartEvents).forEach(innerActivity.getEvents()::remove);
        innerActivity.getInterruptingElementIds().clear();
        // attach incoming and outgoing sequence flows to the multi-instance body
        innerActivity.getIncoming().forEach(flow -> flow.setTarget(multiInstanceBody));
        innerActivity.getOutgoing().forEach(flow -> flow.setSource(multiInstanceBody));
        multiInstanceBody.getOutgoing().addAll(Collections.unmodifiableList(innerActivity.getOutgoing()));
        innerActivity.getOutgoing().clear();
        // replace the inner element with the body
        process.addFlowElement(multiInstanceBody);
    }
}
Also used : MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess) ExecutableActivity(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableActivity) ExecutableMultiInstanceBody(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMultiInstanceBody) LoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ZeebeLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics)

Example 2 with ExecutableMultiInstanceBody

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

the class MultiInstanceActivityTransformer method transform.

@Override
public void transform(final Activity element, final TransformContext context) {
    final ExecutableProcess process = context.getCurrentProcess();
    final ExecutableActivity innerActivity = process.getElementById(element.getId(), ExecutableActivity.class);
    final LoopCharacteristics loopCharacteristics = element.getLoopCharacteristics();
    if (loopCharacteristics instanceof MultiInstanceLoopCharacteristics) {
        final ExecutableLoopCharacteristics miLoopCharacteristics = transformLoopCharacteristics(context, (MultiInstanceLoopCharacteristics) loopCharacteristics);
        final ExecutableMultiInstanceBody multiInstanceBody = new ExecutableMultiInstanceBody(element.getId(), miLoopCharacteristics, innerActivity);
        multiInstanceBody.setElementType(BpmnElementType.MULTI_INSTANCE_BODY);
        multiInstanceBody.setFlowScope(innerActivity.getFlowScope());
        innerActivity.setFlowScope(multiInstanceBody);
        // attach boundary events to the multi-instance body
        innerActivity.getBoundaryEvents().forEach(multiInstanceBody::attach);
        innerActivity.getEventSubprocesses().forEach(multiInstanceBody::attach);
        innerActivity.getEvents().removeAll(innerActivity.getBoundaryEvents());
        innerActivity.getEventSubprocesses().stream().map(ExecutableFlowElementContainer::getStartEvents).forEach(innerActivity.getEvents()::remove);
        innerActivity.getInterruptingElementIds().clear();
        // attach incoming and outgoing sequence flows to the multi-instance body
        innerActivity.getIncoming().forEach(flow -> flow.setTarget(multiInstanceBody));
        innerActivity.getOutgoing().forEach(flow -> flow.setSource(multiInstanceBody));
        multiInstanceBody.getOutgoing().addAll(Collections.unmodifiableList(innerActivity.getOutgoing()));
        innerActivity.getOutgoing().clear();
        // replace the inner element with the body
        process.addFlowElement(multiInstanceBody);
    }
}
Also used : MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess) ExecutableActivity(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableActivity) ExecutableMultiInstanceBody(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMultiInstanceBody) LoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ZeebeLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics)

Example 3 with ExecutableMultiInstanceBody

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

the class MultiInstanceActivityTransformer method transform.

@Override
public void transform(final Activity element, final TransformContext context) {
    final ExecutableProcess process = context.getCurrentProcess();
    final ExecutableActivity innerActivity = process.getElementById(element.getId(), ExecutableActivity.class);
    final LoopCharacteristics loopCharacteristics = element.getLoopCharacteristics();
    if (loopCharacteristics instanceof MultiInstanceLoopCharacteristics) {
        final ExecutableLoopCharacteristics miLoopCharacteristics = transformLoopCharacteristics(context, (MultiInstanceLoopCharacteristics) loopCharacteristics);
        final ExecutableMultiInstanceBody multiInstanceBody = new ExecutableMultiInstanceBody(element.getId(), miLoopCharacteristics, innerActivity);
        multiInstanceBody.setElementType(BpmnElementType.MULTI_INSTANCE_BODY);
        multiInstanceBody.setFlowScope(innerActivity.getFlowScope());
        innerActivity.setFlowScope(multiInstanceBody);
        // attach boundary events to the multi-instance body
        innerActivity.getBoundaryEvents().forEach(multiInstanceBody::attach);
        innerActivity.getEventSubprocesses().forEach(multiInstanceBody::attach);
        innerActivity.getEvents().removeAll(innerActivity.getBoundaryEvents());
        innerActivity.getEventSubprocesses().stream().map(ExecutableFlowElementContainer::getStartEvents).forEach(innerActivity.getEvents()::remove);
        innerActivity.getInterruptingElementIds().clear();
        // attach incoming and outgoing sequence flows to the multi-instance body
        innerActivity.getIncoming().forEach(flow -> flow.setTarget(multiInstanceBody));
        innerActivity.getOutgoing().forEach(flow -> flow.setSource(multiInstanceBody));
        multiInstanceBody.getOutgoing().addAll(Collections.unmodifiableList(innerActivity.getOutgoing()));
        innerActivity.getOutgoing().clear();
        // replace the inner element with the body
        process.addFlowElement(multiInstanceBody);
    }
}
Also used : MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess) ExecutableActivity(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableActivity) ExecutableMultiInstanceBody(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMultiInstanceBody) LoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ZeebeLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics)

Aggregations

ExecutableActivity (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableActivity)3 ExecutableLoopCharacteristics (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics)3 ExecutableMultiInstanceBody (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMultiInstanceBody)3 ExecutableProcess (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess)3 LoopCharacteristics (io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics)3 MultiInstanceLoopCharacteristics (io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics)3 ZeebeLoopCharacteristics (io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics)3