- private Map<String, String[]> buildSubstitutionMappingPropertyMapping(final Component component) {
- if (component == null || CollectionUtils.isEmpty(component.getInputs())) {
- return Collections.emptyMap();
- }
- return component.getInputs().stream().filter(input -> input.isMappedToComponentProperty())
- .map(PropertyDataDefinition::getName)
- .collect(
- Collectors.toMap(
- inputName -> inputName,
- inputName -> new String[]{inputName},
- (inputName1, inputName2) -> inputName1)
- );
- }
-
- private Map<String, String[]> buildSubstitutionMappingAttributesMapping(final Component component) {
- if (component == null || CollectionUtils.isEmpty(component.getOutputs())) {
- return Collections.emptyMap();
- }
- return component.getOutputs().stream()
- .map(AttributeDataDefinition::getName)
- .collect(
- Collectors.toMap(
- outputName -> outputName,
- outputName -> new String[]{outputName},
- (outputName1, outputName2) -> outputName1)
- );
- }
-
- Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent,
- Map<String, DataTypeDefinition>
- dataTypes) {
- if (Objects.isNull(proxyComponent)) {
- return Optional.empty();
- }
- Map<String, ToscaProperty> proxyProperties = new HashMap<>();
- addInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyProperties);
- if (CollectionUtils.isNotEmpty(proxyComponent.getProperties())) {
- proxyProperties.putAll(proxyComponent.getProperties().stream()
- .map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition,
- proxyComponent.getInputs()))
- .collect(Collectors.toMap(PropertyDataDefinition::getName,
- property -> propertyConvertor.convertProperty(dataTypes, property,
- PropertyConvertor.PropertyType.PROPERTY))));
- }
- return MapUtils.isNotEmpty(proxyProperties) ? Optional.of(proxyProperties) : Optional.empty();
- }
-
- void addInputsToProperties(Map<String, DataTypeDefinition> dataTypes,
- List<InputDefinition> componentInputs,
- Map<String, ToscaProperty> mergedProperties) {
- if (CollectionUtils.isEmpty(componentInputs)) {
- return;
- }
- for (InputDefinition input : componentInputs) {
- ToscaProperty property = propertyConvertor.convertProperty(dataTypes, input,
- PropertyConvertor.PropertyType.INPUT);
- mergedProperties.put(input.getName(), property);
- }
- }
-
- Optional<Map<String, Object>> getProxyNodeTypeInterfaces(Component proxyComponent,
- Map<String, DataTypeDefinition> dataTypes) {
- if (Objects.isNull(proxyComponent) || MapUtils.isEmpty(proxyComponent.getInterfaces())) {
- return Optional.empty();
- }
- Map<String, InterfaceDefinition> proxyComponentInterfaces = proxyComponent.getInterfaces();
- //Unset artifact path for operation implementation for proxy node types as for operations with artifacts it is
- // always available in the proxy node template
- removeOperationImplementationForProxyNodeType(proxyComponentInterfaces);
- return Optional.ofNullable(interfacesOperationsConverter
- .getInterfacesMap(proxyComponent, null, proxyComponentInterfaces, dataTypes,
- false, false));
- }
-
- private static void removeOperationImplementationForProxyNodeType(
- Map<String, InterfaceDefinition> proxyComponentInterfaces) {
- if (MapUtils.isEmpty(proxyComponentInterfaces)) {
- return;
- }
- proxyComponentInterfaces.values().stream().map(InterfaceDataDefinition::getOperations)
- .filter(MapUtils::isNotEmpty)
- .forEach(operations -> operations.values().forEach(operation -> operation.setImplementation(null)));
- }