From 597e80af47aeec1d8306f23d32b8c114192f94d8 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Tue, 30 Mar 2021 09:41:24 +0100 Subject: Set default value for ETSI version Sets the default value for ETSI version and updates code to use the default value for any mandatory category specific metdata with null values. Signed-off-by: MichaelMorris Issue-ID: SDC-3548 Change-Id: I445443d1de9447945fb0dd8babd3fcebd8e8ed7d --- .../model/jsonjanusgraph/utils/ModelConverter.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java index f26e0a39ea..d14c72b037 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java @@ -766,30 +766,30 @@ public class ModelConverter { component.setUUID((String) toscaElement.getMetadataValue(JsonPresentationFields.UUID)); component.setIsDeleted((Boolean) toscaElement.getMetadataValue(JsonPresentationFields.IS_DELETED)); component.setToscaType(toscaElement.getToscaType().getValue()); - final List metadataKeys = getCategorySpecificMetadataKeys(toscaElement); + final List metadataKeys = getCategorySpecificMetadataKeys(toscaElement); if (CollectionUtils.isNotEmpty(metadataKeys)) { final Map categorySpecificMetadata = new HashMap<>(); - for (final String metadataKey : metadataKeys) { - categorySpecificMetadata.put(metadataKey, (String) toscaElement.getMetadata().get(metadataKey)); + for (final MetadataKeyDataDefinition metadataKey : metadataKeys) { + if (toscaElement.getMetadata().get(metadataKey.getName()) != null) { + categorySpecificMetadata.put(metadataKey.getName(), (String) toscaElement.getMetadata().get(metadataKey.getName())); + } else if (metadataKey.getDefaultValue() != null && metadataKey.isMandatory()) { + categorySpecificMetadata.put(metadataKey.getName(), metadataKey.getDefaultValue()); + } } component.setCategorySpecificMetadata(categorySpecificMetadata); } } - - private static List getCategorySpecificMetadataKeys(final ToscaElement toscaElement) { - final List metadataKeys = new ArrayList<>(); + + private static List getCategorySpecificMetadataKeys(final ToscaElement toscaElement) { + final List metadataKeys = new ArrayList<>(); final Optional category = getCategory(toscaElement); if (category.isPresent()) { if (CollectionUtils.isNotEmpty(category.get().getMetadataKeys())) { - for (final MetadataKeyDataDefinition metadataKey : category.get().getMetadataKeys()) { - metadataKeys.add(metadataKey.getName()); - } + metadataKeys.addAll(category.get().getMetadataKeys()); } final Optional subCategory = getSubCategory(category.get()); if (subCategory.isPresent() && CollectionUtils.isNotEmpty(subCategory.get().getMetadataKeys())) { - for (final MetadataKeyDataDefinition metadataKey : subCategory.get().getMetadataKeys()) { - metadataKeys.add(metadataKey.getName()); - } + metadataKeys.addAll(subCategory.get().getMetadataKeys()); } } return metadataKeys; -- cgit 1.2.3-korg