Skip to content

Instantly share code, notes, and snippets.

Created March 8, 2018 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4ff1407e2ac5de86960f5eee192bd975 to your computer and use it in GitHub Desktop.
Save anonymous/4ff1407e2ac5de86960f5eee192bd975 to your computer and use it in GitHub Desktop.
package br.com.netsoft.model.todos;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import br.com.netsoft.anotacoes.ExclusaoLogica;
import br.com.netsoft.enuns.CodigoSegmentoFebrabanEnum;
import br.com.netsoft.model.NotaFiscalServicoEntity;
import br.com.netsoft.servico.util.StringUtil;
@Entity
@Table(name = "TB_ENTIDADE", schema = "ENTIDADES", uniqueConstraints = {
@UniqueConstraint(columnNames = { "DS_DOCUMENTO" }, name = "UK_ENTIDADE_DOCUMENTO") }, indexes = {
@Index(columnList = "DS_DOCUMENTO", name = "IDN_ENTIDADE_DOCUMENTO"),
@Index(columnList = "ST_REGISTRO", name = "IDN_ENTIDADE_REGISTRO"),
@Index(columnList = "DS_INSCRICAO_MUNICIPAL", name = "IDN_ENTIDADE_MUNICIPAL") })
@ExclusaoLogica
/**
* Modelo de entidade
*
* @author Guilherme Costa
*/
public class EntidadeEntity extends NotaFiscalServicoEntity {
private static final long serialVersionUID = 2671916631315758849L;
private String cei;
private CodigoSegmentoFebrabanEnum codigoFebrabanSegmento;
private String telefoneTres;
private String documento;
private String emailPrincipal;
private String fantasia;
private String fax;
private String insEstadual;
private String insMunicipal;
private Byte[] logomarca;
private String numeroFebrabam;
private String razaoSocialNome;
private String site;
private String telefone;
private String telefoneDois;
/**
* Classes que ligam a pessoa
*/
private EntidadeEnderecoEntity entidadeEndereco;
@Id
@Column(name = "ID_ENTIDADE")
@SequenceGenerator(name = "ENTIDADES.SQ_ENTIDADE", sequenceName = "ENTIDADES.SQ_ENTIDADE", allocationSize = 1)
@GeneratedValue(generator = "ENTIDADES.SQ_ENTIDADE", strategy = GenerationType.SEQUENCE)
public Long getId() {
return super.getId();
}
@Column(name = "DS_DOCUMENTO", length = 18, nullable = false)
public String getDocumento() {
return documento;
}
public void setDocumento(String documento) {
this.documento = documento;
}
@Column(name = "DS_CEI", length = 12, nullable = false)
public String getCei() {
return cei;
}
public void setCei(String cei) {
this.cei = cei;
}
@Column(name = "DS_INSCRICAO_ESTADUAL", length = 15)
public String getInsEstadual() {
return insEstadual;
}
public void setInsEstadual(String insEstadual) {
this.insEstadual = insEstadual;
}
@Column(name = "DS_RAZAO_SOCIAL_NOME", length = 255, nullable = false)
public String getRazaoSocialNome() {
return razaoSocialNome;
}
public void setRazaoSocialNome(String razaoSocialNome) {
this.razaoSocialNome = razaoSocialNome;
}
@Column(name = "DS_FANTASIA", length = 100, nullable = false)
public String getFantasia() {
return fantasia;
}
public void setFantasia(String fantasia) {
this.fantasia = fantasia;
}
@Column(name = "DS_TELEFONE", length = 11, nullable = false)
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
@Column(name = "DS_TELEFONE_DOIS", length = 11, nullable = false)
public String getTelefoneDois() {
return telefoneDois;
}
public void setTelefoneDois(String telefoneDois) {
this.telefoneDois = telefoneDois;
}
@Column(name = "DS_TELEFONE_TRES", length = 11)
public String getTelefoneTres() {
return telefoneTres;
}
public void setTelefoneTres(String telefoneTres) {
this.telefoneTres = telefoneTres;
}
@Column(name = "DS_FAX", length = 11, nullable = false)
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
@Column(name = "DS_EMAIL_PRINCIPAL", length = 100, nullable = false)
public String getEmailPrincipal() {
return emailPrincipal;
}
public void setEmailPrincipal(String emailPrincipal) {
this.emailPrincipal = emailPrincipal;
}
@Column(name = "DS_SITE", length = 100, nullable = false)
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
@Column(name = "IM_LOGOMARCA")
public Byte[] getLogomarca() {
return logomarca;
}
public void setLogomarca(Byte[] logomarca) {
this.logomarca = logomarca;
}
@Column(name = "DS_INSCRICAO_MUNICIPAL", length = 15)
public String getInsMunicipal() {
return insMunicipal;
}
public void setInsMunicipal(String insMunicipal) {
this.insMunicipal = insMunicipal;
}
@Column(name = "DS_NUMERO_FEBRABAN", length = 4, nullable = false)
public String getNumeroFebrabam() {
return numeroFebrabam;
}
public void setNumeroFebrabam(String numeroFebrabam) {
this.numeroFebrabam = numeroFebrabam;
}
@Column(name = "ST_CD_FEBRABAN_SEG", length = 1, nullable = false)
@Enumerated(EnumType.ORDINAL)
public CodigoSegmentoFebrabanEnum getCodigoFebrabanSegmento() {
return codigoFebrabanSegmento;
}
public void setCodigoFebrabanSegmento(CodigoSegmentoFebrabanEnum codigoFebrabanSegmento) {
this.codigoFebrabanSegmento = codigoFebrabanSegmento;
}
@OneToOne(mappedBy = "entidade", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JsonManagedReference
public EntidadeEnderecoEntity getEntidadeEndereco() {
return entidadeEndereco;
}
public void setEntidadeEndereco(EntidadeEnderecoEntity entidadeEndereco) {
this.entidadeEndereco = entidadeEndereco;
}
@Transient
public String documentoNomeRazao() {
return StringUtil.formataCnpjCpf(this.documento).concat(" - ").concat(this.razaoSocialNome);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment