diff options
Diffstat (limited to 'catalog-model')
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); |