From 7c5d55bcf7a7482a50b79d6423de1a5082bff9a7 Mon Sep 17 00:00:00 2001 From: willgonzz Date: Mon, 8 Nov 2021 13:27:24 -0300 Subject: [PATCH] Actualizacion de seleccion de tipo de Documento --- curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java | 22 +++++++++++----------- curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumento.java | 27 +++++++++++++++++++++++++++ curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumentoConverter.java | 31 +++++++++++++++++++++++++++++++ curriculumsearch/src/main/resources/json/postulante.json | 28 ++++++++++++++-------------- curriculumsearch/src/main/resources/static/main.js | 11 +++++++++-- curriculumsearch/src/main/webapp/jsp/postulante-form.jsp | 19 ++++++++++--------- 6 files changed, 102 insertions(+), 36 deletions(-) create mode 100644 curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumento.java create mode 100644 curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumentoConverter.java diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java index 4a6d56b..4852fd2 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java @@ -30,10 +30,10 @@ public class Postulante { @Size(max = 255) private String apellido; - @Column(name = "ci") + @Column(name = "nro_document") @NotBlank(message = "Este campo no puede estar vacio") @Size(max = 120) - private String ci; + private String nroDocument; @Column(name = "correo") @NotBlank(message = "Este campo no puede estar vacio") @@ -74,9 +74,9 @@ public class Postulante { @NotNull private Nacionalidad nacionalidad; - @Column(name = "tipo_documento", length = 2) - @NotBlank(message = "este campo debe estar completo") - private String tipoDocumento; + @Column(name = "tipo_documento",length = 3) + @NotNull + private TipoDocumento tipoDocumento; @Column(name = "disponibilidad", length = 2) @@ -131,12 +131,12 @@ public class Postulante { this.apellido = apellido; } - public String getCi() { - return ci; + public String getnroDocument() { + return nroDocument; } - public void setCi(String ci) { - this.ci = ci; + public void setnroDocument(String nroDocument) { + this.nroDocument = nroDocument; } public String getCorreo() { @@ -215,13 +215,13 @@ public class Postulante { public void setEstadoCivil(EstadoCivil estadoCivil) { this.estadoCivil = estadoCivil; } - public void setTipoDocumento(String tipoDocumento) { + public void setTipoDocumento(TipoDocumento tipoDocumento) { this.tipoDocumento = tipoDocumento; } public EstadoCivil getEstadoCivil() { return estadoCivil; } - public String getTipoDocumento() { + public TipoDocumento getTipoDocumento() { return tipoDocumento; } public Nacionalidad getNacionalidad() { diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumento.java b/curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumento.java new file mode 100644 index 0000000..c41f122 --- /dev/null +++ b/curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumento.java @@ -0,0 +1,27 @@ +package com.roshka.modelo; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TipoDocumento { + CI("CI","Cedula de identidad"), + DNI("PAS","Pasaporte"), + Otro("Otro","Otro"); + private String code; + private String descripcion; + + private TipoDocumento(String code, String descripcion) { + this.code = code; + this.descripcion = descripcion; + } + public void setDescripcion(String descripcion){ + this.descripcion = descripcion; + } + @JsonValue + public String getCode() { + return code; + } + + public String getDescripcion() { + return descripcion; + } +} diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumentoConverter.java b/curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumentoConverter.java new file mode 100644 index 0000000..483c9cc --- /dev/null +++ b/curriculumsearch/src/main/java/com/roshka/modelo/TipoDocumentoConverter.java @@ -0,0 +1,31 @@ +package com.roshka.modelo; + +import java.util.Arrays; + +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; + +@Converter(autoApply = true) +public class TipoDocumentoConverter implements AttributeConverter { + + @Override + public String convertToDatabaseColumn(TipoDocumento modalidad) { + if (modalidad == null) { + return null; + } + return modalidad.getCode(); + } + + @Override + public TipoDocumento convertToEntityAttribute(String code) { + if (code == null) { + return null; + } + + return Arrays.stream(TipoDocumento.values()) + .filter(c -> c.getCode().equals(code)) + .findFirst() + .orElseThrow(IllegalArgumentException::new); + } +} + diff --git a/curriculumsearch/src/main/resources/json/postulante.json b/curriculumsearch/src/main/resources/json/postulante.json index 3ffaf21..e14b92c 100644 --- a/curriculumsearch/src/main/resources/json/postulante.json +++ b/curriculumsearch/src/main/resources/json/postulante.json @@ -3,11 +3,11 @@ "resumen": "In irure aliquip qui cillum veniam sint amet amet sint ex proident anim mollit.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento":"CI", "nombre": "Taylor", "apellido": "Obrien", "correo": "gladysalexander@dadabase.com", - "ci": 5821432, + "nroDocument": 5821432, "ciudadId": 238, "telefono": "(950) 417-3681", "fechaNacimiento": "2021-08-16", @@ -61,11 +61,11 @@ "resumen": "Do nostrud aliqua adipisicing in sunt aute id do elit ut dolor ad aliquip.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento":"CI", "nombre": "Hopkins", "apellido": "Parks", "correo": "grahamgriffith@zilidium.com", - "ci": 4213361, + "nroDocument": 4213361, "ciudadId": 96, "telefono": "(866) 560-2541", "fechaNacimiento": "2021-09-04", @@ -107,11 +107,11 @@ "resumen": "Occaecat non cupidatat amet reprehenderit consectetur ullamco et.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento":"CI", "nombre": "Alejandra", "apellido": "Riggs", "correo": "ruthrobertson@homelux.com", - "ci": 4605787, + "nroDocument": 4605787, "ciudadId": 30, "telefono": "(876) 580-2411", "fechaNacimiento": "2021-01-28", @@ -153,11 +153,11 @@ "resumen": "Qui ullamco excepteur velit ad ullamco id id nisi irure dolore cupidatat mollit ullamco veniam.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento":"CI", "nombre": "Angelina", "apellido": "Wallace", "correo": "christiwalls@capscreen.com", - "ci": 4591352, + "nroDocument": 4591352, "ciudadId": 65, "telefono": "(931) 499-3122", "fechaNacimiento": "2021-06-05", @@ -199,11 +199,11 @@ "resumen": "Deserunt tempor ut et eiusmod et labore Lorem.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento":"CI", "nombre": "Rivas", "apellido": "Owens", "correo": "shirleyguzman@equitox.com", - "ci": 3969318, + "nroDocument": 3969318, "ciudadId": 143, "telefono": "(972) 524-2610", "fechaNacimiento": "2021-09-09", @@ -245,11 +245,11 @@ "resumen": "Aliqua est adipisicing do exercitation sit laborum aliquip aliqua adipisicing enim aute.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento": "CI", "nombre": "Estelle", "apellido": "Gamble", "correo": "mclaughlinpate@enomen.com", - "ci": 2329745, + "nroDocument": 2329745, "ciudadId": 248, "telefono": "(933) 501-3525", "fechaNacimiento": "2021-03-24", @@ -291,11 +291,11 @@ "resumen": "Officia eiusmod ut reprehenderit tempor consequat elit amet ex voluptate aute anim do.", "nacionalidad":"Paraguayo", "estadoCivil":"Soltero", - "tipoDocumento":"ci", + "tipoDocumento":"CI", "nombre": "Mariana", "apellido": "Ratliff", "correo": "loramiddleton@musanpoly.com", - "ci": 4519594, + "nroDocument": 4519594, "ciudadId": 104, "telefono": "(817) 492-2493", "fechaNacimiento": "2021-07-30", diff --git a/curriculumsearch/src/main/resources/static/main.js b/curriculumsearch/src/main/resources/static/main.js index eb1e56a..9080b8d 100644 --- a/curriculumsearch/src/main/resources/static/main.js +++ b/curriculumsearch/src/main/resources/static/main.js @@ -26,7 +26,14 @@ const formValidator = function () { }, false) }) } - +function carg(elemento) { + var element = document.getElementById('descripcion'); + if(elemento == "otro"){ + element.style.display='block'; + }else{ + element.style.display='none'; + } +} function agregarFieldExpierncia(event){ //recoger del form const pairs = {}; @@ -79,7 +86,7 @@ function agregarFieldExpierncia(event){ content += `
  • ${exp.institucion} - +
  • ` diff --git a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp index c11b9e2..ec59523 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp @@ -180,18 +180,19 @@ - -
    - - -
    - Luce Bien! -
    + +
    + +
    - - + +
    Luce Bien!
    -- libgit2 0.26.0