Search in sources :

Example 6 with HasSourceModels

use of org.mule.runtime.api.meta.model.source.HasSourceModels in project mule by mulesoft.

the class MetadataComponentModelValidator method validate.

@Override
public void validate(ExtensionModel extensionModel, ProblemsReporter problemsReporter) {
    // TODO - MULE-14397 - Improve Dynamic Metadata Enricher to enrich without requiring Classes
    // This is skipped if the extension is loaded with java, but it doesn't have classes which means AST Mode
    Optional<ExtensionTypeDescriptorModelProperty> property = extensionModel.getModelProperty(ExtensionTypeDescriptorModelProperty.class);
    if (property.isPresent()) {
        if (!property.get().getType().getDeclaringClass().isPresent()) {
            return;
        }
    }
    final Table<String, String, Class<?>> names = HashBasedTable.create();
    new ExtensionWalker() {

        @Override
        public void onOperation(HasOperationModels owner, OperationModel model) {
            validateComponent(model);
        }

        @Override
        public void onSource(HasSourceModels owner, SourceModel model) {
            validateComponent(model);
        }

        private void validateComponent(ConnectableComponentModel model) {
            validateMetadataReturnType(extensionModel, model, problemsReporter);
            MetadataResolverFactory resolverFactory = MuleExtensionUtils.getMetadataResolverFactory(model);
            validateMetadataOutputAttributes(model, resolverFactory, problemsReporter);
            validateMetadataKeyId(model, resolverFactory, problemsReporter);
            validateCategoriesInScope(model, resolverFactory, problemsReporter);
            validateResolversName(model, resolverFactory, names, problemsReporter);
        }
    }.walk(extensionModel);
}
Also used : HasOperationModels(org.mule.runtime.api.meta.model.operation.HasOperationModels) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) ConnectableComponentModel(org.mule.runtime.api.meta.model.ConnectableComponentModel) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) MetadataResolverFactory(org.mule.runtime.extension.api.metadata.MetadataResolverFactory) HasSourceModels(org.mule.runtime.api.meta.model.source.HasSourceModels) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Aggregations

HasOperationModels (org.mule.runtime.api.meta.model.operation.HasOperationModels)6 HasSourceModels (org.mule.runtime.api.meta.model.source.HasSourceModels)6 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)5 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)5 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)5 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)4 HasConstructModels (org.mule.runtime.api.meta.model.construct.HasConstructModels)4 List (java.util.List)3 Optional (java.util.Optional)3 ObjectType (org.mule.metadata.api.model.ObjectType)3 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)3 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)3 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)3 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)3 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)3 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)3 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)3 DslSyntaxResolver (org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver)3 String.format (java.lang.String.format)2 Map (java.util.Map)2