use of org.mule.runtime.api.metadata.descriptor.InputMetadataDescriptor in project mule by mulesoft.
the class MetadataInputDelegate method getInputMetadataDescriptors.
/**
* For each of the Component's {@link ParameterModel} creates the corresponding {@link TypeMetadataDescriptor} using only its
* static {@link MetadataType} and ignoring if any parameter has a dynamic type.
*
* @return A {@link List} containing a {@link MetadataResult} of {@link TypeMetadataDescriptor} for each input parameter using
* only its static {@link MetadataType} and ignoring if any parameter has a dynamic type.
*/
MetadataResult<InputMetadataDescriptor> getInputMetadataDescriptors(MetadataContext context, Object key) {
InputMetadataDescriptor.InputMetadataDescriptorBuilder input = InputMetadataDescriptor.builder();
List<MetadataResult<ParameterMetadataDescriptor>> results = new LinkedList<>();
for (ParameterModel parameter : component.getAllParameterModels()) {
MetadataResult<ParameterMetadataDescriptor> result = getParameterMetadataDescriptor(parameter, context, key);
input.withParameter(parameter.getName(), result.get());
results.add(result);
}
List<MetadataFailure> failures = results.stream().flatMap(e -> e.getFailures().stream()).collect(toList());
return failures.isEmpty() ? success(input.build()) : failure(input.build(), failures);
}
use of org.mule.runtime.api.metadata.descriptor.InputMetadataDescriptor in project mule by mulesoft.
the class MetadataMediator method getMetadata.
/**
* Resolves the {@link ComponentMetadataDescriptor} for the associated {@code context} using static and dynamic resolving of the
* Component parameters, attributes and output.
*
* @param context current {@link MetadataContext} that will be used by the {@link InputTypeResolver} and
* {@link OutputTypeResolver}
* @param keyValue {@link Object} resolved {@link MetadataKey} object
* @return Successful {@link MetadataResult} if the MetadataTypes are resolved without errors Failure {@link MetadataResult}
* when the Metadata retrieval of any element fails for any reason
*/
private MetadataResult<ComponentMetadataDescriptor<T>> getMetadata(MetadataContext context, Object keyValue, MetadataAttributes.MetadataAttributesBuilder attributesBuilder) {
MetadataResult<OutputMetadataDescriptor> output = outputDelegate.getOutputMetadataDescriptor(context, keyValue);
MetadataResult<InputMetadataDescriptor> input = inputDelegate.getInputMetadataDescriptors(context, keyValue);
if (output.isSuccess() && input.isSuccess()) {
MetadataAttributes metadataAttributes = getMetadataAttributes(attributesBuilder, outputDelegate, input.get());
T model = getTypedModel(input.get(), output.get());
return success(ComponentMetadataDescriptor.builder(model).withAttributes(metadataAttributes).build());
}
List<MetadataFailure> failures = ImmutableList.<MetadataFailure>builder().addAll(output.getFailures()).addAll(input.getFailures()).build();
return failure(ComponentMetadataDescriptor.builder(component).build(), failures);
}
Aggregations