summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-10-27 12:47:28 +0100
committerMichael Morris <michael.morris@est.tech>2022-11-30 13:26:41 +0000
commit0d708e3bb2502abe50e1ed4069b43536b538ceef (patch)
treea36c57ddeb12207af60c6c5cfc5311246ca4c126 /catalog-model/src/main/java/org
parent15f3f0bb8e0cec965a9714e3681fbdee4b19b3c4 (diff)
Support addition of scalar type constraints
this also supports the addition of the in_range and the valid_values constraints, and supports delete and editing of current and added constraints Issue-ID: SDC-4223 Change-Id: I5ffb4d17d9f8c2730f650153fb4ff89eccfdd474 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java1
2 files changed, 10 insertions, 4 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index cd87dd4fe7..b54b401eb0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -33,8 +33,10 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import com.google.gson.JsonSyntaxException;
import fj.data.Either;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -2143,6 +2145,10 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
GreaterThanConstraint greaterThanConstraint = (GreaterThanConstraint) src;
jsonArray.add(JsonParser.parseString(greaterThanConstraint.getGreaterThan()));
result.add("greaterThan", jsonArray);
+ } else if (src instanceof LessThanConstraint) {
+ LessThanConstraint lessThanConstraint = (LessThanConstraint) src;
+ jsonArray.add(JsonParser.parseString(lessThanConstraint.getLessThan()));
+ result.add("lessThan", jsonArray);
} else if (src instanceof LessOrEqualConstraint) {
LessOrEqualConstraint lessOrEqualConstraint = (LessOrEqualConstraint) src;
jsonArray.add(JsonParser.parseString(lessOrEqualConstraint.getLessOrEqual()));
@@ -2185,8 +2191,9 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
if (value != null) {
if (value instanceof JsonArray) {
JsonArray rangeArray = (JsonArray) value;
- if (rangeArray.size() != 2) {
+ if (rangeArray.size() != 2 || rangeArray.contains(new JsonPrimitive(""))) {
log.error("The range constraint content is invalid. value = {}", value);
+ throw new JsonSyntaxException("The range constraint content is invalid");
} else {
InRangeConstraint rangeConstraint = new InRangeConstraint();
String minValue = rangeArray.get(0).getAsString();
@@ -2248,8 +2255,9 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
case VALID_VALUES:
if (value != null) {
JsonArray rangeArray = (JsonArray) value;
- if (rangeArray.size() == 0) {
+ if (rangeArray.size() == 0 || rangeArray.contains(new JsonPrimitive(""))) {
log.error("The valid values constraint content is invalid. value = {}", value);
+ throw new JsonSyntaxException("The valid values constraint content is invalid");
} else {
ValidValuesConstraint vvConstraint = new ValidValuesConstraint();
List<String> validValues = new ArrayList<>();
@@ -2426,7 +2434,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
return null;
}
-
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
index d0bea82157..740ee8b544 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
@@ -35,7 +35,6 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraint
public class LessThanConstraint extends AbstractComparablePropertyConstraint {
@NotNull
- @Getter
private String lessThan;
@Override