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
9c2b22fe
Commit
9c2b22fe
authored
Nov 08, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
editar cargos y convocatorias. listar cargos
parent
62c9343f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
153 additions
and
51 deletions
+153
-51
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
+16
-37
curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java
+72
-0
curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java
+3
-3
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
+3
-3
curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java
+3
-1
curriculumsearch/src/main/webapp/jsp/cargo-form.jsp
+1
-1
curriculumsearch/src/main/webapp/jsp/cargos.jsp
+50
-0
curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp
+1
-5
curriculumsearch/src/main/webapp/jsp/convocatorias.jsp
+2
-1
curriculumsearch/src/main/webapp/jsp/index.jsp
+2
-0
No files found.
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
View file @
9c2b22fe
package
com
.
roshka
.
controller
;
package
com
.
roshka
.
controller
;
import
java.util.Date
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.repositorio.CargoRepository
;
import
com.roshka.repositorio.CargoRepository
;
import
com.roshka.repositorio.ConvocatoriaRepository
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Controller
@Controller
public
class
CargoController
{
public
class
CargoController
{
CargoRepository
cargoRepo
;
CargoRepository
cargoRepo
;
ConvocatoriaRepository
convoRepo
;
@Autowired
@Autowired
public
CargoController
(
CargoRepository
cargoRepo
,
ConvocatoriaRepository
convoRepo
)
{
public
CargoController
(
CargoRepository
cargoRepo
)
{
this
.
cargoRepo
=
cargoRepo
;
this
.
cargoRepo
=
cargoRepo
;
this
.
convoRepo
=
convoRepo
;
}
}
@RequestMapping
(
"/c
onvocatoria
s"
)
@RequestMapping
(
"/c
argo
s"
)
public
String
menuCargos
(
Model
model
,
public
String
menuCargos
(
Model
model
,
@RequestParam
(
required
=
false
)
Long
cargoId
,
@RequestParam
(
required
=
false
)
String
nombre
@RequestParam
(
required
=
false
)
Integer
isOpen
//1: true, 0: false
)
{
)
{
if
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
())
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
else
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findByNombreContainingIgnoreCase
(
nombre
));
return
"cargos"
;
model
.
addAttribute
(
"convocatorias"
,
convoRepo
.
f1ndByCargoAndEstado
(
new
TypedParameterValue
(
LongType
.
INSTANCE
,
cargoId
),
new
Date
(),
new
TypedParameterValue
(
IntegerType
.
INSTANCE
,
isOpen
)));
//model.addAttribute("convocatorias",cargoId==null? convoRepo.findAll() : convoRepo.findByCargoId(cargoId));
return
"convocatorias"
;
}
}
@RequestMapping
(
"/cargo"
)
@RequestMapping
(
path
=
{
"/cargo"
,
"/cargo/{id}"
},
method
=
RequestMethod
.
GET
)
public
String
formCargo
(
Model
model
)
{
public
String
formCargo
(
Model
model
,
@PathVariable
(
required
=
false
)
Long
id
)
{
model
.
addAttribute
(
"cargo"
,
new
Cargo
());
if
(
id
==
null
)
model
.
addAttribute
(
"cargo"
,
new
Cargo
());
else
model
.
addAttribute
(
"cargo"
,
cargoRepo
.
getById
(
id
));
return
"cargo-form"
;
return
"cargo-form"
;
}
}
@PostMapping
(
"/cargo"
)
@PostMapping
(
path
=
{
"/cargo"
,
"/cargo/{id}"
}
)
public
String
guardarCargo
(
@ModelAttribute
Cargo
cargo
,
BindingResult
result
)
{
public
String
guardarCargo
(
@ModelAttribute
Cargo
cargo
,
BindingResult
result
,
@PathVariable
(
required
=
false
)
Long
id
)
{
if
(
result
.
hasErrors
());
if
(
result
.
hasErrors
());
if
(
id
!=
null
)
cargo
.
setId
(
id
);
cargoRepo
.
save
(
cargo
);
cargoRepo
.
save
(
cargo
);
System
.
out
.
println
(
cargo
.
getNombre
());
System
.
out
.
println
(
cargo
.
getNombre
());
return
"redirect:/cargos"
;
return
"redirect:/cargos"
;
}
}
@RequestMapping
(
"/convocatoria"
)
public
String
formConvocatoria
(
Model
model
)
{
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"convocatoria"
,
new
ConvocatoriaCargo
());
return
"convocatoria-form"
;
}
@PostMapping
(
"/convocatoria"
)
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
)
{
if
(
result
.
hasErrors
());
convoRepo
.
save
(
convocatoria
);
System
.
out
.
println
(
convocatoria
.
getFechaInicio
());
return
"redirect:/cargos"
;
}
}
}
curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java
0 → 100644
View file @
9c2b22fe
package
com
.
roshka
.
controller
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.repositorio.CargoRepository
;
import
com.roshka.repositorio.ConvocatoriaRepository
;
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.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Controller
public
class
ConvocatoriaController
{
CargoRepository
cargoRepo
;
ConvocatoriaRepository
convoRepo
;
@Autowired
public
ConvocatoriaController
(
CargoRepository
cargoRepo
,
ConvocatoriaRepository
convoRepo
)
{
this
.
cargoRepo
=
cargoRepo
;
this
.
convoRepo
=
convoRepo
;
}
@RequestMapping
(
"/convocatorias"
)
public
String
menuConvocatorias
(
Model
model
,
@RequestParam
(
required
=
false
)
Long
cargoId
,
@RequestParam
(
required
=
false
)
Integer
isOpen
//1: true, 0: false
)
{
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
model
.
addAttribute
(
"convocatorias"
,
convoRepo
.
f1ndByCargoAndEstado
(
new
TypedParameterValue
(
LongType
.
INSTANCE
,
cargoId
),
new
Date
(),
new
TypedParameterValue
(
IntegerType
.
INSTANCE
,
isOpen
)));
//model.addAttribute("convocatorias",cargoId==null? convoRepo.findAll() : convoRepo.findByCargoId(cargoId));
return
"convocatorias"
;
}
@RequestMapping
(
path
=
{
"/convocatoria"
,
"/convocatoria/{id}"
})
public
String
formConvocatoria
(
Model
model
,
@PathVariable
(
required
=
false
)
Long
id
)
{
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
if
(
id
==
null
)
model
.
addAttribute
(
"convocatoria"
,
new
ConvocatoriaCargo
());
else
{
ConvocatoriaCargo
cc
=
convoRepo
.
getById
(
id
);
cc
.
setFechaFinS
(
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
((
cc
.
getFechaFin
())));
cc
.
setFechaInicioS
(
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
((
cc
.
getFechaInicio
())));
model
.
addAttribute
(
"convocatoria"
,
cc
);
}
return
"convocatoria-form"
;
}
@PostMapping
(
path
=
{
"/convocatoria"
,
"/convocatoria/{id}"
})
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
,
@PathVariable
(
required
=
false
)
Long
id
)
{
if
(
result
.
hasErrors
());
if
(
id
!=
null
)
convocatoria
.
setId
(
id
);
convoRepo
.
save
(
convocatoria
);
System
.
out
.
println
(
convocatoria
.
getFechaInicio
());
return
"redirect:/convocatorias"
;
}
}
curriculumsearch/src/main/java/com/roshka/modelo/Cargo.java
View file @
9c2b22fe
...
@@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
...
@@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
public
class
Cargo
{
public
class
Cargo
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
l
ong
id
;
private
L
ong
id
;
@NotBlank
@NotBlank
@Column
(
name
=
"nombre"
)
@Column
(
name
=
"nombre"
)
...
@@ -28,13 +28,13 @@ public class Cargo {
...
@@ -28,13 +28,13 @@ public class Cargo {
@JsonManagedReference
@JsonManagedReference
private
List
<
ConvocatoriaCargo
>
convocatorias
;
private
List
<
ConvocatoriaCargo
>
convocatorias
;
public
l
ong
getId
()
{
public
L
ong
getId
()
{
return
id
;
return
id
;
}
}
public
String
getNombre
()
{
public
String
getNombre
()
{
return
nombre
;
return
nombre
;
}
}
public
void
setId
(
l
ong
id
)
{
public
void
setId
(
L
ong
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
void
setNombre
(
String
nombre
)
{
public
void
setNombre
(
String
nombre
)
{
...
...
curriculumsearch/src/main/java/com/roshka/modelo/ConvocatoriaCargo.java
View file @
9c2b22fe
...
@@ -22,7 +22,7 @@ import com.roshka.utils.Helper;
...
@@ -22,7 +22,7 @@ import com.roshka.utils.Helper;
public
class
ConvocatoriaCargo
{
public
class
ConvocatoriaCargo
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
l
ong
id
;
private
L
ong
id
;
@ManyToOne
()
@ManyToOne
()
@JoinColumn
(
name
=
"cargo_id"
,
insertable
=
false
,
updatable
=
false
)
@JoinColumn
(
name
=
"cargo_id"
,
insertable
=
false
,
updatable
=
false
)
...
@@ -52,7 +52,7 @@ public class ConvocatoriaCargo {
...
@@ -52,7 +52,7 @@ public class ConvocatoriaCargo {
@ManyToMany
(
mappedBy
=
"postulaciones"
)
@ManyToMany
(
mappedBy
=
"postulaciones"
)
private
List
<
Postulante
>
postulantes
;
private
List
<
Postulante
>
postulantes
;
public
l
ong
getId
()
{
public
L
ong
getId
()
{
return
id
;
return
id
;
}
}
public
Cargo
getCargo
()
{
public
Cargo
getCargo
()
{
...
@@ -67,7 +67,7 @@ public class ConvocatoriaCargo {
...
@@ -67,7 +67,7 @@ public class ConvocatoriaCargo {
public
Date
getFechaInicio
()
{
public
Date
getFechaInicio
()
{
return
fechaInicio
;
return
fechaInicio
;
}
}
public
void
setId
(
l
ong
id
)
{
public
void
setId
(
L
ong
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
void
setCargo
(
Cargo
cargo
)
{
public
void
setCargo
(
Cargo
cargo
)
{
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java
View file @
9c2b22fe
package
com
.
roshka
.
repositorio
;
package
com
.
roshka
.
repositorio
;
import
java.util.List
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.Cargo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
CargoRepository
extends
JpaRepository
<
Cargo
,
Long
>{
public
interface
CargoRepository
extends
JpaRepository
<
Cargo
,
Long
>{
public
List
<
Cargo
>
findByNombreContainingIgnoreCase
(
String
nombre
);
}
}
curriculumsearch/src/main/webapp/jsp/cargo-form.jsp
View file @
9c2b22fe
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
</head>
</head>
<body>
<body>
<div
class=
"container"
>
<div
class=
"container"
>
<form:form
action=
"/cargo"
method=
"post"
modelAttribute=
"cargo"
class=
"row row-cols-lg-auto g-3 align-items-center"
>
<form:form
action=
"/cargo
/${cargo.id == null ? '' : cargo.id}
"
method=
"post"
modelAttribute=
"cargo"
class=
"row row-cols-lg-auto g-3 align-items-center"
>
<div
class=
"col-12"
>
<div
class=
"col-12"
>
<form:label
class=
"form-label visually-hidden"
path=
"nombre"
>
Nombre del cargo
</form:label>
<form:label
class=
"form-label visually-hidden"
path=
"nombre"
>
Nombre del cargo
</form:label>
<form:input
type=
"text"
path=
"nombre"
class=
"form-control"
placeholder=
"Nombre del cargo"
/>
<form:input
type=
"text"
path=
"nombre"
class=
"form-control"
placeholder=
"Nombre del cargo"
/>
...
...
curriculumsearch/src/main/webapp/jsp/cargos.jsp
0 → 100644
View file @
9c2b22fe
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"form"
uri=
"http://www.springframework.org/tags/form"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Cargo
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin=
"anonymous"
>
<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>
</head>
<body
class=
"container"
>
<div>
<form>
<label
for=
"cargos"
>
Nombre:
</label>
<input
type=
"text"
name=
"nombre"
id=
"nombre"
value=
"${param.nombre}"
/>
<input
type=
"submit"
value=
"Buscar"
>
</form>
<a
href=
"/cargo"
>
Agregar Nuevo Cargo
</a>
</div>
<div>
<table
class=
"table"
>
<thead>
<tr>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
Cargo
</th>
</tr>
</thead>
<tbody>
<c:forEach
items=
"${cargos}"
var=
"cargo"
varStatus=
"sta"
>
<tr>
<th
scope=
"row"
>
${sta.index+1}
</th>
<td>
${cargo.getNombre()}
</td>
<td><a
href=
"/convocatorias?cargoId=${cargo.id}"
>
Ver Convocatorias
</a></td>
<td><a
href=
"/cargo/${cargo.id}"
>
Editar cargo
</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
\ No newline at end of file
curriculumsearch/src/main/webapp/jsp/convocatoria-form.jsp
View file @
9c2b22fe
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
</head>
</head>
<body>
<body>
<div
class=
"container"
>
<div
class=
"container"
>
<form:form
action=
"/convocatoria"
method=
"post"
modelAttribute=
"convocatoria"
>
<form:form
action=
"/convocatoria
/${convocatoria.id == null ? '' : convocatoria.id}
"
method=
"post"
modelAttribute=
"convocatoria"
>
<div
class=
"mb-3"
>
<div
class=
"mb-3"
>
<form:label
path=
"fechaInicioS"
class=
"form-label"
>
Fecha inicial
</form:label>
<form:label
path=
"fechaInicioS"
class=
"form-label"
>
Fecha inicial
</form:label>
<form:input
type=
"date"
class=
"form-control"
path=
"fechaInicioS"
/>
<form:input
type=
"date"
class=
"form-control"
path=
"fechaInicioS"
/>
...
@@ -37,9 +37,6 @@
...
@@ -37,9 +37,6 @@
</div>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Guardar
</button>
<button
type=
"submit"
class=
"btn btn-primary"
>
Guardar
</button>
</form:form>
</form:form>
</div>
</div>
</body>
</body>
</html>
</html>
\ No newline at end of file
curriculumsearch/src/main/webapp/jsp/convocatorias.jsp
View file @
9c2b22fe
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
<label
for=
"cerrado"
>
Cerrado
</label><br>
<label
for=
"cerrado"
>
Cerrado
</label><br>
<input
type=
"submit"
value=
"Buscar"
>
<input
type=
"submit"
value=
"Buscar"
>
</form>
</form>
<a
href=
"/cargo"
>
Agregar Nuevo Cargo
</a>
</div>
</div>
<div>
<div>
<a
href=
"/convocatoria"
>
Agregar Nueva Convocatoria
</a>
<a
href=
"/convocatoria"
>
Agregar Nueva Convocatoria
</a>
...
@@ -54,6 +53,7 @@
...
@@ -54,6 +53,7 @@
<td>
${convocatoria.getFechaFin().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getFechaFin().toString().split(" ")[0]}
</td>
<td>
${convocatoria.getCupos()}
</td>
<td>
${convocatoria.getCupos()}
</td>
<td>
Ver Postulantes
</td>
<td>
Ver Postulantes
</td>
<td><a
href=
"/convocatoria/${convocatoria.id}"
>
Editar
</a></td>
</tr>
</tr>
</c:forEach>
</c:forEach>
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
</tbody>
</tbody>
</table>
</table>
</div>
</div>
</body>
</body>
...
...
curriculumsearch/src/main/webapp/jsp/index.jsp
View file @
9c2b22fe
...
@@ -11,5 +11,6 @@
...
@@ -11,5 +11,6 @@
<a
href=
"postulantes"
>
Lista de postulantes
</a>
<a
href=
"postulantes"
>
Lista de postulantes
</a>
<a
href=
"#"
>
Tecnologias
</a>
<a
href=
"#"
>
Tecnologias
</a>
<a
href=
"convocatorias"
>
Lista de convocatorias
</a>
<a
href=
"convocatorias"
>
Lista de convocatorias
</a>
<a
href=
"cargos"
>
Lista de cargos
</a>
</body>
</body>
</html>
</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