diff --git a/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java b/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java index 95f39d9..11a886d 100644 --- a/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java +++ b/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java @@ -1,8 +1,22 @@ package com.roshka; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.roshka.modelo.Postulante; +import com.roshka.modelo.PostulanteTecnologia; +import com.roshka.modelo.Tecnologia; +import com.roshka.repositorio.PostulanteRepository; +import com.roshka.repositorio.TecnologiaRepository; + +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @SpringBootApplication @@ -14,5 +28,26 @@ public class CurriculumsearchApplication { SpringApplication.run(CurriculumsearchApplication.class, args); } + @Bean + CommandLineRunner runner(PostulanteRepository postRepo,TecnologiaRepository tecRepo) { + return args -> { + // read json and write to db + ObjectMapper mapper = new ObjectMapper(); + TypeReference> typeReference = new TypeReference>(){}; + InputStream inputStream = TypeReference.class.getResourceAsStream("/json/postulante.json"); + try { + List postulantes = mapper.readValue(inputStream,typeReference); + postRepo.saveAll(postulantes); + System.out.println("postulantes Saved!"); + } catch (IOException e){ + System.out.println("Unable to save tecnologias: " + e.getMessage()); + } + + + + + }; + } + } diff --git a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java index 6643744..a999004 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java @@ -16,6 +16,11 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import java.sql.SQLOutput; +import java.util.List; +import java.util.Locale; @Controller @@ -32,9 +37,11 @@ public class PostulanteController { } @RequestMapping("/postulantes") - public String postulantes(Model model) { + public String postulantes(Model model, + @RequestParam(required = false,name = "tec")Long tecnologidaId) { model.addAttribute("tecnologias", tecRepo.findAll()); - model.addAttribute("postulantes", post.findAll()); + if(tecnologidaId==null) model.addAttribute("postulantes", post.findAll()); + else model.addAttribute("postulantes", post.buscarPostulantesPorTecnologia(tecnologidaId)); return "postulantes"; } @@ -74,4 +81,5 @@ public class PostulanteController { .body(ex.getMessage()); } + } diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java b/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java index 9ff67fe..d5a8816 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/EstudioReconocimiento.java @@ -34,6 +34,9 @@ public class EstudioReconocimiento { @JoinColumn private Estudio estudio; + public EstudioReconocimiento() { + + } public EstudioReconocimiento(Long id, String nombre, String certificado) { this.id = id; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java index ce8e758..8b3cead 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java @@ -7,6 +7,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.NotBlank; +import java.util.Locale; @Entity @Table(name="tecnologia") @@ -28,7 +29,7 @@ public class Tecnologia { this.id = id; } public String getNombre() { - return nombre; + return nombre.toLowerCase(); } public void setNombre(String nombre) { this.nombre = nombre; diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java index 19e1c7c..f2785fc 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java @@ -12,4 +12,16 @@ public interface PostulanteRepository extends JpaRepository { @Query("select p from Postulante p join p.estudios e on e.institucion LIKE %?1%") public List findByInstitucionEstudio(String institucion); + @Query("select p from Postulante p " + + "JOIN PostulanteTecnologia pt ON pt.postulante.id = p.id " + + "JOIN Tecnologia t ON t.id = pt.tecnologia.id " + + "WHERE t.nombre = ?1") + public List buscarPostulantesPorTecnologia(String nombre); + + @Query("select p from Postulante p " + + "JOIN PostulanteTecnologia pt ON pt.postulante.id = p.id " + + "JOIN Tecnologia t ON t.id = pt.tecnologia.id " + + "WHERE t.id = ?1") + public List buscarPostulantesPorTecnologia(long tecnologiaId); + } diff --git a/curriculumsearch/src/main/resources/json/postulante.json b/curriculumsearch/src/main/resources/json/postulante.json new file mode 100644 index 0000000..90d1834 --- /dev/null +++ b/curriculumsearch/src/main/resources/json/postulante.json @@ -0,0 +1,338 @@ +[ + { + "resumen": "Esse elit mollit minim pariatur ea dolor nulla aute ullamco duis reprehenderit cillum.", + "nombre": "Lorraine", + "apellido": "Hensley", + "correo": "mercadospears@translink.com", + "ci": 3679238, + "ciudad": "Clarence", + "telefono": "(851) 511-3993", + "fechaNacimiento": "2021-08-13", + "nivelIngles": 2, + "disponibilidad": "C", + "modalidad": "P", + "experiencias": [ + { + "institucion": "Housedown", + "fechaDesde": "2014-01-29", + "fechaHasta": "2016-01-01", + "cargo": "developer frontend", + "descripcion": "Lorem proident ullamco consectetur magna officia reprehenderit culpa consectetur cupidatat aute commodo et voluptate incididunt.", + "nombreReferencia": "Clayton", + "telefonoReferencia": "(924) 476-3465", + "reconocimientos": [ + { + "nombre": "mejor alumno", + "certificado": "cert" + } + ] + } + ], + "estudios": [ + { + "tipoDeEstudio": "universitario", + "institucion": "ua", + "fechaDesde": "2014-06-15", + "fechaHasta": "2016-01-01", + "titulo": "lic inf", + "estudioReconocimiento": [ + { + "nombre": "titest", + "certificado": "titest" + } + ] + } + ], + "tecnologias": [ + { + "tecnologia": { + "nombre": "c#" + }, + "nivel": 3 + }, + { + "tecnologia": { + "nombre": "JAVA" + }, + "nivel": 1 + } + ] + }, + { + "resumen": "Aute est duis qui incididunt nulla minim officia officia non nulla consectetur adipisicing occaecat.", + "nombre": "Stanton", + "apellido": "Adams", + "correo": "leonvazquez@syntac.com", + "ci": 4577602, + "ciudad": "Tuskahoma", + "telefono": "(955) 586-3144", + "fechaNacimiento": "2021-04-11", + "nivelIngles": 1, + "disponibilidad": "P", + "modalidad": "P", + "experiencias": [ + { + "institucion": "Centuria", + "fechaDesde": "2014-08-21", + "fechaHasta": "2016-01-01", + "cargo": "developer frontend", + "descripcion": "Dolor sit aliqua consequat in ullamco in ea.", + "nombreReferencia": "Sharlene", + "telefonoReferencia": "(849) 570-2353", + "reconocimientos": [ + { + "nombre": "ganador de x", + "certificado": "cert" + } + ] + } + ], + "estudios": [ + { + "tipoDeEstudio": "universitario", + "institucion": "ua", + "fechaDesde": "2014-01-07", + "fechaHasta": "2016-01-01", + "titulo": "ing inf", + "estudioReconocimiento": [ + { + "nombre": "titest", + "certificado": "titest" + } + ] + } + ], + "tecnologias": [ + { + "tecnologia": { + "nombre": "python" + }, + "nivel": 4 + }, + { + "tecnologia": { + "nombre": "c" + }, + "nivel": 4 + } + ] + }, + { + "resumen": "Aute consequat occaecat ipsum dolore ad enim ut.", + "nombre": "Grace", + "apellido": "Joyner", + "correo": "miriamlevy@quizka.com", + "ci": 5206543, + "ciudad": "Wikieup", + "telefono": "(941) 577-2187", + "fechaNacimiento": "2021-03-05", + "nivelIngles": 3, + "disponibilidad": "C", + "modalidad": "S", + "experiencias": [ + { + "institucion": "Aquamate", + "fechaDesde": "2014-10-20", + "fechaHasta": "2016-01-01", + "cargo": "developer frontend", + "descripcion": "In pariatur sint minim commodo enim labore esse tempor fugiat veniam.", + "nombreReferencia": "Sonya", + "telefonoReferencia": "(816) 540-2926", + "reconocimientos": [ + { + "nombre": "ganador de x", + "certificado": "cert" + } + ] + } + ], + "estudios": [ + { + "tipoDeEstudio": "universitario", + "institucion": "una", + "fechaDesde": "2014-11-05", + "fechaHasta": "2016-01-01", + "titulo": "lic inf", + "estudioReconocimiento": [ + { + "nombre": "titest", + "certificado": "titest" + } + ] + } + ], + "tecnologias": [ + { + "tecnologia": { + "nombre": "laravel" + }, + "nivel": 4 + }, + { + "tecnologia": { + "nombre": "dot net" + }, + "nivel": 1 + } + ] + }, + { + "resumen": "Ex est enim pariatur ut proident do ullamco sit nulla aute irure ullamco.", + "nombre": "Pat", + "apellido": "Kim", + "correo": "cheribenton@interodeo.com", + "ci": 2095699, + "ciudad": "Ferney", + "telefono": "(802) 538-3821", + "fechaNacimiento": "2021-07-23", + "nivelIngles": 2, + "disponibilidad": "P", + "modalidad": "R", + "experiencias": [ + { + "institucion": "Shopabout", + "fechaDesde": "2014-11-09", + "fechaHasta": "2016-01-01", + "cargo": "developer frontend", + "descripcion": "Reprehenderit deserunt ea laboris occaecat pariatur veniam officia irure quis occaecat elit laboris eiusmod officia.", + "nombreReferencia": "Bray", + "telefonoReferencia": "(824) 544-3117", + "reconocimientos": [ + { + "nombre": "ganador de x", + "certificado": "cert" + } + ] + } + ], + "estudios": [ + { + "tipoDeEstudio": "universitario", + "institucion": "uca", + "fechaDesde": "2014-07-08", + "fechaHasta": "2016-01-01", + "titulo": "ing inf", + "estudioReconocimiento": [ + { + "nombre": "titest", + "certificado": "titest" + } + ] + } + ], + "tecnologias": [ + { + "tecnologia": { + "nombre": "spring" + }, + "nivel": 1 + } + ] + }, + { + "resumen": "Commodo sunt officia aliquip sunt incididunt sit nostrud laboris adipisicing enim velit occaecat cupidatat.", + "nombre": "Shelia", + "apellido": "Moore", + "correo": "auroraweaver@extragene.com", + "ci": 3943771, + "ciudad": "Bourg", + "telefono": "(929) 413-3014", + "fechaNacimiento": "2021-04-03", + "nivelIngles": 1, + "disponibilidad": "C", + "modalidad": "S", + "experiencias": [ + { + "institucion": "Rugstars", + "fechaDesde": "2014-02-06", + "fechaHasta": "2016-01-01", + "cargo": "developer frontend", + "descripcion": "Lorem ipsum adipisicing et minim nulla anim nulla est qui labore laborum dolore.", + "nombreReferencia": "Jeannine", + "telefonoReferencia": "(851) 533-2842", + "reconocimientos": [ + { + "nombre": "ganador de x", + "certificado": "cert" + } + ] + } + ], + "estudios": [ + { + "tipoDeEstudio": "universitario", + "institucion": "uca", + "fechaDesde": "2014-09-16", + "fechaHasta": "2016-01-01", + "titulo": "ing inf", + "estudioReconocimiento": [ + { + "nombre": "titest", + "certificado": "titest" + } + ] + } + ], + "tecnologias": [ + { + "tecnologia": { + "nombre": "postgres" + }, + "nivel": 2 + } + ] + }, + { + "resumen": "Tempor sunt non officia reprehenderit consequat est deserunt nisi ut tempor quis eu.", + "nombre": "Clarissa", + "apellido": "Moses", + "correo": "clarkshepherd@imant.com", + "ci": 1710741, + "ciudad": "Rivers", + "telefono": "(871) 416-2866", + "fechaNacimiento": "2021-10-26", + "nivelIngles": 2, + "disponibilidad": "P", + "modalidad": "S", + "experiencias": [ + { + "institucion": "Imperium", + "fechaDesde": "2014-11-15", + "fechaHasta": "2016-01-01", + "cargo": "developer frontend", + "descripcion": "Incididunt id elit do officia esse in aute duis ipsum ea incididunt.", + "nombreReferencia": "Tamara", + "telefonoReferencia": "(846) 444-3812", + "reconocimientos": [ + { + "nombre": "ganador de x", + "certificado": "cert" + } + ] + } + ], + "estudios": [ + { + "tipoDeEstudio": "universitario", + "institucion": "uca", + "fechaDesde": "2014-12-21", + "fechaHasta": "2016-01-01", + "titulo": "ing inf", + "estudioReconocimiento": [ + { + "nombre": "titest", + "certificado": "titest" + } + ] + } + ], + "tecnologias": [ + { + "tecnologia": { + "nombre": "django" + }, + "nivel": 1 + } + ] + } +] \ No newline at end of file diff --git a/curriculumsearch/src/main/resources/json/tecnologia.json b/curriculumsearch/src/main/resources/json/tecnologia.json new file mode 100644 index 0000000..fb148bf --- /dev/null +++ b/curriculumsearch/src/main/resources/json/tecnologia.json @@ -0,0 +1,22 @@ +[ + { + "id": 1, + "nombre": "python" + }, + { + "id": 2, + "nombre": "flutter" + }, + { + "id": 3, + "nombre": "c#" + }, + { + "id": 4, + "nombre": "c" + }, + { + "id": 5, + "nombre": "spring" + } +] \ No newline at end of file diff --git a/curriculumsearch/src/main/webapp/jsp/list-test.jsp b/curriculumsearch/src/main/webapp/jsp/list-test.jsp new file mode 100644 index 0000000..0965ce8 --- /dev/null +++ b/curriculumsearch/src/main/webapp/jsp/list-test.jsp @@ -0,0 +1,21 @@ +<%@ 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" %> + + + + + + +
+

Lenguajes

+
+
    + +
  • ${item.nombre}
  • +
    +
+
+
+ + diff --git a/curriculumsearch/src/main/webapp/jsp/postulantes.jsp b/curriculumsearch/src/main/webapp/jsp/postulantes.jsp index a022127..f5221d7 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulantes.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulantes.jsp @@ -31,7 +31,7 @@