diff --git a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java index c130ba7..fcadc92 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java @@ -5,6 +5,7 @@ import java.util.Date; import javax.servlet.http.HttpServletRequest; +import com.roshka.modelo.Experiencia; import com.roshka.modelo.Postulante; import com.roshka.repositorio.PostulanteRepository; 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 f4b0220..e57e9df 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 @@ -26,10 +31,17 @@ public class Experiencia { private String referencias; @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; } @@ -86,4 +98,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 83a1f36..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,12 +12,16 @@ public class ExperienciaReconocimiento { @Column(name="id") private long id; - @ManyToOne + @ManyToOne(optional = false) @JoinColumn + @JsonBackReference private Experiencia experiencia; - @Column(name = "nivel") - private long nivel; + @Column(name="nombre") + private String nombre; + + @Column(name="certificado") + private String certificado; public long getId() { return id; @@ -29,10 +35,16 @@ public class ExperienciaReconocimiento { public void setExperiencia(Experiencia experiencia) { this.experiencia = experiencia; } - public long getNivel() { - return nivel; + public String getCertificado() { + return certificado; + } + public String getNombre() { + return nombre; + } + public void setCertificado(String certificado) { + this.certificado = certificado; } - public void setNivel(long nivel) { - this.nivel = nivel; + public void setNombre(String nombre) { + this.nombre = 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 b2f3c1b..b95f448 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 @@ -25,7 +35,7 @@ function agregarFieldExpierncia(){ content += `
  • ${exp.institucion} - +
  • ` @@ -40,7 +50,6 @@ function agregarFieldExpierncia(){ function eliminarExperiencia(event) { //eliminar del array - console.log(event.target.parentElement.id.split("-")[1]) experiencias[event.target.parentElement.id.split("-")[1]]=null //eliminar en html event.target.parentElement.remove() @@ -87,7 +96,6 @@ form.addEventListener("submit",(evt)=>{ postData('postulante', serializeJSON(form)) .then(response => { - console.log(response); // JSON data parsed by `data.json()` call location.replace(response.url); }); evt.preventDefault(); diff --git a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp index 5b41089..c6fd829 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp @@ -7,216 +7,220 @@ - Hello, world! - + + + - +
    -
    -
    -
    -

    Zenda Grace

    -
    4.0
    Pro Member -
    +
    -

    Edit Profile

    +

    Curriculum

    -
    +
    + + +
    + +
    -
    +
    -
    +
    - -
    +
    -
    +
    -
    +
    -
    +
    -
    - - -
    - -
    +
    + +
    + +
    -
    -
    - - -
    - + +
    +
     Experiencia

    +
    -
    -
    - - + +
    - -
    - -
    -
    Edit Experience Experience

    + +
    + +
    -
    -
    +
    - -