Search in sources :

Example 1 with ImmutableConstructModel

use of org.mule.runtime.extension.api.model.construct.ImmutableConstructModel in project mule by mulesoft.

the class MetadataMediator method getTypedModel.

/**
 * Returns a {@link ComponentModel} with its types resolved.
 *
 * @param inputMetadataDescriptor {@link InputMetadataDescriptor} describes the input parameters of the component
 * @param outputMetadataDescriptor {@link OutputMetadataDescriptor} describes the component output
 * @return model with its types resolved by the metadata resolution process
 */
private T getTypedModel(InputMetadataDescriptor inputMetadataDescriptor, OutputMetadataDescriptor outputMetadataDescriptor) {
    Reference<T> typedModel = new Reference<>();
    component.accept(new ComponentModelVisitor() {

        @Override
        public void visit(ConstructModel constructModel) {
            typedModel.set((T) new ImmutableConstructModel(constructModel.getName(), constructModel.getDescription(), resolveParameterGroupModelType(constructModel.getParameterGroupModels(), inputMetadataDescriptor.getAllParameters()), constructModel.getNestedComponents(), constructModel.allowsTopLevelDeclaration(), constructModel.getDisplayModel().orElse(null), constructModel.getErrorModels(), constructModel.getStereotype(), constructModel.getModelProperties()));
        }

        @Override
        public void visit(OperationModel operationModel) {
            OutputModel typedOutputModel = resolveOutputModelType(operationModel.getOutput(), outputMetadataDescriptor.getPayloadMetadata());
            OutputModel typedAttributesModel = resolveOutputModelType(operationModel.getOutputAttributes(), outputMetadataDescriptor.getAttributesMetadata());
            typedModel.set((T) new ImmutableOperationModel(operationModel.getName(), operationModel.getDescription(), resolveParameterGroupModelType(operationModel.getParameterGroupModels(), inputMetadataDescriptor.getAllParameters()), operationModel.getNestedComponents(), typedOutputModel, typedAttributesModel, operationModel.isBlocking(), operationModel.getExecutionType(), operationModel.requiresConnection(), operationModel.isTransactional(), operationModel.supportsStreaming(), operationModel.getDisplayModel().orElse(null), operationModel.getErrorModels(), operationModel.getStereotype(), operationModel.getModelProperties(), operationModel.getNotificationModels()));
        }

        @Override
        public void visit(SourceModel sourceModel) {
            OutputModel typedOutputModel = resolveOutputModelType(sourceModel.getOutput(), outputMetadataDescriptor.getPayloadMetadata());
            OutputModel typedAttributesModel = resolveOutputModelType(sourceModel.getOutputAttributes(), outputMetadataDescriptor.getAttributesMetadata());
            typedModel.set((T) new ImmutableSourceModel(sourceModel.getName(), sourceModel.getDescription(), sourceModel.hasResponse(), true, resolveParameterGroupModelType(sourceModel.getParameterGroupModels(), inputMetadataDescriptor.getAllParameters()), sourceModel.getNestedComponents(), typedOutputModel, typedAttributesModel, resolveSourceCallbackType(sourceModel.getSuccessCallback(), inputMetadataDescriptor.getAllParameters()), resolveSourceCallbackType(sourceModel.getErrorCallback(), inputMetadataDescriptor.getAllParameters()), resolveSourceCallbackType(sourceModel.getTerminateCallback(), inputMetadataDescriptor.getAllParameters()), sourceModel.requiresConnection(), sourceModel.isTransactional(), sourceModel.supportsStreaming(), sourceModel.getDisplayModel().orElse(null), sourceModel.getStereotype(), sourceModel.getErrorModels(), sourceModel.getModelProperties(), sourceModel.getNotificationModels()));
        }
    });
    return typedModel.get();
}
Also used : SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ImmutableSourceModel(org.mule.runtime.extension.api.model.source.ImmutableSourceModel) ConstructModel(org.mule.runtime.api.meta.model.construct.ConstructModel) ImmutableConstructModel(org.mule.runtime.extension.api.model.construct.ImmutableConstructModel) ImmutableOperationModel(org.mule.runtime.extension.api.model.operation.ImmutableOperationModel) ImmutableSourceModel(org.mule.runtime.extension.api.model.source.ImmutableSourceModel) Reference(org.mule.runtime.api.util.Reference) ComponentModelVisitor(org.mule.runtime.api.meta.model.ComponentModelVisitor) ImmutableConstructModel(org.mule.runtime.extension.api.model.construct.ImmutableConstructModel) ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) OutputModel(org.mule.runtime.api.meta.model.OutputModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) ImmutableOperationModel(org.mule.runtime.extension.api.model.operation.ImmutableOperationModel)

Aggregations

ComponentModelVisitor (org.mule.runtime.api.meta.model.ComponentModelVisitor)1 OutputModel (org.mule.runtime.api.meta.model.OutputModel)1 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)1 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)1 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)1 Reference (org.mule.runtime.api.util.Reference)1 ImmutableOutputModel (org.mule.runtime.extension.api.model.ImmutableOutputModel)1 ImmutableConstructModel (org.mule.runtime.extension.api.model.construct.ImmutableConstructModel)1 ImmutableOperationModel (org.mule.runtime.extension.api.model.operation.ImmutableOperationModel)1 ImmutableSourceModel (org.mule.runtime.extension.api.model.source.ImmutableSourceModel)1