aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-03-30 09:41:24 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2021-04-09 06:47:10 +0000
commit597e80af47aeec1d8306f23d32b8c114192f94d8 (patch)
tree6827129cb14eaa4c488e61e2bd50e6e760ab4280
parent6d65fde29c1859a7099d91ed0e8911bcb1823a38 (diff)
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 <michael.morris@est.tech> Issue-ID: SDC-3548 Change-Id: I445443d1de9447945fb0dd8babd3fcebd8e8ed7d
-rw-r--r--catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java24
2 files changed, 14 insertions, 13 deletions
diff --git a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
index 022bc00412..29b8585b3d 100644
--- a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
+++ b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
@@ -27,6 +27,7 @@ services:
etsiVersion:
name: "ETSI Version"
validValues: [ '3.3.1', '2.7.1', '2.5.1' ]
+ default: '2.5.1'
mandatory: true
resources:
NetworkLayer23:
@@ -175,4 +176,4 @@ resources:
icons: ['contrail_route']
SecurityZone:
name: "Security Zone"
- icons: ['security_zone'] \ No newline at end of file
+ icons: ['security_zone']
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<String> metadataKeys = getCategorySpecificMetadataKeys(toscaElement);
+ final List<MetadataKeyDataDefinition> metadataKeys = getCategorySpecificMetadataKeys(toscaElement);
if (CollectionUtils.isNotEmpty(metadataKeys)) {
final Map<String, String> 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<String> getCategorySpecificMetadataKeys(final ToscaElement toscaElement) {
- final List<String> metadataKeys = new ArrayList<>();
+
+ private static List<MetadataKeyDataDefinition> getCategorySpecificMetadataKeys(final ToscaElement toscaElement) {
+ final List<MetadataKeyDataDefinition> metadataKeys = new ArrayList<>();
final Optional<CategoryDefinition> 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<SubCategoryDefinition> 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;