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.OneToOne; |
||
| 9 | import javax.persistence.Table; |
||
| 10 | import javax.persistence.Transient; |
||
| 11 | import javax.validation.constraints.NotNull; |
||
| 12 | import br.gov.al.saude.framework.core.generic.identidade.Identidade; |
||
| 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.PessoaFisicaView; |
||
| 16 | import br.gov.al.saude.srv.model.enums.TipoLado; |
||
| 17 | |||
| 18 | @Entity |
||
| 19 | @Table(name = "srv_servidor_localizacaoarquivo", schema = "sc_srv") |
||
| 20 | public class ServidorLocalizacaoArquivo implements Serializable, Identidade { |
||
| 21 | private static final long serialVersionUID = 1L; |
||
| 22 | |||
| 23 | private PessoaFisicaView pessoa = new PessoaFisicaView(); |
||
| 24 | private Servidor servidor; |
||
| 25 | private Integer numeroCaixa; |
||
| 26 | private Integer numeroPasta; |
||
| 27 | private Integer numeroPrateleira; |
||
| 28 | private String tipoLado; |
||
| 29 | |||
| 30 | @Id |
||
| 31 | @OneToOne |
||
| 32 | @JoinColumn(name="seq_pessoa_servidor", referencedColumnName="seq_pessoa") |
||
| 33 | public PessoaFisicaView getPessoa() { |
||
| 34 | return pessoa; |
||
| 35 | } |
||
| 36 | public void setPessoa(PessoaFisicaView pessoa) { |
||
| 37 | this.pessoa = pessoa; |
||
| 38 | } |
||
| 39 | |||
| 40 | @OneToOne |
||
| 41 | @JoinColumn(name="seq_pessoa_servidor", referencedColumnName="seq_pessoa_servidor", insertable=false, updatable=false) |
||
| 42 | public Servidor getServidor() { |
||
| 43 | return servidor; |
||
| 44 | } |
||
| 45 | public void setServidor(Servidor servidor) { |
||
| 46 | this.servidor = servidor; |
||
| 47 | if(servidor != null) setPessoa(servidor.getPessoa()); |
||
| 48 | } |
||
| 49 | |||
| 50 | @Column(name="num_caixa", length=6) |
||
| 51 | @NotNull(message="Obrigatório infomar a caixa na localização.", groups={Cadastrar.class, Alterar.class}) |
||
| 52 | public Integer getNumeroCaixa() { |
||
| 53 | return numeroCaixa; |
||
| 54 | } |
||
| 55 | public void setNumeroCaixa(Integer numeroCaixa) { |
||
| 56 | this.numeroCaixa = numeroCaixa; |
||
| 57 | } |
||
| 58 | |||
| 59 | @Column(name="num_pasta", length=6) |
||
| 60 | @NotNull(message="Obrigatório infomar a pasta na localização.", groups={Cadastrar.class, Alterar.class}) |
||
| 61 | public Integer getNumeroPasta() { |
||
| 62 | return numeroPasta; |
||
| 63 | } |
||
| 64 | public void setNumeroPasta(Integer numeroPasta) { |
||
| 65 | this.numeroPasta = numeroPasta; |
||
| 66 | } |
||
| 67 | |||
| 68 | @Column(name="num_prateleira") |
||
| 69 | public Integer getNumeroPrateleira() { |
||
| 70 | return numeroPrateleira; |
||
| 71 | } |
||
| 72 | public void setNumeroPrateleira(Integer numeroPrateleira) { |
||
| 73 | this.numeroPrateleira = numeroPrateleira; |
||
| 74 | } |
||
| 75 | |||
| 76 | @Column(name="tip_lado", length=1) |
||
| 77 | public String getTipoLado() { |
||
| 78 | return tipoLado; |
||
| 79 | } |
||
| 80 | public void setTipoLado(String tipoLado) { |
||
| 81 | this.tipoLado = tipoLado; |
||
| 82 | } |
||
| 83 | public void setTipoLado(TipoLado tipoLado){ |
||
| 84 | this.tipoLado = tipoLado.getValue(); |
||
| 85 | } |
||
| 86 | |||
| 87 | @Transient |
||
| 88 | public String getDescricaoTipoLado() { |
||
| 89 | return TipoLado.parse(getTipoLado()).getDescricao(); |
||
| 90 | } |
||
| 91 | |||
| 92 | @Transient |
||
| 93 | @Override |
||
| 94 | public Object getId() { |
||
| 95 | return this.pessoa.getSequencialPessoa(); |
||
| 96 | } |
||
| 97 | @Override |
||
| 98 | public void setId(Object id) { |
||
| 99 | this.pessoa.setSequencialPessoa((Long) id); |
||
| 100 | } |
||
| 101 | |||
| 102 | @Override |
||
| 103 | public int hashCode() { |
||
| 104 | final int prime = 31; |
||
| 105 | int result = 1; |
||
| 106 | result = prime * result + ((pessoa == null) ? 0 : pessoa.hashCode()); |
||
| 107 | return result; |
||
| 108 | } |
||
| 109 | @Override |
||
| 110 | public boolean equals(Object obj) { |
||
| 111 | if (this == obj) |
||
| 112 | return true; |
||
| 113 | if (obj == null) |
||
| 114 | return false; |
||
| 115 | if (getClass() != obj.getClass()) |
||
| 116 | return false; |
||
| 117 | ServidorLocalizacaoArquivo other = (ServidorLocalizacaoArquivo) obj; |
||
| 118 | if (pessoa == null) { |
||
| 119 | if (other.pessoa != null) |
||
| 120 | return false; |
||
| 121 | } else if (!pessoa.equals(other.pessoa)) |
||
| 122 | return false; |
||
| 123 | return true; |
||
| 124 | } |
||
| 125 | |||
| 126 | } |