Search in sources :

Example 1 with MultiInstanceLoopCharacteristics

use of io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics 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);
}
Also used : CompletionCondition(io.camunda.zeebe.model.bpmn.instance.CompletionCondition) LoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics) ExecutableMultiInstanceBody(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMultiInstanceBody) ExecutableProcess(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics) ModelElementTransformer(io.camunda.zeebe.engine.processing.deployment.model.transformation.ModelElementTransformer) ExecutableFlowElementContainer(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElementContainer) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) ZeebeLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics) TransformContext(io.camunda.zeebe.engine.processing.deployment.model.transformation.TransformContext) BpmnElementType(io.camunda.zeebe.protocol.record.value.BpmnElementType) ExecutableActivity(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableActivity) Expression(io.camunda.zeebe.el.Expression) Optional(java.util.Optional) Activity(io.camunda.zeebe.model.bpmn.instance.Activity) Collections(java.util.Collections) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) DirectBuffer(org.agrona.DirectBuffer) DirectBuffer(org.agrona.DirectBuffer) CompletionCondition(io.camunda.zeebe.model.bpmn.instance.CompletionCondition) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) ZeebeLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics) Expression(io.camunda.zeebe.el.Expression) ExecutableLoopCharacteristics(io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics)

Example 2 with MultiInstanceLoopCharacteristics

use of io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics in project zeebe by camunda.

the class MultiInstanceLoopCharacteristicsImpl method registerType.

public static void registerType(final ModelBuilder modelBuilder) {
    final ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(MultiInstanceLoopCharacteristics.class, BPMN_ELEMENT_MULTI_INSTANCE_LOOP_CHARACTERISTICS).namespaceUri(BPMN20_NS).extendsType(LoopCharacteristics.class).instanceProvider(new ModelTypeInstanceProvider<MultiInstanceLoopCharacteristics>() {

        @Override
        public MultiInstanceLoopCharacteristics newInstance(final ModelTypeInstanceContext instanceContext) {
            return new MultiInstanceLoopCharacteristicsImpl(instanceContext);
        }
    });
    isSequentialAttribute = typeBuilder.booleanAttribute(BPMN_ELEMENT_IS_SEQUENTIAL).defaultValue(false).build();
    behaviorAttribute = typeBuilder.enumAttribute(BPMN_ELEMENT_BEHAVIOR, MultiInstanceFlowCondition.class).defaultValue(MultiInstanceFlowCondition.All).build();
    oneBehaviorEventRefAttribute = typeBuilder.stringAttribute(BPMN_ELEMENT_ONE_BEHAVIOR_EVENT_REF).qNameAttributeReference(EventDefinition.class).build();
    noneBehaviorEventRefAttribute = typeBuilder.stringAttribute(BPMN_ELEMENT_NONE_BEHAVIOR_EVENT_REF).qNameAttributeReference(EventDefinition.class).build();
    final SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    loopCardinalityChild = sequenceBuilder.element(LoopCardinality.class).build();
    loopDataInputRefChild = sequenceBuilder.element(LoopDataInputRef.class).qNameElementReference(DataInput.class).build();
    loopDataOutputRefChild = sequenceBuilder.element(LoopDataOutputRef.class).qNameElementReference(DataOutput.class).build();
    outputDataItemChild = sequenceBuilder.element(OutputDataItem.class).build();
    inputDataItemChild = sequenceBuilder.element(InputDataItem.class).build();
    complexBehaviorDefinitionCollection = sequenceBuilder.elementCollection(ComplexBehaviorDefinition.class).build();
    completionConditionChild = sequenceBuilder.element(CompletionCondition.class).build();
    typeBuilder.build();
}
Also used : MultiInstanceFlowCondition(io.camunda.zeebe.model.bpmn.MultiInstanceFlowCondition) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext) LoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics) MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics)

Example 3 with MultiInstanceLoopCharacteristics

use of io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics in project zeebe by zeebe-io.

the class ProcessBuilderTest method testMultiInstanceLoopCharacteristicsSequential.

