From 767b122ea026099e17a2ffde30e6718d2abf150f Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Thu, 17 Feb 2022 15:48:20 +0000 Subject: Support occurrences on node templates Issue-ID: SDC-3711 Change-Id: I9f25454faa8be6987f336b7efd3821cfa09585a1 Signed-off-by: JvD_Ericsson --- .../be/components/impl/ComponentInstanceBusinessLogic.java | 2 ++ .../org/openecomp/sdc/be/tosca/ToscaExportHandler.java | 14 +++++++++++++- .../openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'catalog-be/src/main/java/org/openecomp') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index ca4002f26a..2f712e1e7b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -1263,6 +1263,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { oldComponentInstance.setModificationTime(System.currentTimeMillis()); oldComponentInstance.setCustomizationUUID(UUID.randomUUID().toString()); oldComponentInstance.setDirectives(newComponentInstance.getDirectives()); + oldComponentInstance.setMaxOccurrences(newComponentInstance.getMaxOccurrences()); + oldComponentInstance.setMinOccurrences(newComponentInstance.getMinOccurrences()); if (oldComponentInstance.getGroupInstances() != null) { oldComponentInstance.getGroupInstances().forEach(group -> group.setName(getNewGroupName(oldComponentInstance.getNormalizedName(), ValidationUtils.normalizeComponentInstanceName(newComponentInstance.getName()), group.getName()))); 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 ef63a86d39..5c30d0977c 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 @@ -46,6 +46,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; +import com.google.common.primitives.Ints; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.io.FilenameUtils; @@ -912,6 +913,12 @@ public class ToscaExportHandler { if (MapUtils.isNotEmpty(componentInstance.getToscaArtifacts())) { nodeTemplate.setArtifacts(convertToNodeTemplateArtifacts(componentInstance.getToscaArtifacts())); } + if (componentInstance.getMinOccurrences() != null && componentInstance.getMaxOccurrences()!= null){ + List occur = new ArrayList(); + occur.add(parseToIntIfPossible(componentInstance.getMinOccurrences())); + occur.add(parseToIntIfPossible(componentInstance.getMaxOccurrences())); + nodeTemplate.setOccurrences(occur); + } nodeTemplate.setType(componentInstance.getToscaComponentName()); nodeTemplate.setDirectives(componentInstance.getDirectives()); nodeTemplate.setNode_filter(convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter())); @@ -1015,7 +1022,12 @@ public class ToscaExportHandler { log.debug("finish convert topology template for {} for type {}", component.getUniqueId(), component.getComponentType()); return convertNodeTemplatesRes; } - + + private Object parseToIntIfPossible(final String value) { + final Integer intValue = Ints.tryParse(value); + return intValue == null ? value : intValue; + } + private void handleInstanceInterfaces( Map> componentInstanceInterfaces, ComponentInstance componentInstance, Map dataTypes, ToscaNodeTemplate nodeTemplate, diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java index f909a9c7b1..0a75870502 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java @@ -34,6 +34,7 @@ import org.apache.commons.collections.MapUtils; public class ToscaNodeTemplate { private String type; + private List occurrences; private List directives; private Map metadata; private String description; -- cgit 1.2.3-korg