Search in sources :

Example 1 with ArrayType

use of org.mule.metadata.api.model.ArrayType in project mule by mulesoft.

the class ExtensionDefinitionParser method parseCollectionParameter.

/**
 * Registers a definition for a {@link ParameterModel} which represents an {@link ArrayType}
 *
 * @param key               the key that the parsed value should have on the parsed parameter's map
 * @param name              the parameter's name
 * @param arrayType         the parameter's {@link ArrayType}
 * @param defaultValue      the parameter's default value
 * @param expressionSupport the parameter's {@link ExpressionSupport}
 * @param required          whether the parameter is required
 */
protected void parseCollectionParameter(String key, String name, ArrayType arrayType, Object defaultValue, ExpressionSupport expressionSupport, boolean required, DslElementSyntax parameterDsl, Set<ModelProperty> modelProperties) {
    parseAttributeParameter(key, name, arrayType, defaultValue, expressionSupport, required, modelProperties);
    Class<?> collectionType = ExtensionMetadataTypeUtils.getType(arrayType).orElse(null);
    if (Set.class.equals(collectionType)) {
        collectionType = HashSet.class;
    } else if (Collection.class.equals(collectionType) || Iterable.class.equals(collectionType) || collectionType == null) {
        collectionType = List.class;
    }
    final String collectionElementName = parameterDsl.getElementName();
    addParameter(getChildKey(key), fromChildConfiguration(collectionType).withWrapperIdentifier(collectionElementName));
    addDefinition(baseDefinitionBuilder.withIdentifier(collectionElementName).withTypeDefinition(fromType(collectionType)).build());
    Optional<DslElementSyntax> collectionItemDsl = parameterDsl.getGeneric(arrayType.getType());
    if (parameterDsl.supportsChildDeclaration() && collectionItemDsl.isPresent()) {
        String itemIdentifier = collectionItemDsl.get().getElementName();
        String itemNamespace = collectionItemDsl.get().getPrefix();
        arrayType.getType().accept(new BasicTypeMetadataVisitor() {

            private void addBasicTypeDefinition(MetadataType metadataType) {
                Builder itemDefinitionBuilder = baseDefinitionBuilder.withIdentifier(itemIdentifier).withNamespace(itemNamespace).withTypeDefinition(fromType(ExtensionMetadataTypeUtils.getType(metadataType).orElse(Object.class))).withTypeConverter(value -> resolverOf(name, metadataType, value, getDefaultValue(metadataType).orElse(null), getExpressionSupport(metadataType), false, emptySet()));
                addDefinition(itemDefinitionBuilder.build());
            }

            @Override
            protected void visitBasicType(MetadataType metadataType) {
                addBasicTypeDefinition(metadataType);
            }

            @Override
            public void visitDate(DateType dateType) {
                addBasicTypeDefinition(dateType);
            }

            @Override
            public void visitDateTime(DateTimeType dateTimeType) {
                addBasicTypeDefinition(dateTimeType);
            }

            @Override
            public void visitObject(ObjectType objectType) {
                if (isMap(objectType)) {
                    return;
                }
                DslElementSyntax itemDsl = collectionItemDsl.get();
                if ((itemDsl.supportsTopLevelDeclaration() || itemDsl.supportsChildDeclaration()) && !parsingContext.isRegistered(itemDsl.getElementName(), itemDsl.getPrefix())) {
                    try {
                        parsingContext.registerObjectType(itemDsl.getElementName(), itemDsl.getPrefix(), objectType);
                        new ObjectTypeParameterParser(baseDefinitionBuilder, objectType, getContextClassLoader(), dslResolver, parsingContext).parse().forEach(definition -> addDefinition(definition));
                    } catch (ConfigurationException e) {
                        throw new MuleRuntimeException(createStaticMessage("Could not create parser for collection complex type"), e);
                    }
                }
            }
        });
    }
}
Also used : InfrastructureTypeMapping.getNameMap(org.mule.runtime.module.extension.internal.loader.java.type.InfrastructureTypeMapping.getNameMap) ExpressionBasedParameterResolverValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionBasedParameterResolverValueResolver) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) KeyAttributeDefinitionPair(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair) InfrastructureParameterModelProperty(org.mule.runtime.extension.api.property.InfrastructureParameterModelProperty) BEHAVIOUR(org.mule.runtime.api.meta.model.parameter.ParameterRole.BEHAVIOUR) ParameterRole(org.mule.runtime.api.meta.model.parameter.ParameterRole) DateTimeType(org.mule.metadata.api.model.DateTimeType) RequiredParameterValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.RequiredParameterValueResolverWrapper) Builder.fromSimpleParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleParameter) QueryParameterModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.QueryParameterModelProperty) Instant.ofEpochMilli(java.time.Instant.ofEpochMilli) ArrayType(org.mule.metadata.api.model.ArrayType) Map(java.util.Map) NestableElementModelVisitor(org.mule.runtime.api.meta.model.nested.NestableElementModelVisitor) ExpressionTypedValueValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ModelProperty(org.mule.runtime.api.meta.model.ModelProperty) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ExtensionModelUtils.isContent(org.mule.runtime.extension.api.util.ExtensionModelUtils.isContent) SchedulingStrategyParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.SchedulingStrategyParsingDelegate) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) IntrospectionUtils.isTargetParameter(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isTargetParameter) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) DateType(org.mule.metadata.api.model.DateType) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ZoneId(java.time.ZoneId) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) DefaultValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.DefaultValueResolverParsingDelegate) DateTimeParseException(java.time.format.DateTimeParseException) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) StringType(org.mule.metadata.api.model.StringType) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) IntrospectionUtils.getContainerName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getContainerName) ParameterResolverValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.ParameterResolverValueResolverWrapper) DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) StackedTypesModelProperty.getStackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty.getStackedTypesModelProperty) NativeQueryParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver) MetadataTypeUtils.getDefaultValue(org.mule.metadata.api.utils.MetadataTypeUtils.getDefaultValue) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) StackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty) LocalDateTime(java.time.LocalDateTime) Builder.fromChildMapConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildMapConfiguration) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) Supplier(java.util.function.Supplier) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) ArrayList(java.util.ArrayList) TypeSafeValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeValueResolverWrapper) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) ExtensionMetadataTypeUtils.getExpressionSupport(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getExpressionSupport) TypedInlineParameterGroupParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.TypedInlineParameterGroupParser) MediaTypeValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.MediaTypeValueResolverParsingDelegate) ConversionService(org.springframework.core.convert.ConversionService) TypeDefinition.fromType(org.mule.runtime.dsl.api.component.TypeDefinition.fromType) MuleExtensionUtils.isExpression(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.isExpression) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ParsingDelegate) Builder.fromMultipleDefinitions(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromMultipleDefinitions) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Reference(org.mule.runtime.api.util.Reference) DefaultObjectParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.DefaultObjectParsingDelegate) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) JavaTypeUtils.getType(org.mule.metadata.java.api.utils.JavaTypeUtils.getType) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) TemplateParser(org.mule.runtime.core.privileged.util.TemplateParser) IntrospectionUtils.getMemberName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getMemberName) Date(java.util.Date) Builder.fromChildConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildConfiguration) TypeConverter(org.mule.runtime.dsl.api.component.TypeConverter) IntrospectionUtils.isLiteral(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isLiteral) TypeDefinition.fromMapEntryType(org.mule.runtime.dsl.api.component.TypeDefinition.fromMapEntryType) ProcessorChainValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ProcessorChainValueResolver) IntrospectionUtils.isTypedValue(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isTypedValue) TypedValueValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueValueResolverWrapper) PoolingProfile(org.mule.runtime.api.config.PoolingProfile) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) Builder.fromChildCollectionConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildCollectionConfiguration) ISODateTimeFormat(org.joda.time.format.ISODateTimeFormat) ObjectParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ObjectParsingDelegate) Collection(java.util.Collection) REQUIRED(org.mule.runtime.api.meta.ExpressionSupport.REQUIRED) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) String.format(java.lang.String.format) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) CharsetValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.CharsetValueResolverParsingDelegate) TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) RetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate) TypeSafeExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver) KeyAttributeDefinitionPair.newBuilder(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair.newBuilder) Builder.fromSimpleReferenceParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleReferenceParameter) HashMap(java.util.HashMap) Processor(org.mule.runtime.core.api.processor.Processor) Builder.fromFixedValue(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromFixedValue) ConcurrentMap(java.util.concurrent.ConcurrentMap) ValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ValueResolverParsingDelegate) HashSet(java.util.HashSet) ExtensionMetadataTypeUtils.isFlattenedParameterGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isFlattenedParameterGroup) ImmutableList(com.google.common.collect.ImmutableList) Literal(org.mule.runtime.extension.api.runtime.parameter.Literal) BasicTypeMetadataVisitor(org.mule.metadata.api.visitor.BasicTypeMetadataVisitor) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) ExclusiveOptionalModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ExclusiveOptionalModelProperty) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) NameUtils.hyphenize(org.mule.runtime.extension.api.util.NameUtils.hyphenize) IntrospectionUtils.isParameterResolver(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isParameterResolver) ExpressionSupport(org.mule.runtime.api.meta.ExpressionSupport) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) DateTime(org.joda.time.DateTime) AttributeDefinition(org.mule.runtime.dsl.api.component.AttributeDefinition) AnonymousInlineParameterGroupParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.AnonymousInlineParameterGroupParser) Collectors.toList(java.util.stream.Collectors.toList) ExtensionMetadataTypeUtils(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils) RouteComponentParser(org.mule.runtime.module.extension.internal.config.dsl.construct.RouteComponentParser) FixedTypeParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.FixedTypeParsingDelegate) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) TopLevelParameterObjectFactory(org.mule.runtime.module.extension.internal.config.dsl.parameter.TopLevelParameterObjectFactory) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) StaticLiteralValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) KeyAttributeDefinitionPair.newBuilder(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair.newBuilder) MetadataType(org.mule.metadata.api.model.MetadataType) BasicTypeMetadataVisitor(org.mule.metadata.api.visitor.BasicTypeMetadataVisitor) ObjectType(org.mule.metadata.api.model.ObjectType) DateTimeType(org.mule.metadata.api.model.DateTimeType) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) DateType(org.mule.metadata.api.model.DateType)

