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
b44ae606
Commit
b44ae606
authored
Nov 04, 2021
by
willgonzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creacion de modelos y repositorios de Cuidad y departamento
parent
7b2e1fe1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
259 additions
and
19 deletions
+259
-19
curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java
+18
-3
curriculumsearch/src/main/java/com/roshka/modelo/Ciudad.java
+68
-0
curriculumsearch/src/main/java/com/roshka/modelo/Departamento.java
+54
-0
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
+22
-12
curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java
+2
-1
curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java
+1
-1
curriculumsearch/src/main/java/com/roshka/repositorio/CiudadRepository.java
+9
-0
curriculumsearch/src/main/java/com/roshka/repositorio/DepartamentoRepository.java
+9
-0
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java
+1
-1
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteTecnologiaRepository.java
+0
-1
curriculumsearch/src/main/resources/json/Ciudad.json
+0
-0
curriculumsearch/src/main/resources/json/Departamento.json
+75
-0
curriculumsearch/src/main/resources/json/postulante.json
+0
-0
No files found.
curriculumsearch/src/main/java/com/roshka/CurriculumsearchApplication.java
View file @
b44ae606
...
@@ -6,9 +6,13 @@ import java.util.List;
...
@@ -6,9 +6,13 @@ import java.util.List;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.roshka.modelo.Ciudad
;
import
com.roshka.modelo.Departamento
;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.PostulanteTecnologia
;
import
com.roshka.modelo.PostulanteTecnologia
;
import
com.roshka.modelo.Tecnologia
;
import
com.roshka.modelo.Tecnologia
;
import
com.roshka.repositorio.CiudadRepository
;
import
com.roshka.repositorio.DepartamentoRepository
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.PostulanteRepository
;
import
com.roshka.repositorio.TecnologiaRepository
;
import
com.roshka.repositorio.TecnologiaRepository
;
...
@@ -29,16 +33,27 @@ public class CurriculumsearchApplication {
...
@@ -29,16 +33,27 @@ public class CurriculumsearchApplication {
}
}
@Bean
@Bean
CommandLineRunner
runner
(
PostulanteRepository
postRepo
,
TecnologiaRepository
tecRepo
)
{
CommandLineRunner
runner
(
PostulanteRepository
postRepo
,
TecnologiaRepository
tecRepo
,
DepartamentoRepository
depR
,
CiudadRepository
ciudR
)
{
return
args
->
{
return
args
->
{
try
{
// read json and write to db
// read json and write to db
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
TypeReference
<
List
<
Departamento
>>
typeReference1
=
new
TypeReference
<
List
<
Departamento
>>(){};
InputStream
inputStream
=
TypeReference
.
class
.
getResourceAsStream
(
"/json/Departamento.json"
);
List
<
Departamento
>
departamento
=
mapper
.
readValue
(
inputStream
,
typeReference1
);
depR
.
saveAll
(
departamento
);
System
.
out
.
println
(
"Departamentos Saved!"
);
TypeReference
<
List
<
Ciudad
>>
typeReference2
=
new
TypeReference
<
List
<
Ciudad
>>(){};
inputStream
=
TypeReference
.
class
.
getResourceAsStream
(
"/json/Ciudad.json"
);
List
<
Ciudad
>
ciudades
=
mapper
.
readValue
(
inputStream
,
typeReference2
);
ciudR
.
saveAll
(
ciudades
);
System
.
out
.
println
(
"Cuidad Saved!"
);
TypeReference
<
List
<
Postulante
>>
typeReference
=
new
TypeReference
<
List
<
Postulante
>>(){};
TypeReference
<
List
<
Postulante
>>
typeReference
=
new
TypeReference
<
List
<
Postulante
>>(){};
InputStream
inputStream
=
TypeReference
.
class
.
getResourceAsStream
(
"/json/postulante.json"
);
inputStream
=
TypeReference
.
class
.
getResourceAsStream
(
"/json/postulante.json"
);
try
{
List
<
Postulante
>
postulantes
=
mapper
.
readValue
(
inputStream
,
typeReference
);
List
<
Postulante
>
postulantes
=
mapper
.
readValue
(
inputStream
,
typeReference
);
postRepo
.
saveAll
(
postulantes
);
postRepo
.
saveAll
(
postulantes
);
System
.
out
.
println
(
"postulantes Saved!"
);
System
.
out
.
println
(
"postulantes Saved!"
);
}
catch
(
IOException
e
){
}
catch
(
IOException
e
){
System
.
out
.
println
(
"Unable to save tecnologias: "
+
e
.
getMessage
());
System
.
out
.
println
(
"Unable to save tecnologias: "
+
e
.
getMessage
());
}
}
...
...
curriculumsearch/src/main/java/com/roshka/modelo/Ciudad.java
0 → 100644
View file @
b44ae606
package
com
.
roshka
.
modelo
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
@Entity
@Table
(
name
=
"ciudad"
)
public
class
Ciudad
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
public
Long
id
;
@Column
(
name
=
"nombre"
)
public
String
nombre
;
@Column
(
name
=
"departamento_id"
)
private
Long
departamentoId
;
public
Long
getDepartamentoId
()
{
return
this
.
departamentoId
;
}
public
void
setDepartamentoId
(
Long
departamentoId
)
{
this
.
departamentoId
=
departamentoId
;
}
@ManyToOne
(
targetEntity
=
Departamento
.
class
,
fetch
=
FetchType
.
EAGER
)
@JoinColumn
(
name
=
"departamento_id"
,
insertable
=
false
,
updatable
=
false
)
private
Departamento
departamento
;
public
Long
getId
()
{
return
this
.
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getNombre
()
{
return
this
.
nombre
;
}
public
void
setNombre
(
String
nombre
)
{
this
.
nombre
=
nombre
;
}
public
Departamento
getDepartamento
()
{
return
this
.
departamento
;
}
public
void
setDepartamento
(
Departamento
departamento
)
{
this
.
departamento
=
departamento
;
}
}
curriculumsearch/src/main/java/com/roshka/modelo/Departamento.java
0 → 100644
View file @
b44ae606
package
com
.
roshka
.
modelo
;
import
java.util.List
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.OneToMany
;
import
javax.persistence.Table
;
@Entity
@Table
(
name
=
"departamento"
)
public
class
Departamento
{
@Id
private
Long
id
;
@Column
(
name
=
"nombre"
)
private
String
nombre
;
@OneToMany
(
mappedBy
=
"departamento"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
Ciudad
>
ciudad
;
public
Long
getId
()
{
return
this
.
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getNombre
()
{
return
this
.
nombre
;
}
public
void
setNombre
(
String
nombre
)
{
this
.
nombre
=
nombre
;
}
public
List
<
Ciudad
>
getCiudad
()
{
return
this
.
ciudad
;
}
public
void
setCiudad
(
List
<
Ciudad
>
ciudad
)
{
this
.
ciudad
=
ciudad
;
}
}
\ No newline at end of file
curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java
View file @
b44ae606
...
@@ -39,10 +39,28 @@ public class Postulante {
...
@@ -39,10 +39,28 @@ public class Postulante {
@Email
(
message
=
"Formato incorrecto de correo"
)
@Email
(
message
=
"Formato incorrecto de correo"
)
private
String
correo
;
private
String
correo
;
@Column
(
name
=
"ciudad"
)
@ManyToOne
(
targetEntity
=
Ciudad
.
class
,
fetch
=
FetchType
.
EAGER
)
@NotBlank
(
message
=
"Este campo no puede estar vacio"
)
@JoinColumn
(
name
=
"ciudad_id"
,
insertable
=
false
,
updatable
=
false
)
@Size
(
max
=
120
)
private
Ciudad
ciudad
;
private
String
ciudad
;
@Column
(
name
=
"ciudad_id"
)
private
Long
ciudadId
;
public
Ciudad
getCiudad
()
{
return
this
.
ciudad
;
}
public
void
setCiudad
(
Ciudad
ciudad
)
{
this
.
ciudad
=
ciudad
;
}
public
Long
getCiudadId
()
{
return
this
.
ciudadId
;
}
public
void
setCiudadId
(
Long
ciudadId
)
{
this
.
ciudadId
=
ciudadId
;
}
@Column
(
name
=
"telefono"
)
@Column
(
name
=
"telefono"
)
@NotBlank
(
message
=
"Este campo no puede estar vacio"
)
@NotBlank
(
message
=
"Este campo no puede estar vacio"
)
...
@@ -124,14 +142,6 @@ public class Postulante {
...
@@ -124,14 +142,6 @@ public class Postulante {
this
.
correo
=
correo
;
this
.
correo
=
correo
;
}
}
public
String
getCiudad
()
{
return
ciudad
;
}
public
void
setCiudad
(
String
ciudad
)
{
this
.
ciudad
=
ciudad
;
}
public
String
getTelefono
()
{
public
String
getTelefono
()
{
return
telefono
;
return
telefono
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java
View file @
b44ae606
...
@@ -12,7 +12,7 @@ import javax.persistence.Table;
...
@@ -12,7 +12,7 @@ import javax.persistence.Table;
import
javax.persistence.UniqueConstraint
;
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
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
@Entity
@Entity
...
@@ -37,6 +37,7 @@ public class PostulanteTecnologia {
...
@@ -37,6 +37,7 @@ public class PostulanteTecnologia {
@JoinColumn
@JoinColumn
@JsonBackReference
@JsonBackReference
private
Postulante
postulante
;
private
Postulante
postulante
;
public
long
getId
()
{
public
long
getId
()
{
return
id
;
return
id
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/modelo/Tecnologia.java
View file @
b44ae606
...
@@ -7,7 +7,7 @@ import javax.persistence.GenerationType;
...
@@ -7,7 +7,7 @@ import javax.persistence.GenerationType;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
java.util.Locale
;
@Entity
@Entity
@Table
(
name
=
"tecnologia"
)
@Table
(
name
=
"tecnologia"
)
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/CiudadRepository.java
0 → 100644
View file @
b44ae606
package
com
.
roshka
.
repositorio
;
import
com.roshka.modelo.Ciudad
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
CiudadRepository
extends
JpaRepository
<
Ciudad
,
Long
>
{
}
curriculumsearch/src/main/java/com/roshka/repositorio/DepartamentoRepository.java
0 → 100644
View file @
b44ae606
package
com
.
roshka
.
repositorio
;
import
com.roshka.modelo.Departamento
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
DepartamentoRepository
extends
JpaRepository
<
Departamento
,
Long
>
{
}
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteRepository.java
View file @
b44ae606
...
@@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
...
@@ -6,7 +6,7 @@ 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.Postulante
;
import
com.roshka.modelo.Postulante
;
import
com.roshka.modelo.PostulanteTecnologia
;
public
interface
PostulanteRepository
extends
JpaRepository
<
Postulante
,
Long
>
{
public
interface
PostulanteRepository
extends
JpaRepository
<
Postulante
,
Long
>
{
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/PostulanteTecnologiaRepository.java
View file @
b44ae606
package
com
.
roshka
.
repositorio
;
package
com
.
roshka
.
repositorio
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
com.roshka.modelo.PostulanteTecnologia
;
import
com.roshka.modelo.PostulanteTecnologia
;
...
...
curriculumsearch/src/main/resources/json/Ciudad.json
0 → 100644
View file @
b44ae606
This diff is collapsed.
Click to expand it.
curriculumsearch/src/main/resources/json/Departamento.json
0 → 100644
View file @
b44ae606
[
{
"id"
:
0
,
"nombre"
:
"ASUNCION"
},
{
"id"
:
1
,
"nombre"
:
"CONCEPCION"
},
{
"id"
:
2
,
"nombre"
:
"SAN PEDRO"
},
{
"id"
:
3
,
"nombre"
:
"CORDILLERA"
},
{
"id"
:
4
,
"nombre"
:
"GUAIRA"
},
{
"id"
:
5
,
"nombre"
:
"CAAGUAZU"
},
{
"id"
:
6
,
"nombre"
:
"CAAZAPA"
},
{
"id"
:
7
,
"nombre"
:
"ITAPUA"
},
{
"id"
:
8
,
"nombre"
:
"MISIONES"
},
{
"id"
:
9
,
"nombre"
:
"PARAGUARI"
},
{
"id"
:
10
,
"nombre"
:
"ALTO PARANA"
},
{
"id"
:
11
,
"nombre"
:
"CENTRAL"
},
{
"id"
:
12
,
"nombre"
:
"NEEMBUCU"
},
{
"id"
:
13
,
"nombre"
:
"AMAMBAY"
},
{
"id"
:
14
,
"nombre"
:
"CANINDEYU"
},
{
"id"
:
15
,
"nombre"
:
"PRESIDENTE HAYES"
},
{
"id"
:
16
,
"nombre"
:
"BOQUERON"
},
{
"id"
:
17
,
"nombre"
:
"ALTO PARAGUAY"
}
]
\ No newline at end of file
curriculumsearch/src/main/resources/json/postulante.json
View file @
b44ae606
This diff is collapsed.
Click to expand it.
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