diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2023-06-27 11:20:23 +0100 |
---|---|---|
committer | Vasyl Razinkov <vasyl.razinkov@est.tech> | 2023-08-18 12:37:57 +0000 |
commit | d32437595314c9b5b2aa439a482d0b07286a8072 (patch) | |
tree | 1ae162901579eb0fb9f403ecd41308ac91c17c2a /common-be | |
parent | 98826572a529d01250cf4925dc3f26ac8c35478a (diff) |
Custom tosca functions with valid_values and in_range operators not showing properly
Issue-ID: SDC-4554
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: I8c6ad232951d887593a15562b11c03d8613be29b
Diffstat (limited to 'common-be')
-rw-r--r-- | common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java index 1f7459c59d..fa9e4d5fc7 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/PropertyFilterConstraintDataDefinitionHelper.java @@ -67,10 +67,25 @@ public class PropertyFilterConstraintDataDefinitionHelper { final Optional<ToscaFunction> toscaFunction = createToscaFunctionFromLegacyConstraintValue(valueYaml); if (toscaFunction.isPresent()) { propertyFilterConstraint.setValue(toscaFunction.get()); - } else { + propertyFilterConstraint.setValueType(detectValueType(valueYaml)); + } + else { propertyFilterConstraint.setValue(valueYaml); + if (valueYaml instanceof List) { + List<ToscaFunction> listToscaFunction = new ArrayList<>(); + ((List<?>) valueYaml).stream().forEach(val -> { + final Optional<ToscaFunction> optToscaFunctionLst = createToscaFunctionFromLegacyConstraintValue(val); + if (optToscaFunctionLst.isPresent()) { + listToscaFunction.add(optToscaFunctionLst.get()); + } + }); + propertyFilterConstraint.setValue(listToscaFunction); + propertyFilterConstraint.setValueType(FilterValueType.SEVERAL); + } + else { + propertyFilterConstraint.setValueType(detectValueType(valueYaml)); + } } - propertyFilterConstraint.setValueType(detectValueType(valueYaml)); propertyFilterConstraint.setTargetType(PropertyFilterTargetType.PROPERTY); return propertyFilterConstraint; } @@ -90,9 +105,7 @@ public class PropertyFilterConstraintDataDefinitionHelper { } ToscaFunctionType toscaFunctionType = ToscaFunctionType.findType((String) toscaFunctionTypeObject).orElse(null); if (toscaFunctionType == null) { - if (((String) toscaFunctionTypeObject).equalsIgnoreCase("$get_input_ext") || - ((String) toscaFunctionTypeObject).equalsIgnoreCase("$juel") || - ((String) toscaFunctionTypeObject).equalsIgnoreCase("$other")) { + if (((String) toscaFunctionTypeObject).startsWith("$")) { toscaFunctionType = ToscaFunctionType.CUSTOM; } else { @@ -509,6 +522,26 @@ public class PropertyFilterConstraintDataDefinitionHelper { return FilterValueType.CUSTOM; } } + else if (value instanceof List) { + final Map<?, ?> valueAsMap = (Map<?, ?>) ((List<?>) value).get(0); + if (valueAsMap.containsKey(ToscaFunctionType.CONCAT.getName())) { + return FilterValueType.CONCAT; + } + if (valueAsMap.containsKey(ToscaFunctionType.GET_ATTRIBUTE.getName())) { + return FilterValueType.GET_ATTRIBUTE; + } + if (valueAsMap.containsKey(ToscaFunctionType.GET_PROPERTY.getName())) { + return FilterValueType.GET_PROPERTY; + } + if (valueAsMap.containsKey(ToscaFunctionType.GET_INPUT.getName())) { + return FilterValueType.GET_INPUT; + } + if (valueAsMap.containsKey("$get_input_ext") || + valueAsMap.containsKey("$juel") || + valueAsMap.containsKey("$other")) { + return FilterValueType.CUSTOM; + } + } return FilterValueType.STATIC; } |