aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
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 /catalog-be/src/main
parentb9c6259398063d53d648db7b50e5d2b9358a2ace (diff)
Support occurrences and instance count in import
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4566 Change-Id: I884082253e3b3a9c20da68ab064f4ae6528f6fe0
Diffstat (limited to 'catalog-be/src/main')
-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
2 files changed, 22 insertions, 3 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;