diff --git a/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java b/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java index 177045b..d9c5103 100644 --- a/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java +++ b/curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java @@ -2,6 +2,7 @@ package com.roshka; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.core.type.TypeReference; @@ -9,11 +10,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.roshka.modelo.*; import com.roshka.repositorio.*; +import org.hibernate.PersistentObjectException; 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.JpaRepository; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -28,7 +31,7 @@ public class CurriculumsearchApplication { @Bean CommandLineRunner runner(PostulanteRepository postRepo, TecnologiaRepository tecRepo, DepartamentoRepository depR, - CiudadRepository ciudR, RRHHUserRepository rrhhUserRepository) { + CiudadRepository ciudR, RRHHUserRepository rrhhUserRepository, CargoRepository cargoR, ConvocatoriaRepository convR) { return args -> { try { // read json and write to db @@ -43,9 +46,35 @@ public class CurriculumsearchApplication { List ciudades= mapper.readValue(inputStream,typeReference2); ciudR.saveAll(ciudades); System.out.println("Cuidad Saved!"); + TypeReference> typeReference3 = new TypeReference>(){}; + inputStream = TypeReference.class.getResourceAsStream("/json/cargo.json"); + List cargos= mapper.readValue(inputStream,typeReference3); + cargoR.saveAll(cargos); + cargoR.flush(); + System.out.println("Cargos Saved!"); + /* TypeReference> typeReference5 = new TypeReference>(){}; + inputStream = TypeReference.class.getResourceAsStream("/json/tecnologia.json"); + List tecnologias= mapper.readValue(inputStream,typeReference5); + tecRepo.saveAll(tecnologias); + tecRepo.flush(); + System.out.println("Cargos Saved!"); */ + TypeReference> typeReference4 = new TypeReference>(){}; + inputStream = TypeReference.class.getResourceAsStream("/json/convocatoria.json"); + List convocatorias= mapper.readValue(inputStream,typeReference4); + convocatorias = convR.saveAll(convocatorias); + convR.flush(); + System.out.println("convocatorias Saved!"); TypeReference> typeReference = new TypeReference>(){}; inputStream = TypeReference.class.getResourceAsStream("/json/postulante.json"); List postulantes = mapper.readValue(inputStream,typeReference); + /* for (Postulante postulante : postulantes) { + for (int i = 0; i < postulante.getPostulaciones().size(); i++) { + + postulante.getPostulaciones().set(i, convR.getById(postulante.getPostulaciones().get(i).getId())); + + + } + } */ postRepo.saveAll(postulantes); System.out.println("postulantes Saved!"); String password = new BCryptPasswordEncoder().encode("test"); @@ -58,7 +87,17 @@ public class CurriculumsearchApplication { System.out.println("Usuario Test: \nEmail: test@test.com\nPassword: test"); } catch (IOException e){ - System.out.println("Unable to save tecnologias: " + e.getMessage()); + System.out.println("Unable to save: " + e.getMessage()); + } + catch(PersistentObjectException ex){ + System.out.println("Unable to save: " + ex.getMessage()); + + ex.printStackTrace(); + } + catch(Exception ex){ + System.out.println("Unable to save: " + ex.getMessage()); + + ex.printStackTrace(); } @@ -67,5 +106,21 @@ public class CurriculumsearchApplication { }; } + public static > void guardarJson(T repo,String srcJson ) { + ObjectMapper mapper = new ObjectMapper(); + TypeReference> typeReference1 = new TypeReference>(){}; + InputStream inputStream = TypeReference.class.getResourceAsStream(srcJson); + List listaAguardar; + try { + listaAguardar = mapper.readValue(inputStream,typeReference1); + repo.saveAll(listaAguardar); + repo.flush(); + System.out.println(srcJson+" Saved!"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } diff --git a/curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java b/curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java index 4bd33ca..50f80c0 100644 --- a/curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java +++ b/curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java @@ -10,11 +10,11 @@ public class PostulanteListaDTO { private String nombre; private String apellido; private Disponibilidad disponibilidad; - private Integer nivelIngles; + private Long nivelIngles; private Long experienciaMeses; private List tecnologias; public PostulanteListaDTO(Long id, String nombre, String apellido, Disponibilidad disponibilidad, - Integer nivelIngles, Long experienciaMeses, List tecnologias) { + Long nivelIngles, Long experienciaMeses, List tecnologias) { this.id = id; this.nombre = nombre; this.apellido = apellido; @@ -47,10 +47,10 @@ public class PostulanteListaDTO { public void setDisponibilidad(Disponibilidad disponibilidad) { this.disponibilidad = disponibilidad; } - public Integer getNivelIngles() { + public Long getNivelIngles() { return nivelIngles; } - public void setNivelIngles(Integer nivelIngles) { + public void setNivelIngles(Long nivelIngles) { this.nivelIngles = nivelIngles; } public Long getExperienciaMeses() { diff --git a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java index 9a09b88..0398649 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java @@ -2,6 +2,7 @@ package com.roshka.controller; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Locale; @@ -19,6 +20,7 @@ import com.roshka.modelo.Postulante; import com.roshka.modelo.TipoExperiencia; import com.roshka.repositorio.*; import com.roshka.repositorio.CiudadRepository; +import com.roshka.repositorio.ConvocatoriaRepository; import com.roshka.repositorio.DepartamentoRepository; import com.roshka.repositorio.ExperienciaRepository; import com.roshka.repositorio.InstitucionRepository; @@ -29,7 +31,13 @@ import com.roshka.utils.Helper; import org.hibernate.jpa.TypedParameterValue; import org.hibernate.type.StringType; +import org.hibernate.type.IntegerType; +import org.hibernate.type.LongType; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -47,18 +55,28 @@ public class PostulanteController { InstitucionRepository institucionRepository; DepartamentoRepository depRepo; CiudadRepository ciuRepo; + EstudioRepository estudioRepository; + PostulanteTecnologiaRepository postulanteTecnologiaRepository; + ConvocatoriaRepository cargoRepo; + CargoRepository carRepo; @Autowired public PostulanteController( PostulanteRepository post, TecnologiaRepository tecRepo, ExperienciaRepository expRepo, InstitucionRepository institucionRepository, DepartamentoRepository depRepo, - CiudadRepository ciuRepo) { + CiudadRepository ciuRepo, EstudioRepository estudioRepository, + PostulanteTecnologiaRepository postulanteTecnologiaRepository, + ConvocatoriaRepository cargoRepo, CargoRepository carRepo) { this.post = post; this.tecRepo = tecRepo; this.expRepo = expRepo; this.institucionRepository = institucionRepository; this.depRepo = depRepo; this.ciuRepo = ciuRepo; + this.estudioRepository = estudioRepository; + this.postulanteTecnologiaRepository = postulanteTecnologiaRepository; + this.cargoRepo =cargoRepo; + this.carRepo=carRepo; } @RequestMapping("home") @@ -76,12 +94,17 @@ public class PostulanteController { @RequestParam(required = false)Long lvlEng, @RequestParam(required = false)Long lvlTec, @RequestParam(required = false)Long instId, - @RequestParam(required = false)Long expInMonths + @RequestParam(required = false)Long expInMonths, + @RequestParam(required = false)Long cargoId, + @RequestParam(defaultValue = "0")Integer nroPagina ) { + final Integer CANTIDAD_POR_PAGINA = 5; + Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id")); model.addAttribute("tecnologias", tecRepo.findAll()); model.addAttribute("disponibilidades", Disponibilidad.values()); model.addAttribute("institucionesEducativas", institucionRepository.findAll()); - List postulantes = post.postulantesMultiFiltro(nombre == null || nombre.trim().isEmpty() ? new TypedParameterValue(StringType.INSTANCE,null) : new TypedParameterValue(StringType.INSTANCE,"%"+nombre+"%"), dispo, lvlEng, lvlTec, tecId, instId); + Page postulantesPag = post.postulantesMultiFiltro(nombre == null || nombre.trim().isEmpty() ? new TypedParameterValue(StringType.INSTANCE,null) : new TypedParameterValue(StringType.INSTANCE,"%"+nombre+"%"), dispo, lvlEng, lvlTec, tecId, instId,cargoId,page); + List postulantes = postulantesPag.getContent(); List postulantesDTO = new ArrayList<>(); for (Postulante postulante : postulantes) { @@ -95,6 +118,7 @@ public class PostulanteController { postulantesDTO.add(new PostulanteListaDTO(postulante.getId(), postulante.getNombre(), postulante.getApellido(), postulante.getDisponibilidad(), postulante.getNivelIngles(), expTotal, postulante.getTecnologias())); } + model.addAttribute("pages", postulantesPag.getTotalPages()); model.addAttribute("postulantes", postulantesDTO); return "postulantes"; } @@ -108,11 +132,12 @@ public class PostulanteController { model.addAttribute("estadosCiviles", EstadoCivil.values()); model.addAttribute("nacionalidades", Nacionalidad.values()); model.addAttribute("tiposExperencia", TipoExperiencia.values()); + model.addAttribute("CargosDisponibles", cargoRepo.f1ndByCargoAndEstado(new TypedParameterValue(LongType.INSTANCE, null), new Date(), new TypedParameterValue(IntegerType.INSTANCE, 1))); try { model.addAttribute("ciudades", new ObjectMapper().writeValueAsString(ciuRepo.findAll())); - } catch (JsonProcessingException e) { + } catch (JsonProcessingException er) { // TODO Auto-generated catch block - e.printStackTrace(); + er.printStackTrace(); } model.addAttribute("departamentos", depRepo.findAll()); @@ -121,11 +146,24 @@ public class PostulanteController { @PostMapping(value = "/postulante",consumes = "application/json") public String guardarPostulante(@RequestBody Postulante postulante){ + //Codigo encargado de modificar postulacion si se envia mismo CI + Postulante postulantex = post.findByNroDocument(postulante.getnroDocument()); + if(postulantex != null){ + estudioRepository.findByPostulante(postulantex).forEach(x -> estudioRepository.delete(x)); + expRepo.findByPostulante(postulantex).forEach(x -> expRepo.delete(x)); + postulanteTecnologiaRepository.findByPostulante(postulantex).forEach(x -> postulanteTecnologiaRepository.delete(x)); + postulante.setId(postulantex.getId()); + } postulante.getTecnologias().stream().filter( tec -> tec.getTecnologia().getId() != 0 ).forEach( tec -> tec.setTecnologia(tecRepo.getById(tec.getTecnologia().getId())) - ); + ); + /* for (int i = 0; i < postulante.getPostulaciones().size(); i++) { + postulante.getPostulaciones().set(i, cargoRepo.getById(postulante.getPostulaciones().get(i).getId())); + } + */ + for(Estudio estudio: postulante.getEstudios()){ String nombreIns = ""; nombreIns = estudio.getInstitucion().getNombre().toLowerCase(); diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java b/curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java index 0179d06..7a74fd6 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java @@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonManagedReference; @Table(name = "cargo") public class Cargo { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotBlank @@ -47,4 +47,7 @@ public class Cargo { public void setConvocatorias(List convocatorias) { this.convocatorias = convocatorias; } + public static Object values() { + return null; + } } diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java b/curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java index 5e7ad21..8b00983 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java @@ -15,13 +15,16 @@ import javax.persistence.Table; import javax.persistence.Transient; import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.roshka.utils.Helper; @Entity @Table(name = "convocatoria_cargo") +@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property="@UUID") public class ConvocatoriaCargo { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne() diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java b/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java index 289646d..0cffc60 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Estudio.java @@ -15,7 +15,7 @@ import com.roshka.utils.Helper; @Table(name="estudio") public class Estudio { @Id - @GeneratedValue(strategy=GenerationType.AUTO) + @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") private long id; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java b/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java index 2481e87..d28f010 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java @@ -23,7 +23,7 @@ import javax.validation.constraints.Past; @Table(name = "experiencia") public class Experiencia { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(name = "institucion") diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Institucion.java b/curriculumsearch/src/main/java/com/roshka/modelo/Institucion.java index d1538c5..3e17a42 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Institucion.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Institucion.java @@ -10,7 +10,7 @@ import java.util.List; @Table(name = "institucion") public class Institucion { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private long id; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java index 6a751d2..1d99bb5 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java @@ -3,8 +3,10 @@ package com.roshka.modelo; import javax.persistence.*; import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonManagedReference; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.roshka.utils.Helper; import java.util.ArrayList; @@ -14,9 +16,10 @@ import java.util.List; @Entity @Table(name="postulante") +@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property="@UUID") public class Postulante { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id") private long id; @@ -61,7 +64,7 @@ public class Postulante { @Column(name = "nivel_ingles") @Min(value = 1) @Max(value = 5) - private Integer nivelIngles; + private Long nivelIngles; @Column(name = "curriculum") private String curriculum; @@ -98,12 +101,11 @@ public class Postulante { @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) private List referencias; - @ManyToMany(cascade = CascadeType.ALL) + @ManyToMany() @JoinTable(uniqueConstraints = @UniqueConstraint(columnNames = {"postulante_id","convocatoria_cargo_id"}), joinColumns = @JoinColumn(name="postulante_id", referencedColumnName="id"), inverseJoinColumns= @JoinColumn(name="convocatoria_cargo_id", referencedColumnName="id") ) - @JsonIgnore private List postulaciones; @@ -175,11 +177,11 @@ public class Postulante { this.resumen = resumen; } - public Integer getNivelIngles() { + public Long getNivelIngles() { return nivelIngles; } - public void setNivelIngles(Integer nivelIngles) { + public void setNivelIngles(Long nivelIngles) { this.nivelIngles = nivelIngles; } diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java index dca587e..4a041c2 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java @@ -21,7 +21,7 @@ uniqueConstraints=@UniqueConstraint(columnNames={"postulante_id", "tecnologia_id public class PostulanteTecnologia { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id") private long id ; @@ -29,12 +29,13 @@ public class PostulanteTecnologia { @Min(value = 1) @Max(value = 5) private Long nivel; - @ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE},optional = false) + @ManyToOne(cascade = {CascadeType.PERSIST},optional = false) @JoinColumn private Tecnologia tecnologia; + @ManyToOne() - @JoinColumn + @JoinColumn @JsonBackReference(value = "postulantetecnologia-postulante") private Postulante postulante; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/RRHHUser.java b/curriculumsearch/src/main/java/com/roshka/modelo/RRHHUser.java index 9a09c01..32bf594 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/RRHHUser.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/RRHHUser.java @@ -6,7 +6,7 @@ import javax.persistence.*; @Table(name = "recursos_humanos_user") public class RRHHUser { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(nullable = false, unique = true, length = 45) diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/ReferenciaPersonal.java b/curriculumsearch/src/main/java/com/roshka/modelo/ReferenciaPersonal.java index 75aca3b..00ed654 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/ReferenciaPersonal.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/ReferenciaPersonal.java @@ -1,13 +1,6 @@ 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; +import javax.persistence.*; import javax.validation.constraints.NotBlank; import com.fasterxml.jackson.annotation.JsonBackReference; @@ -16,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; @Table(name = "referencia_personal") public class ReferenciaPersonal { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotBlank @@ -31,7 +24,7 @@ public class ReferenciaPersonal { @Column(name = "relacion") private String relacion; - @ManyToOne(optional = false) + @ManyToOne(cascade = CascadeType.ALL, optional = false) @JoinColumn @JsonBackReference private Postulante postulante; diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java index 4101a0d..5b5ece5 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java @@ -12,7 +12,7 @@ import javax.validation.constraints.NotBlank; @Entity @Table(name="tecnologia") public class Tecnologia { - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @Column(name="id") private long id; diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java index e30b295..25926c9 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java @@ -11,7 +11,8 @@ import org.springframework.data.jpa.repository.Query; public interface ConvocatoriaRepository extends JpaRepository { public List findByCargoId(Long cargoId); - + //@Query(value="selec x from ConvocatoriaCargo x where (x.fechaFinal > ?1)",nativeQuery = true) + //public List findConvocatoriaCargoByCargo(Date fechaFinal); @Query("select c from ConvocatoriaCargo c where ( ?1 is null and ?3 is null) or ( ( ( (c.fechaFin > ?2 and ?3 = 1) or (c.fechaFin < ?2 and ?3 = 0)) or ?3 is null ) and (c.cargoId = ?1 or ?1 is null) )") public List f1ndByCargoAndEstado(TypedParameterValue cargoId, Date fecha, TypedParameterValue isOpen); } diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/EstudioRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/EstudioRepository.java index 50d9336..ad25f79 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/EstudioRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/EstudioRepository.java @@ -1,10 +1,14 @@ package com.roshka.repositorio; +import com.roshka.modelo.Postulante; import org.springframework.data.jpa.repository.JpaRepository; import com.roshka.modelo.Estudio; +import java.util.List; + public interface EstudioRepository extends JpaRepository{ + public List findByPostulante(Postulante postulante); } diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaRepository.java index cebad2a..5eadaaf 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/ExperienciaRepository.java @@ -1,5 +1,6 @@ package com.roshka.repositorio; +import com.roshka.modelo.Postulante; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,4 +10,6 @@ import com.roshka.modelo.Experiencia; public interface ExperienciaRepository extends JpaRepository { public List findByCargoLike(String cargo); + + public List findByPostulante(Postulante postulante); } diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java index cb9ef21..b10de4c 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java @@ -3,6 +3,8 @@ package com.roshka.repositorio; import java.util.List; import org.hibernate.jpa.TypedParameterValue; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -12,6 +14,8 @@ import com.roshka.modelo.Postulante; public interface PostulanteRepository extends JpaRepository { + public Postulante findByNroDocument(String ci); + @Query("select p from Postulante p join p.estudios e on e.institucion.nombre LIKE %?1%") public List findByInstitucionEstudio(String institucion); @@ -41,15 +45,17 @@ public interface PostulanteRepository extends JpaRepository { @Query(value = "select DISTINCT p " + - "from Postulante p join p.experiencias x " + - "join p.estudios e " + - "join p.tecnologias pt " + + "from Postulante p left join p.experiencias x " + + "left join p.estudios e " + + "left join p.tecnologias pt " + + "left join p.postulaciones conv " + "where (?1 is null or lower(p.nombre) LIKE lower(?1) or lower(p.apellido) LIKE lower(?1) ) " + "and (p.disponibilidad = ?2 or ?2 is null) " + "and (p.nivelIngles >= ?3 or ?3 is null) "+ "and (pt.nivel >= ?4 or ?4 is null) "+ "and (pt.tecnologia.id = ?5 or ?5 is null) "+ - " and (e.institucion.id = ?6 or ?6 is null ) ") - public List postulantesMultiFiltro(TypedParameterValue nombre, Disponibilidad disponibilidad, Long nivelInges, Long nivel, Long tecnoId, Long instId); + " and (e.institucion.id = ?6 or ?6 is null ) "+ + " and (conv.cargoId = ?7 or ?7 is null ) ") + public Page postulantesMultiFiltro(TypedParameterValue nombre, Disponibilidad disponibilidad, Long nivelInges, Long nivel, Long tecnoId, Long instId,Long cargoId, Pageable pageable); } diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteTecnologiaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteTecnologiaRepository.java index 8a295b0..012f485 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteTecnologiaRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteTecnologiaRepository.java @@ -1,12 +1,15 @@ package com.roshka.repositorio; +import com.roshka.modelo.Postulante; import org.springframework.data.jpa.repository.JpaRepository; import com.roshka.modelo.PostulanteTecnologia; -public interface PostulanteTecnologiaRepository extends JpaRepository{ +import java.util.List; +public interface PostulanteTecnologiaRepository extends JpaRepository{ + public List findByPostulante(Postulante postulante); } diff --git a/curriculumsearch/src/main/resources/json/cargo.json b/curriculumsearch/src/main/resources/json/cargo.json new file mode 100644 index 0000000..24605e2 --- /dev/null +++ b/curriculumsearch/src/main/resources/json/cargo.json @@ -0,0 +1,10 @@ +[ + { + "id": 1, + "nombre": "dev java" + }, + { + "id": 2, + "nombre": "dev php" + } + ] \ No newline at end of file diff --git a/curriculumsearch/src/main/resources/json/convocatoria.json b/curriculumsearch/src/main/resources/json/convocatoria.json new file mode 100644 index 0000000..b931ede --- /dev/null +++ b/curriculumsearch/src/main/resources/json/convocatoria.json @@ -0,0 +1,16 @@ +[ + { + "id": 1, + "cargoId": 1, + "fechaInicio": "2021-11-01", + "fechaFin": "2021-11-30", + "cupos": 20 + }, + { + "id": 2, + "cargoId": 2, + "fechaInicio": "2021-11-01", + "fechaFin": "2021-11-30", + "cupos": 20 + } + ] \ No newline at end of file diff --git a/curriculumsearch/src/main/resources/json/postulante.json b/curriculumsearch/src/main/resources/json/postulante.json index e14b92c..ace6a6e 100644 --- a/curriculumsearch/src/main/resources/json/postulante.json +++ b/curriculumsearch/src/main/resources/json/postulante.json @@ -1,9 +1,10 @@ [ { - "resumen": "In irure aliquip qui cillum veniam sint amet amet sint ex proident anim mollit.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", - "tipoDocumento":"CI", + "resumen": "In irure aliquip qui cillum veniam sint amet amet sint ex proident anim mollit.", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", + "tipoDocumento": "CI", "nombre": "Taylor", "apellido": "Obrien", "correo": "gladysalexander@dadabase.com", @@ -13,13 +14,13 @@ "fechaNacimiento": "2021-08-16", "nivelIngles": 1, "disponibilidad": "C", - + "experiencias": [ { "institucion": "Fanfare", "fechaDesde": "2014-09-10", "fechaHasta": "2016-01-01", - "tipoExperiencia":"Trabajo Normal", + "tipoExperiencia": "Trabajo Normal", "cargo": "dba", "descripcion": "Enim qui Lorem ut magna.", "nombreReferencia": "Marissa", @@ -29,8 +30,8 @@ "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-08-28", "fechaHasta": "2016-01-01", "temaDeEstudio": "analista" @@ -59,9 +60,10 @@ }, { "resumen": "Do nostrud aliqua adipisicing in sunt aute id do elit ut dolor ad aliquip.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", - "tipoDocumento":"CI", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", + "tipoDocumento": "CI", "nombre": "Hopkins", "apellido": "Parks", "correo": "grahamgriffith@zilidium.com", @@ -80,15 +82,15 @@ "cargo": "developer frontend", "descripcion": "Consequat fugiat qui sint deserunt ullamco.", "nombreReferencia": "Iva", - "tipoExperiencia":"Trabajo Normal", + "tipoExperiencia": "Trabajo Normal", "telefonoReferencia": "(947) 580-2363" } ], "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-07-08", "fechaHasta": "2016-01-01", "temaDeEstudio": "lic inf" @@ -105,9 +107,10 @@ }, { "resumen": "Occaecat non cupidatat amet reprehenderit consectetur ullamco et.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", - "tipoDocumento":"CI", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", + "tipoDocumento": "CI", "nombre": "Alejandra", "apellido": "Riggs", "correo": "ruthrobertson@homelux.com", @@ -124,7 +127,7 @@ "fechaDesde": "2014-08-26", "fechaHasta": "2016-01-01", "cargo": "dba", - "tipoExperiencia":"Trabajo Normal", + "tipoExperiencia": "Trabajo Normal", "descripcion": "Aute culpa ea mollit adipisicing dolore dolore amet adipisicing occaecat commodo enim cillum.", "nombreReferencia": "Rose", "telefonoReferencia": "(853) 471-2006" @@ -133,8 +136,8 @@ "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-02-13", "fechaHasta": "2016-01-01", "temaDeEstudio": "lic inf" @@ -151,9 +154,10 @@ }, { "resumen": "Qui ullamco excepteur velit ad ullamco id id nisi irure dolore cupidatat mollit ullamco veniam.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", - "tipoDocumento":"CI", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", + "tipoDocumento": "CI", "nombre": "Angelina", "apellido": "Wallace", "correo": "christiwalls@capscreen.com", @@ -173,14 +177,14 @@ "descripcion": "Aliquip occaecat minim dolor enim commodo.", "nombreReferencia": "Elba", "telefonoReferencia": "(881) 568-2597", - "tipoExperiencia":"Trabajo Normal" + "tipoExperiencia": "Trabajo Normal" } ], "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-12-22", "fechaHasta": "2016-01-01", "temaDeEstudio": "ing inf" @@ -197,9 +201,10 @@ }, { "resumen": "Deserunt tempor ut et eiusmod et labore Lorem.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", - "tipoDocumento":"CI", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", + "tipoDocumento": "CI", "nombre": "Rivas", "apellido": "Owens", "correo": "shirleyguzman@equitox.com", @@ -219,14 +224,14 @@ "descripcion": "Dolore nulla deserunt fugiat est reprehenderit tempor qui excepteur.", "nombreReferencia": "Crawford", "telefonoReferencia": "(903) 568-2045", - "tipoExperiencia":"Trabajo Normal" + "tipoExperiencia": "Trabajo Normal" } ], "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-08-03", "fechaHasta": "2016-01-01", "temaDeEstudio": "lic inf" @@ -243,8 +248,9 @@ }, { "resumen": "Aliqua est adipisicing do exercitation sit laborum aliquip aliqua adipisicing enim aute.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", "tipoDocumento": "CI", "nombre": "Estelle", "apellido": "Gamble", @@ -265,14 +271,14 @@ "descripcion": "Do do est ad ea pariatur aliquip sit ipsum in duis laborum velit magna.", "nombreReferencia": "Schultz", "telefonoReferencia": "(903) 420-3902", - "tipoExperiencia":"Trabajo Normal" + "tipoExperiencia": "Trabajo Normal" } ], "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-07-13", "fechaHasta": "2016-01-01", "temaDeEstudio": "ing inf" @@ -289,9 +295,10 @@ }, { "resumen": "Officia eiusmod ut reprehenderit tempor consequat elit amet ex voluptate aute anim do.", - "nacionalidad":"Paraguayo", - "estadoCivil":"Soltero", - "tipoDocumento":"CI", + "nacionalidad": "Paraguayo", + "postulaciones": [{ "id": 1 }], + "estadoCivil": "Soltero", + "tipoDocumento": "CI", "nombre": "Mariana", "apellido": "Ratliff", "correo": "loramiddleton@musanpoly.com", @@ -311,15 +318,14 @@ "descripcion": "Anim labore anim veniam deserunt ex aute.", "nombreReferencia": "Francesca", "telefonoReferencia": "(961) 420-2150", - "tipoExperiencia":"Trabajo Normal" - + "tipoExperiencia": "Trabajo Normal" } ], "estudios": [ { "tipoDeEstudio": "TERCIARIO", -"estado": "SUSPENDIDO", - "institucion": {"nombre":"UNA"}, + "estado": "SUSPENDIDO", + "institucion": { "nombre": "UNA" }, "fechaDesde": "2014-10-03", "fechaHasta": "2016-01-01", "temaDeEstudio": "ing inf" @@ -334,4 +340,4 @@ } ] } -] \ No newline at end of file +] diff --git a/curriculumsearch/src/main/resources/static/main.js b/curriculumsearch/src/main/resources/static/main.js index 749e74c..808eef0 100644 --- a/curriculumsearch/src/main/resources/static/main.js +++ b/curriculumsearch/src/main/resources/static/main.js @@ -1,9 +1,19 @@ var cont_experiencia = 0; let cont_estudios = 0; let cont_tecnologia = 0; + +let cont_cargo = 0; const experiencias = []; const estudios = []; const tecnologias = []; +let noValidateFlag = false; + +const postulaciones = []; + +var cont_referencias=0 ; +const referencias= []; + + const formValidator = function () { 'use strict' @@ -20,6 +30,7 @@ const formValidator = function () { if (!form.checkValidity()) { event.preventDefault() event.stopPropagation() + noValidateFlag = true; } form.classList.add('was-validated') @@ -191,6 +202,9 @@ function serializeJSON (form) { pairs["experiencias"] = experiencias.filter(exp => exp)//eliminacion de nulos pairs["estudios"] = estudios.filter(est => est)//eliminacion de nulos pairs["tecnologias"] = tecnologias.filter(tec => tec)//eliminacion de nulos + pairs["postulaciones"] = postulaciones.filter(car => car)//eliminacion de nulos + pairs["referencias"] = referencias.filter(tec => tec) + // Return the JSON string return JSON.stringify(pairs, null, 2); @@ -225,15 +239,18 @@ form.addEventListener("submit",(evt)=>{ // evt.stopPropagation() // } // form.classList.add('was-validated') - postData('postulante', serializeJSON(form)) - .then(response => { - if(response.status==200 || response.status==302){ - location.replace(response.url); - }else{ - console.log(response.text().then(value => console.log(value))) - } - }); - evt.preventDefault(); + if(!noValidateFlag){ + postData('postulante', serializeJSON(form)) + .then(response => { + if(response.status==200 || response.status==302){ + location.replace(response.url); + }else{ + console.log(response.text().then(value => console.log(value))) + } + }); + evt.preventDefault(); + } + noValidateFlag = false } ); document.querySelector("#btn-new-tech").addEventListener('click',()=>{document.querySelector("#tecnologia-nombre").classList.remove('d-none')}) @@ -318,13 +335,95 @@ function agregarFieldEstudio(){ } + + + + function eliminarEstudio(event) { //eliminar del array estudios[event.target.parentElement.id.split("-")[1]]=null //eliminar en html event.target.parentElement.remove() } +/*--------------------------------------------------------------------*/ +function agregarFieldCargo(){ + //recoger del form + const pairs = {}; + const formcar = document.querySelector("[name=cargo-form]"); + const formData = new FormData(formcar); + //Validacion + let returnFlag = false; + + let requiredValues = ["nombre"] + + formData.forEach((value, key)=>{ + if(requiredValues.includes(key) + && value==="" && returnFlag == false){ + console.log(key, value) + returnFlag = true; + } + }); + + if(returnFlag===true){ + let message = "Rellene " + for(let i=0;i option[value="'+pairs["cargo-id"]+'"]').innerHTML} + console.log(postulaciones) + formcar.reset(); + //imprimir lista actualizada + const div = document.querySelector("#cargos") + const div1 = document.createElement('div'); + + let content1='
    ' + for (let index = 0; index < postulaciones.length; index++) { + const car = postulaciones[index]; + if(car==null) continue; + content1 += ` +
  • + ${document.querySelector('[name=cargo-id] > option[value="'+car.id+'"]').innerHTML} + +
  • + + ` + } + content1 += "
" + div1.innerHTML = content1 + div.innerHTML = ''; + div.appendChild(div1); + cont_cargo++; +} + +/*---------------------------------------------------------------------------------------------------*/ +function eliminarCargoPostulante(event) { + //eliminar del array + postulaciones[event.target.parentElement.id.split("-")[1]]=null + //eliminar en html + event.target.parentElement.remove() +} +/*--------------------------------------------------------------------*/ //evento para cambio de ciudad segun departamento @@ -351,3 +450,82 @@ function listarCiudades(depId){ } + + + +function agregarFieldReferencia(event){ + //recoger del form + const pairs = {}; + const formexp = document.querySelector("[name=referencia-form]"); + const formData = new FormData(formexp); + const referenciaPersonal = [{},{},{}]; + let pos_rec; + let returnFlag = false; + + let requiredValues = ["nombre", "relacion", "telefono"] + + formData.forEach((value, key)=>{ + if(requiredValues.includes(key) + && value==="" && returnFlag == false){ + console.log(key, value) + returnFlag = true; + } + }); + + if(returnFlag===true){ + let message = "Rellene " + for(let i=0;i 1) { + referenciaPersonal[pos_rec[2]][pos_rec[1]] = value + } + else{ + pairs[name] = value + } + + } + pairs["referenciaPersonal"] = referenciaPersonal.filter(rec => rec.nombre); + referencias[cont_referencias] = pairs; + formexp.reset(); + //imprimir lista actualizada + const div = document.querySelector("#referencia") + const div1 = document.createElement('div'); + let content='
    ' + for (let index = 0; index < referencias.length; index++) { + const exp = referencias[index]; + if(exp==null) continue; + content += ` +
  • + ${exp.nombre} + +
  • + + ` + } + content += "
" + div1.innerHTML = content + div.innerHTML = ''; + div.appendChild(div1); + cont_referencias++; +} + +/*----------------------------------------------------------------- */ +function eliminarReferencia(event) { + //eliminar del array + referencias[event.target.parentElement.id.split("-")[1]]=null + //eliminar en html + event.target.parentElement.remove() +} +/*----------------------------------------------------------------- */ + + + + diff --git a/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp b/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp index 1ebe5d2..c6bead7 100644 --- a/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp +++ b/curriculumsearch/src/main/webapp/jsp/detallepostulante.jsp @@ -16,7 +16,7 @@


-
+



@@ -67,6 +67,12 @@
+

+ + +
+
+ diff --git a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp index 63b3b5f..649ba5d 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp @@ -234,11 +234,11 @@
@@ -260,7 +260,13 @@ - +
+
 Cargo al que postulas

+
+ +
+
+
 Agregar Experiencia

@@ -282,21 +288,57 @@
 Agregar Tecnologia

+
- + +
+
 Referencias Personales

+
+
+
- + Cancelar
- + + + @@ -91,7 +92,17 @@ + +
Ver
+
+
+ \ No newline at end of file