Example 2 with ArrayType

use of org.mule.metadata.api.model.ArrayType in project mule by mulesoft.

the class ExtensionDefinitionParser method parseField.

private void parseField(ObjectType type, DslElementSyntax typeDsl, ObjectFieldType objectField, Map<String, ParameterRole> parametersRole) {
    final MetadataType fieldType = objectField.getValue();
    final String fieldName = objectField.getKey().getName().getLocalPart();
    final boolean acceptsReferences = ExtensionMetadataTypeUtils.acceptsReferences(objectField);
    final Object defaultValue = getDefaultValue(fieldType).orElse(null);
    final ExpressionSupport expressionSupport = getExpressionSupport(objectField);
    Optional<DslElementSyntax> fieldDsl = typeDsl.getContainedElement(fieldName);
    if (!fieldDsl.isPresent() && !isFlattenedParameterGroup(objectField)) {
        return;
    }
    Optional<String> keyName = getInfrastructureParameterName(fieldType);
    if (keyName.isPresent()) {
        parseObject(fieldName, keyName.get(), (ObjectType) fieldType, defaultValue, expressionSupport, false, acceptsReferences, fieldDsl.get(), emptySet());
        return;
    }
    final boolean isContent = isContent(parametersRole.getOrDefault(fieldName, BEHAVIOUR));
    fieldType.accept(new MetadataTypeVisitor() {

        @Override
        protected void defaultVisit(MetadataType metadataType) {
            if (!parseAsContent(isContent, metadataType)) {
                parseAttributeParameter(fieldName, fieldName, metadataType, defaultValue, expressionSupport, false, emptySet());
            }
        }

        @Override
        public void visitString(StringType stringType) {
            if (fieldDsl.get().supportsChildDeclaration()) {
                String elementName = fieldDsl.get().getElementName();
                addParameter(fieldName, fromChildConfiguration(String.class).withWrapperIdentifier(elementName));
                addDefinition(baseDefinitionBuilder.withIdentifier(elementName).withTypeDefinition(fromType(String.class)).withTypeConverter(value -> resolverOf(elementName, stringType, value, defaultValue, expressionSupport, false, emptySet(), acceptsReferences)).build());
            } else {
                defaultVisit(stringType);
            }
        }

        @Override
        public void visitObject(ObjectType objectType) {
            if (objectType.isOpen()) {
                if (!parseAsContent(isContent, objectType)) {
                    parseMapParameters(fieldName, fieldName, objectType, defaultValue, expressionSupport, false, fieldDsl.get(), emptySet());
                }
                return;
            }
            if (isFlattenedParameterGroup(objectField)) {
                dslResolver.resolve(objectType).ifPresent(objectDsl -> objectType.getFields().forEach(field -> parseField(objectType, objectDsl, field, parametersRole)));
                return;
            }
            if (parseAsContent(isContent, objectType)) {
                return;
            }
            DslElementSyntax dsl = fieldDsl.get();
            if (!parsingContext.isRegistered(dsl.getElementName(), dsl.getPrefix())) {
                parsingContext.registerObjectType(dsl.getElementName(), dsl.getPrefix(), type);
                parseObjectParameter(fieldName, fieldName, objectType, defaultValue, expressionSupport, false, acceptsReferences, dsl, emptySet());
            } else {
                parseObject(fieldName, fieldName, objectType, defaultValue, expressionSupport, false, acceptsReferences, dsl, emptySet());
            }
        }

        @Override
        public void visitArrayType(ArrayType arrayType) {
            if (!parseAsContent(isContent, arrayType)) {
                parseCollectionParameter(fieldName, fieldName, arrayType, defaultValue, expressionSupport, false, fieldDsl.get(), emptySet());
            }
        }

        private boolean parseAsContent(boolean isContent, MetadataType type) {
            if (isContent) {
                parseFromTextExpression(fieldName, fieldDsl.get(), () -> value -> resolverOf(fieldName, type, value, defaultValue, expressionSupport, false, emptySet(), false));
                return true;
            }
            return false;
        }
    });
}
Also used : InfrastructureTypeMapping.getNameMap(org.mule.runtime.module.extension.internal.loader.java.type.InfrastructureTypeMapping.getNameMap) ExpressionBasedParameterResolverValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionBasedParameterResolverValueResolver) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) KeyAttributeDefinitionPair(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair) InfrastructureParameterModelProperty(org.mule.runtime.extension.api.property.InfrastructureParameterModelProperty) BEHAVIOUR(org.mule.runtime.api.meta.model.parameter.ParameterRole.BEHAVIOUR) ParameterRole(org.mule.runtime.api.meta.model.parameter.ParameterRole) DateTimeType(org.mule.metadata.api.model.DateTimeType) RequiredParameterValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.RequiredParameterValueResolverWrapper) Builder.fromSimpleParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleParameter) QueryParameterModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.QueryParameterModelProperty) Instant.ofEpochMilli(java.time.Instant.ofEpochMilli) ArrayType(org.mule.metadata.api.model.ArrayType) Map(java.util.Map) NestableElementModelVisitor(org.mule.runtime.api.meta.model.nested.NestableElementModelVisitor) ExpressionTypedValueValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ModelProperty(org.mule.runtime.api.meta.model.ModelProperty) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ExtensionModelUtils.isContent(org.mule.runtime.extension.api.util.ExtensionModelUtils.isContent) SchedulingStrategyParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.SchedulingStrategyParsingDelegate) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) IntrospectionUtils.isTargetParameter(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isTargetParameter) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) DateType(org.mule.metadata.api.model.DateType) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ZoneId(java.time.ZoneId) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) DefaultValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.DefaultValueResolverParsingDelegate) DateTimeParseException(java.time.format.DateTimeParseException) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) StringType(org.mule.metadata.api.model.StringType) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) IntrospectionUtils.getContainerName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getContainerName) ParameterResolverValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.ParameterResolverValueResolverWrapper) DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) StackedTypesModelProperty.getStackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty.getStackedTypesModelProperty) NativeQueryParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver) MetadataTypeUtils.getDefaultValue(org.mule.metadata.api.utils.MetadataTypeUtils.getDefaultValue) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) StackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty) LocalDateTime(java.time.LocalDateTime) Builder.fromChildMapConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildMapConfiguration) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) Supplier(java.util.function.Supplier) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) ArrayList(java.util.ArrayList) TypeSafeValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeValueResolverWrapper) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) ExtensionMetadataTypeUtils.getExpressionSupport(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getExpressionSupport) TypedInlineParameterGroupParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.TypedInlineParameterGroupParser) MediaTypeValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.MediaTypeValueResolverParsingDelegate) ConversionService(org.springframework.core.convert.ConversionService) TypeDefinition.fromType(org.mule.runtime.dsl.api.component.TypeDefinition.fromType) MuleExtensionUtils.isExpression(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.isExpression) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ParsingDelegate) Builder.fromMultipleDefinitions(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromMultipleDefinitions) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Reference(org.mule.runtime.api.util.Reference) DefaultObjectParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.DefaultObjectParsingDelegate) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) JavaTypeUtils.getType(org.mule.metadata.java.api.utils.JavaTypeUtils.getType) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) TemplateParser(org.mule.runtime.core.privileged.util.TemplateParser) IntrospectionUtils.getMemberName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getMemberName) Date(java.util.Date) Builder.fromChildConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildConfiguration) TypeConverter(org.mule.runtime.dsl.api.component.TypeConverter) IntrospectionUtils.isLiteral(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isLiteral) TypeDefinition.fromMapEntryType(org.mule.runtime.dsl.api.component.TypeDefinition.fromMapEntryType) ProcessorChainValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ProcessorChainValueResolver) IntrospectionUtils.isTypedValue(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isTypedValue) TypedValueValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueValueResolverWrapper) PoolingProfile(org.mule.runtime.api.config.PoolingProfile) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) Builder.fromChildCollectionConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildCollectionConfiguration) ISODateTimeFormat(org.joda.time.format.ISODateTimeFormat) ObjectParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ObjectParsingDelegate) Collection(java.util.Collection) REQUIRED(org.mule.runtime.api.meta.ExpressionSupport.REQUIRED) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) String.format(java.lang.String.format) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) CharsetValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.CharsetValueResolverParsingDelegate) TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) RetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate) TypeSafeExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver) KeyAttributeDefinitionPair.newBuilder(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair.newBuilder) Builder.fromSimpleReferenceParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleReferenceParameter) HashMap(java.util.HashMap) Processor(org.mule.runtime.core.api.processor.Processor) Builder.fromFixedValue(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromFixedValue) ConcurrentMap(java.util.concurrent.ConcurrentMap) ValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ValueResolverParsingDelegate) HashSet(java.util.HashSet) ExtensionMetadataTypeUtils.isFlattenedParameterGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isFlattenedParameterGroup) ImmutableList(com.google.common.collect.ImmutableList) Literal(org.mule.runtime.extension.api.runtime.parameter.Literal) BasicTypeMetadataVisitor(org.mule.metadata.api.visitor.BasicTypeMetadataVisitor) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) ExclusiveOptionalModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ExclusiveOptionalModelProperty) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) NameUtils.hyphenize(org.mule.runtime.extension.api.util.NameUtils.hyphenize) IntrospectionUtils.isParameterResolver(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isParameterResolver) ExpressionSupport(org.mule.runtime.api.meta.ExpressionSupport) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) DateTime(org.joda.time.DateTime) AttributeDefinition(org.mule.runtime.dsl.api.component.AttributeDefinition) AnonymousInlineParameterGroupParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.AnonymousInlineParameterGroupParser) Collectors.toList(java.util.stream.Collectors.toList) ExtensionMetadataTypeUtils(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils) RouteComponentParser(org.mule.runtime.module.extension.internal.config.dsl.construct.RouteComponentParser) FixedTypeParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.FixedTypeParsingDelegate) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) TopLevelParameterObjectFactory(org.mule.runtime.module.extension.internal.config.dsl.parameter.TopLevelParameterObjectFactory) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) StaticLiteralValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver) StringType(org.mule.metadata.api.model.StringType) MetadataType(org.mule.metadata.api.model.MetadataType) ExtensionMetadataTypeUtils.getExpressionSupport(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getExpressionSupport) ExpressionSupport(org.mule.runtime.api.meta.ExpressionSupport) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)

