Blame |
Last modification |
View Log
| Download
| RSS feed
package br.edu.cesmac.sic.core.domain.model;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.hibernate.envers.AuditTable;
import org.hibernate.envers.Audited;
import org.hibernate.envers.RelationTargetAuditMode;
import br.edu.cesmac.core.interfaces.Alterar;
import br.edu.cesmac.core.interfaces.Cadastrar;
import br.edu.cesmac.core.util.VerificadorUtil;
@Audited
@AuditTable
(value=
"sic_aud_documento_aluno", schema=
"admsic001")
@
Entity
@Table
(name=
"sic_documento_aluno", schema=
"admsic001")
public class DocumentoAluno
implements Serializable {
private static final long serialVersionUID = 1L
;
private Long sequencial
;
private ProjetoPesquisaAluno projetoPesquisaAluno
;
private Arquivo arquivo
;
private String tipoDocumentoAluno
;
@Id
@GeneratedValue
(strategy=GenerationType.
AUTO)
@Column
(name=
"seq_documento_aluno", nullable=
false)
public Long getSequencial
() {
return sequencial
;
}
public void setSequencial
(Long sequencial
) {
this.
sequencial = sequencial
;
}
@Audited
(targetAuditMode = RelationTargetAuditMode.
NOT_AUDITED)
@ManyToOne
@JoinColumns
(value=
{
@JoinColumn
(name=
"num_matricula", referencedColumnName=
"num_matricula", nullable=
false),
@JoinColumn
(name=
"seq_projeto_pesquisa", referencedColumnName=
"seq_projeto_pesquisa", nullable=
false),
})
public ProjetoPesquisaAluno getProjetoPesquisaAluno
() {
return projetoPesquisaAluno
;
}
public void setProjetoPesquisaAluno
(ProjetoPesquisaAluno projetoPesquisaAluno
) {
this.
projetoPesquisaAluno = projetoPesquisaAluno
;
}
@Audited
(targetAuditMode = RelationTargetAuditMode.
NOT_AUDITED)
@Valid
@OneToOne
(fetch=FetchType.
LAZY, cascade=CascadeType.
ALL, orphanRemoval=
true)
@NotNull
(message=
"Obrigatório informar o arquivo", groups=
{Cadastrar.
class, Alterar.
class})
@JoinColumn
(name=
"seq_arquivo", referencedColumnName=
"seq_arquivo", nullable=
false, insertable=
true, updatable=
true)
public Arquivo getArquivo
() {
return arquivo
;
}
public void setArquivo
(Arquivo arquivo
) {
this.
arquivo = arquivo
;
}
@Column
(name=
"tip_documento_aluno", nullable=
false)
public String getTipoDocumentoAluno
() {
return tipoDocumentoAluno
;
}
public void setTipoDocumentoAluno
(String tipoDocumentoAluno
) {
this.
tipoDocumentoAluno = tipoDocumentoAluno
;
}
@
Override
public int hashCode
() {
final int prime =
31;
int result =
1;
result = prime
* result +
((arquivo ==
null) ? 0 : arquivo.
hashCode());
result = prime
* result +
((projetoPesquisaAluno ==
null) ? 0 : projetoPesquisaAluno.
hashCode());
result = prime
* result +
((sequencial ==
null) ? 0 : sequencial.
hashCode());
result = prime
* result +
((tipoDocumentoAluno ==
null) ? 0 : tipoDocumentoAluno.
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;
DocumentoAluno other =
(DocumentoAluno
) obj
;
if (arquivo ==
null) {
if (other.
arquivo !=
null)
return false;
} else if (!arquivo.
equals(other.
arquivo))
return false;
if (projetoPesquisaAluno ==
null) {
if (other.
projetoPesquisaAluno !=
null)
return false;
} else if (!projetoPesquisaAluno.
equals(other.
projetoPesquisaAluno))
return false;
if (sequencial ==
null) {
if (other.
sequencial !=
null)
return false;
} else if (!sequencial.
equals(other.
sequencial))
return false;
if (tipoDocumentoAluno ==
null) {
if (other.
tipoDocumentoAluno !=
null)
return false;
} else if (!tipoDocumentoAluno.
equals(other.
tipoDocumentoAluno))
return false;
return true;
}
@Transient
public String getExtensaoDoArquivo
() {
return VerificadorUtil.
naoEstaNulo(getArquivo
())? getArquivo
().
getExtensao() :
null;
}
}