Rev 182 |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
package br.com.ec.views;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import br.com.ec.util.FormatarUtil;
import br.com.ec.util.VerificadorUtil;
@
Entity
@Table
(name=
"vw_pessoa", schema=
"admscg001")
public class PessoaView
implements Serializable {
private static final long serialVersionUID = 1L
;
private Long sequencial
;
private String nome
;
private String numeroCpf
;
private String tipoSexo
;
private Date dataNascimento
;
private String email
;
private Boolean ativo
;
private String codigoIntegracao
;
private PessoaEnderecoView endereco
;
private Set<PessoaTelefoneView
> telefones =
new HashSet<PessoaTelefoneView
>();
private Set<OcupacaoView
> ocupacoes =
new HashSet<>();
@Id
@Column
(name=
"seq_pessoa", nullable=
false)
public Long getSequencial
() {
return sequencial
;
}
public void setSequencial
(Long sequencial
) {
this.
sequencial = sequencial
;
}
@Column
(name=
"nom_pessoa", nullable=
false)
public String getNome
() {
return nome
;
}
public void setNome
(String nome
) {
this.
nome = nome
;
}
@Column
(name=
"num_cpf", nullable=
false)
public String getNumeroCpf
() {
return numeroCpf
;
}
public void setNumeroCpf
(String numeroCpf
) {
this.
numeroCpf = numeroCpf
;
}
@Column
(name=
"tip_sexo", nullable=
false)
public String getTipoSexo
() {
return tipoSexo
;
}
public void setTipoSexo
(String tipoSexo
) {
this.
tipoSexo = tipoSexo
;
}
@Temporal
(TemporalType.
DATE)
@Column
(name=
"dat_nascimento", nullable=
false)
public Date getDataNascimento
() {
return dataNascimento
;
}
public void setDataNascimento
(Date dataNascimento
) {
this.
dataNascimento = dataNascimento
;
}
@Column
(name=
"dsc_email", nullable=
false)
public String getEmail
() {
return email
;
}
public void setEmail
(String email
) {
this.
email = email
;
}
@Column
(name=
"ind_ativo")
public Boolean getAtivo
() {
return ativo
;
}
public void setAtivo
(Boolean ativo
) {
this.
ativo = ativo
;
}
@Column
(name=
"cod_pessoa_integracao")
public String getCodigoIntegracao
() {
return codigoIntegracao
;
}
public void setCodigoIntegracao
(String codigoIntegracao
) {
this.
codigoIntegracao = codigoIntegracao
;
}
@OneToMany
(mappedBy =
"pessoa")
public Set<PessoaTelefoneView
> getTelefones
() {
return telefones
;
}
public void setTelefones
(Set<PessoaTelefoneView
> telefones
) {
this.
telefones = telefones
;
}
@ManyToMany
@JoinTable
(schema=
"admscg001", name=
"vw_pessoa_ocupacao", joinColumns=
{@JoinColumn
(name=
"seq_pessoa")}, inverseJoinColumns=
{@JoinColumn
(name=
"cod_ocupacao")})
public Set<OcupacaoView
> getOcupacoes
() {
return ocupacoes
;
}
public void setOcupacoes
(Set<OcupacaoView
> ocupacoes
) {
this.
ocupacoes = ocupacoes
;
}
@OneToOne
(mappedBy=
"pessoa")
public PessoaEnderecoView getEndereco
() {
return endereco
;
}
public void setEndereco
(PessoaEnderecoView endereco
) {
this.
endereco = endereco
;
}
@
Override
public int hashCode
() {
final int prime =
31;
int result =
1;
result = prime
* result +
((sequencial ==
null) ? 0 : sequencial.
hashCode());
return result
;
}
@
Override
public boolean equals
(Object obj
) {
if (this == obj
)
return true;
if (obj ==
null)
return false;
if (getClass
() != obj.
getClass())
return false;
PessoaView other =
(PessoaView
) obj
;
if (sequencial ==
null) {
if (other.
sequencial !=
null)
return false;
} else if (!sequencial.
equals(other.
sequencial))
return false;
return true;
}
@Transient
public String getNumeroCpfFormatado
() {
return VerificadorUtil.
naoEstaNuloOuVazio(getNumeroCpf
())? FormatarUtil.
retornarCPFFormatado(getNumeroCpf
()) :
null;
}
@Transient
public String getTelefonesFormatados
() {
StringBuilder telefones =
new StringBuilder();
for (PessoaTelefoneView telefone : getTelefones
()) {
if (telefones.
length() > 0) {
telefones.
append(", ");
}
telefones.
append(FormatarUtil.
retornarTelefoneFormatado(telefone.
getNumeroTelefone()));
}
return telefones.
toString();
}
}