@Test
public void testMultiInstanceLoopCharacteristicsSequential() {
    modelInstance = Bpmn.createProcess().startEvent().userTask("task").multiInstance().sequential().cardinality("card").completionCondition("compl").multiInstanceDone().endEvent().done();
    final UserTask userTask = modelInstance.getModelElementById("task");
    final Collection<MultiInstanceLoopCharacteristics> miCharacteristics = userTask.getChildElementsByType(MultiInstanceLoopCharacteristics.class);
    assertThat(miCharacteristics).hasSize(1);
    final MultiInstanceLoopCharacteristics miCharacteristic = miCharacteristics.iterator().next();
    assertThat(miCharacteristic.isSequential()).isTrue();
    assertThat(miCharacteristic.getLoopCardinality().getTextContent()).isEqualTo("card");
    assertThat(miCharacteristic.getCompletionCondition().getTextContent()).isEqualTo("compl");
}
Also used : MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) UserTask(io.camunda.zeebe.model.bpmn.instance.UserTask) Test(org.junit.Test)

Example 4 with MultiInstanceLoopCharacteristics

use of io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics in project zeebe by camunda-cloud.

the class ProcessBuilderTest method testMultiInstanceLoopCharacteristicsParallel.

@Test
public void testMultiInstanceLoopCharacteristicsParallel() {
    modelInstance = Bpmn.createProcess().startEvent().userTask("task").multiInstance().parallel().multiInstanceDone().endEvent().done();
    final UserTask userTask = modelInstance.getModelElementById("task");
    final Collection<MultiInstanceLoopCharacteristics> miCharacteristics = userTask.getChildElementsByType(MultiInstanceLoopCharacteristics.class);
    assertThat(miCharacteristics).hasSize(1);
    final MultiInstanceLoopCharacteristics miCharacteristic = miCharacteristics.iterator().next();
    assertThat(miCharacteristic.isSequential()).isFalse();
}
Also used : MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) UserTask(io.camunda.zeebe.model.bpmn.instance.UserTask) Test(org.junit.Test)

Example 5 with MultiInstanceLoopCharacteristics

use of io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics in project zeebe by camunda-cloud.

the class ProcessBuilderTest method testMultiInstanceLoopCharacteristicsSequential.

@Test
public void testMultiInstanceLoopCharacteristicsSequential() {
    modelInstance = Bpmn.createProcess().startEvent().userTask("task").multiInstance().sequential().cardinality("card").completionCondition("compl").multiInstanceDone().endEvent().done();
    final UserTask userTask = modelInstance.getModelElementById("task");
    final Collection<MultiInstanceLoopCharacteristics> miCharacteristics = userTask.getChildElementsByType(MultiInstanceLoopCharacteristics.class);
    assertThat(miCharacteristics).hasSize(1);
    final MultiInstanceLoopCharacteristics miCharacteristic = miCharacteristics.iterator().next();
    assertThat(miCharacteristic.isSequential()).isTrue();
    assertThat(miCharacteristic.getLoopCardinality().getTextContent()).isEqualTo("card");
    assertThat(miCharacteristic.getCompletionCondition().getTextContent()).isEqualTo("compl");
}
Also used : MultiInstanceLoopCharacteristics(io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics) UserTask(io.camunda.zeebe.model.bpmn.instance.UserTask) Test(org.junit.Test)

Aggregations

MultiInstanceLoopCharacteristics (io.camunda.zeebe.model.bpmn.instance.MultiInstanceLoopCharacteristics)15 LoopCharacteristics (io.camunda.zeebe.model.bpmn.instance.LoopCharacteristics)9 ExecutableActivity (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableActivity)6 ExecutableLoopCharacteristics (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableLoopCharacteristics)6 ExecutableMultiInstanceBody (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableMultiInstanceBody)6 ExecutableProcess (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableProcess)6 UserTask (io.camunda.zeebe.model.bpmn.instance.UserTask)6 ZeebeLoopCharacteristics (io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeLoopCharacteristics)6 Test (org.junit.Test)6 Expression (io.camunda.zeebe.el.Expression)3 ExecutableFlowElementContainer (io.camunda.zeebe.engine.processing.deployment.model.element.ExecutableFlowElementContainer)3 ModelElementTransformer (io.camunda.zeebe.engine.processing.deployment.model.transformation.ModelElementTransformer)3 TransformContext (io.camunda.zeebe.engine.processing.deployment.model.transformation.TransformContext)3 MultiInstanceFlowCondition (io.camunda.zeebe.model.bpmn.MultiInstanceFlowCondition)3 Activity (io.camunda.zeebe.model.bpmn.instance.Activity)3 CompletionCondition (io.camunda.zeebe.model.bpmn.instance.CompletionCondition)3 BpmnElementType (io.camunda.zeebe.protocol.record.value.BpmnElementType)3 BufferUtil (io.camunda.zeebe.util.buffer.BufferUtil)3 Collections (java.util.Collections)3 Optional (java.util.Optional)3