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
1
Merge Requests
1
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
Oscar Enrique Gonzalez Escurra
th-app-java
Commits
d4e647f7
Commit
d4e647f7
authored
Nov 10, 2021
by
willgonzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Postulantes convocatoria
parent
ee6c61fc
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
141 additions
and
6 deletions
+141
-6
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
+20
-3
curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java
+3
-0
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
+3
-0
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
+3
-1
curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java
+0
-0
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
+2
-1
curriculumsearch/src/main/resources/static/main.js
+73
-0
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
+37
-1
No files found.
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
View file @
d4e647f7
package
com
.
roshka
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
javax.validation.ConstraintViolationException
;
...
...
@@ -13,13 +14,18 @@ import com.roshka.modelo.EstadoCivil;
import
com.roshka.modelo.Nacionalidad
;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.TipoExperiencia
;
import
com.roshka.repositorio.CargoRepository
;
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
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.TecnologiaRepository
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.hibernate.type.IntegerType
;
import
org.hibernate.type.LongType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -38,15 +44,19 @@ public class PostulanteController {
InstitucionRepository
institucionRepository
;
DepartamentoRepository
depRepo
;
CiudadRepository
ciuRepo
;
ConvocatoriaRepository
cargoRepo
;
CargoRepository
carRepo
;
@Autowired
public
PostulanteController
(
PostulanteRepository
post
,
TecnologiaRepository
tecRepo
,
ExperienciaRepository
expRepo
,
InstitucionRepository
institucionRepository
,
DepartamentoRepository
depRepo
,
CiudadRepository
ciuRepo
)
{
public
PostulanteController
(
PostulanteRepository
post
,
TecnologiaRepository
tecRepo
,
ExperienciaRepository
expRepo
,
InstitucionRepository
institucionRepository
,
DepartamentoRepository
depRepo
,
CiudadRepository
ciuRepo
,
ConvocatoriaRepository
cargoRepo
,
CargoRepository
carRepo
)
{
this
.
post
=
post
;
this
.
tecRepo
=
tecRepo
;
this
.
expRepo
=
expRepo
;
this
.
institucionRepository
=
institucionRepository
;
this
.
depRepo
=
depRepo
;
this
.
ciuRepo
=
ciuRepo
;
this
.
cargoRepo
=
cargoRepo
;
this
.
carRepo
=
carRepo
;
}
...
...
@@ -75,11 +85,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
e
r
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
r
.
printStackTrace
();
}
model
.
addAttribute
(
"departamentos"
,
depRepo
.
findAll
());
...
...
@@ -94,6 +105,12 @@ public class PostulanteController {
).
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
()){
Institucion
institucion
=
institucionRepository
.
findByNombre
(
estudio
.
getInstitucion
().
getNombre
());
if
(
institucion
==
null
){
...
...
curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java
View file @
d4e647f7
...
...
@@ -47,4 +47,7 @@ public class Cargo {
public
void
setConvocatorias
(
List
<
ConvocatoriaCargo
>
convocatorias
)
{
this
.
convocatorias
=
convocatorias
;
}
public
static
Object
values
()
{
return
null
;
}
}
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
View file @
d4e647f7
...
...
@@ -15,10 +15,13 @@ 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
)
...
...
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
View file @
d4e647f7
...
...
@@ -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,6 +16,7 @@ import java.util.List;
@Entity
@Table
(
name
=
"postulante"
)
@JsonIdentityInfo
(
generator
=
ObjectIdGenerators
.
UUIDGenerator
.
class
,
property
=
"@UUID"
)
public
class
Postulante
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
...
...
@@ -103,7 +106,6 @@ public class Postulante {
joinColumns
=
@JoinColumn
(
name
=
"postulante_id"
,
referencedColumnName
=
"id"
),
inverseJoinColumns
=
@JoinColumn
(
name
=
"convocatoria_cargo_id"
,
referencedColumnName
=
"id"
)
)
@JsonIgnore
private
List
<
ConvocatoriaCargo
>
postulaciones
;
...
...
curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java
View file @
d4e647f7
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
View file @
d4e647f7
...
...
@@ -11,7 +11,8 @@ import org.springframework.data.jpa.repository.Query;
public
interface
ConvocatoriaRepository
extends
JpaRepository
<
ConvocatoriaCargo
,
Long
>
{
public
List
<
ConvocatoriaCargo
>
findByCargoId
(
Long
cargoId
);
//@Query(value="selec x from ConvocatoriaCargo x where (x.fechaFinal > ?1)",nativeQuery = true)
//public List<ConvocatoriaCargo> 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
<
ConvocatoriaCargo
>
f1ndByCargoAndEstado
(
TypedParameterValue
cargoId
,
Date
fecha
,
TypedParameterValue
isOpen
);
}
curriculumsearch/src/main/resources/static/main.js
View file @
d4e647f7
var
cont_experiencia
=
0
;
let
cont_estudios
=
0
;
let
cont_tecnologia
=
0
;
let
cont_cargo
=
0
;
const
experiencias
=
[];
const
estudios
=
[];
const
tecnologias
=
[];
const
postulaciones
=
[];
const
formValidator
=
function
()
{
'use strict'
...
...
@@ -190,6 +192,7 @@ 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
// Return the JSON string
return
JSON
.
stringify
(
pairs
,
null
,
2
);
...
...
@@ -319,7 +322,77 @@ function eliminarEstudio(event) {
//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
<
requiredValues
.
length
;
i
++
){
message
+=
", "
+
requiredValues
[
i
];
}
message
+=
" como minimo."
alert
(
message
);
return
;
}
for
(
const
[
name
,
value
]
of
formData
){
pairs
[
name
]
=
value
}
console
.
log
(
pairs
)
postulaciones
[
cont_cargo
]
=
{}
postulaciones
[
cont_cargo
][
"id"
]
=
pairs
[
"cargo-id"
]
//postulaciones[cont_cargo]["cargo"]=pairs["cargo-id"]=="-1"?{nombre: pairs["cargo-nombre"]}:{id: pairs["cargo-id"],nombre:document.querySelector('[name=cargo-id] > option[value="'+pairs["cargo-id"]+'"]').innerHTML}
console
.
log
(
postulaciones
)
formcar
.
reset
();
//imprimir lista actualizada
const
div
=
document
.
querySelector
(
"#cargos"
)
const
div1
=
document
.
createElement
(
'div'
);
console
.
log
(
postulaciones
[
0
])
let
content1
=
'<ul>'
for
(
let
index
=
0
;
index
<
postulaciones
.
length
;
index
++
)
{
const
car
=
postulaciones
[
index
];
if
(
car
==
null
)
continue
;
content1
+=
`
<li id="car-
${
index
}
">
${
document
.
querySelector
(
'[name=cargo-id] > option[value="'
+
pairs
[
"cargo-id"
]
+
'"]'
).
innerHTML
}
<button type="button" onclick="eliminarCargoPostulante(event)">Eliminar</button>
</li>
`
}
content1
+=
"</ul>"
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
...
...
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
View file @
d4e647f7
...
...
@@ -260,6 +260,12 @@
</select>
</div>
<div
class=
"inputs p-3 py-5"
>
<div
class=
" inputs d-flex justify-content-between align-items-center experience"
><span
class=
"border px-3 p-1 add-experience"
data-toggle=
"modal"
data-target=
"#cargoForm"
><i
class=
"fa fa-plus"
></i>
Cargo al que postulas
</span></div><br>
</div>
<div
class=
"mt-3 gap-2 d-flex justify-content-between"
id=
"cargos"
>
</div>
<div
class=
"inputs p-3 py-5"
>
<div
class=
" inputs d-flex justify-content-between align-items-center experience"
><span
class=
"border px-3 p-1 add-experience"
data-toggle=
"modal"
data-target=
"#experienciaForm"
><i
class=
"fa fa-plus"
></i>
Agregar Experiencia
</span></div><br>
...
...
@@ -296,7 +302,37 @@
</div>
</div>
</form>
<!---------------------------------------Modal de Cargos disponibles---------------------------------------------------------------->
<div
class=
"modal fade"
id=
"cargoForm"
tabindex=
"-2"
role=
"dialog"
aria-labelledby=
"cargoForm"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLabel"
>
CargosDisponibles
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
<form
name=
"cargo-form"
class=
"needs-validation"
novalidate
>
<label
for=
"cargo-nombre"
class=
"form-label"
>
Cargo
</label>
<div
class=
"input-group mb-3"
>
<select
class=
"form-select"
name=
"cargo-id"
aria-label=
"Default select example"
required
>
<option
value=
"-1"
selected
>
Open this select menu
</option>
<c:forEach
items=
"${CargosDisponibles}"
var=
"convocatoria"
>
<option
value=
"${convocatoria.getId()}"
>
${convocatoria.getCargo().getNombre()}
</option>
</c:forEach>
>
</select>
</div>
</form>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Close
</button>
<button
type=
"button"
class=
"btn btn-primary"
onclick=
"agregarFieldCargo()"
data-dismiss=
"modal"
>
Agregar
</button>
</div>
</div>
</div>
</div>
<!-------------------------------------------------------------------------------------------------------------------------->
<!--Modal de Experiencia-->
<div
class=
"modal fade"
id=
"experienciaForm"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"experienciaForm"
aria-hidden=
"true"
>
...
...
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