Search in sources :

Example 1 with TypeKeysResolver

use of org.mule.runtime.api.metadata.resolving.TypeKeysResolver in project mule by mulesoft.

the class MetadataKeysDelegate method getMetadataKeys.

MetadataResult<MetadataKeysContainer> getMetadataKeys(MetadataContext context, Object partialKey, ReflectionCache reflectionCache) {
    final TypeKeysResolver keyResolver = resolverFactory.getKeyResolver();
    final String componentResolverName = keyResolver.getCategoryName();
    final MetadataKeysContainerBuilder keysContainer = MetadataKeysContainerBuilder.getInstance();
    if (keyParts.isEmpty()) {
        return success(keysContainer.add(componentResolverName, ImmutableSet.of(new NullMetadataKey())).build());
    }
    try {
        final Map<Integer, ParameterModel> partsByOrder = getPartOrderMapping(keyParts);
        Set<MetadataKey> metadataKeys;
        if (keyResolver instanceof PartialTypeKeysResolver && hasInitialLevel(partialKey, partsByOrder, reflectionCache)) {
            metadataKeys = singleton(((PartialTypeKeysResolver) keyResolver).resolveChilds(context, partialKey));
        } else {
            metadataKeys = keyResolver.getKeys(context);
        }
        final Set<MetadataKey> enrichedMetadataKeys = metadataKeys.stream().map(metadataKey -> cloneAndEnrichMetadataKey(metadataKey, partsByOrder)).map(MetadataKeyBuilder::build).collect(toSet());
        keysContainer.add(componentResolverName, enrichedMetadataKeys);
        return success(keysContainer.build());
    } catch (Exception e) {
        return failure(newFailure(e).onKeys());
    }
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) MetadataKeysContainerBuilder(org.mule.runtime.api.metadata.MetadataKeysContainerBuilder) PartialTypeKeysResolver(org.mule.runtime.api.metadata.resolving.PartialTypeKeysResolver) TypeKeysResolver(org.mule.runtime.api.metadata.resolving.TypeKeysResolver) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) PartialTypeKeysResolver(org.mule.runtime.api.metadata.resolving.PartialTypeKeysResolver)

Example 2 with TypeKeysResolver

use of org.mule.runtime.api.metadata.resolving.TypeKeysResolver in project mule by mulesoft.

the class ConfigurationProviderToolingAdapter method addComponentKeys.

private void addComponentKeys(List<? extends ComponentModel> components, MetadataContext metadataContext, MetadataKeysContainerBuilder keysBuilder) throws MetadataResolvingException, ConnectionException {
    for (ComponentModel component : components) {
        TypeKeysResolver keysResolver = getMetadataResolverFactory(component).getKeyResolver();
        String categoryName = keysResolver.getCategoryName();
        if (!NULL_CATEGORY_NAME.equals(categoryName) && !keysBuilder.containsCategory(categoryName)) {
            keysBuilder.add(categoryName, keysResolver.getKeys(metadataContext));
        }
    }
}
Also used : ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) TypeKeysResolver(org.mule.runtime.api.metadata.resolving.TypeKeysResolver)

Aggregations

TypeKeysResolver (org.mule.runtime.api.metadata.resolving.TypeKeysResolver)2 ComponentModel (org.mule.runtime.api.meta.model.ComponentModel)1 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)1 MetadataKey (org.mule.runtime.api.metadata.MetadataKey)1 MetadataKeysContainerBuilder (org.mule.runtime.api.metadata.MetadataKeysContainerBuilder)1 PartialTypeKeysResolver (org.mule.runtime.api.metadata.resolving.PartialTypeKeysResolver)1 NullMetadataKey (org.mule.runtime.extension.api.metadata.NullMetadataKey)1