summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-11-14 11:33:20 +0000
committerMichael Morris <michael.morris@est.tech>2022-12-01 09:58:42 +0000
commit7eefea2dec674b66f07aaaf21901e183067868b3 (patch)
treeff5429d593e28e28bfd14d875830193435c15423 /catalog-model/src
parent4a754a8c898fb397e19876de2d19141d047a9e58 (diff)
Support addition of pattern constraint
Issue-ID: SDC-4260 Change-Id: I2eccf88472c144d8f595a9d8ec028705e924fd67 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java6
2 files changed, 20 insertions, 0 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 b54b401eb0..dc97e25af1 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
@@ -100,6 +100,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.LessThanConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.MaxLengthConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.MinLengthConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.PatternConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
import org.openecomp.sdc.be.model.validation.ToscaFunctionValidator;
@@ -2300,6 +2301,16 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
log.warn("The value of max length constraint is null");
}
break;
+ case PATTERN:
+ if (value != null) {
+ String asString = value.getAsString();
+ log.debug("Before adding value to PatternConstraint object. value = {}", asString);
+ propertyConstraint = new PatternConstraint(asString);
+ break;
+ } else {
+ log.warn("The value of pattern constraint is null");
+ }
+ break;
default:
log.warn("Key {} is not supported. Ignored.", key);
}
@@ -2360,6 +2371,9 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
case MAX_LENGTH:
propertyConstraint = deserializeConstraintWithIntegerOperand(value, MaxLengthConstraint.class);
break;
+ case PATTERN:
+ propertyConstraint = deserializeConstraintWithStringOperand(value, PatternConstraint.class);
+ break;
default:
log.warn("Key {} is not supported. Ignored.", field.getKey());
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
index be4805bc87..1ee96311ec 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.util.regex.Pattern;
import javax.validation.constraints.NotNull;
+import lombok.NoArgsConstructor;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
@@ -29,6 +30,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolatio
import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException;
import lombok.Getter;
+@NoArgsConstructor
public class PatternConstraint extends AbstractStringPropertyConstraint {
@NotNull
@@ -36,6 +38,10 @@ public class PatternConstraint extends AbstractStringPropertyConstraint {
private String pattern;
private Pattern compiledPattern;
+ public PatternConstraint(String pattern) {
+ setPattern(pattern);
+ }
+
public void setPattern(String pattern) {
this.pattern = pattern;
this.compiledPattern = Pattern.compile(this.pattern);