From 461f20fd6fb23c594361c734525cdd281b72c2e3 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Fri, 20 Oct 2023 19:34:42 +0100 Subject: Fix null values in model node type values Signed-off-by: MichaelMorris Issue-ID: SDC-4663 Change-Id: I707d4532be97f093110cdc29d8807014259d8145 --- .../openecomp/sdc/be/tosca/CommonCsarGenerator.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'catalog-be/src/main/java') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java index a0e4203fe0..d80a91f0e4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java @@ -40,6 +40,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.EnumMap; import java.util.HashMap; @@ -745,7 +746,7 @@ public class CommonCsarGenerator { final Object object = propertiesFromMergingContent.get(key); if (object instanceof Map) { ((Map) object).keySet().forEach(s -> - propertiesMap.put(s, ((Map) value).get(s)) + propertiesMap.put(s, getValue(s, (Map) value)) ); } else { propertiesMap.putAll(createProperties(value)); @@ -758,6 +759,24 @@ public class CommonCsarGenerator { return result; } + private Object getValue(final String key, Map value) { + final String mappedKey = mapKey(key); + if (mappedKey.equals("schemaType")) { + return Collections.singletonMap("type", value.get(mappedKey)); + } + return value.get(mappedKey); + } + + private String mapKey(final String key) { + if (key.equals("entry_schema")) { + return "schemaType"; + } + if (key.equals("default")) { + return "defaultValue"; + } + return key; + } + private Map createProperties(final Object value) { final Map propertiesMap = new HashMap<>(); propertiesMap.put("type", ((Map) value).get("type")); -- cgit 1.2.3-korg