summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorojasdubey <ojas.dubey@amdocs.com>2019-05-22 21:27:32 +0530
committerOren Kleks <orenkle@amdocs.com>2019-05-23 05:50:24 +0000
commite50b5687b62edbafa12bf3825b0441077c5a4820 (patch)
treebd834fb7659eb6d5d802dec6efa4538eda31589d /catalog-be/src/main/java/org
parentd00c7d99c6c2a8a4f7929db90a4de1e6bd6c3dfa (diff)
Fix service proxy node type4.0.0-ONAP1.4.1
Added properties, interfaces and requirements of the child service to the node type of proxy in the parent Change-Id: I23bb2ddce6cf621d166ffec3031148860d0f4321 Issue-ID: SDC-2313 Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java62
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java146
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java109
3 files changed, 260 insertions, 57 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
index bd797c970b..245eb59301 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
@@ -58,6 +58,7 @@ import static org.apache.commons.lang3.StringUtils.isNoneBlank;
public class CapabilityRequirementConverter {
private static final String NO_CAPABILITIES = "No Capabilities for node type";
+ private static final String NO_REQUIREMENTS = "No Requirements for node type";
private static CapabilityRequirementConverter instance;
private static final Logger logger = Logger.getLogger(CapabilityRequirementConverter.class);
private static final String PATH_DELIMITER = ".";
@@ -84,6 +85,18 @@ public class CapabilityRequirementConverter {
return c.getPreviousName();
}
+ public String buildRequirementNameForComponentInstance(Map<String,Component> componentCache,
+ ComponentInstance componentInstance,
+ RequirementDefinition r) {
+ String prefix = buildCapReqNamePrefix(componentInstance.getNormalizedName());
+ if (ComponentUtilities.isNotUpdatedCapReqName(prefix, r.getName(), r.getPreviousName())) {
+ return buildSubstitutedName(componentCache, r.getName(), r.getPreviousName(), r.getPath(), r.getOwnerId(),
+ componentInstance).left()
+ .orValue(r.getName());
+ }
+ return r.getPreviousName();
+ }
+
private String buildCapReqNamePrefix(String normalizedName) {
return normalizedName + PATH_DELIMITER;
}
@@ -187,6 +200,38 @@ public class CapabilityRequirementConverter {
return result;
}
+ /**
+ * Allows to convert requirements of a server proxy node type to tosca template requirements
+ * @param instanceProxy
+ * @return converted tosca template requirements
+ */
+ List<Map<String, ToscaRequirement>> convertProxyRequirements(Map<String, Component> componentCache,
+ ComponentInstance instanceProxy) {
+ Map<String, List<RequirementDefinition>> requirements = instanceProxy.getRequirements();
+ List<Map<String, ToscaRequirement>> toscaRequirements = new ArrayList<>();
+ if (requirements != null) {
+ requirements.entrySet().stream()
+ .flatMap(e -> e.getValue().stream())
+ .forEach(req -> {
+ ImmutablePair<String, ToscaRequirement> pair = convertProxyRequirement(
+ buildRequirementNameForComponentInstance(componentCache, instanceProxy, req), req);
+ Map<String, ToscaRequirement> requirement = new HashMap<>();
+ requirement.put(pair.left, pair.right);
+ toscaRequirements.add(requirement);
+ });
+ } else {
+ logger.debug(NO_REQUIREMENTS);
+ }
+
+ return toscaRequirements;
+ }
+
+ private ImmutablePair<String, ToscaRequirement> convertProxyRequirement(String requirementName,
+ RequirementDefinition r) {
+ ToscaRequirement toscaRequirement = createToscaRequirement(r);
+ return new ImmutablePair<>(requirementName, toscaRequirement);
+ }
+
private List<Map<String, ToscaRequirement>> convertRequirementsAsList(Map<String, Component> componentsCache, Component component) {
Map<String, List<RequirementDefinition>> requirements = component.getRequirements();
List<Map<String, ToscaRequirement>> toscaRequirements = new ArrayList<>();
@@ -202,7 +247,7 @@ public class CapabilityRequirementConverter {
logger.debug("Finish convert Requirements for node type");
}
} else {
- logger.debug("No Requirements for node type");
+ logger.debug(NO_REQUIREMENTS);
}
return toscaRequirements;
}
@@ -384,6 +429,11 @@ public class CapabilityRequirementConverter {
name = buildReqNamePerOwnerByPath(componentsCache, component, r);
}
logger.debug("the requirement {} belongs to resource {} ", name, component.getUniqueId());
+ ToscaRequirement toscaRequirement = createToscaRequirement(r);
+ return new ImmutablePair<>(name, toscaRequirement);
+ }
+
+ private ToscaRequirement createToscaRequirement(RequirementDefinition r) {
ToscaRequirement toscaRequirement = new ToscaRequirement();
List<Object> occurrences = new ArrayList<>();
@@ -397,8 +447,7 @@ public class CapabilityRequirementConverter {
toscaRequirement.setNode(r.getNode());
toscaRequirement.setCapability(r.getCapability());
toscaRequirement.setRelationship(r.getRelationship());
-
- return new ImmutablePair<>(name, toscaRequirement);
+ return toscaRequirement;
}
/**
@@ -424,17 +473,16 @@ public class CapabilityRequirementConverter {
/**
* Allows to convert capabilities of a server proxy node type to tosca template capabilities
- * @param component
- * @param proxyComponent
* @param instanceProxy
* @param dataTypes
* @return
*/
- public Map<String, ToscaCapability> convertProxyCapabilities(Map<String, Component> componentCache, Component component, Component proxyComponent, ComponentInstance instanceProxy, Map<String, DataTypeDefinition> dataTypes) {
+ public Map<String, ToscaCapability> convertProxyCapabilities(Map<String, Component> componentCache,
+ ComponentInstance instanceProxy,
+ Map<String, DataTypeDefinition> dataTypes) {
Map<String, List<CapabilityDefinition>> capabilities = instanceProxy.getCapabilities();
Map<String, ToscaCapability> toscaCapabilities = new HashMap<>();
if (capabilities != null) {
- boolean isNodeType = ModelConverter.isAtomicComponent(component);
for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) {
entry.getValue()
.stream()
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index b6c2adb283..7ca25abe14 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -45,7 +45,6 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
import org.openecomp.sdc.be.model.tosca.converters.ToscaValueBaseConverter;
import org.openecomp.sdc.be.tosca.model.*;
import org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil;
@@ -76,9 +75,12 @@ import java.util.stream.Collectors;
import static org.apache.commons.collections.CollectionUtils.isEmpty;
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import static org.apache.commons.collections.MapUtils.isNotEmpty;
-import static org.apache.commons.lang.StringUtils.isNotEmpty;
import static org.openecomp.sdc.be.tosca.utils.InterfacesOperationsToscaUtil.addInterfaceDefinitionElement;
import static org.openecomp.sdc.be.tosca.utils.InterfacesOperationsToscaUtil.addInterfaceTypeElement;
+import static org.openecomp.sdc.be.tosca.utils.ToscaExportUtils.addInputsToProperties;
+import static org.openecomp.sdc.be.tosca.utils.ToscaExportUtils.getProxyNodeTypeInterfaces;
+import static org.openecomp.sdc.be.tosca.utils.ToscaExportUtils.getProxyNodeTypeProperties;
+import static org.openecomp.sdc.be.tosca.utils.ToscaExportUtils.resolvePropertyDefaultValueFromInput;
@org.springframework.stereotype.Component("tosca-export-handler")
public class ToscaExportHandler {
@@ -224,7 +226,8 @@ public class ToscaExportHandler {
}
toscaNode = importsRes.left().value().left;
Map<String, Component> componentCache = importsRes.left().value().right;
- Either<Map<String, ToscaNodeType>, ToscaError> nodeTypesMapEither = createProxyNodeTypes(componentCache , component );
+ Either<Map<String, ToscaNodeType>, ToscaError> nodeTypesMapEither = createProxyNodeTypes(componentCache,
+ component);
if (nodeTypesMapEither.isRight()) {
log.debug("Failed to fetch normative service proxy resource by tosca name, error {}",
nodeTypesMapEither.right().value());
@@ -235,6 +238,16 @@ public class ToscaExportHandler {
toscaNode.setNode_types(nodeTypesMap);
}
+ Either<Map<String, Object>, ToscaError> proxyInterfaceTypesEither = createProxyInterfaceTypes(component);
+ if (proxyInterfaceTypesEither.isRight()) {
+ log.debug("Failed to populate service proxy local interface types in tosca, error {}",
+ nodeTypesMapEither.right().value());
+ return Either.right(proxyInterfaceTypesEither.right().value());
+ }
+ Map<String, Object> proxyInterfaceTypes = proxyInterfaceTypesEither.left().value();
+ if (MapUtils.isNotEmpty(proxyInterfaceTypes)) {
+ toscaNode.setInterface_types(proxyInterfaceTypes);
+ }
Either<Map<String, DataTypeDefinition>, TitanOperationStatus> dataTypesEither = dataTypeCache.getAll();
if (dataTypesEither.isRight()) {
@@ -545,58 +558,25 @@ public class ToscaExportHandler {
List<InputDefinition> inputDef = component.getInputs();
Map<String, ToscaProperty> mergedProperties = new HashMap<>();
addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
- if (inputDef != null) {
- addInputsToProperties(dataTypes, inputDef, mergedProperties);
- }
+ addInputsToProperties(dataTypes, inputDef, mergedProperties);
if(CollectionUtils.isNotEmpty(component.getProperties())) {
List<PropertyDefinition> properties = component.getProperties();
- mergedProperties = properties.stream().collect(Collectors.toMap(
+ Map<String, ToscaProperty> convertedProperties = properties.stream().collect(Collectors.toMap(
PropertyDataDefinition::getName,
property -> propertyConvertor.convertProperty(dataTypes, property,
PropertyConvertor.PropertyType.PROPERTY)));
+ // merge component properties and inputs properties
+ mergedProperties.putAll(convertedProperties);
}
if (MapUtils.isNotEmpty(mergedProperties)) {
- if (Objects.nonNull(inputDef)) {
- resolveDefaultPropertyValue(inputDef, mergedProperties, dataTypes);
- }
+ resolvePropertyDefaultValueFromInput(inputDef, mergedProperties, dataTypes);
toscaNodeType.setProperties(mergedProperties);
}
// Extracted to method for code reuse
return convertReqCapAndTypeName(componentsCache, component, toscaNode, nodeTypes, toscaNodeType, dataTypes);
}
- private void resolveDefaultPropertyValue(List<InputDefinition> inputDef,
- Map<String, ToscaProperty> mergedProperties,
- Map<String, DataTypeDefinition> dataTypes) {
- for (Map.Entry<String, ToscaProperty> mergedPropertyEntry : mergedProperties.entrySet()) {
- ToscaProperty value = mergedPropertyEntry.getValue();
- if (Objects.nonNull(value) && value.getDefaultp() instanceof Map) {
- Map<String, String> valueAsMap = (Map<String, String>) value.getDefaultp();
- String inputName = valueAsMap.get(ToscaFunctions.GET_INPUT.getFunctionName());
- Optional<InputDefinition> matchedInputDefinition = inputDef.stream()
- .filter(componentInput -> componentInput.getName().equals(inputName))
- .findFirst();
- if (matchedInputDefinition.isPresent()) {
- InputDefinition matchedInput = matchedInputDefinition.get();
- Object resolvedDefaultValue = new PropertyConvertor().convertToToscaObject(matchedInput.getType(),
- matchedInput.getDefaultValue(), matchedInput.getSchemaType(), dataTypes, false);
- value.setDefaultp(resolvedDefaultValue);
- mergedProperties.put(mergedPropertyEntry.getKey(), value);
- }
- }
- }
- }
-
- private void addInputsToProperties(Map<String, DataTypeDefinition> dataTypes,
- List<InputDefinition> inputDef,
- Map<String, ToscaProperty> mergedProperties) {
- for(InputDefinition input : inputDef) {
- ToscaProperty property = propertyConvertor.convertProperty(dataTypes, input, PropertyConvertor.PropertyType.INPUT);
- mergedProperties.put(input.getName(), property);
- }
- }
-
private Either<ToscaTemplate, ToscaError> convertReqCapAndTypeName(Map<String, Component> componentsCache, Component component, ToscaTemplate toscaNode,
Map<String, ToscaNodeType> nodeTypes, ToscaNodeType toscaNodeType,
Map<String, DataTypeDefinition> dataTypes) {
@@ -908,7 +888,59 @@ public class ToscaExportHandler {
return toscaNodeType;
}
- private Either<Map<String, ToscaNodeType>, ToscaError> createProxyNodeTypes(Map<String, Component> componentCache ,Component container ) {
+ private Either<Map<String, Object>, ToscaError> createProxyInterfaceTypes(Component container) {
+
+ Map<String, Object> proxyInterfaceTypes = new HashMap<>();
+ Either<Map<String, Object>, ToscaError> res = Either.left(proxyInterfaceTypes);
+ List<ComponentInstance> componentInstances = container.getComponentInstances();
+ if (CollectionUtils.isEmpty(componentInstances)) {
+ return res;
+ }
+ Map<String, ComponentInstance> serviceProxyInstanceList = new HashMap<>();
+ componentInstances.stream()
+ .filter(this::isComponentOfTypeServiceProxy)
+ .forEach(inst -> serviceProxyInstanceList.put(inst.getToscaComponentName(), inst));
+ if (MapUtils.isEmpty(serviceProxyInstanceList)) {
+ return res;
+ }
+ for (Entry<String, ComponentInstance> entryProxy : serviceProxyInstanceList.entrySet()) {
+ Component serviceComponent;
+ ComponentParametersView componentParametersView = new ComponentParametersView();
+ componentParametersView.disableAll();
+ componentParametersView.setIgnoreInterfaces(false);
+ Either<Component, StorageOperationStatus> service = toscaOperationFacade
+ .getToscaElement(entryProxy.getValue().getSourceModelUid(), componentParametersView);
+ if (service.isRight()) {
+ log.debug("Failed to fetch original service component with id {} for instance {}",
+ entryProxy.getValue().getSourceModelUid(), entryProxy.getValue().getName());
+ return Either.right(ToscaError.GENERAL_ERROR);
+ } else {
+ serviceComponent = service.left().value();
+ }
+
+ Either<Map<String, InterfaceDefinition>, StorageOperationStatus> lifecycleTypeEither =
+ interfaceLifecycleOperation.getAllInterfaceLifecycleTypes();
+ if(lifecycleTypeEither.isRight()){
+ log.debug("Failed to retrieve global interface types :", lifecycleTypeEither.right().value());
+ return Either.right(ToscaError.GENERAL_ERROR);
+ }
+
+ List<String> allGlobalInterfaceTypes = lifecycleTypeEither.left().value().values().stream()
+ .map(InterfaceDataDefinition::getType)
+ .collect(Collectors.toList());
+ //Add interface types for local interfaces in the original service component for proxy
+ Map<String, Object> localInterfaceTypes = addInterfaceTypeElement(serviceComponent,
+ allGlobalInterfaceTypes);
+ if (MapUtils.isNotEmpty(localInterfaceTypes)) {
+ proxyInterfaceTypes.putAll(localInterfaceTypes);
+ }
+
+ }
+ return Either.left(proxyInterfaceTypes);
+ }
+
+ private Either<Map<String, ToscaNodeType>, ToscaError> createProxyNodeTypes(Map<String, Component> componentCache,
+ Component container) {
Map<String, ToscaNodeType> nodeTypesMap = new HashMap<>();
Either<Map<String, ToscaNodeType>, ToscaError> res = Either.left(nodeTypesMap);
@@ -931,9 +963,6 @@ public class ToscaExportHandler {
if (serviceProxyInstanceList.isEmpty()) {
return res;
}
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreCapabilities(false);
- filter.setIgnoreComponentInstances(false);
Either<Resource, StorageOperationStatus> serviceProxyOrigin = toscaOperationFacade
.getLatestByName("serviceProxy");
if (serviceProxyOrigin.isRight()) {
@@ -948,6 +977,10 @@ public class ToscaExportHandler {
ComponentParametersView componentParametersView = new ComponentParametersView();
componentParametersView.disableAll();
componentParametersView.setIgnoreCategories(false);
+ componentParametersView.setIgnoreProperties(false);
+ componentParametersView.setIgnoreInputs(false);
+ componentParametersView.setIgnoreInterfaces(false);
+ componentParametersView.setIgnoreRequirements(false);
Either<Component, StorageOperationStatus> service = toscaOperationFacade
.getToscaElement(entryProxy.getValue().getSourceModelUid(), componentParametersView);
if (service.isRight()) {
@@ -956,15 +989,16 @@ public class ToscaExportHandler {
serviceComponent = service.left().value();
}
- ToscaNodeType toscaNodeType = createProxyNodeType(componentCache , origComponent, serviceComponent, entryProxy.getValue());
+ ToscaNodeType toscaNodeType = createProxyNodeType(componentCache, origComponent, serviceComponent,
+ entryProxy.getValue());
nodeTypesMap.put(entryProxy.getKey(), toscaNodeType);
}
return Either.left(nodeTypesMap);
}
- private ToscaNodeType createProxyNodeType(Map<String, Component> componentCache , Component origComponent, Component proxyComponent,
- ComponentInstance instance) {
+ private ToscaNodeType createProxyNodeType(Map<String, Component> componentCache , Component origComponent,
+ Component proxyComponent, ComponentInstance instance) {
ToscaNodeType toscaNodeType = new ToscaNodeType();
String derivedFrom = ((Resource) origComponent).getToscaResourceName();
@@ -975,9 +1009,21 @@ public class ToscaExportHandler {
}
Map<String, DataTypeDefinition> dataTypes = dataTypesEither.left().value();
Map<String, ToscaCapability> capabilities = this.capabilityRequirementConverter
- .convertProxyCapabilities( componentCache ,origComponent, proxyComponent, instance, dataTypes);
+ .convertProxyCapabilities(componentCache, instance, dataTypes);
+
+ if (MapUtils.isNotEmpty(capabilities)) {
+ toscaNodeType.setCapabilities(capabilities);
+ }
+ List<Map<String, ToscaRequirement>> proxyNodeTypeRequirements = this.capabilityRequirementConverter
+ .convertProxyRequirements(componentCache, instance);
+ if (CollectionUtils.isNotEmpty(proxyNodeTypeRequirements)) {
+ toscaNodeType.setRequirements(proxyNodeTypeRequirements);
+ }
+ Optional<Map<String, ToscaProperty>> proxyProperties = getProxyNodeTypeProperties(proxyComponent, dataTypes);
+ proxyProperties.ifPresent(toscaNodeType::setProperties);
- toscaNodeType.setCapabilities(capabilities);
+ Optional<Map<String, Object>> proxyInterfaces = getProxyNodeTypeInterfaces(proxyComponent, dataTypes);
+ proxyInterfaces.ifPresent(toscaNodeType::setInterfaces);
return toscaNodeType;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java
new file mode 100644
index 0000000000..20e0698276
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2016-2019 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.tosca.utils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.be.tosca.PropertyConvertor;
+import org.openecomp.sdc.be.tosca.model.ToscaProperty;
+
+public class ToscaExportUtils {
+
+ private ToscaExportUtils() {
+ //Hiding implicit default constructor
+ }
+
+ public static Optional<Map<String, Object>> getProxyNodeTypeInterfaces(Component proxyComponent,
+ Map<String, DataTypeDefinition> dataTypes) {
+ if (Objects.isNull(proxyComponent) || MapUtils.isEmpty(proxyComponent.getInterfaces())) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(InterfacesOperationsToscaUtil
+ .getInterfacesMap(proxyComponent, null, proxyComponent.getInterfaces(), dataTypes, false, false));
+ }
+
+ public static 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()
+ .collect(Collectors.toMap(PropertyDataDefinition::getName,
+ property -> PropertyConvertor.getInstance().convertProperty(dataTypes, property,
+ PropertyConvertor.PropertyType.PROPERTY))));
+ }
+ resolvePropertyDefaultValueFromInput(proxyComponent.getInputs(), proxyProperties, dataTypes);
+
+ return MapUtils.isNotEmpty(proxyProperties) ? Optional.of(proxyProperties) : Optional.empty();
+ }
+
+
+ public static void resolvePropertyDefaultValueFromInput(List<InputDefinition> componentInputs,
+ Map<String, ToscaProperty> mergedProperties,
+ Map<String, DataTypeDefinition> dataTypes) {
+ if (MapUtils.isEmpty(mergedProperties) || CollectionUtils.isEmpty(componentInputs)) {
+ return;
+ }
+ for (Map.Entry<String, ToscaProperty> mergedPropertyEntry : mergedProperties.entrySet()) {
+ ToscaProperty value = mergedPropertyEntry.getValue();
+ if (Objects.nonNull(value) && value.getDefaultp() instanceof Map) {
+ Map<String, String> valueAsMap = (Map<String, String>) value.getDefaultp();
+ String inputName = valueAsMap.get(ToscaFunctions.GET_INPUT.getFunctionName());
+ Optional<InputDefinition> matchedInputDefinition = componentInputs.stream()
+ .filter(componentInput -> componentInput.getName().equals(inputName))
+ .findFirst();
+ if (matchedInputDefinition.isPresent()) {
+ InputDefinition matchedInput = matchedInputDefinition.get();
+ Object resolvedDefaultValue = new PropertyConvertor().convertToToscaObject(matchedInput.getType(),
+ matchedInput.getDefaultValue(), matchedInput.getSchemaType(), dataTypes, false);
+ value.setDefaultp(resolvedDefaultValue);
+ mergedProperties.put(mergedPropertyEntry.getKey(), value);
+ }
+ }
+ }
+ }
+
+ public static void addInputsToProperties(Map<String, DataTypeDefinition> dataTypes,
+ List<InputDefinition> componentInputs,
+ Map<String, ToscaProperty> mergedProperties) {
+ if (CollectionUtils.isEmpty(componentInputs)) {
+ return;
+ }
+ for(InputDefinition input : componentInputs) {
+ ToscaProperty property = new PropertyConvertor().convertProperty(dataTypes, input,
+ PropertyConvertor.PropertyType.INPUT);
+ mergedProperties.put(input.getName(), property);
+ }
+ }
+
+}