diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2023-02-15 17:14:59 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-05-16 15:05:13 +0000 |
commit | 8183ade590e367f28e13484201d2c9526be221dc (patch) | |
tree | 735d600ec26ed9caea7657f7224a7e5f6f05cb62 /common-be | |
parent | 5768f2e5a056df6b23f7f8a87529d5ca00063c68 (diff) |
Support additional operands for node filters
Issue-ID: SDC-4395
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: I66b172d100ffd2757de88bc7640761f31fd20c28
Diffstat (limited to 'common-be')
4 files changed, 35 insertions, 2 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinition.java index 9284b530eb..3dc11248f2 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinition.java @@ -38,4 +38,5 @@ public class PropertyFilterConstraintDataDefinition { private ConstraintType operator; private FilterValueType valueType; private Object value; + private String originalType; } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinitionJsonDeserializer.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinitionJsonDeserializer.java index a767133a4c..894b54b291 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinitionJsonDeserializer.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinitionJsonDeserializer.java @@ -22,11 +22,13 @@ package org.openecomp.sdc.be.datatypes.elements; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -73,6 +75,9 @@ public class PropertyFilterConstraintDataDefinitionJsonDeserializer extends StdD if (node.get("valueType") != null) { propertyFilterConstraint.setValueType(FilterValueType.valueOf(node.get("valueType").asText())); } + if (node.get("originalType") != null) { + propertyFilterConstraint.setOriginalType(node.get("originalType").asText()); + } propertyFilterConstraint.setValue(deserializeValue(node.get("value"))); return propertyFilterConstraint; @@ -91,7 +96,25 @@ public class PropertyFilterConstraintDataDefinitionJsonDeserializer extends StdD LOGGER.debug(COULD_NOT_PARSE_CLASS, PropertyFilterConstraintDataDefinition.class.getName(), Map.class.getName(), e); } try { - return objectMapper.treeToValue(value, List.class); + if (value.isArray()) { + try { + objectMapper.treeToValue(value.get(0), ToscaFunction.class); + } catch (JsonProcessingException e) { + return objectMapper.treeToValue(value, List.class); + } + List<ToscaFunction> listToscaFunction = new ArrayList<>(); + value.forEach(nodeListValue -> { + try { + listToscaFunction.add(objectMapper.treeToValue(nodeListValue, ToscaFunction.class)); + } catch (JsonProcessingException e) { + LOGGER.debug(COULD_NOT_PARSE_CLASS, PropertyFilterConstraintDataDefinition.class.getName(), List.class.getName(), e); + } + }); + return listToscaFunction; + } + else { + return objectMapper.treeToValue(value, List.class); + } } catch (final Exception e) { LOGGER.debug(COULD_NOT_PARSE_CLASS, PropertyFilterConstraintDataDefinition.class.getName(), List.class.getName(), e); } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConstraintType.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConstraintType.java index 2963b6bcd1..263bd70ab7 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConstraintType.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConstraintType.java @@ -48,6 +48,10 @@ public enum ConstraintType { ConstraintType.GREATER_OR_EQUAL, ConstraintType.LESS_OR_EQUAL, ConstraintType.LESS_THAN); + private static final Set<ConstraintType> lengthConstraints = Set.of( + ConstraintType.LENGTH, + ConstraintType.MIN_LENGTH, + ConstraintType.MAX_LENGTH); private final String type; private final List<String> typeAlias; @@ -74,4 +78,8 @@ public enum ConstraintType { return comparableConstraints.contains(this); } + public boolean isLengthConstraint() { + return lengthConstraints.contains(this); + } + } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterValueType.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterValueType.java index cacc4b1bac..62a19b8041 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterValueType.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterValueType.java @@ -35,7 +35,8 @@ public enum FilterValueType { GET_INPUT("get_input", "service_input"), GET_ATTRIBUTE("get_attribute", null), YAML("yaml", null), - CONCAT("concat", null); + CONCAT("concat", null), + SEVERAL("several", null); private final String name; private final String legacyName; |