Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amparo Oliver
th-app-java
Commits
47d5b40d
Commit
47d5b40d
authored
Nov 09, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lista postulante con filtro
parent
9c2b22fe
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
183 additions
and
28 deletions
+183
-28
curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java
+71
-0
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
+30
-3
curriculumsearch/src/main/java/com/roshka/modelo/DisponibilidadConverter.java
+6
-1
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
+3
-3
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java
+14
-0
curriculumsearch/src/main/java/com/roshka/utils/Helper.java
+10
-0
curriculumsearch/src/main/webapp/jsp/postulantes.jsp
+49
-21
No files found.
curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java
0 → 100644
View file @
47d5b40d
package
com
.
roshka
.
DTO
;
import
java.util.List
;
import
com.roshka.modelo.Disponibilidad
;
import
com.roshka.modelo.PostulanteTecnologia
;
public
class
PostulanteListaDTO
{
private
Long
id
;
private
String
nombre
;
private
String
apellido
;
private
Disponibilidad
disponibilidad
;
private
Integer
nivelIngles
;
private
Long
experienciaMeses
;
private
List
<
PostulanteTecnologia
>
tecnologias
;
public
PostulanteListaDTO
(
Long
id
,
String
nombre
,
String
apellido
,
Disponibilidad
disponibilidad
,
Integer
nivelIngles
,
Long
experienciaMeses
,
List
<
PostulanteTecnologia
>
tecnologias
)
{
this
.
id
=
id
;
this
.
nombre
=
nombre
;
this
.
apellido
=
apellido
;
this
.
disponibilidad
=
disponibilidad
;
this
.
nivelIngles
=
nivelIngles
;
this
.
experienciaMeses
=
experienciaMeses
;
this
.
tecnologias
=
tecnologias
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getNombre
()
{
return
nombre
;
}
public
void
setNombre
(
String
nombre
)
{
this
.
nombre
=
nombre
;
}
public
String
getApellido
()
{
return
apellido
;
}
public
void
setApellido
(
String
apellido
)
{
this
.
apellido
=
apellido
;
}
public
Disponibilidad
getDisponibilidad
()
{
return
disponibilidad
;
}
public
void
setDisponibilidad
(
Disponibilidad
disponibilidad
)
{
this
.
disponibilidad
=
disponibilidad
;
}
public
Integer
getNivelIngles
()
{
return
nivelIngles
;
}
public
void
setNivelIngles
(
Integer
nivelIngles
)
{
this
.
nivelIngles
=
nivelIngles
;
}
public
Long
getExperienciaMeses
()
{
return
experienciaMeses
;
}
public
void
setExperienciaMeses
(
Long
experienciaMeses
)
{
this
.
experienciaMeses
=
experienciaMeses
;
}
public
List
<
PostulanteTecnologia
>
getTecnologias
()
{
return
tecnologias
;
}
public
void
setTecnologias
(
List
<
PostulanteTecnologia
>
tecnologias
)
{
this
.
tecnologias
=
tecnologias
;
}
}
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
View file @
47d5b40d
package
com
.
roshka
.
controller
;
package
com
.
roshka
.
controller
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
javax.validation.ConstraintViolationException
;
import
javax.validation.ConstraintViolationException
;
import
com.roshka.DTO.PostulanteListaDTO
;
import
com.roshka.modelo.*
;
import
com.roshka.modelo.*
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
@@ -19,7 +21,10 @@ import com.roshka.repositorio.ExperienciaRepository;
...
@@ -19,7 +21,10 @@ import com.roshka.repositorio.ExperienciaRepository;
import
com.roshka.repositorio.InstitucionRepository
;
import
com.roshka.repositorio.InstitucionRepository
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.TecnologiaRepository
;
import
com.roshka.repositorio.TecnologiaRepository
;
import
com.roshka.utils.Helper
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.hibernate.type.StringType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
...
@@ -59,10 +64,32 @@ public class PostulanteController {
...
@@ -59,10 +64,32 @@ public class PostulanteController {
@RequestMapping
(
"/postulantes"
)
@RequestMapping
(
"/postulantes"
)
public
String
postulantes
(
Model
model
,
public
String
postulantes
(
Model
model
,
@RequestParam
(
required
=
false
,
name
=
"tec"
)
Long
tecnologidaId
)
{
@RequestParam
(
required
=
false
)
Long
tecId
,
@RequestParam
(
required
=
false
)
String
nombre
,
@RequestParam
(
required
=
false
)
Disponibilidad
dispo
,
@RequestParam
(
required
=
false
)
Integer
lvlEng
,
@RequestParam
(
required
=
false
)
Integer
lvlTec
,
@RequestParam
(
required
=
false
)
Long
instId
,
@RequestParam
(
required
=
false
)
Long
expInMonths
)
{
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findAll
());
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findAll
());
if
(
tecnologidaId
==
null
)
model
.
addAttribute
(
"postulantes"
,
post
.
findAll
());
model
.
addAttribute
(
"disponibilidades"
,
Disponibilidad
.
values
());
else
model
.
addAttribute
(
"postulantes"
,
post
.
buscarPostulantesPorTecnologia
(
tecnologidaId
));
model
.
addAttribute
(
"institucionesEducativas"
,
institucionRepository
.
findAll
());
List
<
Postulante
>
postulantes
=
post
.
postulantesMultiFiltro
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
()
?
new
TypedParameterValue
(
StringType
.
INSTANCE
,
null
)
:
new
TypedParameterValue
(
StringType
.
INSTANCE
,
"%"
+
nombre
+
"%"
),
dispo
,
lvlEng
,
lvlTec
,
tecId
,
instId
);
List
<
PostulanteListaDTO
>
postulantesDTO
=
new
ArrayList
<>();
for
(
Postulante
postulante
:
postulantes
)
{
long
expTotal
=
0
;
//Sumamos el tiempo de experiencia total en meses de cada postulante
//expTotal = postulante.getExperiencias().stream().mapToLong(e -> Helper.getMonthsDifference(e.getFechaDesde(), e.getFechaHasta())).sum();
for
(
Experiencia
experiencia
:
postulante
.
getExperiencias
())
{
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
()));
}
model
.
addAttribute
(
"postulantes"
,
postulantesDTO
);
return
"postulantes"
;
return
"postulantes"
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/modelo/DisponibilidadConverter.java
View file @
47d5b40d
...
@@ -6,7 +6,7 @@ import javax.persistence.AttributeConverter;
...
@@ -6,7 +6,7 @@ import javax.persistence.AttributeConverter;
import
javax.persistence.Converter
;
import
javax.persistence.Converter
;
@Converter
(
autoApply
=
true
)
@Converter
(
autoApply
=
true
)
public
class
DisponibilidadConverter
implements
AttributeConverter
<
Disponibilidad
,
String
>
{
public
class
DisponibilidadConverter
implements
AttributeConverter
<
Disponibilidad
,
String
>
,
org
.
springframework
.
core
.
convert
.
converter
.
Converter
<
String
,
Disponibilidad
>
{
@Override
@Override
public
String
convertToDatabaseColumn
(
Disponibilidad
modalidad
)
{
public
String
convertToDatabaseColumn
(
Disponibilidad
modalidad
)
{
...
@@ -27,4 +27,9 @@ public class DisponibilidadConverter implements AttributeConverter<Disponibilida
...
@@ -27,4 +27,9 @@ public class DisponibilidadConverter implements AttributeConverter<Disponibilida
.
findFirst
()
.
findFirst
()
.
orElseThrow
(
IllegalArgumentException:
:
new
);
.
orElseThrow
(
IllegalArgumentException:
:
new
);
}
}
@Override
public
Disponibilidad
convert
(
String
arg0
)
{
return
convertToEntityAttribute
(
arg0
);
}
}
}
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
View file @
47d5b40d
...
@@ -61,7 +61,7 @@ public class Postulante {
...
@@ -61,7 +61,7 @@ public class Postulante {
@Column
(
name
=
"nivel_ingles"
)
@Column
(
name
=
"nivel_ingles"
)
@Min
(
value
=
1
)
@Min
(
value
=
1
)
@Max
(
value
=
5
)
@Max
(
value
=
5
)
private
long
nivelIngles
;
private
Integer
nivelIngles
;
@Column
(
name
=
"curriculum"
)
@Column
(
name
=
"curriculum"
)
private
String
curriculum
;
private
String
curriculum
;
...
@@ -175,11 +175,11 @@ public class Postulante {
...
@@ -175,11 +175,11 @@ public class Postulante {
this
.
resumen
=
resumen
;
this
.
resumen
=
resumen
;
}
}
public
long
getNivelIngles
()
{
public
Integer
getNivelIngles
()
{
return
nivelIngles
;
return
nivelIngles
;
}
}
public
void
setNivelIngles
(
long
nivelIngles
)
{
public
void
setNivelIngles
(
Integer
nivelIngles
)
{
this
.
nivelIngles
=
nivelIngles
;
this
.
nivelIngles
=
nivelIngles
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java
View file @
47d5b40d
...
@@ -2,9 +2,11 @@ package com.roshka.repositorio;
...
@@ -2,9 +2,11 @@ package com.roshka.repositorio;
import
java.util.List
;
import
java.util.List
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
com.roshka.modelo.Disponibilidad
;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.Postulante
;
...
@@ -35,4 +37,16 @@ public interface PostulanteRepository extends JpaRepository<Postulante,Long> {
...
@@ -35,4 +37,16 @@ public interface PostulanteRepository extends JpaRepository<Postulante,Long> {
"join Tecnologia tec on pt.tecnologia.id=tec.id "
+
"join Tecnologia tec on pt.tecnologia.id=tec.id "
+
"where tec.nombre=?1 and pt.nivel=?2"
)
"where tec.nombre=?1 and pt.nivel=?2"
)
public
List
<
Postulante
>
findByPostulanteTecnologiaM
(
String
tecno
,
long
idt
);
public
List
<
Postulante
>
findByPostulanteTecnologiaM
(
String
tecno
,
long
idt
);
@Query
(
value
=
"select DISTINCT p "
+
"from Postulante p join p.experiencias x "
+
"join p.estudios e "
+
"join p.tecnologias pt "
+
"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
<
Postulante
>
postulantesMultiFiltro
(
TypedParameterValue
nombre
,
Disponibilidad
disponibilidad
,
Integer
nivelInges
,
Integer
nivel
,
Long
tecnoId
,
Long
instId
);
}
}
curriculumsearch/src/main/java/com/roshka/utils/Helper.java
View file @
47d5b40d
...
@@ -2,6 +2,9 @@ package com.roshka.utils;
...
@@ -2,6 +2,9 @@ package com.roshka.utils;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.YearMonth
;
import
java.time.ZoneOffset
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Date
;
import
java.util.Date
;
public
class
Helper
{
public
class
Helper
{
...
@@ -21,4 +24,11 @@ public class Helper {
...
@@ -21,4 +24,11 @@ public class Helper {
return
null
;
return
null
;
}
}
}
}
public
static
final
long
getMonthsDifference
(
Date
date1
,
Date
date2
)
{
YearMonth
m1
=
YearMonth
.
from
(
date1
.
toInstant
().
atZone
(
ZoneOffset
.
UTC
));
YearMonth
m2
=
YearMonth
.
from
(
date2
.
toInstant
().
atZone
(
ZoneOffset
.
UTC
));
return
m1
.
until
(
m2
,
ChronoUnit
.
MONTHS
)
+
1
;
}
}
}
curriculumsearch/src/main/webapp/jsp/postulantes.jsp
View file @
47d5b40d
...
@@ -13,28 +13,56 @@
...
@@ -13,28 +13,56 @@
</head>
</head>
<body
class=
"container"
>
<body
class=
"container"
>
<div
id=
"buscador"
>
<div
id=
"buscador"
>
<div
class=
"dropdown"
id=
"experiencia"
>
<form
name=
"buscador"
>
<a
class=
"btn btn-secondary dropdown-toggle"
href=
"#"
role=
"button"
id=
"dropdownMenuLink"
data-bs-toggle=
"dropdown"
aria-expanded=
"false"
>
<label
for=
"nombre"
>
Nombre
</label>
Experiencia
<input
type=
"text"
name=
"nombre"
id=
"nombre"
value=
"${param.nombre}"
>
</a>
<button>
Buscar
</button>
<br>
<ul
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuLink"
>
<label
for=
"dispo"
>
Disponbilidad
</label>
<li><a
class=
"dropdown-item"
href=
"#"
>
Junior
</a></li>
<select
name=
"dispo"
id=
"dispo"
>
<li><a
class=
"dropdown-item"
href=
"#"
>
Semisenior
</a></li>
<option
value=
""
>
Seleccione una opcion
</option>
<li><a
class=
"dropdown-item"
href=
"#"
>
Senior
</a></li>
<c:forEach
items=
"${disponibilidades}"
var=
"disponibilidad"
>
</ul>
<option
value=
"${disponibilidad}"
${
param
.
dispo =
=
disponibilidad
?
"
selected
"
:
""}
>
${disponibilidad.getDescripcion()}
</option>
</div>
</c:forEach>
<div
class=
"dropdown"
id=
"tecnologia"
>
</select>
<a
class=
"btn btn-secondary dropdown-toggle"
href=
"#"
role=
"button"
id=
"dropdownMenuLink"
data-bs-toggle=
"dropdown"
aria-expanded=
"false"
>
<label
for=
"tecId"
>
Tecnologias
</label>
Tecnologia
<select
name=
"tecId"
id=
"tecId"
>
</a>
<option
value=
""
>
Seleccione una opcion
</option>
<ul
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuLink"
>
<c:forEach
items=
"${tecnologias}"
var=
"tecnologia"
>
<c:forEach
items=
"${tecnologias}"
var=
"tecnologia"
>
<li><a
class=
"dropdown-item"
href=
"?tec=${tecnologia.id}"
>
${tecnologia.nombre}
</a></li
>
<option
value=
"${tecnologia.id}"
${
param
.
tecId =
=
tecnologia
.
id
?
"
selected
"
:
""}
>
${tecnologia.nombre}
</option
>
</c:forEach>
</c:forEach>
</ul>
</select>
</div>
<label
for=
"instId"
>
Institucion Educativa
</label>
<select
name=
"instId"
id=
"instId"
>
<option
value=
""
>
Seleccione una opcion
</option>
<c:forEach
items=
"${institucionesEducativas}"
var=
"inst"
>
<option
value=
"${inst.id}"
${
param
.
instId =
=
inst
.
id
?
"
selected
"
:
""}
>
${inst.nombre}
</option>
</c:forEach>
</select>
<br>
<label
for=
"lvlEng"
>
Nivel de Ingles
</label>
<select
name=
"lvlEng"
id=
"lvlEng"
>
<option
value=
""
>
Seleccione una opcion
</option>
<c:forEach
var =
"lvl"
begin =
"1"
end =
"5"
>
<option
value=
"${lvl}"
${
param
.
lvlEng =
=
lvl
?
"
selected
"
:
""}
>
${lvl}
</option>
</c:forEach>
</select>
<label
for=
"lvlTec"
>
Nivel de Tecnologia
</label>
<select
name=
"lvlTec"
id=
"lvlTec"
>
<option
value=
""
>
Seleccione una opcion
</option>
<c:forEach
var =
"lvl"
begin =
"1"
end =
"5"
>
<option
value=
"${lvl}"
${
param
.
lvlTec =
=
lvl
?
"
selected
"
:
""}
>
${lvl}
</option>
</c:forEach>
</select>
<label
for=
"expInMonths"
>
Experiencia en general
</label>
<select
name=
"expInMonths"
id=
"expInMonths"
>
<option
value=
""
>
Seleccione una opcion
</option>
<option
value=
"6"
>
Mayor a 6 meses
</option>
<option
value=
"12"
>
Mayor a 1 año
</option>
<option
value=
"36"
>
Mayor a 3 años
</option>
<option
value=
"60"
>
Mayor a 5 años
</option>
</select>
</form>
</div>
</div>
<table
class=
"table"
>
<table
class=
"table"
>
<thead>
<thead>
...
@@ -54,7 +82,7 @@
...
@@ -54,7 +82,7 @@
<td>
${postulante.nombre} ${postulante.apellido}
</td>
<td>
${postulante.nombre} ${postulante.apellido}
</td>
<td>
${postulante.disponibilidad.getDescripcion()}
</td>
<td>
${postulante.disponibilidad.getDescripcion()}
</td>
<td>
${postulante.nivelIngles}
</td>
<td>
${postulante.nivelIngles}
</td>
<td>
0
</td>
<td>
${postulante.experienciaMeses}
</td>
<td>
<td>
<c:forEach
items=
"${postulante.tecnologias}"
var=
"detalle_tecnologia"
varStatus=
"staTec"
>
<c:forEach
items=
"${postulante.tecnologias}"
var=
"detalle_tecnologia"
varStatus=
"staTec"
>
${detalle_tecnologia.getTecnologia().getNombre()}${not staTec.last ? "," : ""}
${detalle_tecnologia.getTecnologia().getNombre()}${not staTec.last ? "," : ""}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment