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
84b0c84e
Commit
84b0c84e
authored
Nov 09, 2021
by
Cesar Giulano Gonzalez Maqueda
Browse files
Options
Browse Files
Download
Plain Diff
Merge con joel
parents
3b579ba3
2bf14160
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
229 additions
and
57 deletions
+229
-57
curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java
+71
-0
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
+42
-4
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
+11
-1
curriculumsearch/src/main/webapp/jsp/postulantes.jsp
+82
-48
No files found.
curriculumsearch/src/main/java/com/roshka/DTO/PostulanteListaDTO.java
0 → 100644
View file @
84b0c84e
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 @
84b0c84e
package
com
.
roshka
.
controller
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
import
javax.validation.ConstraintViolationException
;
import
com.roshka.DTO.PostulanteListaDTO
;
import
com.roshka.modelo.*
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -13,7 +17,17 @@ import com.roshka.modelo.Nacionalidad;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.TipoExperiencia
;
import
com.roshka.repositorio.*
;
import
com.roshka.repositorio.CiudadRepository
;
import
com.roshka.repositorio.DepartamentoRepository
;
import
com.roshka.repositorio.ExperienciaRepository
;
import
com.roshka.repositorio.InstitucionRepository
;
import
com.roshka.repositorio.PostulanteRepository
;
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.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -55,10 +69,32 @@ public class PostulanteController {
@RequestMapping
(
"/postulantes"
)
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
)
Long
lvlEng
,
@RequestParam
(
required
=
false
)
Long
lvlTec
,
@RequestParam
(
required
=
false
)
Long
instId
,
@RequestParam
(
required
=
false
)
Long
expInMonths
)
{
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findAll
());
if
(
tecnologidaId
==
null
)
model
.
addAttribute
(
"postulantes"
,
post
.
findAll
());
else
model
.
addAttribute
(
"postulantes"
,
post
.
buscarPostulantesPorTecnologia
(
tecnologidaId
));
model
.
addAttribute
(
"disponibilidades"
,
Disponibilidad
.
values
());
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"
;
}
...
...
@@ -90,7 +126,9 @@ public class PostulanteController {
tec
->
tec
.
setTecnologia
(
tecRepo
.
getById
(
tec
.
getTecnologia
().
getId
()))
);
for
(
Estudio
estudio:
postulante
.
getEstudios
()){
Institucion
institucion
=
institucionRepository
.
findByNombre
(
estudio
.
getInstitucion
().
getNombre
());
String
nombreIns
=
""
;
nombreIns
=
estudio
.
getInstitucion
().
getNombre
().
toLowerCase
();
Institucion
institucion
=
institucionRepository
.
findByNombre
(
nombreIns
);
if
(
institucion
==
null
){
institucionRepository
.
save
(
estudio
.
getInstitucion
());
}
else
{
...
...
curriculumsearch/src/main/java/com/roshka/modelo/DisponibilidadConverter.java
View file @
84b0c84e
...
...
@@ -6,7 +6,7 @@ import javax.persistence.AttributeConverter;
import
javax.persistence.Converter
;
@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
public
String
convertToDatabaseColumn
(
Disponibilidad
modalidad
)
{
...
...
@@ -27,4 +27,9 @@ public class DisponibilidadConverter implements AttributeConverter<Disponibilida
.
findFirst
()
.
orElseThrow
(
IllegalArgumentException:
:
new
);
}
@Override
public
Disponibilidad
convert
(
String
arg0
)
{
return
convertToEntityAttribute
(
arg0
);
}
}
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
View file @
84b0c84e
...
...
@@ -61,7 +61,7 @@ public class Postulante {
@Column
(
name
=
"nivel_ingles"
)
@Min
(
value
=
1
)
@Max
(
value
=
5
)
private
long
nivelIngles
;
private
Integer
nivelIngles
;
@Column
(
name
=
"curriculum"
)
private
String
curriculum
;
...
...
@@ -175,11 +175,11 @@ public class Postulante {
this
.
resumen
=
resumen
;
}
public
long
getNivelIngles
()
{
public
Integer
getNivelIngles
()
{
return
nivelIngles
;
}
public
void
setNivelIngles
(
long
nivelIngles
)
{
public
void
setNivelIngles
(
Integer
nivelIngles
)
{
this
.
nivelIngles
=
nivelIngles
;
}
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java
View file @
84b0c84e
...
...
@@ -2,9 +2,11 @@ package com.roshka.repositorio;
import
java.util.List
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
com.roshka.modelo.Disponibilidad
;
import
com.roshka.modelo.Postulante
;
...
...
@@ -35,4 +37,16 @@ public interface PostulanteRepository extends JpaRepository<Postulante,Long> {
"join Tecnologia tec on pt.tecnologia.id=tec.id "
+
"where tec.nombre=?1 and pt.nivel=?2"
)
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
,
Long
nivelInges
,
Long
nivel
,
Long
tecnoId
,
Long
instId
);
}
curriculumsearch/src/main/java/com/roshka/utils/Helper.java
View file @
84b0c84e
...
...
@@ -2,6 +2,9 @@ package com.roshka.utils;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.YearMonth
;
import
java.time.ZoneOffset
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Date
;
public
class
Helper
{
...
...
@@ -12,7 +15,7 @@ public class Helper {
*/
public
static
Date
convertirFecha
(
String
fecha
)
{
try
{
if
(
fecha
==
null
||
fecha
.
trim
().
equals
(
""
))
return
null
;
return
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
parse
(
fecha
);
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
...
...
@@ -21,4 +24,11 @@ public class Helper {
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 @
84b0c84e
...
...
@@ -11,52 +11,78 @@
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin=
"anonymous"
></script>
<title>
Lista de postulantes
</title>
</head>
<body>
<div
class=
"container"
>
<jsp:include
page=
"header.jsp"
/>
<div
id=
"buscador"
>
<div
class=
"dropdown"
id=
"experiencia"
>
<a
class=
"btn btn-secondary dropdown-toggle"
href=
"#"
role=
"button"
id=
"dropdownMenuLink"
data-bs-toggle=
"dropdown"
aria-expanded=
"false"
>
Experiencia
</a>
<ul
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuLink"
>
<li><a
class=
"dropdown-item"
href=
"#"
>
Junior
</a></li>
<li><a
class=
"dropdown-item"
href=
"#"
>
Semisenior
</a></li>
<li><a
class=
"dropdown-item"
href=
"#"
>
Senior
</a></li>
</ul>
</div>
<div
class=
"dropdown"
id=
"tecnologia"
>
<a
class=
"btn btn-secondary dropdown-toggle"
href=
"#"
role=
"button"
id=
"dropdownMenuLink"
data-bs-toggle=
"dropdown"
aria-expanded=
"false"
>
Tecnologia
</a>
<ul
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuLink"
>
<c:forEach
items=
"${tecnologias}"
var=
"tecnologia"
>
<li><a
class=
"dropdown-item"
href=
"?tec=${tecnologia.id}"
>
${tecnologia.nombre}
</a></li>
</c:forEach>
</ul>
</div>
</div>
<table
class=
"table"
>
<thead>
<tr>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
Nombre
</th>
<th
scope=
"col"
>
Disponibilidad
</th>
<th
scope=
"col"
>
Nivel de Ingles
</th>
<th
scope=
"col"
>
Experiencia
</th>
<th
scope=
"col"
>
Tecnologias
</th>
</tr>
</thead>
<tbody>
<body
class=
"container"
>
<div
id=
"buscador"
>
<form
name=
"buscador"
>
<label
for=
"nombre"
>
Nombre
</label>
<input
type=
"text"
name=
"nombre"
id=
"nombre"
value=
"${param.nombre}"
>
<button>
Buscar
</button>
<br>
<label
for=
"dispo"
>
Disponbilidad
</label>
<select
name=
"dispo"
id=
"dispo"
>
<option
value=
""
>
Seleccione una opcion
</option>
<c:forEach
items=
"${disponibilidades}"
var=
"disponibilidad"
>
<option
value=
"${disponibilidad}"
${
param
.
dispo =
=
disponibilidad
?
"
selected
"
:
""}
>
${disponibilidad.getDescripcion()}
</option>
</c:forEach>
</select>
<label
for=
"tecId"
>
Tecnologias
</label>
<select
name=
"tecId"
id=
"tecId"
>
<option
value=
""
>
Seleccione una opcion
</option>
<c:forEach
items=
"${tecnologias}"
var=
"tecnologia"
>
<option
value=
"${tecnologia.id}"
${
param
.
tecId =
=
tecnologia
.
id
?
"
selected
"
:
""}
>
${tecnologia.nombre}
</option>
</c:forEach>
</select>
<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>
<table
class=
"table"
>
<thead>
<tr>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
Nombre
</th>
<th
scope=
"col"
>
Disponibilidad
</th>
<th
scope=
"col"
>
Nivel de Ingles
</th>
<th
scope=
"col"
>
Experiencia
</th>
<th
scope=
"col"
>
Tecnologias
</th>
</tr>
</thead>
<tbody>
<c:forEach
items=
"${postulantes}"
var=
"postulante"
varStatus=
"staPost"
>
<tr>
<th
scope=
"row"
>
${staPost.index + 1}
</th>
<td>
${postulante.nombre} ${postulante.apellido}
</td>
<td>
${postulante.disponibilidad.getDescripcion()}
</td>
<td>
${postulante.nivelIngles}
</td>
<td>
0
</td>
<td>
${postulante.experienciaMeses}
</td>
<td>
<c:forEach
items=
"${postulante.tecnologias}"
var=
"detalle_tecnologia"
varStatus=
"staTec"
>
${detalle_tecnologia.getTecnologia().getNombre()}${not staTec.last ? "," : ""}
...
...
@@ -65,13 +91,20 @@
</tr>
</c:forEach>
</tbody>
</table>
<div
id=
"paginator"
>
</div>
</div>
</div>
<script>
function
habilitarLvlTec
(){
//si se selecciono una tecnologia entonces permitir seleccionar un nivel
lvlTec
.
disabled
=
tecId
.
value
==
false
if
(
lvlTec
.
disabled
){
lvlTec
.
firstElementChild
.
selected
=
true
;
}
}
const
tecId
=
document
.
querySelector
(
"#tecId"
);
const
lvlTec
=
document
.
querySelector
(
"#lvlTec"
);
tecId
.
addEventListener
(
'change'
,
habilitarLvlTec
);
habilitarLvlTec
()
</script>
</body>
</html>
\ No newline at end of file
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