Blame |
Last modification |
View Log
| Download
| RSS feed
package br.gov.al.saude.scs.model.view;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.hibernate.annotations.ForeignKey;
import br.gov.al.saude.framework.core.generic.identidade.Identidade;
import br.gov.al.saude.scg.model.view.PessoaFisicaView;
@
Entity
@Table
(name =
"vw_servidor", schema =
"sc_srv")
public class ServidorView
implements Serializable, Identidade,
Comparable<ServidorView
> {
private static final long serialVersionUID = 1L
;
private PessoaFisicaView pessoa
;
private String nome
;
private String cpf
;
private String sexo
;
private Date dataNascimento
;
private String email
;
private String nacionalidade
;
private String tipoGrauInstrucao
;
@Id
@OneToOne
@ForeignKey
(name=
"fk_servidor_pessoa")
@JoinColumn
(name=
"seq_pessoa_servidor", referencedColumnName=
"seq_pessoa")
public PessoaFisicaView getPessoa
() {
return pessoa
;
}
public void setPessoa
(PessoaFisicaView pessoa
) {
this.
pessoa = pessoa
;
}
@Column
(name=
"nom_pessoa")
public String getNome
() {
return nome
;
}
public void setNome
(String nome
) {
this.
nome = nome
;
}
@Column
(name=
"num_cpf")
public String getCpf
() {
return cpf
;
}
public void setCpf
(String cpf
) {
this.
cpf = cpf
;
}
@Column
(name=
"tip_sexo")
public String getSexo
() {
return sexo
;
}
public void setSexo
(String sexo
) {
this.
sexo = sexo
;
}
@Temporal
(TemporalType.
DATE)
@Column
(name=
"dat_nascimento")
public Date getDataNascimento
() {
return dataNascimento
;
}
public void setDataNascimento
(Date dataNascimento
) {
this.
dataNascimento = dataNascimento
;
}
@Column
(name=
"dsc_email")
public String getEmail
() {
return email
;
}
public void setEmail
(String email
) {
this.
email = email
;
}
@Column
(name=
"dsc_nacionalidade")
public String getNacionalidade
() {
return nacionalidade
;
}
public void setNacionalidade
(String nacionalidade
) {
this.
nacionalidade = nacionalidade
;
}
@Column
(name=
"tip_grau_instrucao")
public String getTipoGrauInstrucao
() {
return tipoGrauInstrucao
;
}
public void setTipoGrauInstrucao
(String tipoGrauInstrucao
) {
this.
tipoGrauInstrucao = tipoGrauInstrucao
;
}
@
Override
@Transient
public Object getId
() {
return pessoa.
getId();
}
@
Override
public void setId
(Object id
) {
this.
pessoa.
setId((Long) id
);
}
@Transient
public String getSexoPorExtenso
() {
if("M".
equals(sexo
))
return "Masculino";
if("F".
equals(sexo
))
return "Feminino";
return null;
}
@Transient
public Long getSequencialDaPessoa
() {
return pessoa
!=
null ? pessoa.
getSequencialPessoa() :
null;
}
@
Override
public int hashCode
() {
final int prime =
31;
int result =
1;
result = prime
* result +
((getId
() ==
null) ? 0 : getId
().
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;
ServidorView other =
(ServidorView
) obj
;
if (getId
() ==
null) {
if (other.
getId() !=
null)
return false;
} else if (!getId
().
equals(other.
getId()))
return false;
return true;
}
@
Override
public int compareTo
(ServidorView o
) {
return getNome
().
compareToIgnoreCase(o.
getNome());
}
}