Commit cc04d876 authored by Martin Lowe's avatar Martin Lowe 🇨🇦 Committed by Martin Lowe
Browse files

Add Hibernate Validation to the db model classes

parent 0a830d7e
......@@ -22,6 +22,7 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.ws.rs.core.MultivaluedMap;
import org.eclipsefoundation.core.namespace.DefaultUrlParameterNames;
......@@ -53,10 +54,15 @@ public class Address extends BareNode implements TargetedClone<Address> {
@JoinColumn(name = "organization_id", unique = true)
private FormOrganization organization;
@NotBlank(message = "Street cannot be blank")
private String street;
@NotBlank(message = "City cannot be blank")
private String city;
@NotBlank(message = "Province/state cannot be blank")
private String provinceState;
@NotBlank(message = "Country cannot be blank")
private String country;
@NotBlank(message = "Postal code cannot be blank")
private String postalCode;
/** @return the id */
......
......@@ -25,6 +25,8 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.ws.rs.core.MultivaluedMap;
import org.eclipsefoundation.core.namespace.DefaultUrlParameterNames;
......@@ -58,13 +60,19 @@ public class Contact extends BareNode implements TargetedClone<Contact> {
@JoinColumn(name = "form_id")
private MembershipForm form;
@NotBlank(message = "First name cannot be blank")
@JsonbProperty(value = "first_name")
private String fName;
@NotBlank(message = "Last name cannot be blank")
@JsonbProperty(value = "last_name")
private String lName;
@Email(message = "Email address is not valid")
private String email;
@NotBlank(message = "Job title cannot be blank")
@JsonbProperty(value = "job_title")
private String title;
@NotBlank(message = "Contact type cannot be blank")
@Enumerated(EnumType.STRING)
private ContactTypes type;
......
......@@ -24,6 +24,8 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.ws.rs.core.MultivaluedMap;
import org.eclipsefoundation.core.namespace.DefaultUrlParameterNames;
......@@ -44,7 +46,9 @@ public class FormOrganization extends BareNode implements TargetedClone<FormOrga
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;
@NotBlank(message = "Legal name cannot be blank")
private String legalName;
@NotBlank(message = "Twitter handle cannot be blank")
@JsonbProperty("twitter")
private String twitterHandle;
......@@ -52,7 +56,7 @@ public class FormOrganization extends BareNode implements TargetedClone<FormOrga
@OneToOne(targetEntity = MembershipForm.class)
@JoinColumn(name = "form_id", unique = true)
private MembershipForm form;
@NotNull(message = "Organization Address must be set")
@OneToOne(cascade = { CascadeType.ALL }, mappedBy = "organization")
private Address address;
......
......@@ -24,10 +24,10 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.ws.rs.core.MultivaluedMap;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.eclipsefoundation.core.namespace.DefaultUrlParameterNames;
import org.eclipsefoundation.persistence.dto.BareNode;
import org.eclipsefoundation.persistence.dto.filter.DtoFilter;
......@@ -37,6 +37,8 @@ import org.eclipsefoundation.persistence.model.ParameterizedSQLStatementBuilder;
import org.eclipsefoundation.react.namespace.MembershipFormAPIParameterNames;
import org.hibernate.annotations.GenericGenerator;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Represents a prospective Working Group relationship with the current
* organization (based on the form)
......@@ -52,9 +54,12 @@ public class FormWorkingGroup extends BareNode implements TargetedClone<FormWork
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;
@NotBlank(message = "Working Group ID cannot be blank")
@JsonProperty("working_group")
private String workingGroupID;
@NotBlank(message = "Participation level cannot be blank")
private String participationLevel;
@NotNull(message = "Effective date cannot be blank")
private Date effectiveDate;
// form entity
......@@ -62,6 +67,7 @@ public class FormWorkingGroup extends BareNode implements TargetedClone<FormWork
@JoinColumn(name = "form_id")
private MembershipForm form;
@NotNull(message = "Organization Contact cannot be null")
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(referencedColumnName = "id", unique = true)
private Contact contact;
......
......@@ -20,6 +20,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.ws.rs.core.MultivaluedMap;
import org.eclipsefoundation.core.namespace.DefaultUrlParameterNames;
......@@ -43,13 +44,17 @@ public class MembershipForm extends BareNode implements TargetedClone<Membership
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;
private String userID;
@NotBlank(message = "Membership level cannot be blank")
private String membershipLevel;
@NotBlank(message = "Signing authority cannot be blank")
private boolean signingAuthority;
@NotBlank(message = "Purchase order state cannot be blank")
private String purchaseOrderRequired;
private String vatNumber;
private String registrationCountry;
@SortableField
private Long dateCreated;
@NotBlank(message = "The form state cannot be blank")
private FormState state;
/** @return the id */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment