Validaciones sobre models 2

parent 13b70dce
......@@ -12,6 +12,9 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
......@@ -22,17 +25,28 @@ public class Estudio {
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private long id;
@Column(name="tipo_de_studio")
@NotBlank
private String tipoDeEstudio;
@Column(name="institucion")
@NotBlank
private String institucion;
@Column(name="fecha_desde")
@NotNull
@Past
private Date fechaDesde;
@Column(name="fecha_hasta")
private Date fechaHasta;
@Column(name="referencias")
private String referencias;
@Column(name="titulo")
@NotBlank
private String titulo;
@ManyToOne
......
......@@ -9,6 +9,7 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonBackReference;
......@@ -19,10 +20,15 @@ public class EstudioReconocimiento {
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Long id;
@Column(name="nombre")
@NotBlank
private String nombre;
@Column(name="certificado")
@NotBlank
private String certificado;
@JsonBackReference
@ManyToOne
@JoinColumn
......
......@@ -14,6 +14,9 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
@Entity
@Table(name = "experiencia")
......@@ -21,18 +24,29 @@ public class Experiencia {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "institucion")
@NotBlank
private String institucion;
@Column(name = "fecha_desde")
@Past
@NotNull
private Date fechaDesde;
@Column(name = "fecha_hasta")
private Date fechaHasta;
@Column(name = "referencias")
private String referencias;
@Column(name = "cargo")
@NotBlank
private String cargo;
@Column(name = "descripcion")
private String descripcion;
@JsonBackReference
@ManyToOne(optional = false)
@JoinColumn
......
......@@ -8,6 +8,9 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
......@@ -18,15 +21,20 @@ public class PostulanteTecnologia {
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private long id ;
@Column(name="nivel")
@Min(value = 1)
@Max(value = 5)
private Long nivel;
@ManyToOne()
@JoinColumn
private Tecnologia tecnologia;
@ManyToOne()
@ManyToOne()
@JoinColumn
@JsonBackReference
private Postulante postulante;
private Postulante postulante;
public long getId() {
return id;
}
......
......@@ -6,6 +6,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
@Entity
@Table(name="tecnologia")
......@@ -16,6 +17,7 @@ public class Tecnologia {
private long id;
@Column(name="nombre")
@NotBlank
private String nombre;
......
......@@ -96,7 +96,9 @@ form.addEventListener("submit",(evt)=>{
postData('postulante', serializeJSON(form))
.then(response => {
location.replace(response.url);
if(response.status==200 || response.status==302){
location.replace(response.url);
}
});
evt.preventDefault();
} );
\ No newline at end of file
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