aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/SubInterfaceConsolidationDataHandler.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java79
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java7
3 files changed, 22 insertions, 76 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/SubInterfaceConsolidationDataHandler.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/SubInterfaceConsolidationDataHandler.java
index 6dc44f9758..d1b4148672 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/SubInterfaceConsolidationDataHandler.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/SubInterfaceConsolidationDataHandler.java
@@ -1,5 +1,4 @@
/*
-/*
* Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -80,7 +79,7 @@ public class SubInterfaceConsolidationDataHandler implements ConsolidationDataHa
throw new UnsupportedOperationException(
- "API removeParamNameFromAttrFuncList " + "not supported for SubInterfaceConsolidationDataHandler");
+ "API removeParamNameFromAttrFuncList doesn't supported for SubInterfaceConsolidationDataHandler");
}
@Override
@@ -190,12 +189,9 @@ public class SubInterfaceConsolidationDataHandler implements ConsolidationDataHa
if (MapUtils.isEmpty(resourceIdTranslatedResourceIdMap)) {
return Optional.empty();
}
- for (Map.Entry<String, String> entry : resourceIdTranslatedResourceIdMap.entrySet()) {
- if (entry.getValue().equals(parentPortNodeTemplateId)) {
- return Optional.of(entry.getKey());
- }
- }
- return Optional.empty();
+ return resourceIdTranslatedResourceIdMap.entrySet().stream()
+ .filter(entry -> entry.getValue().equals(parentPortNodeTemplateId))
+ .findFirst().map(Map.Entry::getKey);
}
private TranslateTo createTranslateTo(FunctionTranslator functionTranslator, String resourceId,
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
index 01e601738b..e7c32e195b 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
@@ -39,9 +39,9 @@ import org.openecomp.sdc.translator.services.heattotosca.impl.functiontranslatio
import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants.TRANS_MAPPING_DELIMITER_CHAR;
-/**
- * Utility class for consolidation data collection helper methods.
- */
+ /**
+ * Utility class for consolidation data collection helper methods.
+ */
public class ConsolidationDataUtil {
private static final String UNDERSCORE = "_";
@@ -195,24 +195,6 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants.
/**
* Checks if the current HEAT resource if of type compute.
*
- * @param heatOrchestrationTemplate the heat orchestration template
- * @param resourceId the resource id
- * @return true if the resource is of compute type and false otherwise
- */
- public static boolean isComputeResource(HeatOrchestrationTemplate heatOrchestrationTemplate,
- String resourceId) {
- String resourceType = heatOrchestrationTemplate.getResources().get(resourceId).getType();
- Map<String, ImplementationConfiguration> supportedComputeResources =
- TranslationContext.getSupportedConsolidationComputeResources();
- if (supportedComputeResources.containsKey(resourceType)) {
- return supportedComputeResources.get(resourceType).isEnable();
- }
- return false;
- }
-
- /**
- * Checks if the current HEAT resource if of type compute.
- *
* @param resource the resource
* @return true if the resource is of compute type and false otherwise
*/
@@ -229,24 +211,6 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants.
/**
* Checks if the current HEAT resource if of type port.
*
- * @param heatOrchestrationTemplate the heat orchestration template
- * @param resourceId the resource id
- * @return true if the resource is of port type and false otherwise
- */
- public static boolean isPortResource(HeatOrchestrationTemplate heatOrchestrationTemplate,
- String resourceId) {
- String resourceType = heatOrchestrationTemplate.getResources().get(resourceId).getType();
- Map<String, ImplementationConfiguration> supportedPortResources =
- TranslationContext.getSupportedConsolidationPortResources();
- if (supportedPortResources.containsKey(resourceType)) {
- return supportedPortResources.get(resourceType).isEnable();
- }
- return false;
- }
-
- /**
- * Checks if the current HEAT resource if of type port.
- *
* @param resource the resource
* @return true if the resource is of port type and false otherwise
*/
@@ -263,21 +227,6 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants.
/**
* Checks if the current HEAT resource if of type volume.
*
- * @param heatOrchestrationTemplate the heat orchestration template
- * @param resourceId the resource id
- * @return true if the resource is of volume type and false otherwise
- */
- public static boolean isVolumeResource(HeatOrchestrationTemplate heatOrchestrationTemplate,
- String resourceId) {
- String resourceType = heatOrchestrationTemplate.getResources().get(resourceId).getType();
- return resourceType.equals(HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource())
- || resourceType.equals(HeatResourcesTypes.CINDER_VOLUME_ATTACHMENT_RESOURCE_TYPE
- .getHeatResource());
- }
-
- /**
- * Checks if the current HEAT resource if of type volume.
- *
* @param resource the resource
* @return true if the resource is of volume type and false otherwise
*/
@@ -403,19 +352,19 @@ import static org.openecomp.sdc.translator.services.heattotosca.ConfigConstants.
}
private static String getToscaPropertyName(FunctionTranslator functionTranslator) {
- String toscaPropertyName = functionTranslator.getPropertyName();
HeatOrchestrationTemplate heatOrchestrationTemplate = functionTranslator.getHeatOrchestrationTemplate();
Resource resource = heatOrchestrationTemplate.getResources().get(functionTranslator.getResourceId());
- boolean isNestedResource = HeatToToscaUtil.isNestedResource(resource);
- if (!isNestedResource) {
- String heatPropertyName = toscaPropertyName;
- //For handling get_attr in inner levels for complex properties
- if (toscaPropertyName.contains(TRANS_MAPPING_DELIMITER_CHAR)) {
- heatPropertyName =
- toscaPropertyName.substring(0, toscaPropertyName.indexOf(TRANS_MAPPING_DELIMITER_CHAR));
- }
- toscaPropertyName = HeatToToscaUtil.getToscaPropertyName(functionTranslator.getContext(),
- resource.getType(), heatPropertyName);
+ String toscaPropertyName = functionTranslator.getPropertyName();
+ if (!HeatToToscaUtil.isNestedResource(resource)) {
+ return HeatToToscaUtil.getToscaPropertyName(functionTranslator.getContext(),
+ resource.getType(), getHeatPropertyName(toscaPropertyName));
+ }
+ return toscaPropertyName;
+ }
+
+ private static String getHeatPropertyName(String toscaPropertyName) {
+ if (toscaPropertyName.contains(TRANS_MAPPING_DELIMITER_CHAR)) {
+ return toscaPropertyName.substring(0, toscaPropertyName.indexOf(TRANS_MAPPING_DELIMITER_CHAR));
}
return toscaPropertyName;
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
index bd8b558f11..2d283d301a 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
@@ -652,9 +652,10 @@ public class HeatToToscaUtil {
Optional<String> nestedHeatFileName = HeatToToscaUtil.getNestedHeatFileName(resource);
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil().yamlToObject(
context.getFileContent(nestedHeatFileName.get()), HeatOrchestrationTemplate.class);
- if (Objects.nonNull(nestedHeatOrchestrationTemplate.getResources())) {
- for (String innerResourceId : nestedHeatOrchestrationTemplate.getResources().keySet()) {
- if (ConsolidationDataUtil.isComputeResource(nestedHeatOrchestrationTemplate, innerResourceId)) {
+ Map<String, Resource> resources = nestedHeatOrchestrationTemplate.getResources();
+ if (Objects.nonNull(resources)) {
+ for (Resource innerResource : resources.values()) {
+ if (ConsolidationDataUtil.isComputeResource(innerResource)) {
return true;
}
}