Example 3 with ArrayType

use of org.mule.metadata.api.model.ArrayType in project mule by mulesoft.

the class DefaultExtensionBuildingDefinitionProvider method registerTopLevelParameter.

private void registerTopLevelParameter(final MetadataType parameterType, Builder definitionBuilder, ClassLoader extensionClassLoader, DslSyntaxResolver dslSyntaxResolver, ExtensionParsingContext parsingContext, ReflectionCache reflectionCache) {
    Optional<DslElementSyntax> dslElement = dslSyntaxResolver.resolve(parameterType);
    if (!dslElement.isPresent() || parsingContext.isRegistered(dslElement.get().getElementName(), dslElement.get().getPrefix()) || !IntrospectionUtils.isInstantiable(parameterType, reflectionCache)) {
        return;
    }
    parameterType.accept(new MetadataTypeVisitor() {

        @Override
        public void visitObject(ObjectType objectType) {
            DslElementSyntax pojoDsl = dslElement.get();
            if (pojoDsl.supportsTopLevelDeclaration() || (pojoDsl.supportsChildDeclaration() && pojoDsl.isWrapped()) || getSubstitutionGroup(objectType).isPresent() || parsingContext.getAllSubTypes().contains(objectType)) {
                parseWith(new ObjectTypeParameterParser(definitionBuilder, objectType, extensionClassLoader, dslSyntaxResolver, parsingContext));
            }
            registerSubTypes(objectType, definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
        }

        @Override
        public void visitArrayType(ArrayType arrayType) {
            registerTopLevelParameter(arrayType.getType(), definitionBuilder, extensionClassLoader, dslSyntaxResolver, parsingContext, reflectionCache);
        }

        @Override
        public void visitUnion(UnionType unionType) {
            unionType.getTypes().forEach(type -> type.accept(this));
        }
    });
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) ComponentBuildingDefinitionProvider(org.mule.runtime.dsl.api.component.ComponentBuildingDefinitionProvider) IntrospectionUtils(org.mule.runtime.module.extension.internal.util.IntrospectionUtils) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ArrayType(org.mule.metadata.api.model.ArrayType) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) UnionType(org.mule.metadata.api.model.UnionType) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) Preconditions.checkState(org.mule.runtime.api.util.Preconditions.checkState) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) OperationDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.operation.OperationDefinitionParser) ObjectType(org.mule.metadata.api.model.ObjectType) ConstructDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.construct.ConstructDefinitionParser) ConfigurationDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.config.ConfigurationDefinitionParser) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ExtensionMetadataTypeUtils.getSubstitutionGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getSubstitutionGroup) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) Stream(java.util.stream.Stream) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) SourceDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.source.SourceDefinitionParser) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) Optional(java.util.Optional) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) ConnectionProviderDefinitionParser(org.mule.runtime.module.extension.internal.config.dsl.connection.ConnectionProviderDefinitionParser) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) MuleExtensionUtils.getClassLoader(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.getClassLoader) ComponentLocationVisitor(org.mule.runtime.config.internal.dsl.model.ComponentLocationVisitor) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) CustomBuildingDefinitionProviderModelProperty(org.mule.runtime.core.internal.extension.CustomBuildingDefinitionProviderModelProperty) ImmutableList(com.google.common.collect.ImmutableList) ExtensionBuildingDefinitionProvider(org.mule.runtime.module.extension.internal.config.ExtensionBuildingDefinitionProvider) ClassUtils.withContextClassLoader(org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader) LinkedList(java.util.LinkedList) ModuleOperationMessageProcessorChainBuilder(org.mule.runtime.core.internal.processor.chain.ModuleOperationMessageProcessorChainBuilder) TypeDefinition.fromType(org.mule.runtime.dsl.api.component.TypeDefinition.fromType) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) XmlExtensionModelProperty(org.mule.runtime.extension.api.property.XmlExtensionModelProperty) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) ObjectType(org.mule.metadata.api.model.ObjectType) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) UnionType(org.mule.metadata.api.model.UnionType) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor)

