use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.
the class MetadataMediator method resolveParameterGroupModelType.
private List<ParameterGroupModel> resolveParameterGroupModelType(List<ParameterGroupModel> untypedParameterGroups, Map<String, ParameterMetadataDescriptor> inputTypeDescriptors) {
List<ParameterGroupModel> parameterGroups = new LinkedList<>();
untypedParameterGroups.forEach(parameterGroup -> {
List<ParameterModel> parameters = new LinkedList<>();
parameterGroup.getParameterModels().forEach(parameterModel -> {
ParameterMetadataDescriptor parameterMetadataDescriptor = inputTypeDescriptors.get(parameterModel.getName());
ParameterModel typedParameterModel = new ImmutableParameterModel(parameterModel.getName(), parameterModel.getDescription(), parameterMetadataDescriptor.getType(), parameterMetadataDescriptor.isDynamic(), parameterModel.isRequired(), parameterModel.isOverrideFromConfig(), parameterModel.getExpressionSupport(), parameterModel.getDefaultValue(), parameterModel.getRole(), parameterModel.getDslConfiguration(), parameterModel.getDisplayModel().orElse(null), parameterModel.getLayoutModel().orElse(null), parameterModel.getValueProviderModel().orElse(null), parameterModel.getAllowedStereotypes(), parameterModel.getModelProperties());
parameters.add(typedParameterModel);
});
parameterGroups.add(new ImmutableParameterGroupModel(parameterGroup.getName(), parameterGroup.getDescription(), parameters, parameterGroup.getExclusiveParametersModels(), parameterGroup.isShowInDsl(), parameterGroup.getDisplayModel().orElse(null), parameterGroup.getLayoutModel().orElse(null), parameterGroup.getModelProperties()));
});
return parameterGroups;
}
use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.
the class ConfigurationBasedElementModelFactory method addElementParameter.
private void addElementParameter(Multimap<ComponentIdentifier, ComponentConfiguration> innerComponents, Map<String, String> parameters, DslElementSyntax groupDsl, DslElementModel.Builder<ParameterGroupModel> groupElementBuilder, ParameterModel paramModel) {
groupDsl.getContainedElement(paramModel.getName()).ifPresent(paramDsl -> {
if (isInfrastructure(paramModel)) {
handleInfrastructure(paramModel, paramDsl, innerComponents, parameters, groupElementBuilder);
return;
}
ComponentConfiguration paramComponent = getSingleComponentConfiguration(innerComponents, getIdentifier(paramDsl));
if (paramDsl.isWrapped()) {
resolveWrappedElement(groupElementBuilder, paramModel, paramDsl, paramComponent);
return;
}
String value = paramDsl.supportsAttributeDeclaration() ? parameters.get(paramDsl.getAttributeName()) : null;
Optional<String> defaultValue = getDefaultValue(paramModel);
if (paramComponent != null || !isBlank(value) || defaultValue.isPresent()) {
DslElementModel.Builder<ParameterModel> paramElementBuilder = DslElementModel.<ParameterModel>builder().withModel(paramModel).withDsl(paramDsl);
if (paramComponent != null && !isContent(paramModel)) {
paramElementBuilder.withConfig(paramComponent);
paramModel.getType().accept(new MetadataTypeVisitor() {
@Override
public void visitArrayType(ArrayType arrayType) {
MetadataType itemType = arrayType.getType();
paramDsl.getGeneric(itemType).ifPresent(itemdsl -> {
ComponentIdentifier itemIdentifier = getIdentifier(itemdsl).get();
paramComponent.getNestedComponents().forEach(c -> {
if (c.getIdentifier().equals(itemIdentifier)) {
itemType.accept(getComponentChildVisitor(paramElementBuilder, c, itemType, VALUE_ATTRIBUTE_NAME, itemdsl, defaultValue, new ArrayDeque<>()));
}
});
});
}
@Override
public void visitObject(ObjectType objectType) {
if (isMap(objectType)) {
populateMapEntries(objectType, paramDsl, paramElementBuilder, paramComponent);
return;
}
populateObjectFields(objectType, paramComponent, paramDsl, paramElementBuilder, new ArrayDeque<>());
}
});
} else {
if (isBlank(value)) {
if (paramComponent != null && paramComponent.getValue().isPresent() && !isBlank(paramComponent.getValue().get())) {
value = paramComponent.getValue().get().trim();
} else if (defaultValue.isPresent()) {
value = defaultValue.get();
paramElementBuilder.isExplicitInDsl(false);
}
}
paramElementBuilder.withValue(value);
}
groupElementBuilder.containing(paramElementBuilder.build());
}
});
}
use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel in project mule by mulesoft.
the class DeclarationBasedElementModelFactory method addInlineGroupElement.
private <T> void addInlineGroupElement(ParameterGroupModel group, DslElementSyntax elementDsl, InternalComponentConfiguration.Builder parentConfig, DslElementModel.Builder<T> parentElement, Optional<ParameterGroupElementDeclaration> declaration) {
elementDsl.getChild(group.getName()).ifPresent(groupDsl -> {
DslElementModel.Builder<ParameterGroupModel> groupElementBuilder = DslElementModel.<ParameterGroupModel>builder().withModel(group).withDsl(groupDsl).isExplicitInDsl(declaration.isPresent());
InternalComponentConfiguration.Builder groupConfigBuilder = InternalComponentConfiguration.builder().withIdentifier(asIdentifier(groupDsl));
addGroupParameterElements(group, groupDsl, groupConfigBuilder, groupElementBuilder, declaration);
ComponentConfiguration groupConfig = groupConfigBuilder.build();
groupElementBuilder.withConfig(groupConfig);
parentConfig.withNestedComponent(groupConfig);
parentElement.containing(groupElementBuilder.build());
});
}
use of org.mule.runtime.api.meta.model.parameter.ParameterGroupModel 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