From 488c141eefc3f0ef0728e3dc48c1201fcd4e881e Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 15 Nov 2021 15:56:45 -0300 Subject: [PATCH] template inheritance jsp. validacion de nombre duplicado en tecnologia y cargo --- .vscode/settings.json | 3 +++ curriculumsearch/pom.xml | 7 +++++++ curriculumsearch/src/main/java/com/roshka/controller/CargoController.java | 9 +++++++-- curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java | 9 +++++++-- curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java | 6 +++--- curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java | 1 + curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java | 2 ++ curriculumsearch/src/main/resources/application.properties | 8 +++++--- curriculumsearch/src/main/webapp/jsp/cargo-form.jsp | 91 ++++++++++++++++++++++++++++++++++++++----------------------------------------------------- curriculumsearch/src/main/webapp/jsp/cargos.jsp | 112 ++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------- curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp | 79 +++++++++++++++++++++++++++++++++++-------------------------------------------- curriculumsearch/src/main/webapp/jsp/convocatorias.jsp | 26 ++++++++------------------ curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp | 30 ++++++------------------------ curriculumsearch/src/main/webapp/jsp/index.jsp | 2 +- curriculumsearch/src/main/webapp/jsp/layouts/base.jsp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ curriculumsearch/src/main/webapp/jsp/postulantes.jsp | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------- curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp | 43 +++++++++++-------------------------------- curriculumsearch/src/main/webapp/jsp/tecnologias.jsp | 23 +++++------------------ 18 files changed, 396 insertions(+), 405 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 curriculumsearch/src/main/webapp/jsp/layouts/base.jsp diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/curriculumsearch/pom.xml b/curriculumsearch/pom.xml index 0068dd8..eea26ac 100644 --- a/curriculumsearch/pom.xml +++ b/curriculumsearch/pom.xml @@ -74,6 +74,13 @@ + + kr.pe.kwonnam.jsp + jsp-template-inheritance + 0.3.RELEASE + compile + + diff --git a/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java b/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java index 342dfaf..d1f6a84 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java @@ -1,6 +1,8 @@ package com.roshka.controller; +import javax.validation.Valid; + import com.roshka.modelo.Cargo; import com.roshka.repositorio.CargoRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -42,8 +44,11 @@ public class CargoController { } @PostMapping(path = {"/cargo","/cargo/{id}"}) - public String guardarCargo(@ModelAttribute Cargo cargo, BindingResult result, @PathVariable(required = false) Long id) { - if(result.hasErrors()); + public String guardarCargo(@Valid @ModelAttribute Cargo cargo, BindingResult result, @PathVariable(required = false) Long id, Model model) { + if(result.hasErrors() || (id==null && cargoRepo.existsByNombreIgnoreCase(cargo.getNombre()) )){ + model.addAttribute("mismoNombre", true); + return "cargo-form"; + }; if(id != null ) cargo.setId(id); cargoRepo.save(cargo); System.out.println(cargo.getNombre()); diff --git a/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java b/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java index e7a5333..b8649b2 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java @@ -1,5 +1,7 @@ package com.roshka.controller; +import javax.validation.Valid; + import com.roshka.modelo.Tecnologia; import com.roshka.repositorio.TecnologiaRepository; @@ -45,8 +47,11 @@ public String addtecnologiaView(Model model,@PathVariable(required = false) Long } @PostMapping(path = {"/tecnologia","/tecnologia/{id}"}) - public String addtecnologia(@ModelAttribute Tecnologia tecnologia, BindingResult result, @PathVariable(required = false) Long id) { - if(result.hasErrors()); + public String addtecnologia(@Valid @ModelAttribute Tecnologia tecnologia, BindingResult result, @PathVariable(required = false) Long id, Model model) { + if(result.hasErrors() || (id==null && tecRepo.existsByNombreIgnoreCase(tecnologia.getNombre()))){ + model.addAttribute("mismoNombre", true); + return "tecnologia-form"; + } if(id != null ) tecnologia.setId(id); tecRepo.save(tecnologia); System.out.println(tecnologia.getNombre()); diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java index 5b5ece5..e2181d6 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java @@ -15,17 +15,17 @@ public class Tecnologia { @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @Column(name="id") - private long id; + private Long id; @Column(name="nombre") @NotBlank(message = "Este campo no puede estar vacio") private String nombre; - public long getId() { + public Long getId() { return id; } - public void setId(long id) { + public void setId(Long id) { this.id = id; } public String getNombre() { diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java index 556bc1c..c78b922 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java @@ -8,4 +8,5 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface CargoRepository extends JpaRepository{ public List findByNombreContainingIgnoreCase(String nombre); + public boolean existsByNombreIgnoreCase(String nombre); } diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java index fed1587..b1cbba7 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java @@ -9,4 +9,6 @@ import com.roshka.modelo.Tecnologia; public interface TecnologiaRepository extends JpaRepository { public List findByNombreContainingIgnoreCase(String nombre); + + public boolean existsByNombreIgnoreCase(String nombre); } diff --git a/curriculumsearch/src/main/resources/application.properties b/curriculumsearch/src/main/resources/application.properties index 031335f..db9e3ea 100644 --- a/curriculumsearch/src/main/resources/application.properties +++ b/curriculumsearch/src/main/resources/application.properties @@ -1,10 +1,10 @@ spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect -#spring.jpa.show-sql=true +spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true -#logging.level.org.hibernate.SQL=DEBUG -#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE +logging.level.org.hibernate.SQL=DEBUG +logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE spring.sql.init.mode=always spring.sql.init.platform=postgres @@ -16,3 +16,5 @@ spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true #server.port=8888 spring.mvc.view.prefix=/jsp/ spring.mvc.view.suffix=.jsp +jsp-inheritance-prefix=/jsp/layouts/ +jsp-inheritance-suffix=.jsp \ No newline at end of file diff --git a/curriculumsearch/src/main/webapp/jsp/cargo-form.jsp b/curriculumsearch/src/main/webapp/jsp/cargo-form.jsp index 1b88d76..c8b48cb 100644 --- a/curriculumsearch/src/main/webapp/jsp/cargo-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/cargo-form.jsp @@ -1,54 +1,39 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib -prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page -contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - Cargo - - - - - - -
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + +
-
${cargo.id == null ? "Agregar" : "Modificar"} Cargo
- -
- Nombre del cargo - - -
-
- -
-
-
-
- - +
${cargo.id == null ? "Agregar" : "Modificar"} Cargo
+ +
+ Nombre del cargo + + +
+ Este nombre ya existe +
+
+
+ +
+
+ + + + + + diff --git a/curriculumsearch/src/main/webapp/jsp/cargos.jsp b/curriculumsearch/src/main/webapp/jsp/cargos.jsp index acda338..9e4aeb2 100644 --- a/curriculumsearch/src/main/webapp/jsp/cargos.jsp +++ b/curriculumsearch/src/main/webapp/jsp/cargos.jsp @@ -1,67 +1,51 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - Cargo - - - - - - -
-

Lista de cargos

-
-
- - - -
- Agregar Nuevo Cargo -
-
- - - - - - - - - - - - - - - - - -
#Cargo
${sta.index+1}${cargo.getNombre()} - Ver Convocatorias - Editar cargo
-
-
- - +<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + + +
+

Lista de cargos

+
+
+ + + +
+ Agregar Nuevo Cargo +
+
+ + + + + + + + + + + + + + + + + +
#Cargo
${sta.index+1}${cargo.getNombre()} + Ver Convocatorias + Editar cargo
+
+
+
+ + + +
diff --git a/curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp b/curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp index 6653ffd..d922034 100644 --- a/curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp @@ -1,47 +1,38 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - Convocatoria - - - - - - -
-

Agregar Convocatoria

-
- -
- Fecha inicial - - -
-
- Fecha Fin - -
-
- Cupos: - -
-
- Cargo - - - ${cargo.nombre} - - -
- -
-
-
- - \ No newline at end of file +<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + + +

${convocatoria.id == null ? "Agregar" : "Modificar"} Convocatoria

+
+ +
+ Fecha inicial + + +
+
+ Fecha Fin + +
+
+ Cupos: + +
+
+ Cargo + + + ${cargo.nombre} + + +
+ +
+
+
+ + + +
diff --git a/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp b/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp index cdec6d8..8d9df9b 100644 --- a/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp +++ b/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp @@ -1,20 +1,9 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - Cargo - - - - - - -
+<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + +

Lista de convocatorias

@@ -67,7 +56,8 @@
-
- - - \ No newline at end of file + + + + + diff --git a/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp b/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp index 3eeaffc..42bc193 100644 --- a/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp +++ b/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp @@ -1,21 +1,9 @@ <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - - - - - - - - Tecnologia - - - - - - -
+<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + +

DETALLE POSTULANTE

@@ -107,13 +95,7 @@
+
+ + - - - - - - - - - \ No newline at end of file diff --git a/curriculumsearch/src/main/webapp/jsp/index.jsp b/curriculumsearch/src/main/webapp/jsp/index.jsp index 6112019..f3e56ce 100644 --- a/curriculumsearch/src/main/webapp/jsp/index.jsp +++ b/curriculumsearch/src/main/webapp/jsp/index.jsp @@ -8,7 +8,7 @@ - Document + RRHH diff --git a/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp b/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp new file mode 100644 index 0000000..9c97b2a --- /dev/null +++ b/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp @@ -0,0 +1,79 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> +<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + + + + + + RRHH + + +
+ + + +
+ +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/curriculumsearch/src/main/webapp/jsp/postulantes.jsp b/curriculumsearch/src/main/webapp/jsp/postulantes.jsp index 2920166..6fbd783 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulantes.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulantes.jsp @@ -1,147 +1,136 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - - - Lista de postulantes - - - - -
-

Lista de Postulantes

-
- - - - -
- - - - - - - - +<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + + +

Lista de Postulantes

+
+ + + +
- - - - + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#NombreDisponibilidadNivel de InglesExperienciaTecnologiasEstado
${staPost.index + 1}${postulante.nombre} ${postulante.apellido}${postulante.disponibilidad.getDescripcion()}${postulante.nivelIngles}${postulante.experienciaMeses} + + ${detalle_tecnologia.getTecnologia().getNombre()}${not staTec.last ? "," : ""} + + ${postulante.estado.getEstado()}Ver
+
+ +
+
+ + - - - \ No newline at end of file + } + function buscarPagina(nro){ + nro-- + const aBuscar = 'nroPagina='+nro + if(!location.search) location.search = "?"+aBuscar + const inicial = location.search.search(aBuscar); + if(inicial==-1){//si no se encuentra y hay otros queries + location.search = "&"+aBuscar + } + location.search.replace('nroPagina=',aBuscar) + } + const tecId = document.querySelector("#tecId"); + const lvlTec = document.querySelector("#lvlTec"); + tecId.addEventListener('change',habilitarLvlTec); + habilitarLvlTec() + + +
diff --git a/curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp b/curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp index 0470123..5fb19f9 100644 --- a/curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp @@ -1,45 +1,24 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - - - - - - Agregar Tecnologia - - - - - - -
-

Agregar Tecnologia

+<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + + +

${tecnologia.id == null ? "Agregar" : "Modificar"} Tecnologia

- Nombre: + Nombre: + +
+ Este nombre ya existe +
-
- - - - - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp b/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp index b0f6899..3570908 100644 --- a/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp +++ b/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp @@ -1,20 +1,9 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - - - Tecnologia - - - - - - -
+<%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%> + +

Lista de Tecnologias

@@ -49,7 +38,5 @@
-
- - - \ No newline at end of file + + -- libgit2 0.26.0