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 javax.persistence.Column; |
||
| 5 | import javax.persistence.Entity; |
||
| 6 | import javax.persistence.Id; |
||
| 7 | import javax.persistence.JoinColumn; |
||
| 8 | import javax.persistence.ManyToOne; |
||
| 9 | import javax.persistence.OneToOne; |
||
| 10 | import javax.persistence.PrePersist; |
||
| 11 | import javax.persistence.Table; |
||
| 12 | import javax.validation.constraints.NotNull; |
||
| 13 | import br.gov.al.saude.framework.core.interfaces.Alterar; |
||
| 14 | import br.gov.al.saude.framework.core.interfaces.Cadastrar; |
||
| 15 | import br.gov.al.saude.framework.model.UfView; |
||
| 16 | |||
| 17 | @Entity |
||
| 18 | @Table(name = "srv_servdadofunc_conselho", schema = "sc_srv") |
||
| 19 | public class ServidorDadoFuncionalConselho implements Serializable { |
||
| 20 | private static final long serialVersionUID = 1L; |
||
| 21 | |||
| 22 | private Long sequencial; |
||
| 23 | private ServidorDadoFuncional servidorDadoFuncional; |
||
| 24 | private String numeroInscricaoConselho; |
||
| 25 | private Conselho conselho; |
||
| 26 | private UfView uf; |
||
| 27 | |||
| 28 | @Id |
||
| 29 | @Column(name="seq_servidor_dadofuncional") |
||
| 30 | public Long getSequencial() { |
||
| 31 | return sequencial; |
||
| 32 | } |
||
| 33 | public void setSequencial(Long sequencial) { |
||
| 34 | this.sequencial = sequencial; |
||
| 35 | } |
||
| 36 | |||
| 37 | @OneToOne |
||
| 38 | @JoinColumn(name="seq_servidor_dadofuncional", referencedColumnName="seq_servidor_dadofuncional", insertable=false, updatable=false) |
||
| 39 | public ServidorDadoFuncional getServidorDadoFuncional() { |
||
| 40 | return servidorDadoFuncional; |
||
| 41 | } |
||
| 42 | public void setServidorDadoFuncional(ServidorDadoFuncional servidorDadoFuncional) { |
||
| 43 | this.servidorDadoFuncional = servidorDadoFuncional; |
||
| 44 | if(servidorDadoFuncional != null) setSequencial(servidorDadoFuncional.getSequencial()); |
||
| 45 | } |
||
| 46 | |||
| 47 | @Column(name="num_inscricao_conselho", length=10, nullable=false) |
||
| 48 | @NotNull(message="Obrigatório informar o número de inscrição no conselho.", groups={Cadastrar.class, Alterar.class}) |
||
| 49 | public String getNumeroInscricaoConselho() { |
||
| 50 | return numeroInscricaoConselho; |
||
| 51 | } |
||
| 52 | public void setNumeroInscricaoConselho(String numeroInscricaoConselho) { |
||
| 53 | this.numeroInscricaoConselho = numeroInscricaoConselho; |
||
| 54 | } |
||
| 55 | |||
| 56 | @ManyToOne |
||
| 57 | @JoinColumn(name="cod_conselho", referencedColumnName="cod_conselho") |
||
| 58 | @NotNull(message="Obrigatório informar o conselho.", groups={Cadastrar.class, Alterar.class}) |
||
| 59 | public Conselho getConselho() { |
||
| 60 | return conselho; |
||
| 61 | } |
||
| 62 | public void setConselho(Conselho conselho) { |
||
| 63 | this.conselho = conselho; |
||
| 64 | } |
||
| 65 | |||
| 66 | @ManyToOne |
||
| 67 | @JoinColumn(name="cod_uf", referencedColumnName="cod_uf") |
||
| 68 | @NotNull(message="Obrigatório informar a UF do conselho.", groups={Cadastrar.class, Alterar.class}) |
||
| 69 | public UfView getUf() { |
||
| 70 | return uf; |
||
| 71 | } |
||
| 72 | public void setUf(UfView uf) { |
||
| 73 | this.uf = uf; |
||
| 74 | } |
||
| 75 | |||
| 76 | @Override |
||
| 77 | public int hashCode() { |
||
| 78 | final int prime = 31; |
||
| 79 | int result = 1; |
||
| 80 | result = prime * result |
||
| 81 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 82 | return result; |
||
| 83 | } |
||
| 84 | @Override |
||
| 85 | public boolean equals(Object obj) { |
||
| 86 | if (this == obj) |
||
| 87 | return true; |
||
| 88 | if (obj == null) |
||
| 89 | return false; |
||
| 90 | if (getClass() != obj.getClass()) |
||
| 91 | return false; |
||
| 92 | ServidorDadoFuncionalConselho other = (ServidorDadoFuncionalConselho) obj; |
||
| 93 | if (sequencial == null) { |
||
| 94 | if (other.sequencial != null) |
||
| 95 | return false; |
||
| 96 | } else if (!sequencial.equals(other.sequencial)) |
||
| 97 | return false; |
||
| 98 | return true; |
||
| 99 | } |
||
| 100 | |||
| 101 | @PrePersist |
||
| 102 | private void setarSequencialAntesDeInserir() { |
||
| 103 | if(servidorDadoFuncional != null) setSequencial(servidorDadoFuncional.getSequencial()); |
||
| 104 | } |
||
| 105 | |||
| 106 | } |