summaryrefslogtreecommitdiffstats
path: root/common-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'common-be/src')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinition.java1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyFilterConstraintDataDefinitionJsonDeserializer.java25
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConstraintType.java8
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterValueType.java3
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;