Example 4 with ArrayType

use of org.mule.metadata.api.model.ArrayType in project mule by mulesoft.

the class ExtensionDefinitionParser method parseParameters.

/**
 * Parsers the given {@code parameters} and generates matching definitions
 *
 * @param parameters a list of {@link ParameterModel}
 */
protected void parseParameters(List<ParameterModel> parameters) {
    parameters.forEach(parameter -> {
        final DslElementSyntax paramDsl = dslResolver.resolve(parameter);
        final boolean isContent = isContent(parameter);
        parameter.getType().accept(new MetadataTypeVisitor() {

            @Override
            protected void defaultVisit(MetadataType metadataType) {
                if (!parseAsContent(metadataType)) {
                    parseAttributeParameter(parameter);
                }
            }

            @Override
            public void visitString(StringType stringType) {
                if (paramDsl.supportsChildDeclaration()) {
                    parseFromTextExpression(parameter, paramDsl, () -> {
                        Optional<QueryParameterModelProperty> query = parameter.getModelProperty(QueryParameterModelProperty.class);
                        return value -> {
                            ValueResolver<String> resolver = resolverOf(parameter.getName(), stringType, value, parameter.getDefaultValue(), parameter.getExpressionSupport(), parameter.isRequired(), parameter.getModelProperties(), acceptsReferences(parameter));
                            return query.map(p -> (ValueResolver<String>) new NativeQueryParameterValueResolver(resolver, p.getQueryTranslator())).orElse(resolver);
                        };
                    });
                } else {
                    defaultVisit(stringType);
                }
            }

            @Override
            public void visitObject(ObjectType objectType) {
                if (parseAsContent(objectType)) {
                    return;
                }
                if (isMap(objectType)) {
                    parseMapParameters(parameter, objectType, paramDsl);
                    return;
                }
                if (!parsingContext.isRegistered(paramDsl.getElementName(), paramDsl.getPrefix())) {
                    if (!paramDsl.supportsTopLevelDeclaration() && paramDsl.supportsChildDeclaration()) {
                        parsingContext.registerObjectType(paramDsl.getElementName(), paramDsl.getPrefix(), objectType);
                    }
                    parseObjectParameter(parameter, paramDsl);
                } else {
                    parseObject(getKey(parameter), parameter.getName(), objectType, parameter.getDefaultValue(), parameter.getExpressionSupport(), parameter.isRequired(), acceptsReferences(parameter), paramDsl, parameter.getModelProperties());
                }
            }

            @Override
            public void visitArrayType(ArrayType arrayType) {
                if (!parseAsContent(arrayType)) {
                    parseCollectionParameter(parameter, arrayType, paramDsl);
                }
            }

            private boolean parseAsContent(MetadataType type) {
                if (isContent) {
                    parseFromTextExpression(parameter, paramDsl, () -> value -> resolverOf(parameter.getName(), type, value, parameter.getDefaultValue(), parameter.getExpressionSupport(), parameter.isRequired(), parameter.getModelProperties(), acceptsReferences(parameter)));
                    return true;
                }
                return false;
            }
        });
    });
}
Also used : InfrastructureTypeMapping.getNameMap(org.mule.runtime.module.extension.internal.loader.java.type.InfrastructureTypeMapping.getNameMap) ExpressionBasedParameterResolverValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionBasedParameterResolverValueResolver) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) KeyAttributeDefinitionPair(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair) InfrastructureParameterModelProperty(org.mule.runtime.extension.api.property.InfrastructureParameterModelProperty) BEHAVIOUR(org.mule.runtime.api.meta.model.parameter.ParameterRole.BEHAVIOUR) ParameterRole(org.mule.runtime.api.meta.model.parameter.ParameterRole) DateTimeType(org.mule.metadata.api.model.DateTimeType) RequiredParameterValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.RequiredParameterValueResolverWrapper) Builder.fromSimpleParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleParameter) QueryParameterModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.QueryParameterModelProperty) Instant.ofEpochMilli(java.time.Instant.ofEpochMilli) ArrayType(org.mule.metadata.api.model.ArrayType) Map(java.util.Map) NestableElementModelVisitor(org.mule.runtime.api.meta.model.nested.NestableElementModelVisitor) ExpressionTypedValueValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ModelProperty(org.mule.runtime.api.meta.model.ModelProperty) NestableElementModel(org.mule.runtime.api.meta.model.nested.NestableElementModel) ExtensionModelUtils.isContent(org.mule.runtime.extension.api.util.ExtensionModelUtils.isContent) SchedulingStrategyParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.SchedulingStrategyParsingDelegate) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) IntrospectionUtils.isTargetParameter(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isTargetParameter) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) DateType(org.mule.metadata.api.model.DateType) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ZoneId(java.time.ZoneId) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) DefaultValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.DefaultValueResolverParsingDelegate) DateTimeParseException(java.time.format.DateTimeParseException) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) StringType(org.mule.metadata.api.model.StringType) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) IntrospectionUtils.getContainerName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getContainerName) ParameterResolverValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.ParameterResolverValueResolverWrapper) DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) StackedTypesModelProperty.getStackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty.getStackedTypesModelProperty) NativeQueryParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver) MetadataTypeUtils.getDefaultValue(org.mule.metadata.api.utils.MetadataTypeUtils.getDefaultValue) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) StackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty) LocalDateTime(java.time.LocalDateTime) Builder.fromChildMapConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildMapConfiguration) VALUE_ATTRIBUTE_NAME(org.mule.runtime.internal.dsl.DslConstants.VALUE_ATTRIBUTE_NAME) Supplier(java.util.function.Supplier) ObjectTypeParameterParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.ObjectTypeParameterParser) ArrayList(java.util.ArrayList) TypeSafeValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeValueResolverWrapper) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) ExtensionMetadataTypeUtils.getExpressionSupport(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getExpressionSupport) TypedInlineParameterGroupParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.TypedInlineParameterGroupParser) MediaTypeValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.MediaTypeValueResolverParsingDelegate) ConversionService(org.springframework.core.convert.ConversionService) TypeDefinition.fromType(org.mule.runtime.dsl.api.component.TypeDefinition.fromType) MuleExtensionUtils.isExpression(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.isExpression) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ParsingDelegate) Builder.fromMultipleDefinitions(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromMultipleDefinitions) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Reference(org.mule.runtime.api.util.Reference) DefaultObjectParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.DefaultObjectParsingDelegate) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) JavaTypeUtils.getType(org.mule.metadata.java.api.utils.JavaTypeUtils.getType) ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) TemplateParser(org.mule.runtime.core.privileged.util.TemplateParser) IntrospectionUtils.getMemberName(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getMemberName) Date(java.util.Date) Builder.fromChildConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildConfiguration) TypeConverter(org.mule.runtime.dsl.api.component.TypeConverter) IntrospectionUtils.isLiteral(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isLiteral) TypeDefinition.fromMapEntryType(org.mule.runtime.dsl.api.component.TypeDefinition.fromMapEntryType) ProcessorChainValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ProcessorChainValueResolver) IntrospectionUtils.isTypedValue(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isTypedValue) TypedValueValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueValueResolverWrapper) PoolingProfile(org.mule.runtime.api.config.PoolingProfile) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) Builder.fromChildCollectionConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildCollectionConfiguration) ISODateTimeFormat(org.joda.time.format.ISODateTimeFormat) ObjectParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ObjectParsingDelegate) Collection(java.util.Collection) REQUIRED(org.mule.runtime.api.meta.ExpressionSupport.REQUIRED) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) String.format(java.lang.String.format) NestedRouteModel(org.mule.runtime.api.meta.model.nested.NestedRouteModel) List(java.util.List) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Builder(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition.Builder) CharsetValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.CharsetValueResolverParsingDelegate) TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) RetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate) TypeSafeExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver) KeyAttributeDefinitionPair.newBuilder(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair.newBuilder) Builder.fromSimpleReferenceParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleReferenceParameter) HashMap(java.util.HashMap) Processor(org.mule.runtime.core.api.processor.Processor) Builder.fromFixedValue(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromFixedValue) ConcurrentMap(java.util.concurrent.ConcurrentMap) ValueResolverParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.ValueResolverParsingDelegate) HashSet(java.util.HashSet) ExtensionMetadataTypeUtils.isFlattenedParameterGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isFlattenedParameterGroup) ImmutableList(com.google.common.collect.ImmutableList) Literal(org.mule.runtime.extension.api.runtime.parameter.Literal) BasicTypeMetadataVisitor(org.mule.metadata.api.visitor.BasicTypeMetadataVisitor) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) ExclusiveOptionalModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ExclusiveOptionalModelProperty) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) NameUtils.hyphenize(org.mule.runtime.extension.api.util.NameUtils.hyphenize) IntrospectionUtils.isParameterResolver(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isParameterResolver) ExpressionSupport(org.mule.runtime.api.meta.ExpressionSupport) NestedChainModel(org.mule.runtime.api.meta.model.nested.NestedChainModel) DateTime(org.joda.time.DateTime) AttributeDefinition(org.mule.runtime.dsl.api.component.AttributeDefinition) AnonymousInlineParameterGroupParser(org.mule.runtime.module.extension.internal.config.dsl.parameter.AnonymousInlineParameterGroupParser) Collectors.toList(java.util.stream.Collectors.toList) ExtensionMetadataTypeUtils(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils) RouteComponentParser(org.mule.runtime.module.extension.internal.config.dsl.construct.RouteComponentParser) FixedTypeParsingDelegate(org.mule.runtime.module.extension.internal.config.dsl.object.FixedTypeParsingDelegate) NestedComponentModel(org.mule.runtime.api.meta.model.nested.NestedComponentModel) TopLevelParameterObjectFactory(org.mule.runtime.module.extension.internal.config.dsl.parameter.TopLevelParameterObjectFactory) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) StaticLiteralValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver) QueryParameterModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.QueryParameterModelProperty) Optional(java.util.Optional) StringType(org.mule.metadata.api.model.StringType) MetadataType(org.mule.metadata.api.model.MetadataType) NativeQueryParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) ExpressionBasedParameterResolverValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionBasedParameterResolverValueResolver) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) ExpressionTypedValueValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver) NativeQueryParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ProcessorChainValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ProcessorChainValueResolver) TypeSafeExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver) StaticLiteralValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)

