aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2023-06-01 07:59:31 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-06-14 21:47:35 +0000
commit56288ac75d57367587442043743879b8649055ac (patch)
tree1309d8ef1ed95c3db6d0219fc09c7826c5761f30
parentacd364bb34d1288e3999c5c6ccf5fa8fba752e22 (diff)
Fix different issues when adding properties
Issue-ID: SDC-4522 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I6408570e5a3b571f3222f31ae30910061736a6c9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java1
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts2
3 files changed, 9 insertions, 7 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
index 74cf8eb43f..fcaa840832 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
@@ -183,7 +183,8 @@ public class PropertyValueConstraintValidationUtil {
List<PropertyDefinition> propertyDefinitions = dataTypeDefinitionCache.get(propertyDefinition.getType()).getProperties();
try {
Map<String, Object> valueMap = MapUtils
- .emptyIfNull(ConstraintUtil.parseToCollection(propertyDefinition.getValue(), new TypeReference<>() {
+ .emptyIfNull(ConstraintUtil.parseToCollection(null != propertyDefinition.getValue() ?
+ propertyDefinition.getValue() : propertyDefinition.getDefaultValue(), new TypeReference<>() {
}));
if (CollectionUtils.isEmpty(propertyDefinitions)) {
checkAndEvaluatePrimitiveProperty(propertyDefinition, dataTypeDefinitionCache.get(propertyDefinition.getType()));
@@ -252,7 +253,8 @@ public class PropertyValueConstraintValidationUtil {
return CollectionUtils.isNotEmpty(list);
} else {
Map<String, Object> valueMap = MapUtils
- .emptyIfNull(ConstraintUtil.parseToCollection(propertyDefinition.getValue(), new TypeReference<>() {
+ .emptyIfNull(ConstraintUtil.parseToCollection(null != propertyDefinition.getValue() ?
+ propertyDefinition.getValue() : propertyDefinition.getDefaultValue(), new TypeReference<>() {
}));
return MapUtils.isNotEmpty(valueMap);
}
@@ -295,11 +297,11 @@ public class PropertyValueConstraintValidationUtil {
.forEach(propertyConstraint -> {
try {
if (ToscaType.LIST == toscaPropertyType1) {
- Collection<Object> list = ConstraintUtil.parseToCollection(propertyDefinition.getValue(), new TypeReference<>() {
+ Collection<Object> list = ConstraintUtil.parseToCollection(null != propertyDefinition.getValue() ? propertyDefinition.getValue() : propertyDefinition.getDefaultValue(), new TypeReference<>() {
});
propertyConstraint.validate(list);
} else if (ToscaType.MAP == toscaPropertyType1) {
- final Map<String, Object> map = ConstraintUtil.parseToCollection(propertyDefinition.getValue(), new TypeReference<>() {
+ final Map<String, Object> map = ConstraintUtil.parseToCollection(null != propertyDefinition.getValue() ? propertyDefinition.getValue() : propertyDefinition.getDefaultValue(), new TypeReference<>() {
});
propertyConstraint.validate(map);
}
@@ -353,7 +355,8 @@ public class PropertyValueConstraintValidationUtil {
if (propertyDefinition.getSchemaType() == null) {
propertyDefinition.setSchema(createStringSchema());
}
- final Map<String, Object> map = ConstraintUtil.parseToCollection(propertyDefinition.getValue(), new TypeReference<>() {
+ final Map<String, Object> map = ConstraintUtil.parseToCollection(null != propertyDefinition.getValue() ?
+ propertyDefinition.getValue() : propertyDefinition.getDefaultValue(), new TypeReference<>() {
});
evaluateCollectionType(propertyDefinition, map);
} catch (ConstraintValueDoNotMatchPropertyTypeException e) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
index 569294d0b8..71a4ab61ce 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
@@ -133,7 +133,6 @@ public class ValidValuesConstraint extends AbstractPropertyConstraint {
} else {
map = ConstraintUtil.parseToCollection(propertyDefinition.getDefaultValue(), new TypeReference<>() {});
}
-
valuesToValidate = map.values();
} else {
if (propertyDefinition.getValue() != null) {
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
index fc0581a5c1..0be5193298 100644
--- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
+++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
@@ -246,7 +246,7 @@ export class PropertyFormViewModel {
this.$scope.myValue = {'': null};
break;
case PROPERTY_TYPES.LIST:
- this.$scope.myValue = [];
+ this.$scope.myValue = [''];
break;
default:
this.$scope.myValue = {};