use of org.mule.runtime.api.metadata.MetadataKeyBuilder in project mule by mulesoft.
the class InvokeKeysResolver method buildServiceKey.
private MetadataKey buildServiceKey(ForwardingSoapClient connection, WebServiceDefinition ws) {
String serviceId = ws.getServiceId();
SoapMetadataResolver resolver = connection.getSoapClient(serviceId).getMetadataResolver();
MetadataKeyBuilder key = newKey(serviceId).withDisplayName(ws.getFriendlyName());
List<String> excludedOperations = ws.getExcludedOperations();
resolver.getAvailableOperations().stream().filter(ope -> !excludedOperations.contains(ope)).forEach(ope -> key.withChild(newKey(ope).withDisplayName(NameUtils.titleize(ope))));
return key.build();
}
use of org.mule.runtime.api.metadata.MetadataKeyBuilder in project mule by mulesoft.
the class MetadataKeyIdObjectResolver method reconstructKeyFromType.
/**
* Given a {@link Object} representing the resolved value for a {@link MetadataKey}, generates the {@link MetadataKey} object.
*
* @param resolvedKey
* @return {@link MetadataKey} reconstructed from the resolved object key
* @throws MetadataResolvingException
*/
MetadataKey reconstructKeyFromType(Object resolvedKey, ReflectionCache reflectionCache) throws MetadataResolvingException {
if (isKeyLess() || resolvedKey == null) {
return new NullMetadataKey();
}
if (keyParts.size() == 1) {
return newKey(valueOf(resolvedKey)).build();
}
MetadataKeyBuilder rootBuilder = null;
MetadataKeyBuilder childBuilder = null;
for (ParameterModel p : keyParts) {
try {
if (p.getModelProperty(DeclaringMemberModelProperty.class).isPresent()) {
MetadataKeyBuilder fieldBuilder = getKeyFromField(resolvedKey, p.getModelProperty(DeclaringMemberModelProperty.class).get(), reflectionCache);
if (rootBuilder == null) {
rootBuilder = fieldBuilder;
childBuilder = rootBuilder;
} else {
childBuilder.withChild(fieldBuilder);
childBuilder = fieldBuilder;
}
}
} catch (Exception e) {
throw new MetadataResolvingException("Could not construct Metadata Key part for parameter " + p.getName(), FailureCode.INVALID_METADATA_KEY, e);
}
}
return rootBuilder != null ? rootBuilder.build() : new NullMetadataKey();
}
use of org.mule.runtime.api.metadata.MetadataKeyBuilder in project mule by mulesoft.
the class MetadataKeysDelegate method cloneAndEnrichMetadataKey.
/**
* Given a {@link MetadataKey}, this is navigated recursively cloning each {@link MetadataKey} of the tree structure creating a
* {@link MultilevelMetadataKeyBuilder} and adding the partName of each {@link MetadataKey} found.
*
* @param key {@link MetadataKey} to be cloned and enriched
* @param partOrderMapping {@link Map} that contains the mapping of the name of each part of the {@link MetadataKey}
* @param level the current level of the part of the {@link MetadataKey} to be cloned and enriched
* @return a {@link MetadataKeyBuilder} with the cloned and enriched keys
*/
private MetadataKeyBuilder cloneAndEnrichMetadataKey(MetadataKey key, Map<Integer, ParameterModel> partOrderMapping, int level) {
final MetadataKeyBuilder keyBuilder = newKey(key.getId(), partOrderMapping.get(level).getName()).withDisplayName(key.getDisplayName());
key.getProperties().forEach(keyBuilder::withProperty);
key.getChilds().forEach(childKey -> keyBuilder.withChild(cloneAndEnrichMetadataKey(childKey, partOrderMapping, level + 1)));
return keyBuilder;
}
Aggregations