use of org.mule.runtime.api.meta.model.nested.NestedChainModel in project mule by mulesoft.
the class CoreExtensionModelTestCase method flow.
@Test
public void flow() {
final ConstructModel flow = coreExtensionModel.getConstructModel("flow").get();
assertThat(flow.getStereotype().getType(), is(FLOW.getType()));
assertThat(flow.allowsTopLevelDeclaration(), is(true));
final List<ParameterModel> paramModels = flow.getAllParameterModels();
assertThat(paramModels, hasSize(2));
ParameterModel initialState = paramModels.get(0);
assertThat(initialState.getName(), is("initialState"));
assertThat(initialState.getDefaultValue(), is("started"));
ParameterModel maxConcurrency = paramModels.get(1);
assertThat(maxConcurrency.getName(), is("maxConcurrency"));
List<? extends NestableElementModel> nestedComponents = flow.getNestedComponents();
assertThat(nestedComponents, hasSize(3));
NestableElementModel source = nestedComponents.get(0);
assertThat(source.getName(), is("source"));
assertThat(source.isRequired(), is(false));
assertThat(source, instanceOf(NestedComponentModel.class));
assertThat(((NestedComponentModel) source).getAllowedStereotypes(), contains(SOURCE));
NestableElementModel chain = nestedComponents.get(1);
assertThat(chain.getName(), is("processors"));
assertThat(chain.isRequired(), is(true));
assertThat(chain, instanceOf(NestedChainModel.class));
assertThat(((NestedChainModel) chain).getAllowedStereotypes().stream().anyMatch(s -> s.getType().equals(PROCESSOR.getType())), is(true));
NestableElementModel errorHandler = nestedComponents.get(2);
assertThat(errorHandler.getName(), is("errorHandler"));
assertThat(errorHandler.isRequired(), is(false));
assertThat(errorHandler, instanceOf(NestedComponentModel.class));
assertThat(((NestedComponentModel) errorHandler).getAllowedStereotypes(), contains(ERROR_HANDLER));
}
use of org.mule.runtime.api.meta.model.nested.NestedChainModel in project mule by mulesoft.
the class ExecutableTypeSchemaDelegate method generateNestedRouteElement.
private void generateNestedRouteElement(ExtensionType type, DslElementSyntax routeDsl, NestedRouteModel routeModel) {
NestedChainModel chain = (NestedChainModel) routeModel.getNestedComponents().get(0);
LocalComplexType complexType = builder.getObjectSchemaDelegate().createTypeExtension(MULE_ABSTRACT_EXTENSION_TYPE);
ExplicitGroup routeSequence = new ExplicitGroup();
complexType.getComplexContent().getExtension().setSequence(routeSequence);
generateNestedProcessorElement(complexType.getComplexContent().getExtension(), chain);
registerParameters(complexType.getComplexContent().getExtension(), routeModel.getAllParameterModels());
TopLevelElement routeElement = builder.createTopLevelElement(routeDsl.getElementName(), BigInteger.valueOf(routeModel.getMinOccurs()), MAX_ONE);
routeElement.setComplexType(complexType);
type.getSequence().getParticle().add(objectFactory.createElement(routeElement));
if (routeModel.getMinOccurs() > 0) {
type.getSequence().setMinOccurs(ONE);
}
}
use of org.mule.runtime.api.meta.model.nested.NestedChainModel in project mule by mulesoft.
the class AbstractComponentDefinitionParser method doParse.
@Override
protected Builder doParse(Builder definitionBuilder) throws ConfigurationException {
Builder finalBuilder = definitionBuilder.withIdentifier(operationDsl.getElementName()).withTypeDefinition(fromType(getMessageProcessorType())).withObjectFactoryType(getMessageProcessorFactoryType()).withConstructorParameterDefinition(fromFixedValue(extensionModel).build()).withConstructorParameterDefinition(fromFixedValue(componentModel).build()).withConstructorParameterDefinition(fromReferenceObject(MuleContext.class).build()).withConstructorParameterDefinition(fromReferenceObject(Registry.class).build()).withConstructorParameterDefinition(fromReferenceObject(PolicyManager.class).build()).withSetterParameterDefinition(TARGET_PARAMETER_NAME, fromSimpleParameter(TARGET_PARAMETER_NAME).build()).withSetterParameterDefinition(TARGET_VALUE_PARAMETER_NAME, fromSimpleParameter(TARGET_VALUE_PARAMETER_NAME).build()).withSetterParameterDefinition(CONFIG_PROVIDER_ATTRIBUTE_NAME, fromSimpleReferenceParameter(CONFIG_ATTRIBUTE_NAME).build()).withSetterParameterDefinition(CURSOR_PROVIDER_FACTORY_FIELD_NAME, fromChildConfiguration(CursorProviderFactory.class).build()).withSetterParameterDefinition("retryPolicyTemplate", fromChildConfiguration(RetryPolicyTemplate.class).build());
Optional<? extends NestableElementModel> nestedChain = componentModel.getNestedComponents().stream().filter(c -> c instanceof NestedChainModel).findFirst();
if (nestedChain.isPresent()) {
// TODO MULE-13483: improve parsers to support things like [source, chainOfProcessors, errorHandler]
// or [chainOfProcessors, errorHandler]
finalBuilder = finalBuilder.withSetterParameterDefinition("nestedProcessors", fromChildCollectionConfiguration(Processor.class).build());
parseParameters(componentModel.getAllParameterModels());
} else {
List<ParameterGroupModel> inlineGroups = getInlineGroups(componentModel);
parseParameters(getFlatParameters(inlineGroups, componentModel.getAllParameterModels()));
for (ParameterGroupModel group : inlineGroups) {
parseInlineParameterGroup(group);
}
// TODO MULE-13483
parseNestedComponents(componentModel.getNestedComponents());
}
return finalBuilder;
}
Aggregations