Experiencia.java 4.02 KB
Newer Older
1 2
package com.roshka.modelo;

3 4 5
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
6
import java.util.List;
7 8 9 10 11

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
12 13 14 15

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

16
import javax.persistence.*;
17 18 19
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
20 21 22

@Entity
@Table(name = "experiencia")
23
public class Experiencia {
24 25 26
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
27

28
    @Column(name = "institucion")
29
    @NotBlank(message = "Este campo no puede estar vacio")
30
    private String institucion;
31

32
    @Column(name = "fecha_desde")
33 34
    @Past(message = "Este campo no puede estar en el futuro")
    @NotNull(message = "Este campo no puede estar vacio")
35
    private Date fechaDesde;
36

37 38
    @Column(name = "fecha_hasta")
    private Date fechaHasta;
39 40 41 42
    @Column(name = "nombre_referencia")
    private String nombreReferencia;
    @Column(name = "telefono_referencia")
    private String telefonoReferencia;
43
    @Column(name = "cargo")
44
    @NotBlank(message = "Este campo no puede estar vacio")
45
    private String cargo;
46

47 48
    @Column(name = "descripcion")
    private String descripcion;
49

50 51
    @JsonBackReference
    @ManyToOne(optional = false)
52 53
    @JoinColumn
    private Postulante postulante;
54

55 56 57 58
    @JsonManagedReference
    @OneToMany(mappedBy = "experiencia",cascade = CascadeType.ALL)
    private List<ExperienciaReconocimiento> reconocimientos;

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public String getInstitucion() {
        return institucion;
    }
    public void setInstitucion(String institucion) {
        this.institucion = institucion;
    }
    public Date getFechaDesde() {
        return fechaDesde;
    }
    public void setFechaDesde(Date fechaDesde) {
        this.fechaDesde = fechaDesde;
    }
77 78 79 80 81 82 83 84 85 86
    public void setFechaDesde(String fechaDesde) {
        if(fechaDesde==null || fechaDesde.isEmpty()) return;

        try {
            this.fechaDesde = new SimpleDateFormat("yyyy-mm-dd").parse(fechaDesde);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
87 88 89 90 91 92
    public Date getFechaHasta() {
        return fechaHasta;
    }
    public void setFechaHasta(Date fechaHasta) {
        this.fechaHasta = fechaHasta;
    }
93 94 95 96 97 98 99 100 101 102
    public void setFechaHasta(String fechaHasta) {
        if(fechaHasta==null || fechaHasta.isEmpty()) return;

        try {
            this.fechaHasta = new SimpleDateFormat("yyyy-mm-dd").parse(fechaHasta);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
103 104
    public String getNombreReferencia() {
        return nombreReferencia;
105
    }
106 107 108 109 110 111 112 113
    public String getTelefonoReferencia() {
        return telefonoReferencia;
    }
    public void setNombreReferencia(String nombreReferencia) {
        this.nombreReferencia = nombreReferencia;
    }
    public void setTelefonoReferencia(String telefonoReferencia) {
        this.telefonoReferencia = telefonoReferencia;
114 115 116 117 118 119 120
    }
    public String getCargo() {
        return cargo;
    }
    public void setCargo(String cargo) {
        this.cargo = cargo;
    }
121 122 123 124 125 126
    public void setPostulante(Postulante postulante) {
        this.postulante = postulante;
    }
    public Postulante getPostulante() {
        return postulante;
    }
127 128 129 130 131 132 133 134 135 136 137 138
    public String getDescripcion() {
        return descripcion;
    }
    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }
    public void setReconocimientos(List<ExperienciaReconocimiento> reconocimientos) {
        this.reconocimientos = reconocimientos;
    }
    public List<ExperienciaReconocimiento> getReconocimientos() {
        return reconocimientos;
    }
139
}