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);
}
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();
}
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");
}
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();
}
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");
}
Aggregations