summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-07-12 09:10:40 +0100
committerMichaelMorris <michael.morris@est.tech>2023-07-12 09:42:18 +0100
commit6791c53443a13a6c3d37b9351480365ee80b4c31 (patch)
tree1545678a55a32298d6c7763ac0bf08bd633d7a74
parentb9c6259398063d53d648db7b50e5d2b9358a2ace (diff)
Support occurrences and instance count in import
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4566 Change-Id: I884082253e3b3a9c20da68ab064f4ae6528f6fe0
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java22
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java3
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java3
4 files changed, 27 insertions, 4 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index b90e3bb0b8..7c031a29e7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -107,13 +107,10 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyFilterConstraintDataDefin
import org.openecomp.sdc.be.datatypes.elements.SubPropertyToscaFunction;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
-import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
-import org.openecomp.sdc.be.datatypes.enums.PropertySource;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -825,6 +822,7 @@ public class YamlTemplateParsingHandler {
setDirectives(nodeTemplateInfo, nodeTemplateJsonMap);
setNodeFilter(nodeTemplateInfo, nodeTemplateJsonMap);
setSubstitutions(substitutionMappings, nodeTemplateInfo);
+ setOccurrencesAndInstanceCount(nodeTemplateInfo, nodeTemplateJsonMap);
} else {
rollbackWithException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE);
}
@@ -932,6 +930,24 @@ public class YamlTemplateParsingHandler {
.createNodeFilterData(nodeTemplateJsonMap.get(TypeUtils.ToscaTagNamesEnum.NODE_FILTER.getElementName())));
}
}
+
+ @SuppressWarnings("unchecked")
+ private void setOccurrencesAndInstanceCount(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
+ if (nodeTemplateJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
+ List<Object> occurrences = (List<Object>) nodeTemplateJsonMap.get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
+ nodeTemplateInfo.setMinOccurrences(occurrences.get(0).toString());
+ nodeTemplateInfo.setMaxOccurrences(occurrences.get(1).toString());
+ }
+ if (nodeTemplateJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.INSTANCE_COUNT.getElementName())) {
+ Object instanceCount = nodeTemplateJsonMap.get(TypeUtils.ToscaTagNamesEnum.INSTANCE_COUNT.getElementName());
+ if (instanceCount instanceof Map) {
+ String instanceCountAsString = "{get_input:" + (String)((Map)instanceCount).get("get_input") + "}";
+ nodeTemplateInfo.setInstanceCount(instanceCountAsString);
+ } else {
+ nodeTemplateInfo.setInstanceCount(instanceCount.toString());
+ }
+ }
+ }
@SuppressWarnings("unchecked")
private Map<String, List<UploadReqInfo>> createReqModuleFromYaml(Map<String, Object> nodeTemplateJsonMap, String nodeName) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index b6a7fccff4..a31e9234c1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -2721,6 +2721,9 @@ public class ServiceImportBusinessLogic {
Resource origResource = existingnodeTypeMap.get(uploadComponentInstanceInfo.getType());
componentInstance.setName(uploadComponentInstanceInfo.getName());
componentInstance.setIcon(origResource.getIcon());
+ componentInstance.setMinOccurrences(uploadComponentInstanceInfo.getMinOccurrences());
+ componentInstance.setMaxOccurrences(uploadComponentInstanceInfo.getMaxOccurrences());
+ componentInstance.setInstanceCount(uploadComponentInstanceInfo.getInstanceCount());
resourcesInstancesMap.put(componentInstance, origResource);
} catch (final ComponentException e) {
throw e;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
index 5aad2fb91d..f950827d77 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
@@ -44,4 +44,7 @@ public class UploadComponentInstanceInfo {
private Map<String, UploadInterfaceInfo> interfaces;
private UploadNodeFilterInfo uploadNodeFilterInfo;
private Map<String, List<OperationUi>> operations;
+ private String maxOccurrences;
+ private String minOccurrences;
+ private String instanceCount;
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
index ff5677208a..a7e6975347 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
@@ -79,7 +79,8 @@ public class TypeUtils {
IMPLEMENTATION("implementation"),
SUBSTITUTION_FILTERS("substitution_filter"),
DERIVED_FROM_NAME("derivedFromName"),
- INTERFACE_TYPES("interface_types");
+ INTERFACE_TYPES("interface_types"),
+ INSTANCE_COUNT("instance_count");
// @formatter:om
private final String elementName;