Commit 55d9f7f3 by willgonzz

Estados y comentariosrrhh para postulante

parent b2a47f91
......@@ -3,6 +3,7 @@ package com.roshka.DTO;
import java.util.List;
import com.roshka.modelo.Disponibilidad;
import com.roshka.modelo.EstadoPostulante;
import com.roshka.modelo.PostulanteTecnologia;
public class PostulanteListaDTO {
......@@ -13,8 +14,9 @@ public class PostulanteListaDTO {
private Long nivelIngles;
private Long experienciaMeses;
private List<PostulanteTecnologia> tecnologias;
private EstadoPostulante estado;
public PostulanteListaDTO(Long id, String nombre, String apellido, Disponibilidad disponibilidad,
Long nivelIngles, Long experienciaMeses, List<PostulanteTecnologia> tecnologias) {
Long nivelIngles, Long experienciaMeses, List<PostulanteTecnologia> tecnologias,EstadoPostulante estado) {
this.id = id;
this.nombre = nombre;
this.apellido = apellido;
......@@ -22,6 +24,7 @@ public class PostulanteListaDTO {
this.nivelIngles = nivelIngles;
this.experienciaMeses = experienciaMeses;
this.tecnologias = tecnologias;
this.estado=estado;
}
public Long getId() {
return id;
......@@ -65,7 +68,12 @@ public class PostulanteListaDTO {
public void setTecnologias(List<PostulanteTecnologia> tecnologias) {
this.tecnologias = tecnologias;
}
public EstadoPostulante getEstado(){
return estado;
}
public void setEstado(EstadoPostulante estado){
this.estado=estado;
}
}
......@@ -14,6 +14,7 @@ import com.roshka.modelo.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.roshka.modelo.Disponibilidad;
import com.roshka.modelo.EstadoPostulante;
import com.roshka.modelo.EstadoCivil;
import com.roshka.modelo.Nacionalidad;
import com.roshka.modelo.Postulante;
......@@ -42,6 +43,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;
......@@ -90,6 +92,7 @@ public class PostulanteController {
public String postulantes(Model model,
@RequestParam(required = false)Long tecId,
@RequestParam(required = false)String nombre,
@RequestParam(required = false)EstadoPostulante estado,
@RequestParam(required = false)Disponibilidad dispo,
@RequestParam(required = false)Long lvlEng,
@RequestParam(required = false)Long lvlTec,
......@@ -103,7 +106,8 @@ public class PostulanteController {
model.addAttribute("tecnologias", tecRepo.findAll());
model.addAttribute("disponibilidades", Disponibilidad.values());
model.addAttribute("institucionesEducativas", institucionRepository.findAll());
Page<Postulante> 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);
model.addAttribute("estadoP", EstadoPostulante.values());
Page<Postulante> 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,estado);
List<Postulante> postulantes = postulantesPag.getContent();
List<PostulanteListaDTO> postulantesDTO = new ArrayList<>();
......@@ -115,14 +119,14 @@ public class PostulanteController {
expTotal += Helper.getMonthsDifference(experiencia.getFechaDesde(), experiencia.getFechaHasta());
}
if(expInMonths != null && expInMonths > expTotal) continue;
postulantesDTO.add(new PostulanteListaDTO(postulante.getId(), postulante.getNombre(), postulante.getApellido(), postulante.getDisponibilidad(), postulante.getNivelIngles(), expTotal, postulante.getTecnologias()));
postulantesDTO.add(new PostulanteListaDTO(postulante.getId(), postulante.getNombre(), postulante.getApellido(), postulante.getDisponibilidad(), postulante.getNivelIngles(), expTotal, postulante.getTecnologias(),postulante.getEstadoPostulante()));
}
model.addAttribute("pages", postulantesPag.getTotalPages());
model.addAttribute("postulantes", postulantesDTO);
return "postulantes";
}
@RequestMapping("/postulante")
public String getFormPostulante(Model model){
model.addAttribute("tecnologias", tecRepo.findAll());
......@@ -140,10 +144,10 @@ public class PostulanteController {
er.printStackTrace();
}
model.addAttribute("departamentos", depRepo.findAll());
return "postulante-form";
}
@PostMapping(value = "/postulante",consumes = "application/json")
public String guardarPostulante(@RequestBody Postulante postulante){
//Codigo encargado de modificar postulacion si se envia mismo CI
......@@ -155,31 +159,31 @@ public class PostulanteController {
postulante.setId(postulantex.getId());
}
postulante.getTecnologias().stream().filter(
tec -> tec.getTecnologia().getId() != 0
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();
Institucion institucion = institucionRepository.findByNombre(nombreIns);
if(institucion==null){
institucionRepository.save(estudio.getInstitucion());
}else{
estudio.setInstitucion(institucion);
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();
Institucion institucion = institucionRepository.findByNombre(nombreIns);
if(institucion==null){
institucionRepository.save(estudio.getInstitucion());
}else{
estudio.setInstitucion(institucion);
}
}
post.save(postulante);
return "redirect:/postulacion-correcta";
}
}
post.save(postulante);
return "redirect:/postulacion-correcta";
}
@GetMapping("/postulacion-correcta")
public String successPostulation(Model model){
@GetMapping("/postulacion-correcta")
public String successPostulation(Model model){
model.addAttribute("mensaje1", "Tu informacion se ha recibido correctamente!");
model.addAttribute("mensaje2", " espera por que nos pongamos en contacto!");
return "exitoRegistro";
......@@ -188,26 +192,38 @@ public class PostulanteController {
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler({MethodArgumentNotValidException.class})
public ResponseEntity<String> handleValidationExceptions(
MethodArgumentNotValidException ex) {
MethodArgumentNotValidException ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ex.getMessage());
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler({ConstraintViolationException.class})
public ResponseEntity<String> handleValidationExceptions2(
ConstraintViolationException ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ex.getMessage());
}
@GetMapping({"/postulante/{postulanteId}"})
public String getPostulanteDetalle(Model model, @PathVariable("postulanteId") Long postulanteId) {
Postulante p = post.findById(postulanteId).orElse(null);
model.addAttribute("postulante",p);
return "detallepostulante";
}
}
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler({ConstraintViolationException.class})
public ResponseEntity<String> handleValidationExceptions2(
ConstraintViolationException ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ex.getMessage());
}
@GetMapping({"/postulante/{postulanteId}"})
public String getPostulanteDetalle(Model model, @PathVariable("postulanteId") Long postulanteId) {
Postulante p = post.findById(postulanteId).orElse(null);
model.addAttribute("postulante",p);
model.addAttribute("estadoP", EstadoPostulante.values());
return "detallepostulante";
}
@PostMapping({"/postulante/{postulanteId}"})
public String setPostulanteEstado(@ModelAttribute Postulante postulante, BindingResult result, @PathVariable("postulanteId") Long postulanteId) {
//post.setPostulanteEstadoAndComentario(postulante.getEstadoPostulante(),postulante.getComentarioRRHH(), postulante.getId());
Postulante postulanteVd = post.getById(postulanteId);
postulanteVd.setEstadoPostulante(postulante.getEstadoPostulante());
postulanteVd.setComentarioRRHH(postulante.getComentarioRRHH());
post.setPostulanteEstadoAndComentario(postulante.getEstadoPostulante(), postulante.getComentarioRRHH(), postulanteId);
//post.save(postulanteVd);
return "redirect:/postulante/"+postulanteId;
}
}
\ No newline at end of file
package com.roshka.modelo;
public enum EstadoPostulante {
NUEVO("Nuevo"), CONTACTADO("Contactado"), RECHAZADO("Rechazado"), CONTRADADO("Contradado"), VOLVERLLAMAR ("Volver a llamar");
private final String estado;
EstadoPostulante(String estado){
this.estado=estado;
}
public String getEstado(){
return this.estado;
}
}
package com.roshka.modelo;
import java.util.Arrays;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class EstadoPostulanteConverter implements AttributeConverter<EstadoPostulante, String>, org.springframework.core.convert.converter.Converter<String,EstadoPostulante> {
@Override
public String convertToDatabaseColumn(EstadoPostulante modalidad) {
if (modalidad == null) {
return null;
}
return modalidad.getEstado();
}
@Override
public EstadoPostulante convertToEntityAttribute(String estado) {
if (estado == null) {
return null;
}
return Arrays.stream(EstadoPostulante.values())
.filter(c -> c.getEstado().equals(estado))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
@Override
public EstadoPostulante convert(String arg0) {
return convertToEntityAttribute(arg0);
}
}
......@@ -72,6 +72,13 @@ public class Postulante {
@Column(name="estado_civil")
@NotNull
private EstadoCivil estadoCivil;
@Column(name="estado_postulante")
@NotNull
private EstadoPostulante estadoPostulante=EstadoPostulante.NUEVO;
@Column(name="comentario_rrhh")
private String comentarioRRHH;
@Column(name="nacionalidad", length = 2)
@NotNull
......@@ -271,4 +278,17 @@ public class Postulante {
public List<ReferenciaPersonal> getReferencias() {
return referencias;
}
public EstadoPostulante getEstadoPostulante() {
return this.estadoPostulante;
}
public void setEstadoPostulante(EstadoPostulante estadoPostulante) {
this.estadoPostulante = estadoPostulante;
}
public String getComentarioRRHH(){
return comentarioRRHH;
}
public void setComentarioRRHH(String comentarioRRHH){
this.comentarioRRHH=comentarioRRHH;
}
}
......@@ -2,13 +2,17 @@ package com.roshka.repositorio;
import java.util.List;
import javax.transaction.Transactional;
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.Modifying;
import org.springframework.data.jpa.repository.Query;
import com.roshka.modelo.Disponibilidad;
import com.roshka.modelo.EstadoPostulante;
import com.roshka.modelo.Postulante;
......@@ -55,7 +59,23 @@ public interface PostulanteRepository extends JpaRepository<Postulante,Long> {
"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 ) "+
" and (conv.cargoId = ?7 or ?7 is null ) ")
public Page<Postulante> postulantesMultiFiltro(TypedParameterValue nombre, Disponibilidad disponibilidad, Long nivelInges, Long nivel, Long tecnoId, Long instId,Long cargoId, Pageable pageable);
" and (conv.cargoId = ?7 or ?7 is null ) "+
"and (p.estadoPostulante = ?8 or ?8 is null) " )
public Page<Postulante> postulantesMultiFiltro(TypedParameterValue nombre, Disponibilidad disponibilidad, Long nivelInges, Long nivel, Long tecnoId, Long instId,Long cargoId, Pageable pageable, EstadoPostulante estado);
@Transactional
@Modifying
@Query("UPDATE Postulante p SET p.estadoPostulante = ?1 , p.comentarioRRHH = ?2 WHERE p.id = ?3")
void setPostulanteEstadoAndComentario(EstadoPostulante eP, String comentario, Long Id);
/*@Transactional
@Modifying
@Query("UPDATE Postulante p SET p.estadoPostulante = ?1 WHERE p.id = ?2")
void setPostulanteEstadoPostulante(EstadoPostulante eP, Long Id);
@Transactional
@Modifying
@Query("UPDATE Postulante p SET p.comentarioRRHH = ?1 WHERE p.id = ?2")
void setPostulanteEstadoComentario( String comentario, Long Id);*/
}
......@@ -27,8 +27,9 @@
<label>Curriculum: ${postulante.curriculum}</label><br>
<label>Estado civil: ${postulante.estadoCivil}</label><br>
<label>Nacionalidad: ${postulante.nacionalidad}</label><br>
<label>Disponibilidad: ${postulante.disponibilidad}</label><br>
<label>Disponibilidad: ${postulante.disponibilidad}</label><br>
<label>Estado del Postulante: ${postulante.estadoPostulante.getEstado()}</label><br>
<label>Comentario RRHH: ${postulante.getComentarioRRHH()}</label><br>
<br><label>TECNOLOGIAS</label><br>
<c:forEach items="${postulante.tecnologias}" var="detalle_tecnologia">
<label>Tecnologias: ${detalle_tecnologia.getTecnologia().getNombre()} -</label>
......@@ -75,7 +76,35 @@
</div>
<div style="padding:10px ;margin: 5px;border: 3px solid black;">
<h2>Cambiar Estado del Postulante y Comentario de RRHH</h2>
<form:form class="needs-validation" method="post" modelAttribute="postulante">
<form:label path="estadoPostulante" class="form-label">Estado</form:label>
<div class="inputs">
<form:select class="form-select" path="estadoPostulante" aria-label="Default select example">
<c:forEach items="${estadoP}" var="estadoPostulante">
<c:choose>
<c:when test="${estadoPostulante.getEstado()=='Nuevo' }">
</c:when>
<c:otherwise>
<form:option value="${estadoPostulante}">${estadoPostulante.getEstado()}</form:option>
</c:otherwise>
</c:choose>
</c:forEach>
</form:select>
</div>
<div class="inputs">
<form:label path="comentarioRRHH" class="form-label">ComentarioRRHH</form:label>
<form:textarea class="form-control" path="comentarioRRHH" id="comentarioRRHH"></form:textarea>
</div>
<input type="submit" value="submit"/>
</form:form>
</div>
</body>
</html>
\ No newline at end of file
......@@ -18,6 +18,13 @@
<input type="text" name="nombre" id="nombre" value="${param.nombre}">
<button>Buscar</button>
<br>
<label for="estado">Estado</label>
<select name="estado" id="estado">
<option value="">Seleccione una opcion</option>
<c:forEach items="${estadoP}" var="estados">
<option value="${estados}" ${param.estado == estados ? "selected" : ""}>${estados.getEstado()}</option>
</c:forEach>
</select>
<label for="dispo">Disponbilidad</label>
<select name="dispo" id="dispo">
<option value="">Seleccione una opcion</option>
......@@ -74,6 +81,7 @@
<th scope="col">Nivel de Ingles</th>
<th scope="col">Experiencia</th>
<th scope="col">Tecnologias</th>
<th scope="col">Estado</th>
</tr>
</thead>
<tbody>
......@@ -83,12 +91,13 @@
<td>${postulante.nombre} ${postulante.apellido}</td>
<td>${postulante.disponibilidad.getDescripcion()}</td>
<td>${postulante.nivelIngles}</td>
<td>${postulante.experienciaMeses}</td>
<td>${postulante.experienciaMeses}<op></td>
<td>
<c:forEach items="${postulante.tecnologias}" var="detalle_tecnologia" varStatus="staTec">
${detalle_tecnologia.getTecnologia().getNombre()}${not staTec.last ? "," : ""}
</c:forEach>
</td>
<td>${postulante.estado.getEstado()}</td>
<td><a href="/postulante/${postulante.id}">Ver</a></td>
</tr>
</c:forEach>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment