diff --git a/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java b/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java index 4b8694c..480639e 100644 --- a/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java +++ b/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Component.java @@ -14,14 +14,15 @@ */ package org.jtalks.common.model.entity; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.NotBlank; -import org.jtalks.common.validation.annotations.UniqueConstraint; -import ru.javatalks.utils.general.Assert; - -import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.List; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.NotBlank; + +import ru.javatalks.utils.general.Assert; /** * Represent jtalks engine component. @@ -29,7 +30,6 @@ * @author Pavel Vervenko * @author Vahluev Vyacheslav */ -@UniqueConstraint public class Component extends Entity { private static final String COMPONENT_NAME_ILLEGAL_LENGTH = "{component.name.length_constraint_violation}"; private static final String COMPONENT_DESCRIPTION_ILLEGAL_LENGTH = "{component.description.length_constraint_violation}"; @@ -87,15 +87,13 @@ } /** - * Get the component properties - * @return properties + * @return properties component properties */ public List getProperties() { return properties; } /** - * Set the component properties * @param properties to set */ public void setProperties(List properties) { @@ -103,7 +101,6 @@ } /** - * Get the component description. * @return description description of the component */ public String getDescription() { @@ -111,7 +108,6 @@ } /** - * Set components description. * @param description new description of the component * @exception IllegalArgumentException if the description is null */ @@ -121,15 +117,13 @@ } /** - * Get component's name. - * @return name name of the component + * @return name component's name */ public String getName() { return name; } /** - * Set the name of the component. * @param name new name of the component * @exception IllegalArgumentException if the name is null */ @@ -139,7 +133,6 @@ } /** - * Get the type of the component. * @return type type of the component */ public ComponentType getComponentType() { @@ -147,7 +140,6 @@ } /** - * Set component's type. * @param type new type of the component */ public void setComponentType(ComponentType type) { @@ -165,9 +157,8 @@ } /** - * Sets the property some value if one is exist. If it - * is not, then adds a new property - * + * Sets the property some value if one is exist. If it is not, then adds a new property + * * @param name is the name of the property * @param value is the value of the property */ @@ -178,13 +169,13 @@ return; } } - + addProperty(name, value); } /** - * Returns the property by its name or null - * if none was found + * Returns the property by its name or null if none was found + * * @param name is the name of the property * @return property value or null if not found */ diff --git a/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Property.java b/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Property.java index 3199573..79958f4 100644 --- a/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Property.java +++ b/jtalks-common-model/src/main/java/org/jtalks/common/model/entity/Property.java @@ -29,17 +29,14 @@ public static final int PROPERTY_NAME_MAX_LENGTH = 256; - /** - * Property's name - */ @NotBlank(message = PROPERTY_CANT_BE_VOID) @Length(max = PROPERTY_NAME_MAX_LENGTH, message = PROPERTY_NAME_ILLEGAL_LENGTH) private String name; - /** - * Property's value - */ + private String value; + private String validationRule; + /** * Default constructor, sets nothing, used only by hibernate */ @@ -47,19 +44,29 @@ } /** - * Constructor which sets name and value of the property + * Constructor which sets name and value of the property. + * + * @param name of the property + * @param value of the property + * @param validationRule rule for validating value of the property in the UI tear + */ + public Property(String name, String value, String validationRule) { + this.name = name; + this.value = value; + this.validationRule = validationRule; + } + + /** + * Constructor which sets name and value of the property. For the validatingRule, empty string is set. * * @param name of the property * @param value of the property */ public Property(String name, String value) { - this.name = name; - this.value = value; + this(name, value, ""); } /** - * Gets the name of the property - * * @return name of the property */ public String getName() { @@ -67,8 +74,6 @@ } /** - * Sets the name of the property - * * @param name new name of the property */ public void setName(String name) { @@ -76,8 +81,6 @@ } /** - * Gets the value of the property - * * @return current value of the property */ public String getValue() { @@ -85,11 +88,23 @@ } /** - * Sets the value of the property - * * @param value new value of the property */ public void setValue(String value) { this.value = value; } + + /** + * @return rule for validating value of the property in UI tear + */ + public String getValidationRule() { + return validationRule; + } + + /** + * @param validationRule rule for validating value of the property in UI tear + */ + public void setValidationRule(String validationRule) { + this.validationRule = validationRule; + } } diff --git a/jtalks-common-model/src/main/resources/org/jtalks/common/migrations/V18__Add_validation_constraint_for_property.sql b/jtalks-common-model/src/main/resources/org/jtalks/common/migrations/V18__Add_validation_constraint_for_property.sql new file mode 100644 index 0000000..5175cf4 --- /dev/null +++ b/jtalks-common-model/src/main/resources/org/jtalks/common/migrations/V18__Add_validation_constraint_for_property.sql @@ -0,0 +1 @@ +ALTER TABLE PROPERTIES ADD VALIDATION_RULE VARCHAR(64) NOT NULL DEFAULT ''; \ No newline at end of file