use of org.mule.runtime.api.meta.model.parameter.ParameterizedModel in project mule by mulesoft.
the class ParametersResolver method getParametersAsResolverSet.
/**
* Constructs a {@link ResolverSet} from the parameters groups, using {@link #toValueResolver(Object, Set)} to process the values.
*
* @return a {@link ResolverSet}
*/
public ResolverSet getParametersAsResolverSet(MuleContext muleContext, ParameterizedModel model, List<ParameterGroupModel> groups) throws ConfigurationException {
List<ParameterGroupModel> inlineGroups = getInlineGroups(groups);
List<ParameterModel> allParameters = groups.stream().flatMap(g -> g.getParameterModels().stream()).collect(toList());
ResolverSet resolverSet = getParametersAsResolverSet(model, getFlatParameters(inlineGroups, allParameters), muleContext);
for (ParameterGroupModel group : inlineGroups) {
getInlineGroupResolver(group, resolverSet, muleContext);
}
return resolverSet;
}
use of org.mule.runtime.api.meta.model.parameter.ParameterizedModel in project mule by mulesoft.
the class DefaultXmlArtifactDeclarationLoader method declareRoute.
private Optional<RouteElementDeclaration> declareRoute(ComposableModel model, DslElementSyntax elementDsl, ConfigLine child, ElementDeclarer extensionElementsDeclarer) {
return model.getNestedComponents().stream().filter(nestedModel -> elementDsl.getContainedElement(nestedModel.getName()).map(nestedDsl -> child.getIdentifier().equals(nestedDsl.getElementName())).orElse(false)).filter(nestedModel -> nestedModel instanceof NestedRouteModel).findFirst().map(nestedModel -> {
RouteElementDeclarer routeDeclarer = extensionElementsDeclarer.newRoute(nestedModel.getName());
DslElementSyntax routeDsl = elementDsl.getContainedElement(nestedModel.getName()).get();
declareParameterizedComponent((ParameterizedModel) nestedModel, routeDsl, routeDeclarer, child.getConfigAttributes(), child.getChildren());
declareComposableModel((ComposableModel) nestedModel, elementDsl, child, routeDeclarer);
return routeDeclarer.getDeclaration();
});
}
use of org.mule.runtime.api.meta.model.parameter.ParameterizedModel 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.api.meta.model.parameter.ParameterizedModel in project mule by mulesoft.
the class ValueProviderModelValidator method validateModel.
private void validateModel(ParameterizedModel model, ProblemsReporter problemsReporter, boolean supportsConnectionsAndConfigs) {
ReflectionCache reflectionCache = new ReflectionCache();
model.getAllParameterModels().forEach(param -> param.getModelProperty(ValueProviderFactoryModelProperty.class).ifPresent(modelProperty -> validateOptionsResolver(param, modelProperty, model, problemsReporter, supportsConnectionsAndConfigs, reflectionCache)));
}
use of org.mule.runtime.api.meta.model.parameter.ParameterizedModel in project mule by mulesoft.
the class IntrospectionUtils method getParameterClasses.
/**
* Traverses through all the {@link ParameterModel}s of the {@code extensionModel} and returns the {@link Class classes} that
* are modeled by each parameter's {@link ParameterModel#getType()}.
* <p>
* This includes every single {@link ParameterModel} in the model, including configs, providers, operations, etc.
*
* @param extensionModel a {@link ExtensionModel}
* @return a non {@code null} {@link Set}
*/
public static Set<Class<?>> getParameterClasses(ExtensionModel extensionModel, ClassLoader extensionClassLoader) {
Set<Class<?>> parameterClasses = new HashSet<>();
new ExtensionWalker() {
@Override
public void onParameter(ParameterizedModel owner, ParameterGroupModel groupModel, ParameterModel model) {
parameterClasses.addAll(collectRelativeClasses(model.getType(), extensionClassLoader));
}
}.walk(extensionModel);
return parameterClasses;
}
Aggregations