Commit 14988be1 by Joel Florentin

identity en id de los modelos.

parent e1ff3f2b
...@@ -2,6 +2,7 @@ package com.roshka; ...@@ -2,6 +2,7 @@ package com.roshka;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
...@@ -51,23 +52,29 @@ public class CurriculumsearchApplication { ...@@ -51,23 +52,29 @@ public class CurriculumsearchApplication {
cargoR.saveAll(cargos); cargoR.saveAll(cargos);
cargoR.flush(); cargoR.flush();
System.out.println("Cargos Saved!"); System.out.println("Cargos Saved!");
/* TypeReference<List<Tecnologia>> typeReference5 = new TypeReference<List<Tecnologia>>(){};
inputStream = TypeReference.class.getResourceAsStream("/json/tecnologia.json");
List<Tecnologia> tecnologias= mapper.readValue(inputStream,typeReference5);
tecRepo.saveAll(tecnologias);
tecRepo.flush();
System.out.println("Cargos Saved!"); */
TypeReference<List<ConvocatoriaCargo>> typeReference4 = new TypeReference<List<ConvocatoriaCargo>>(){}; TypeReference<List<ConvocatoriaCargo>> typeReference4 = new TypeReference<List<ConvocatoriaCargo>>(){};
inputStream = TypeReference.class.getResourceAsStream("/json/convocatoria.json"); inputStream = TypeReference.class.getResourceAsStream("/json/convocatoria.json");
List<ConvocatoriaCargo> convocatorias= mapper.readValue(inputStream,typeReference4); List<ConvocatoriaCargo> convocatorias= mapper.readValue(inputStream,typeReference4);
convR.saveAll(convocatorias); convocatorias = convR.saveAll(convocatorias);
convR.flush(); convR.flush();
System.out.println("convocatorias Saved!"); System.out.println("convocatorias Saved!");
TypeReference<List<Postulante>> typeReference = new TypeReference<List<Postulante>>(){}; TypeReference<List<Postulante>> typeReference = new TypeReference<List<Postulante>>(){};
inputStream = TypeReference.class.getResourceAsStream("/json/postulante.json"); inputStream = TypeReference.class.getResourceAsStream("/json/postulante.json");
List<Postulante> postulantes = mapper.readValue(inputStream,typeReference); List<Postulante> postulantes = mapper.readValue(inputStream,typeReference);
/* for (Postulante postulante : postulantes) { /* for (Postulante postulante : postulantes) {
for (int i = 0; i < postulante.getPostulaciones().size(); i++) { for (int i = 0; i < postulante.getPostulaciones().size(); i++) {
postulante.getPostulaciones().set(i, convR.getById(postulante.getPostulaciones().get(i).getId())); postulante.getPostulaciones().set(i, convR.getById(postulante.getPostulaciones().get(i).getId()));
postulante.getPostulaciones().get(i).getFechaInicio();
} }
} */ } */
postRepo.saveAll(postulantes); postRepo.saveAll(postulantes);
System.out.println("postulantes Saved!"); System.out.println("postulantes Saved!");
String password = new BCryptPasswordEncoder().encode("test"); String password = new BCryptPasswordEncoder().encode("test");
......
...@@ -144,13 +144,13 @@ public class PostulanteController { ...@@ -144,13 +144,13 @@ public class PostulanteController {
tec -> tec.getTecnologia().getId() != 0 tec -> tec.getTecnologia().getId() != 0
).forEach( ).forEach(
tec -> tec.setTecnologia(tecRepo.getById(tec.getTecnologia().getId())) tec -> tec.setTecnologia(tecRepo.getById(tec.getTecnologia().getId()))
); );
for (int i = 0; i < postulante.getPostulaciones().size(); i++) { /* for (int i = 0; i < postulante.getPostulaciones().size(); i++) {
postulante.getPostulaciones().set(i, cargoRepo.getById(postulante.getPostulaciones().get(i).getId())); postulante.getPostulaciones().set(i, cargoRepo.getById(postulante.getPostulaciones().get(i).getId()));
} }
*/
for(Estudio estudio: postulante.getEstudios()){ for(Estudio estudio: postulante.getEstudios()){
String nombreIns = ""; String nombreIns = "";
nombreIns = estudio.getInstitucion().getNombre().toLowerCase(); nombreIns = estudio.getInstitucion().getNombre().toLowerCase();
......
...@@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonManagedReference; ...@@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonManagedReference;
@Table(name = "cargo") @Table(name = "cargo")
public class Cargo { public class Cargo {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@NotBlank @NotBlank
......
...@@ -24,7 +24,7 @@ import com.roshka.utils.Helper; ...@@ -24,7 +24,7 @@ import com.roshka.utils.Helper;
@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property="@UUID") @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property="@UUID")
public class ConvocatoriaCargo { public class ConvocatoriaCargo {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@ManyToOne() @ManyToOne()
......
...@@ -15,7 +15,7 @@ import com.roshka.utils.Helper; ...@@ -15,7 +15,7 @@ import com.roshka.utils.Helper;
@Table(name="estudio") @Table(name="estudio")
public class Estudio { public class Estudio {
@Id @Id
@GeneratedValue(strategy=GenerationType.AUTO) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
......
...@@ -23,7 +23,7 @@ import javax.validation.constraints.Past; ...@@ -23,7 +23,7 @@ import javax.validation.constraints.Past;
@Table(name = "experiencia") @Table(name = "experiencia")
public class Experiencia { public class Experiencia {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private long id;
@Column(name = "institucion") @Column(name = "institucion")
......
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
@Table(name = "institucion") @Table(name = "institucion")
public class Institucion { public class Institucion {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id") @Column(name = "id")
private long id; private long id;
......
...@@ -19,7 +19,7 @@ import java.util.List; ...@@ -19,7 +19,7 @@ import java.util.List;
@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property="@UUID") @JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property="@UUID")
public class Postulante { public class Postulante {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
...@@ -101,7 +101,7 @@ public class Postulante { ...@@ -101,7 +101,7 @@ public class Postulante {
@OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL) @OneToMany(mappedBy = "postulante",cascade = CascadeType.ALL)
private List<ReferenciaPersonal> referencias; private List<ReferenciaPersonal> referencias;
@ManyToMany(cascade = CascadeType.ALL) @ManyToMany()
@JoinTable(uniqueConstraints = @UniqueConstraint(columnNames = {"postulante_id","convocatoria_cargo_id"}), @JoinTable(uniqueConstraints = @UniqueConstraint(columnNames = {"postulante_id","convocatoria_cargo_id"}),
joinColumns = @JoinColumn(name="postulante_id", referencedColumnName="id"), joinColumns = @JoinColumn(name="postulante_id", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="convocatoria_cargo_id", referencedColumnName="id") inverseJoinColumns= @JoinColumn(name="convocatoria_cargo_id", referencedColumnName="id")
......
...@@ -21,7 +21,7 @@ uniqueConstraints=@UniqueConstraint(columnNames={"postulante_id", "tecnologia_id ...@@ -21,7 +21,7 @@ uniqueConstraints=@UniqueConstraint(columnNames={"postulante_id", "tecnologia_id
public class PostulanteTecnologia { public class PostulanteTecnologia {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id ; private long id ;
...@@ -29,7 +29,7 @@ public class PostulanteTecnologia { ...@@ -29,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,CascadeType.MERGE},optional = false) @ManyToOne(cascade = {CascadeType.PERSIST},optional = false)
@JoinColumn @JoinColumn
private Tecnologia tecnologia; private Tecnologia tecnologia;
......
...@@ -6,7 +6,7 @@ import javax.persistence.*; ...@@ -6,7 +6,7 @@ import javax.persistence.*;
@Table(name = "recursos_humanos_user") @Table(name = "recursos_humanos_user")
public class RRHHUser { public class RRHHUser {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(nullable = false, unique = true, length = 45) @Column(nullable = false, unique = true, length = 45)
......
...@@ -16,7 +16,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; ...@@ -16,7 +16,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
@Table(name = "referencia_personal") @Table(name = "referencia_personal")
public class ReferenciaPersonal { public class ReferenciaPersonal {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@NotBlank @NotBlank
......
...@@ -12,7 +12,7 @@ import javax.validation.constraints.NotBlank; ...@@ -12,7 +12,7 @@ import javax.validation.constraints.NotBlank;
@Entity @Entity
@Table(name="tecnologia") @Table(name="tecnologia")
public class Tecnologia { public class Tecnologia {
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Id @Id
@Column(name="id") @Column(name="id")
private long id; private long id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment