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
52078ec2
Commit
52078ec2
authored
Nov 02, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listar tecnologias existentes
parent
2c98ce83
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
8 deletions
+48
-8
curriculumsearch/pom.xml
+6
-0
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
+13
-2
curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java
+4
-2
curriculumsearch/src/main/resources/application.properties
+4
-1
curriculumsearch/src/main/resources/static/main.js
+5
-1
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
+16
-2
No files found.
curriculumsearch/pom.xml
View file @
52078ec2
...
@@ -57,6 +57,12 @@
...
@@ -57,6 +57,12 @@
<artifactId>
hibernate-validator
</artifactId>
<artifactId>
hibernate-validator
</artifactId>
<version>
6.0.13.Final
</version>
<version>
6.0.13.Final
</version>
</dependency>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
<version>
1.2
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
View file @
52078ec2
...
@@ -6,11 +6,13 @@ import javax.validation.ConstraintViolationException;
...
@@ -6,11 +6,13 @@ import javax.validation.ConstraintViolationException;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.Postulante
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.TecnologiaRepository
;
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
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -20,19 +22,28 @@ public class PostulanteController {
...
@@ -20,19 +22,28 @@ public class PostulanteController {
@Autowired
@Autowired
PostulanteRepository
post
;
PostulanteRepository
post
;
@Autowired
TecnologiaRepository
tecRepo
;
@RequestMapping
(
"/"
)
@RequestMapping
(
"/"
)
public
String
index
()
{
public
String
index
()
{
return
"index"
;
return
"index"
;
}
}
@RequestMapping
(
"/postulante"
)
@RequestMapping
(
"/postulante"
)
public
String
getFormPostulante
(){
public
String
getFormPostulante
(
Model
model
){
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findAll
());
return
"postulante-form"
;
return
"postulante-form"
;
}
}
@PostMapping
(
value
=
"/postulante"
,
consumes
=
"application/json"
)
@PostMapping
(
value
=
"/postulante"
,
consumes
=
"application/json"
)
public
String
guardarPostulante
(
@RequestBody
Postulante
postulante
){
public
String
guardarPostulante
(
@RequestBody
Postulante
postulante
){
//se obtiene referencia de todas las tecnologias existentes
postulante
.
getTecnologias
().
stream
().
filter
(
tec
->
tec
.
getTecnologia
().
getId
()
!=
0
).
forEach
(
tec
->
tec
.
setTecnologia
(
tecRepo
.
getById
(
tec
.
getTecnologia
().
getId
()))
);
post
.
save
(
postulante
);
post
.
save
(
postulante
);
return
"redirect:/"
;
return
"redirect:/"
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java
View file @
52078ec2
...
@@ -9,13 +9,15 @@ import javax.persistence.Id;
...
@@ -9,13 +9,15 @@ import javax.persistence.Id;
import
javax.persistence.JoinColumn
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.UniqueConstraint
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
@Entity
@Entity
@Table
(
name
=
"postulante_tecnologia"
)
@Table
(
name
=
"postulante_tecnologia"
,
uniqueConstraints
=
@UniqueConstraint
(
columnNames
={
"postulante_id"
,
"tecnologia_id"
}))
public
class
PostulanteTecnologia
{
public
class
PostulanteTecnologia
{
@Id
@Id
...
@@ -27,7 +29,7 @@ public class PostulanteTecnologia {
...
@@ -27,7 +29,7 @@ public class PostulanteTecnologia {
@Min
(
value
=
1
)
@Min
(
value
=
1
)
@Max
(
value
=
5
)
@Max
(
value
=
5
)
private
Long
nivel
;
private
Long
nivel
;
@ManyToOne
(
cascade
=
CascadeType
.
PERSIST
)
@ManyToOne
(
cascade
=
{
CascadeType
.
PERSIST
,
CascadeType
.
MERGE
},
optional
=
false
)
@JoinColumn
@JoinColumn
private
Tecnologia
tecnologia
;
private
Tecnologia
tecnologia
;
...
...
curriculumsearch/src/main/resources/application.properties
View file @
52078ec2
spring.jpa.hibernate.ddl-auto
=
create-drop
spring.jpa.hibernate.ddl-auto
=
create-drop
spring.jpa.database-platform
=
org.hibernate.dialect.PostgreSQLDialect
spring.jpa.database-platform
=
org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql
=
true
spring.jpa.properties.hibernate.format_sql
=
true
logging.level.org.hibernate.SQL
=
DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder
=
TRACE
spring.sql.init.mode
=
always
spring.sql.init.mode
=
always
spring.sql.init.platform
=
postgres
spring.sql.init.platform
=
postgres
...
...
curriculumsearch/src/main/resources/static/main.js
View file @
52078ec2
...
@@ -56,10 +56,11 @@ function agregarFieldTecnologia(){
...
@@ -56,10 +56,11 @@ function agregarFieldTecnologia(){
pairs
[
name
]
=
value
pairs
[
name
]
=
value
}
}
tecnologias
[
cont_tecnologia
]
=
{}
tecnologias
[
cont_tecnologia
]
=
{}
tecnologias
[
cont_tecnologia
][
"tecnologia"
]
=
{
nombre
:
pairs
.
nombre
}
tecnologias
[
cont_tecnologia
][
"tecnologia"
]
=
pairs
[
"tecnologia-id"
]
==
"-1"
?{
nombre
:
pairs
[
"tecnologia-nombre"
]}:{
id
:
pairs
[
"tecnologia-id"
],
nombre
:
document
.
querySelector
(
'option[value="'
+
pairs
[
"tecnologia-id"
]
+
'"]'
).
innerHTML
}
tecnologias
[
cont_tecnologia
][
"nivel"
]
=
pairs
.
nivel
tecnologias
[
cont_tecnologia
][
"nivel"
]
=
pairs
.
nivel
//tecnologias[cont_tecnologia] = pairs;
//tecnologias[cont_tecnologia] = pairs;
formtecn
.
reset
();
formtecn
.
reset
();
document
.
querySelector
(
"#tecnologia-nombre"
).
classList
.
add
(
'd-none'
)
//imprimir lista actualizada
//imprimir lista actualizada
const
div
=
document
.
querySelector
(
"#tecnologias"
)
const
div
=
document
.
querySelector
(
"#tecnologias"
)
const
div1
=
document
.
createElement
(
'div'
);
const
div1
=
document
.
createElement
(
'div'
);
...
@@ -150,3 +151,5 @@ form.addEventListener("submit",(evt)=>{
...
@@ -150,3 +151,5 @@ form.addEventListener("submit",(evt)=>{
});
});
evt
.
preventDefault
();
evt
.
preventDefault
();
}
);
}
);
document
.
querySelector
(
"#btn-new-tech"
).
addEventListener
(
'click'
,()
=>
{
document
.
querySelector
(
"#tecnologia-nombre"
).
classList
.
remove
(
'd-none'
)})
\ No newline at end of file
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
View file @
52078ec2
<
%@
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>
<!doctype html>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
...
@@ -158,8 +161,19 @@
...
@@ -158,8 +161,19 @@
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
<form
name=
"tecnologia-form"
>
<form
name=
"tecnologia-form"
>
<label
for=
"nombre"
class=
"form-label"
>
Nombre
</label>
<label
for=
"tecnologia-nombre"
class=
"form-label"
>
Tecnologia
</label>
<input
type=
"text"
class=
"form-control"
name=
"nombre"
id=
"nombre"
>
<div
class=
"input-group mb-3"
>
<select
class=
"form-select"
name=
"tecnologia-id"
aria-label=
"Default select example"
>
<option
value=
"-1"
selected
>
Open this select menu
</option>
<c:forEach
items=
"${tecnologias}"
var=
"tecnologia"
>
<option
value=
"${tecnologia.id}"
>
${tecnologia.nombre}
</option>
</c:forEach>
</select>
<button
class=
"btn btn-outline-secondary"
type=
"button"
id=
"btn-new-tech"
>
Agregar nuevo
</button>
</div>
<input
type=
"text"
class=
"form-control d-none"
name=
"tecnologia-nombre"
id=
"tecnologia-nombre"
>
<label
for=
"nivel"
class=
"form-label"
>
Nivel
</label>
<label
for=
"nivel"
class=
"form-label"
>
Nivel
</label>
<input
type=
"number"
class=
"form-control"
name=
"nivel"
id=
"nivel"
>
<input
type=
"number"
class=
"form-control"
name=
"nivel"
id=
"nivel"
>
</form>
</form>
...
...
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