diff --git a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java index a0d74fa..e1df4f6 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java @@ -1,11 +1,5 @@ package com.roshka.controller; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.servlet.http.HttpServletRequest; - -import com.roshka.modelo.Experiencia; import com.roshka.modelo.Postulante; import com.roshka.repositorio.PostulanteRepository; @@ -35,10 +29,6 @@ public class PostulanteController { @PostMapping(value = "/postulante",consumes = "application/json") public String guardarPostulante(@RequestBody Postulante postulante){ post.save(postulante); - for(Experiencia exp: postulante.getExperiencias()){ - exp.setPostulante(postulante); - } - post.save(postulante); return "redirect:/"; } diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java b/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java index 87228d1..818fbc9 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java @@ -12,6 +12,9 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonManagedReference; @Entity @Table(name="estudio") public class Estudio { @@ -34,8 +37,10 @@ public class Estudio { @ManyToOne @JoinColumn + @JsonBackReference private Postulante postulante; + @JsonManagedReference @OneToMany(mappedBy = "estudio") private List estudioReconocimiento; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java b/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java index 47b92a1..4ed255b 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java @@ -10,6 +10,8 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; +import com.fasterxml.jackson.annotation.JsonBackReference; + @Entity @Table(name="estudio_reconocimiento") public class EstudioReconocimiento { @@ -21,6 +23,7 @@ public class EstudioReconocimiento { private String nombre; @Column(name="certificado") private String certificado; + @JsonBackReference @ManyToOne @JoinColumn private Estudio estudio; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java b/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java index 5818910..a316f93 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java @@ -3,11 +3,16 @@ package com.roshka.modelo; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonManagedReference; + import javax.persistence.*; @Entity @@ -22,14 +27,23 @@ public class Experiencia { private Date fechaDesde; @Column(name = "fecha_hasta") private Date fechaHasta; - @Column(name = "referencias") - private String referencias; + @Column(name = "nombre_referencia") + private String nombreReferencia; + @Column(name = "telefono_referencia") + private String telefonoReferencia; @Column(name = "cargo") private String cargo; - @ManyToOne + @Column(name = "descripcion") + private String descripcion; + @JsonBackReference + @ManyToOne(optional = false) @JoinColumn private Postulante postulante; + @JsonManagedReference + @OneToMany(mappedBy = "experiencia",cascade = CascadeType.ALL) + private List reconocimientos; + public long getId() { return id; } @@ -74,11 +88,17 @@ public class Experiencia { e.printStackTrace(); } } - public String getReferencias() { - return referencias; + public String getNombreReferencia() { + return nombreReferencia; + } + public String getTelefonoReferencia() { + return telefonoReferencia; + } + public void setNombreReferencia(String nombreReferencia) { + this.nombreReferencia = nombreReferencia; } - public void setReferencias(String referencias) { - this.referencias = referencias; + public void setTelefonoReferencia(String telefonoReferencia) { + this.telefonoReferencia = telefonoReferencia; } public String getCargo() { return cargo; @@ -92,4 +112,16 @@ public class Experiencia { public Postulante getPostulante() { return postulante; } + public String getDescripcion() { + return descripcion; + } + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + public void setReconocimientos(List reconocimientos) { + this.reconocimientos = reconocimientos; + } + public List getReconocimientos() { + return reconocimientos; + } } diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaReconocimiento.java b/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaReconocimiento.java index 23c0e38..1cb47a8 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaReconocimiento.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaReconocimiento.java @@ -2,6 +2,8 @@ package com.roshka.modelo; import javax.persistence.*; +import com.fasterxml.jackson.annotation.JsonBackReference; + @Entity @Table(name = "experiencia_reconocimiento") public class ExperienciaReconocimiento { @@ -10,8 +12,9 @@ public class ExperienciaReconocimiento { @Column(name="id") private long id; - @ManyToOne + @ManyToOne(optional = false) @JoinColumn + @JsonBackReference private Experiencia experiencia; @Column(name="nombre") diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaTecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaTecnologia.java deleted file mode 100644 index cb5d42a..0000000 --- a/curriculumsearch/src/main/java/com/roshka/modelo/ExperienciaTecnologia.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.roshka.modelo; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -@Entity -@Table(name = "experiencia_tecnologia") -public class ExperienciaTecnologia { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") - private Long id; - - @ManyToOne - @JoinColumn - private Experiencia experencia; - - @ManyToOne - @JoinColumn - private Tecnologia tecnologia; - - @Column(name="nivel") - private Long nivel; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Experiencia getExperencia() { - return experencia; - } - - public void setExperencia(Experiencia experencia) { - this.experencia = experencia; - } - - public Tecnologia getTecnologia() { - return tecnologia; - } - - public void setTecnologia(Tecnologia tecnologia) { - this.tecnologia = tecnologia; - } - - public Long getNivel() { - return nivel; - } - - public void setNivel(Long nivel) { - this.nivel = nivel; - } - - -} diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java index 80a0358..b8b0cc8 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java @@ -2,8 +2,11 @@ package com.roshka.modelo; import javax.persistence.*; +import com.fasterxml.jackson.annotation.JsonManagedReference; + import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -52,12 +55,15 @@ public class Postulante { @Column(name = "disponibilidad") private String disponibilidad; + @JsonManagedReference @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) private List tecnologias; + @JsonManagedReference @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) - private List experiencias; + private List experiencias = new ArrayList<>(); + @JsonManagedReference @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) private List estudios; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java index a22ce03..21aa0ff 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java @@ -8,6 +8,8 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; + +import com.fasterxml.jackson.annotation.JsonBackReference; @Entity @Table(name="postulante_tecnologia") @@ -23,6 +25,7 @@ public class PostulanteTecnologia { private Tecnologia tecnologia; @ManyToOne() @JoinColumn + @JsonBackReference private Postulante postulante; public long getId() { return id; diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaTecnologiaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaTecnologiaRepository.java deleted file mode 100644 index 892ae97..0000000 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaTecnologiaRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.roshka.repositorio; - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.roshka.modelo.ExperienciaTecnologia; - -public interface ExperienciaTecnologiaRepository extends JpaRepository { - - -} diff --git a/curriculumsearch/src/main/resources/static/main.js b/curriculumsearch/src/main/resources/static/main.js index c065837..3a43ec3 100644 --- a/curriculumsearch/src/main/resources/static/main.js +++ b/curriculumsearch/src/main/resources/static/main.js @@ -9,9 +9,19 @@ function agregarFieldExpierncia(){ const pairs = {}; const formexp = document.querySelector("[name=experiencia-form]"); const formData = new FormData(formexp); + const reconocimientos = [{},{},{}]; + let pos_rec; for (const [name, value] of formData){ - pairs[name] = value + pos_rec = name.split("-");//rec-nombre-index + if (pos_rec.length > 1) { + reconocimientos[pos_rec[2]][pos_rec[1]] = value + } + else{ + pairs[name] = value + } + } + pairs["reconocimientos"] = reconocimientos.filter(rec => rec.nombre); experiencias[cont_experiencia] = pairs; formexp.reset(); //imprimir lista actualizada diff --git a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp index ba8fa3d..7236c2e 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp @@ -100,9 +100,40 @@ - - - + + + + + + + + + + +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+