package br.gov.al.saude.srv.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import org.hibernate.envers.AuditTable;
import org.hibernate.envers.Audited;
import org.hibernate.envers.RelationTargetAuditMode;
import br.gov.al.saude.framework.core.interfaces.Alterar;
import br.gov.al.saude.framework.core.interfaces.Cadastrar;
import br.gov.al.saude.framework.core.util.VerificadorUtil;
import br.gov.al.saude.srv.model.enums.TipoRegimeTrabalho;
@Audited
@AuditTable
(value=
"srv_hist_servdadofunc_matricula", schema=
"sc_srv")
@
Entity
@Table
(name =
"srv_servdadofunc_matricula", schema =
"sc_srv")
@Inheritance
(strategy=InheritanceType.
JOINED)
@PrimaryKeyJoinColumn
(name =
"seq_servidor_dadofuncional", referencedColumnName =
"seq_servidor_dadofuncional")
public class ServidorDadoFuncionalMatricula
extends ServidorDadoFuncional
implements Serializable {
private static final long serialVersionUID = 1L
;
private Long matriculaServidor
;
private Integer digitoMatricula
;
private SituacaoServidor situacaoServidor
;
private Long ordem
;
private String tipoRegimeTrabalho
;
private Orgao orgao
;
private Date dataNomeacao
;
private Date dataPosse
;
private Date dataExercicio
;
private Funcao funcao
;
@Column
(name=
"num_matricula_servidor", nullable=
false)
@NotNull
(message=
"Obrigatório informar a matrícula.", groups=
{Cadastrar.
class, Alterar.
class})
public Long getMatriculaServidor
() {
return matriculaServidor
;
}
public void setMatriculaServidor
(Long matriculaServidor
) {
this.
matriculaServidor = matriculaServidor
;
}
@Column
(name=
"num_digito_matricula", nullable=
false, length=
1)
@NotNull
(message=
"Obrigatório informar o dígito da matrícula.", groups=
{Cadastrar.
class, Alterar.
class})
public Integer getDigitoMatricula
() {
return digitoMatricula
;
}
public void setDigitoMatricula
(Integer digitoMatricula
) {
this.
digitoMatricula = digitoMatricula
;
}
@Audited
(targetAuditMode = RelationTargetAuditMode.
NOT_AUDITED)
@ManyToOne
@JoinColumn
(name=
"cod_situacao_servidor", referencedColumnName=
"cod_situacao_servidor", nullable=
false)
@NotNull
(message=
"Obrigatório informar a situação do servidor.", groups=
{Cadastrar.
class, Alterar.
class})
public SituacaoServidor getSituacaoServidor
() {
return situacaoServidor
;
}
public void setSituacaoServidor
(SituacaoServidor situacaoServidor
) {
this.
situacaoServidor = situacaoServidor
;
}
@Column
(name=
"num_ordem", nullable=
false)
@NotNull
(message=
"Obrigatório informar o número de ordem.", groups=
{Cadastrar.
class, Alterar.
class})
public Long getOrdem
() {
return ordem
;
}
public void setOrdem
(Long ordem
) {
this.
ordem = ordem
;
}
@Column
(name=
"tip_regime_trabalho", nullable=
false, length=
1)
@NotNull
(message=
"Obrigatório informar o regime de trabalho.", groups=
{Cadastrar.
class, Alterar.
class})
public String getTipoRegimeTrabalho
() {
return tipoRegimeTrabalho
;
}
public void setTipoRegimeTrabalho
(String tipoRegimeTrabalho
) {
this.
tipoRegimeTrabalho = tipoRegimeTrabalho
;
}
@Transient
public String getDescricaoTipoRegimeTrabalho
() {
return VerificadorUtil.
naoEstaNuloOuVazio(tipoRegimeTrabalho
) ? TipoRegimeTrabalho.
parse(tipoRegimeTrabalho
).
getDescricao() :
"";
}
@Audited
(targetAuditMode = RelationTargetAuditMode.
NOT_AUDITED)
@ManyToOne
@JoinColumn
(name=
"seq_orgao_origem", referencedColumnName=
"seq_orgao", nullable=
false)
@NotNull
(message=
"Obrigatório informar o órgão de origem.", groups=
{Cadastrar.
class, Alterar.
class})
public Orgao getOrgao
() {
return orgao
;
}
public void setOrgao
(Orgao orgao
) {
this.
orgao = orgao
;
}
@Temporal
(TemporalType.
DATE)
@Column
(name=
"dat_nomeacao", nullable=
false)
@NotNull
(message=
"Obrigatório informar a data de nomeação.", groups=
{Cadastrar.
class, Alterar.
class})
public Date getDataNomeacao
() {
return dataNomeacao
;
}
public void setDataNomeacao
(Date dataNomeacao
) {
this.
dataNomeacao = dataNomeacao
;
}
@Temporal
(TemporalType.
DATE)
@Column
(name=
"dat_posse", nullable=
false)
@NotNull
(message=
"Obrigatório informar a data de posse.", groups=
{Cadastrar.
class, Alterar.
class})
public Date getDataPosse
() {
return dataPosse
;
}
public void setDataPosse
(Date dataPosse
) {
this.
dataPosse = dataPosse
;
}
@Temporal
(TemporalType.
DATE)
@Column
(name=
"dat_exercicio", nullable=
false)
@NotNull
(message=
"Obrigatório informar a data de exercício.", groups=
{Cadastrar.
class, Alterar.
class})
public Date getDataExercicio
() {
return dataExercicio
;
}
public void setDataExercicio
(Date dataExercicio
) {
this.
dataExercicio = dataExercicio
;
}
@Audited
(targetAuditMode = RelationTargetAuditMode.
NOT_AUDITED)
@ManyToOne
@JoinColumn
(name=
"cod_funcao", referencedColumnName=
"cod_funcao", nullable=
false)
public Funcao getFuncao
() {
return funcao
;
}
public void setFuncao
(Funcao funcao
) {
this.
funcao = funcao
;
}
@
Override
public int hashCode
() {
if (getSequencial
() !=
null) return super.
hashCode();
final int prime =
31;
int result =
super.
hashCode();
result = prime
* result
+
((dataExercicio ==
null) ? 0 : dataExercicio.
hashCode());
result = prime
* result
+
((dataNomeacao ==
null) ? 0 : dataNomeacao.
hashCode());
result = prime
* result
+
((dataPosse ==
null) ? 0 : dataPosse.
hashCode());
result = prime
* result
+
((digitoMatricula ==
null) ? 0 : digitoMatricula.
hashCode());
result = prime
* result +
((funcao ==
null) ? 0 : funcao.
hashCode());
result = prime
* result
+
((matriculaServidor ==
null) ? 0 : matriculaServidor
.
hashCode());
result = prime
* result +
((ordem ==
null) ? 0 : ordem.
hashCode());
result = prime
* result +
((orgao ==
null) ? 0 : orgao.
hashCode());
result = prime
* result
+
((situacaoServidor ==
null) ? 0 : situacaoServidor.
hashCode());
result = prime
* result
+
((tipoRegimeTrabalho ==
null) ? 0 : tipoRegimeTrabalho
.
hashCode());
return result
;
}
@
Override
public boolean equals
(Object obj
) {
if (getSequencial
() !=
null) return super.
equals(obj
);
if (this == obj
)
return true;
if (!super.
equals(obj
))
return false;
if (getClass
() != obj.
getClass())
return false;
ServidorDadoFuncionalMatricula other =
(ServidorDadoFuncionalMatricula
) obj
;
if (dataExercicio ==
null) {
if (other.
dataExercicio !=
null)
return false;
} else if (!dataExercicio.
equals(other.
dataExercicio))
return false;
if (dataNomeacao ==
null) {
if (other.
dataNomeacao !=
null)
return false;
} else if (!dataNomeacao.
equals(other.
dataNomeacao))
return false;
if (dataPosse ==
null) {
if (other.
dataPosse !=
null)
return false;
} else if (!dataPosse.
equals(other.
dataPosse))
return false;
if (digitoMatricula ==
null) {
if (other.
digitoMatricula !=
null)
return false;
} else if (!digitoMatricula.
equals(other.
digitoMatricula))
return false;
if (funcao ==
null) {
if (other.
funcao !=
null)
return false;
} else if (!funcao.
equals(other.
funcao))
return false;
if (matriculaServidor ==
null) {
if (other.
matriculaServidor !=
null)
return false;
} else if (!matriculaServidor.
equals(other.
matriculaServidor))
return false;
if (ordem ==
null) {
if (other.
ordem !=
null)
return false;
} else if (!ordem.
equals(other.
ordem))
return false;
if (orgao ==
null) {
if (other.
orgao !=
null)
return false;
} else if (!orgao.
equals(other.
orgao))
return false;
if (situacaoServidor ==
null) {
if (other.
situacaoServidor !=
null)
return false;
} else if (!situacaoServidor.
equals(other.
situacaoServidor))
return false;
if (tipoRegimeTrabalho ==
null) {
if (other.
tipoRegimeTrabalho !=
null)
return false;
} else if (!tipoRegimeTrabalho.
equals(other.
tipoRegimeTrabalho))
return false;
return true;
}
}