Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.srv.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | |||
| 6 | import javax.persistence.Column; |
||
| 7 | import javax.persistence.Entity; |
||
| 8 | import javax.persistence.GeneratedValue; |
||
| 9 | import javax.persistence.GenerationType; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.JoinColumn; |
||
| 12 | import javax.persistence.ManyToOne; |
||
| 13 | import javax.persistence.SequenceGenerator; |
||
| 14 | import javax.persistence.Table; |
||
| 15 | import javax.persistence.Temporal; |
||
| 16 | import javax.persistence.TemporalType; |
||
| 17 | import javax.persistence.Transient; |
||
| 18 | import javax.validation.constraints.NotNull; |
||
| 19 | |||
| 20 | import br.gov.al.saude.framework.core.generic.identidade.Identidade; |
||
| 21 | import br.gov.al.saude.framework.core.interfaces.Alterar; |
||
| 22 | import br.gov.al.saude.framework.core.interfaces.Cadastrar; |
||
| 23 | import br.gov.al.saude.srv.model.enums.TipoQualificacao; |
||
| 24 | |||
| 25 | @Entity |
||
| 26 | @Table(name = "srv_servidor_qualificacao", schema = "sc_srv") |
||
| 27 | public class ServidorQualificacao implements Serializable, Identidade, Comparable<ServidorQualificacao> { |
||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Long sequencial; |
||
| 31 | private String descricao; |
||
| 32 | private String tipoQualificacao; |
||
| 33 | private String instituicao; |
||
| 34 | private Date dataInicial; |
||
| 35 | private Date dataFinal; |
||
| 36 | private Integer cargaHoraria; |
||
| 37 | private String observacao; |
||
| 38 | private Servidor servidor; |
||
| 39 | |||
| 40 | |||
| 41 | @Id |
||
| 42 | @Column(name="seq_servidor_qualificacao", nullable=false) |
||
| 43 | @GeneratedValue(generator = "SERVIDOR_QUALIFICACAO_GENERATOR", strategy = GenerationType.SEQUENCE) |
||
| 44 | @SequenceGenerator(name = "SERVIDOR_QUALIFICACAO_GENERATOR", sequenceName = "sc_srv.sq_servidoqualif", initialValue = 1, allocationSize = 1) |
||
| 45 | public Long getSequencial() { |
||
| 46 | return sequencial; |
||
| 47 | } |
||
| 48 | public void setSequencial(Long sequencial) { |
||
| 49 | this.sequencial = sequencial; |
||
| 50 | } |
||
| 51 | |||
| 52 | |||
| 53 | @Column(name="dsc_qualificacao", length=200, nullable=false) |
||
| 54 | @NotNull(message="Obrigatório informar a descrição.", groups={Cadastrar.class, Alterar.class}) |
||
| 55 | public String getDescricao() { |
||
| 56 | return descricao; |
||
| 57 | } |
||
| 58 | public void setDescricao(String descricao) { |
||
| 59 | this.descricao = descricao; |
||
| 60 | } |
||
| 61 | |||
| 62 | |||
| 63 | @Column(name="tip_qualificacao", length=1, nullable=false) |
||
| 64 | @NotNull(message="Obrigatório informar o tipo da qualificação.", groups={Cadastrar.class, Alterar.class}) |
||
| 65 | public String getTipoQualificacao() { |
||
| 66 | return tipoQualificacao; |
||
| 67 | } |
||
| 68 | public void setTipoQualificacao(String tipoQualificacao) { |
||
| 69 | this.tipoQualificacao = tipoQualificacao; |
||
| 70 | } |
||
| 71 | public void setTipoQualificacao(TipoQualificacao tipoQualificacao) { |
||
| 72 | this.tipoQualificacao = tipoQualificacao.getValue(); |
||
| 73 | } |
||
| 74 | |||
| 75 | @Transient |
||
| 76 | public String getDescricaoTipoQualificacao() { |
||
| 77 | return TipoQualificacao.parse(getTipoQualificacao()).getDescricao(); |
||
| 78 | } |
||
| 79 | |||
| 80 | @Column(name="dsc_instituicao", length=200, nullable=false) |
||
| 81 | @NotNull(message="Obrigatório informar a instituição.", groups={Cadastrar.class, Alterar.class}) |
||
| 82 | public String getInstituicao() { |
||
| 83 | return instituicao; |
||
| 84 | } |
||
| 85 | public void setInstituicao(String instituicao) { |
||
| 86 | this.instituicao = instituicao; |
||
| 87 | } |
||
| 88 | |||
| 89 | @Temporal(TemporalType.DATE) |
||
| 90 | @Column(name="dat_inicial", nullable=false) |
||
| 91 | @NotNull(message="Obrigatório informar a data inicial.", groups={Cadastrar.class, Alterar.class}) |
||
| 92 | public Date getDataInicial() { |
||
| 93 | return dataInicial; |
||
| 94 | } |
||
| 95 | public void setDataInicial(Date dataInicial) { |
||
| 96 | this.dataInicial = dataInicial; |
||
| 97 | } |
||
| 98 | |||
| 99 | @Temporal(TemporalType.DATE) |
||
| 100 | @Column(name="dat_final", nullable=false) |
||
| 101 | @NotNull(message="Obrigatório informar a data final.", groups={Cadastrar.class, Alterar.class}) |
||
| 102 | public Date getDataFinal() { |
||
| 103 | return dataFinal; |
||
| 104 | } |
||
| 105 | public void setDataFinal(Date dataFinal) { |
||
| 106 | this.dataFinal = dataFinal; |
||
| 107 | } |
||
| 108 | |||
| 109 | @Column(name="qtd_carga_horaria", nullable=false) |
||
| 110 | @NotNull(message="Obrigatório informar a carga horária.", groups={Cadastrar.class, Alterar.class}) |
||
| 111 | public Integer getCargaHoraria() { |
||
| 112 | return cargaHoraria; |
||
| 113 | } |
||
| 114 | public void setCargaHoraria(Integer cargaHoraria) { |
||
| 115 | this.cargaHoraria = cargaHoraria; |
||
| 116 | } |
||
| 117 | |||
| 118 | @Column(name="dsc_observacao") |
||
| 119 | public String getObservacao() { |
||
| 120 | return observacao; |
||
| 121 | } |
||
| 122 | public void setObservacao(String observacao) { |
||
| 123 | this.observacao = observacao; |
||
| 124 | } |
||
| 125 | |||
| 126 | @ManyToOne |
||
| 127 | @JoinColumn(name="seq_pessoa_servidor", referencedColumnName="seq_pessoa_servidor", nullable=false) |
||
| 128 | public Servidor getServidor() { |
||
| 129 | return servidor; |
||
| 130 | } |
||
| 131 | public void setServidor(Servidor servidor) { |
||
| 132 | this.servidor = servidor; |
||
| 133 | } |
||
| 134 | |||
| 135 | @Transient |
||
| 136 | @Override |
||
| 137 | public Object getId() { |
||
| 138 | return this.sequencial; |
||
| 139 | } |
||
| 140 | @Override |
||
| 141 | public void setId(Object id) { |
||
| 142 | this.sequencial = (Long) id; |
||
| 143 | } |
||
| 144 | |||
| 145 | |||
| 146 | @Override |
||
| 147 | public int compareTo(ServidorQualificacao servidorQualificacao) { |
||
| 148 | return this.dataInicial.compareTo(servidorQualificacao.getDataInicial()); |
||
| 149 | } |
||
| 150 | |||
| 151 | @Override |
||
| 152 | public int hashCode() { |
||
| 153 | final int prime = 31; |
||
| 154 | int result = 1; |
||
| 155 | result = prime * result |
||
| 156 | + ((cargaHoraria == null) ? 0 : cargaHoraria.hashCode()); |
||
| 157 | result = prime * result |
||
| 158 | + ((dataFinal == null) ? 0 : dataFinal.hashCode()); |
||
| 159 | result = prime * result |
||
| 160 | + ((dataInicial == null) ? 0 : dataInicial.hashCode()); |
||
| 161 | result = prime * result |
||
| 162 | + ((descricao == null) ? 0 : descricao.hashCode()); |
||
| 163 | result = prime * result |
||
| 164 | + ((instituicao == null) ? 0 : instituicao.hashCode()); |
||
| 165 | result = prime * result |
||
| 166 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 167 | result = prime |
||
| 168 | * result |
||
| 169 | + ((tipoQualificacao == null) ? 0 : tipoQualificacao.hashCode()); |
||
| 170 | return result; |
||
| 171 | } |
||
| 172 | |||
| 173 | @Override |
||
| 174 | public boolean equals(Object obj) { |
||
| 175 | if (this == obj) |
||
| 176 | return true; |
||
| 177 | if (obj == null) |
||
| 178 | return false; |
||
| 179 | if (getClass() != obj.getClass()) |
||
| 180 | return false; |
||
| 181 | ServidorQualificacao other = (ServidorQualificacao) obj; |
||
| 182 | if (cargaHoraria == null) { |
||
| 183 | if (other.cargaHoraria != null) |
||
| 184 | return false; |
||
| 185 | } else if (!cargaHoraria.equals(other.cargaHoraria)) |
||
| 186 | return false; |
||
| 187 | if (dataFinal == null) { |
||
| 188 | if (other.dataFinal != null) |
||
| 189 | return false; |
||
| 190 | } else if (!dataFinal.equals(other.dataFinal)) |
||
| 191 | return false; |
||
| 192 | if (dataInicial == null) { |
||
| 193 | if (other.dataInicial != null) |
||
| 194 | return false; |
||
| 195 | } else if (!dataInicial.equals(other.dataInicial)) |
||
| 196 | return false; |
||
| 197 | if (descricao == null) { |
||
| 198 | if (other.descricao != null) |
||
| 199 | return false; |
||
| 200 | } else if (!descricao.equals(other.descricao)) |
||
| 201 | return false; |
||
| 202 | if (instituicao == null) { |
||
| 203 | if (other.instituicao != null) |
||
| 204 | return false; |
||
| 205 | } else if (!instituicao.equals(other.instituicao)) |
||
| 206 | return false; |
||
| 207 | if (sequencial == null) { |
||
| 208 | if (other.sequencial != null) |
||
| 209 | return false; |
||
| 210 | } else if (!sequencial.equals(other.sequencial)) |
||
| 211 | return false; |
||
| 212 | if (tipoQualificacao == null) { |
||
| 213 | if (other.tipoQualificacao != null) |
||
| 214 | return false; |
||
| 215 | } else if (!tipoQualificacao.equals(other.tipoQualificacao)) |
||
| 216 | return false; |
||
| 217 | return true; |
||
| 218 | } |
||
| 219 | |||
| 220 | } |