aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-02-24 15:37:56 +0000
committerMichael Morris <michael.morris@est.tech>2023-02-24 19:25:37 +0000
commitec03d4b9491636f580c7f8133d6e550dd01cc031 (patch)
tree1148b4397c7cb26582d1f91753977eaf3c9ccf39 /catalog-be/src/main/java
parent287b5c443f135bee69a9b32919f481ec40495dbf (diff)
Type list of floats not generated correctly in tosca
types of list/map and sub types of int/float were generated as strings in tosca instead of numbers Issue-ID: SDC-4418 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I9d58d89a03cee212e92e5fe775a28118aee86645
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index d603e795c8..d1cd495222 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -133,7 +133,7 @@ public class PropertyConvertor {
if (CollectionUtils.isNotEmpty(property.getConstraints())) {
try {
- prop.setConstraints(convertConstraints(property.getConstraints(), property.getType()));
+ prop.setConstraints(convertConstraints(property.getConstraints(), property.getType(), property.getSchemaType()));
} catch (ConstraintValueDoNotMatchPropertyTypeException e) {
log.error(e.getMessage());
}
@@ -141,14 +141,14 @@ public class PropertyConvertor {
return prop;
}
- private List<ToscaPropertyConstraint> convertConstraints(List<PropertyConstraint> constraints, String propertyType)
+ private List<ToscaPropertyConstraint> convertConstraints(List<PropertyConstraint> constraints, String propertyType, String schemaType)
throws ConstraintValueDoNotMatchPropertyTypeException {
List<ToscaPropertyConstraint> convertedConstraints = new ArrayList<>();
for (PropertyConstraint constraint : constraints) {
if (constraint instanceof EqualConstraint) {
EqualConstraint equalConstraint = ((EqualConstraint) constraint);
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
equalConstraint.changeConstraintValueTypeTo(propertyType);
}
@@ -158,7 +158,7 @@ public class PropertyConvertor {
if (constraint instanceof GreaterThanConstraint) {
GreaterThanConstraint greaterThanConstraint = ((GreaterThanConstraint) constraint);
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
greaterThanConstraint.changeConstraintValueTypeTo(propertyType);
}
@@ -168,7 +168,7 @@ public class PropertyConvertor {
if (constraint instanceof GreaterOrEqualConstraint) {
GreaterOrEqualConstraint greaterOrEqualConstraint = ((GreaterOrEqualConstraint) constraint);
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
greaterOrEqualConstraint.changeConstraintValueTypeTo(propertyType);
}
@@ -178,7 +178,7 @@ public class PropertyConvertor {
if (constraint instanceof LessThanConstraint) {
LessThanConstraint lessThanConstraint = ((LessThanConstraint) constraint);
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
lessThanConstraint.changeConstraintValueTypeTo(propertyType);
}
@@ -188,7 +188,7 @@ public class PropertyConvertor {
if (constraint instanceof LessOrEqualConstraint) {
LessOrEqualConstraint lessOrEqualConstraint = ((LessOrEqualConstraint) constraint);
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
lessOrEqualConstraint.changeConstraintValueTypeTo(propertyType);
}
@@ -198,7 +198,7 @@ public class PropertyConvertor {
if (constraint instanceof InRangeConstraint) {
InRangeConstraint inRangeConstraint = (InRangeConstraint) constraint;
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
inRangeConstraint.changeConstraintValueTypeTo(propertyType);
}
@@ -207,7 +207,9 @@ public class PropertyConvertor {
if (constraint instanceof ValidValuesConstraint) {
ValidValuesConstraint validValues = ((ValidValuesConstraint) constraint);
- if (doesPropertyTypeNeedConverted(propertyType)) {
+ if (isTypeMapOrList(propertyType) && doesTypeNeedConvertingToIntOrFloat(schemaType)) {
+ validValues.changeConstraintValueTypeTo(schemaType);
+ } else if (doesTypeNeedConvertingToIntOrFloat(propertyType)) {
validValues.changeConstraintValueTypeTo(propertyType);
}
@@ -230,10 +232,14 @@ public class PropertyConvertor {
return convertedConstraints;
}
- private boolean doesPropertyTypeNeedConverted(String propertyType) {
+ private boolean doesTypeNeedConvertingToIntOrFloat(String propertyType) {
return ToscaType.INTEGER.getType().equals(propertyType) || ToscaType.FLOAT.getType().equals(propertyType);
}
+ private boolean isTypeMapOrList (String type) {
+ return ToscaType.MAP.getType().equals(type) || ToscaType.LIST.getType().equals(type);
+ }
+
public Object convertToToscaObject(PropertyDataDefinition property, String value, Map<String, DataTypeDefinition> dataTypes,
boolean preserveEmptyValue) {
String propertyType = property.getType();