Rev 182 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 178 | espaco | 1 | package br.com.ec.views; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | import java.util.HashSet; |
||
| 6 | import java.util.Set; |
||
| 7 | |||
| 8 | import javax.persistence.Column; |
||
| 9 | import javax.persistence.Entity; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.JoinColumn; |
||
| 12 | import javax.persistence.JoinTable; |
||
| 13 | import javax.persistence.ManyToMany; |
||
| 14 | import javax.persistence.OneToMany; |
||
| 15 | import javax.persistence.OneToOne; |
||
| 16 | import javax.persistence.Table; |
||
| 17 | import javax.persistence.Temporal; |
||
| 18 | import javax.persistence.TemporalType; |
||
| 19 | import javax.persistence.Transient; |
||
| 20 | |||
| 21 | import br.com.ec.util.FormatarUtil; |
||
| 22 | import br.com.ec.util.VerificadorUtil; |
||
| 23 | |||
| 24 | @Entity |
||
| 25 | @Table(name="vw_pessoa", schema="admscg001") |
||
| 26 | public class PessoaView implements Serializable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Long sequencial; |
||
| 31 | private String nome; |
||
| 32 | private String numeroCpf; |
||
| 33 | private String tipoSexo; |
||
| 34 | private Date dataNascimento; |
||
| 35 | private String email; |
||
| 36 | private Boolean ativo; |
||
| 37 | private String codigoIntegracao; |
||
| 38 | private PessoaEnderecoView endereco; |
||
| 39 | private Set<PessoaTelefoneView> telefones = new HashSet<PessoaTelefoneView>(); |
||
| 40 | private Set<OcupacaoView> ocupacoes = new HashSet<>(); |
||
| 41 | |||
| 42 | @Id |
||
| 43 | @Column(name="seq_pessoa", nullable=false) |
||
| 44 | public Long getSequencial() { |
||
| 45 | return sequencial; |
||
| 46 | } |
||
| 47 | |||
| 48 | public void setSequencial(Long sequencial) { |
||
| 49 | this.sequencial = sequencial; |
||
| 50 | } |
||
| 51 | |||
| 52 | @Column(name="nom_pessoa", nullable=false) |
||
| 53 | public String getNome() { |
||
| 54 | return nome; |
||
| 55 | } |
||
| 56 | |||
| 57 | public void setNome(String nome) { |
||
| 58 | this.nome = nome; |
||
| 59 | } |
||
| 60 | |||
| 61 | @Column(name="num_cpf", nullable=false) |
||
| 62 | public String getNumeroCpf() { |
||
| 63 | return numeroCpf; |
||
| 64 | } |
||
| 65 | |||
| 66 | public void setNumeroCpf(String numeroCpf) { |
||
| 67 | this.numeroCpf = numeroCpf; |
||
| 68 | } |
||
| 69 | |||
| 70 | @Column(name="tip_sexo", nullable=false) |
||
| 71 | public String getTipoSexo() { |
||
| 72 | return tipoSexo; |
||
| 73 | } |
||
| 74 | |||
| 75 | public void setTipoSexo(String tipoSexo) { |
||
| 76 | this.tipoSexo = tipoSexo; |
||
| 77 | } |
||
| 78 | |||
| 79 | @Temporal(TemporalType.DATE) |
||
| 80 | @Column(name="dat_nascimento", nullable=false) |
||
| 81 | public Date getDataNascimento() { |
||
| 82 | return dataNascimento; |
||
| 83 | } |
||
| 84 | |||
| 85 | public void setDataNascimento(Date dataNascimento) { |
||
| 86 | this.dataNascimento = dataNascimento; |
||
| 87 | } |
||
| 88 | |||
| 89 | @Column(name="dsc_email", nullable=false) |
||
| 90 | public String getEmail() { |
||
| 91 | return email; |
||
| 92 | } |
||
| 93 | |||
| 94 | public void setEmail(String email) { |
||
| 95 | this.email = email; |
||
| 96 | } |
||
| 97 | |||
| 98 | @Column(name="ind_ativo") |
||
| 99 | public Boolean getAtivo() { |
||
| 100 | return ativo; |
||
| 101 | } |
||
| 102 | |||
| 103 | public void setAtivo(Boolean ativo) { |
||
| 104 | this.ativo = ativo; |
||
| 105 | } |
||
| 106 | |||
| 107 | @Column(name="cod_pessoa_integracao") |
||
| 108 | public String getCodigoIntegracao() { |
||
| 109 | return codigoIntegracao; |
||
| 110 | } |
||
| 111 | |||
| 112 | public void setCodigoIntegracao(String codigoIntegracao) { |
||
| 113 | this.codigoIntegracao = codigoIntegracao; |
||
| 114 | } |
||
| 115 | |||
| 116 | @OneToMany(mappedBy = "pessoa") |
||
| 117 | public Set<PessoaTelefoneView> getTelefones() { |
||
| 118 | return telefones; |
||
| 119 | } |
||
| 120 | |||
| 121 | public void setTelefones(Set<PessoaTelefoneView> telefones) { |
||
| 122 | this.telefones = telefones; |
||
| 123 | } |
||
| 124 | |||
| 125 | @ManyToMany |
||
| 126 | @JoinTable(schema="admscg001", name="vw_pessoa_ocupacao", joinColumns={@JoinColumn(name="seq_pessoa")}, inverseJoinColumns={@JoinColumn(name="cod_ocupacao")}) |
||
| 127 | public Set<OcupacaoView> getOcupacoes() { |
||
| 128 | return ocupacoes; |
||
| 129 | } |
||
| 130 | |||
| 131 | public void setOcupacoes(Set<OcupacaoView> ocupacoes) { |
||
| 132 | this.ocupacoes = ocupacoes; |
||
| 133 | } |
||
| 134 | |||
| 135 | @OneToOne(mappedBy="pessoa") |
||
| 136 | public PessoaEnderecoView getEndereco() { |
||
| 137 | return endereco; |
||
| 138 | } |
||
| 139 | |||
| 140 | public void setEndereco(PessoaEnderecoView endereco) { |
||
| 141 | this.endereco = endereco; |
||
| 142 | } |
||
| 143 | |||
| 144 | @Override |
||
| 145 | public int hashCode() { |
||
| 146 | final int prime = 31; |
||
| 147 | int result = 1; |
||
| 148 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 149 | return result; |
||
| 150 | } |
||
| 151 | |||
| 152 | @Override |
||
| 153 | public boolean equals(Object obj) { |
||
| 154 | if (this == obj) |
||
| 155 | return true; |
||
| 156 | if (obj == null) |
||
| 157 | return false; |
||
| 158 | if (getClass() != obj.getClass()) |
||
| 159 | return false; |
||
| 160 | PessoaView other = (PessoaView) obj; |
||
| 161 | if (sequencial == null) { |
||
| 162 | if (other.sequencial != null) |
||
| 163 | return false; |
||
| 164 | } else if (!sequencial.equals(other.sequencial)) |
||
| 165 | return false; |
||
| 166 | return true; |
||
| 167 | } |
||
| 168 | |||
| 169 | @Transient |
||
| 170 | public String getNumeroCpfFormatado() { |
||
| 171 | return VerificadorUtil.naoEstaNuloOuVazio(getNumeroCpf())? FormatarUtil.retornarCPFFormatado(getNumeroCpf()) : null; |
||
| 172 | } |
||
| 173 | |||
| 174 | @Transient |
||
| 175 | public String getTelefonesFormatados() { |
||
| 176 | StringBuilder telefones = new StringBuilder(); |
||
| 177 | for (PessoaTelefoneView telefone : getTelefones()) { |
||
| 178 | if (telefones.length() > 0) { |
||
| 179 | telefones.append(", "); |
||
| 180 | } |
||
| 181 | telefones.append(FormatarUtil.retornarTelefoneFormatado(telefone.getNumeroTelefone())); |
||
| 182 | } |
||
| 183 | return telefones.toString(); |
||
| 184 | } |
||
| 185 | |||
| 186 | } |