use of org.mule.runtime.config.internal.model.ComponentModel in project mule by mulesoft.
the class ComponentModelReader method extractComponentDefinitionModel.
public ComponentModel extractComponentDefinitionModel(ConfigLine configLine, String configFileName) {
String namespace = configLine.getNamespace() == null ? CORE_PREFIX : configLine.getNamespace();
ComponentModel.Builder builder = new ComponentModel.Builder().setIdentifier(builder().namespace(namespace).name(configLine.getIdentifier()).build()).setTextContent(resolveValueIfIsPlaceHolder(configLine.getTextContent())).setConfigFileName(configFileName).setLineNumber(configLine.getLineNumber());
to(builder).addNode(from(configLine).getNode());
for (SimpleConfigAttribute simpleConfigAttribute : configLine.getConfigAttributes().values()) {
builder.addParameter(simpleConfigAttribute.getName(), resolveValueIfIsPlaceHolder(simpleConfigAttribute.getValue()), simpleConfigAttribute.isValueFromSchema());
}
List<ComponentModel> componentModels = configLine.getChildren().stream().map(childConfigLine -> extractComponentDefinitionModel(childConfigLine, configFileName)).collect(Collectors.toList());
componentModels.stream().forEach(componentDefinitionModel -> builder.addChildComponentModel(componentDefinitionModel));
ConfigLine parent = configLine.getParent();
if (parent != null && isConfigurationTopComponent(parent)) {
builder.markAsRootComponent();
}
ComponentModel componentModel = builder.build();
for (ComponentModel innerComponentModel : componentModel.getInnerComponents()) {
innerComponentModel.setParent(componentModel);
}
return componentModel;
}
Aggregations