use of org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax in project mule by mulesoft.
the class ConfigurationBasedElementModelFactory method populateComposableElements.
private void populateComposableElements(ComposableModel model, DslElementSyntax elementDsl, DslElementModel.Builder builder, ComponentConfiguration configuration) {
configuration.getNestedComponents().forEach(nestedComponentConfig -> {
DslElementModel nestedElement = createIdentifiedElement(nestedComponentConfig);
if (nestedElement != null) {
builder.containing(nestedElement);
} else {
model.getNestedComponents().stream().filter(nestedModel -> nestedModel instanceof NestedRouteModel).filter(nestedModel -> elementDsl.getContainedElement(nestedModel.getName()).map(nestedDsl -> getIdentifier(nestedDsl).map(id -> nestedComponentConfig.getIdentifier().equals(id)).orElse(false)).orElse(false)).findFirst().ifPresent(nestedModel -> {
DslElementSyntax routeDsl = elementDsl.getContainedElement(nestedModel.getName()).get();
DslElementModel.Builder<? extends NestableElementModel> routeBuilder = DslElementModel.<NestableElementModel>builder().withModel(nestedModel).withDsl(routeDsl).withConfig(nestedComponentConfig).isExplicitInDsl(true);
populateParameterizedElements((ParameterizedModel) nestedModel, routeDsl, routeBuilder, nestedComponentConfig);
nestedComponentConfig.getNestedComponents().forEach(routeElement -> {
DslElementModel nestableElementModel = createIdentifiedElement(routeElement);
if (nestableElementModel != null) {
routeBuilder.containing(nestableElementModel);
}
});
builder.containing(routeBuilder.build());
});
}
});
}
use of org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax in project mule by mulesoft.
the class DeclarationBasedElementModelFactory method createList.
private void createList(ParameterListValue list, DslElementSyntax listDsl, Object model, ArrayType listType, InternalComponentConfiguration.Builder parentConfig, DslElementModel.Builder parentElement) {
final DslElementModel.Builder listElement = DslElementModel.builder().withModel(model).withDsl(listDsl);
final InternalComponentConfiguration.Builder listConfig = InternalComponentConfiguration.builder().withIdentifier(asIdentifier(listDsl));
final MetadataType itemType = listType.getType();
listDsl.getGeneric(itemType).ifPresent(itemDsl -> list.getValues().forEach(value -> createListItemConfig(itemType, value, itemDsl, listConfig, listElement)));
ComponentConfiguration result = listConfig.build();
parentConfig.withNestedComponent(result);
parentElement.containing(listElement.withConfig(result).build());
}
use of org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax in project mule by mulesoft.
the class DeclarationBasedElementModelFactory method createConfigurationElement.
private DslElementModel<ConfigurationModel> createConfigurationElement(ConfigurationModel model, ConfigurationElementDeclaration configDeclaration) {
DslElementSyntax configDsl = dsl.resolve(model);
InternalComponentConfiguration.Builder configuration = InternalComponentConfiguration.builder().withIdentifier(asIdentifier(configDsl)).withParameter(NAME_ATTRIBUTE_NAME, configDeclaration.getRefName());
DslElementModel.Builder<ConfigurationModel> element = createParameterizedElementModel(model, configDsl, configDeclaration, configuration);
configDeclaration.getConnection().ifPresent(connection -> addConnectionProvider(connection, model, configuration, element));
return element.withConfig(configuration.build()).build();
}
Aggregations