Example 5 with ArrayType

use of org.mule.metadata.api.model.ArrayType in project mule by mulesoft.

the class QueryMetadataTestCase method getDsqlQueryAutomaticGeneratedOutputMetadata.

@Test
public void getDsqlQueryAutomaticGeneratedOutputMetadata() throws Exception {
    location = QUERY_LOCATION;
    MetadataKey dsqlKey = newKey(DSQL_QUERY).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(dsqlKey);
    assertThat(entityMetadata.isSuccess(), is(true));
    MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType();
    assertThat(generatedType, is(instanceOf(ArrayType.class)));
    assertCircleType((ObjectType) ((ArrayType) generatedType).getType());
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) ExtensionsTestUtils.toMetadataType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType) MetadataType(org.mule.metadata.api.model.MetadataType) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Aggregations

ArrayType (org.mule.metadata.api.model.ArrayType)26 MetadataType (org.mule.metadata.api.model.MetadataType)25 ObjectType (org.mule.metadata.api.model.ObjectType)20 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)17 Optional (java.util.Optional)14 ObjectFieldType (org.mule.metadata.api.model.ObjectFieldType)13 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)13 String.format (java.lang.String.format)12 List (java.util.List)12 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)12 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)12 Reference (org.mule.runtime.api.util.Reference)12 Map (java.util.Map)11 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)11 Set (java.util.Set)10 Collectors.toList (java.util.stream.Collectors.toList)10 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)10 StringType (org.mule.metadata.api.model.StringType)9 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)9 ExtensionMetadataTypeUtils.isMap (org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap)9