Complete field constraint documentation in repository API (#565)
* Document constraints in builders. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Completed constraint documentation in repository API Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix typo. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -10,11 +10,11 @@ package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* Extension for {@link NamedEntity} that are versioned.
|
||||
@@ -27,9 +27,9 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEntity implements NamedVersionedEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "version", nullable = false, length = 64)
|
||||
@Size(max = 64)
|
||||
@NotEmpty
|
||||
@Column(name = "version", nullable = false, length = NamedVersionedEntity.VERSION_MAX_SIZE)
|
||||
@Size(min = 1, max = NamedVersionedEntity.VERSION_MAX_SIZE)
|
||||
@NotNull
|
||||
private String version;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.persistence.Index;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -29,7 +30,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -54,13 +54,13 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
|
||||
CascadeType.PERSIST }, fetch = FetchType.EAGER, orphanRemoval = true)
|
||||
private Set<DistributionSetTypeElement> elements;
|
||||
|
||||
@Column(name = "type_key", nullable = false, updatable = false, length = 64)
|
||||
@Size(max = 64)
|
||||
@NotEmpty
|
||||
@Column(name = "type_key", nullable = false, updatable = false, length = DistributionSetType.KEY_MAX_SIZE)
|
||||
@Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE)
|
||||
@NotNull
|
||||
private String key;
|
||||
|
||||
@Column(name = "colour", nullable = true, length = 16)
|
||||
@Size(max = 16)
|
||||
@Column(name = "colour", nullable = true, length = DistributionSetType.COLOUR_MAX_SIZE)
|
||||
@Size(max = DistributionSetType.COLOUR_MAX_SIZE)
|
||||
private String colour;
|
||||
|
||||
@Column(name = "deleted")
|
||||
|
||||
@@ -77,8 +77,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
||||
@Column(name = "deleted")
|
||||
private boolean deleted;
|
||||
|
||||
@Column(name = "vendor", nullable = true, length = 256)
|
||||
@Size(max = 256)
|
||||
@Column(name = "vendor", nullable = true, length = SoftwareModule.VENDOR_MAX_SIZE)
|
||||
@Size(max = SoftwareModule.VENDOR_MAX_SIZE)
|
||||
private String vendor;
|
||||
|
||||
@CascadeOnDelete
|
||||
|
||||
@@ -14,10 +14,10 @@ import javax.persistence.Index;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* Type of a software modules.
|
||||
@@ -35,17 +35,17 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements SoftwareModuleType {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "type_key", nullable = false, length = 64)
|
||||
@Size(max = 64)
|
||||
@NotEmpty
|
||||
@Column(name = "type_key", nullable = false, length = SoftwareModuleType.KEY_MAX_SIZE)
|
||||
@Size(min = 1, max = SoftwareModuleType.KEY_MAX_SIZE)
|
||||
@NotNull
|
||||
private String key;
|
||||
|
||||
@Column(name = "max_ds_assignments", nullable = false)
|
||||
@Min(1)
|
||||
private int maxAssignments;
|
||||
|
||||
@Column(name = "colour", nullable = true, length = 16)
|
||||
@Size(max = 16)
|
||||
@Column(name = "colour", nullable = true, length = SoftwareModuleType.COLOUR_MAX_SIZE)
|
||||
@Size(max = SoftwareModuleType.COLOUR_MAX_SIZE)
|
||||
private String colour;
|
||||
|
||||
@Column(name = "deleted")
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.eclipse.hawkbit.repository.model.Tag;
|
||||
public class JpaTag extends AbstractJpaNamedEntity implements Tag {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "colour", nullable = true, length = 16)
|
||||
@Size(max = 16)
|
||||
@Column(name = "colour", nullable = true, length = Tag.COLOUR_MAX_SIZE)
|
||||
@Size(max = Tag.COLOUR_MAX_SIZE)
|
||||
private String colour;
|
||||
|
||||
protected JpaTag() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
@@ -38,13 +39,13 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery {
|
||||
private static final long serialVersionUID = 7493966984413479089L;
|
||||
|
||||
@Column(name = "name", length = 64, nullable = false)
|
||||
@Size(max = 64)
|
||||
@Column(name = "name", length = NamedEntity.NAME_MAX_SIZE, nullable = false)
|
||||
@Size(max = NamedEntity.NAME_MAX_SIZE)
|
||||
@NotEmpty
|
||||
private String name;
|
||||
|
||||
@Column(name = "query", length = 1024, nullable = false)
|
||||
@Size(max = 1024)
|
||||
@Column(name = "query", length = TargetFilterQuery.QUERY_MAX_SIZE, nullable = false)
|
||||
@Size(max = TargetFilterQuery.QUERY_MAX_SIZE)
|
||||
@NotEmpty
|
||||
private String query;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user