summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;