diff options
author | JvD_Ericsson <jeff.van.dam@est.tech> | 2022-02-17 15:48:20 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-03-10 13:27:17 +0000 |
commit | 767b122ea026099e17a2ffde30e6718d2abf150f (patch) | |
tree | a03f53058977efeeb8e60ec28808775aaaeacb9d /catalog-be/src | |
parent | ca1cef5e1c74dc5e8d2fb17864648e94b9b66aa0 (diff) |
Support occurrences on node templates
Issue-ID: SDC-3711
Change-Id: I9f25454faa8be6987f336b7efd3821cfa09585a1
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'catalog-be/src')
3 files changed, 16 insertions, 1 deletions
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<Object> occur = new ArrayList<Object>(); + 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<String, List<ComponentInstanceInterface>> componentInstanceInterfaces, ComponentInstance componentInstance, Map<String, DataTypeDefinition> 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<Object> occurrences; private List<String> directives; private Map<String, String> metadata; private String description; |