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.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_arquivo_projeto", schema=
"admsic001")
@
Entity
@Table
(name=
"sic_arquivo_projeto", schema=
"admsic001")
public class ArquivoProjeto
implements Serializable {
private static final long serialVersionUID = 1L
;
private Long sequencial
;
private ProjetoPesquisa projetoPesquisa =
new ProjetoPesquisa
();
private Arquivo arquivo
;
private String tipoDocumentoProjeto
;
@Id
@GeneratedValue
(strategy=GenerationType.
AUTO)
@Column
(name=
"seq_arquivo_projeto", nullable=
false)
public Long getSequencial
() {
return sequencial
;
}
public void setSequencial
(Long sequencial
) {
this.
sequencial = sequencial
;
}
@Audited
(targetAuditMode = RelationTargetAuditMode.
NOT_AUDITED)
@OneToOne
@JoinColumn
(name=
"seq_projeto_pesquisa", referencedColumnName=
"seq_projeto_pesquisa", nullable=
false)
public ProjetoPesquisa getProjetoPesquisa
() {
return projetoPesquisa
;
}
public void setProjetoPesquisa
(ProjetoPesquisa projetoPesquisa
) {
this.
projetoPesquisa = projetoPesquisa
;
}
@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_projeto", nullable=
false)
public String getTipoDocumentoProjeto
() {
return tipoDocumentoProjeto
;
}
public void setTipoDocumentoProjeto
(String tipoDocumentoProjeto
) {
this.
tipoDocumentoProjeto = tipoDocumentoProjeto
;
}
@
Override
public int hashCode
() {
final int prime =
31;
int result =
1;
result = prime
* result +
((arquivo ==
null) ? 0 : arquivo.
hashCode());
result = prime
* result +
((projetoPesquisa ==
null) ? 0 : projetoPesquisa.
hashCode());
result = prime
* result +
((sequencial ==
null) ? 0 : sequencial.
hashCode());
result = prime
* result +
((tipoDocumentoProjeto ==
null) ? 0 : tipoDocumentoProjeto.
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;
ArquivoProjeto other =
(ArquivoProjeto
) obj
;
if (arquivo ==
null) {
if (other.
arquivo !=
null)
return false;
} else if (!arquivo.
equals(other.
arquivo))
return false;
if (projetoPesquisa ==
null) {
if (other.
projetoPesquisa !=
null)
return false;
} else if (!projetoPesquisa.
equals(other.
projetoPesquisa))
return false;
if (sequencial ==
null) {
if (other.
sequencial !=
null)
return false;
} else if (!sequencial.
equals(other.
sequencial))
return false;
if (tipoDocumentoProjeto ==
null) {
if (other.
tipoDocumentoProjeto !=
null)
return false;
} else if (!tipoDocumentoProjeto.
equals(other.
tipoDocumentoProjeto))
return false;
return true;
}
@Transient
public String getExtensaoDoArquivo
() {
return VerificadorUtil.
naoEstaNulo(getArquivo
())? getArquivo
().
getExtensao() :
null;
}
}