From 59c3411321ff07467d63ecb3e8ea2436faa3150f Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 10 Apr 2024 20:09:45 -0300 Subject: [PATCH 1/2] AL-4135 --- pom.xml | 2 +- .../rjconsultores/ventaboletos/entidad/Empresa.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 41167ee3a..cada2e45f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 br.com.rjconsultores ModelWeb - 1.44.0 + 1.44.1 diff --git a/src/com/rjconsultores/ventaboletos/entidad/Empresa.java b/src/com/rjconsultores/ventaboletos/entidad/Empresa.java index e783d2b2e..a1db2e6a4 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Empresa.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Empresa.java @@ -451,6 +451,9 @@ public class Empresa implements Serializable, Auditavel { @Column(name = "INDIMPRESSAOAPOSCONFABERTO") private Boolean indImpressaoAposConfAberto;; + @Column(name = "INDSAFTAO") + private Boolean indSaftao; + public Empresa() { super(); } @@ -1642,6 +1645,13 @@ public class Empresa implements Serializable, Auditavel { public void setIndImpressaoAposConfAberto(Boolean indImpressaoAposConfAberto) { this.indImpressaoAposConfAberto = indImpressaoAposConfAberto; } - + + public Boolean getIndSaftao() { + return indSaftao; + } + + public void setIndSaftao(Boolean indSaftao) { + this.indSaftao = indSaftao; + } } From 85a3c6dee1a1f55bbf0f285b50ab50070122232a Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 12 Apr 2024 19:33:02 -0300 Subject: [PATCH 2/2] AL-4135 --- .../dao/EmpresaCertificadoConfigDAO.java | 15 ++ .../EmpresaCertificadoConfigHibernateDAO.java | 43 +++++ .../entidad/EmpresaCertificadoConfig.java | 156 ++++++++++++++++++ .../enums/EnumTipoCertificado.java | 11 ++ .../EmpresaCertificadoConfigService.java | 10 ++ .../EmpresaCertificadoConfigServiceImpl.java | 69 ++++++++ .../ventaboletos/utilerias/CustomEnum.java | 2 +- 7 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/EmpresaCertificadoConfigDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaCertificadoConfigHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/EmpresaCertificadoConfig.java create mode 100644 src/com/rjconsultores/ventaboletos/enums/EnumTipoCertificado.java create mode 100644 src/com/rjconsultores/ventaboletos/service/EmpresaCertificadoConfigService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/EmpresaCertificadoConfigServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaCertificadoConfigDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaCertificadoConfigDAO.java new file mode 100644 index 000000000..7db804baa --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaCertificadoConfigDAO.java @@ -0,0 +1,15 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaCertificadoConfig; +import com.rjconsultores.ventaboletos.enums.EnumTipoCertificado; + +public interface EmpresaCertificadoConfigDAO extends GenericDAO { + + public List obtenerTodos(); + + public EmpresaCertificadoConfig buscarPorEmpresa(Empresa empresa, EnumTipoCertificado enumTipoCertificado); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaCertificadoConfigHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaCertificadoConfigHibernateDAO.java new file mode 100644 index 000000000..2c5aff4e4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaCertificadoConfigHibernateDAO.java @@ -0,0 +1,43 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.EmpresaCertificadoConfigDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaCertificadoConfig; +import com.rjconsultores.ventaboletos.enums.EnumTipoCertificado; + +@Repository("empresaCertificadoConfigDAO") +public class EmpresaCertificadoConfigHibernateDAO extends GenericHibernateDAO + implements EmpresaCertificadoConfigDAO { + + @Autowired + public EmpresaCertificadoConfigHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @Override + public EmpresaCertificadoConfig buscarPorEmpresa(Empresa empresa, EnumTipoCertificado enumTipoCertificado) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("empresa", empresa)); + c.add(Restrictions.eq("nome", enumTipoCertificado.toString())); + + return (EmpresaCertificadoConfig) c.uniqueResult(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/EmpresaCertificadoConfig.java b/src/com/rjconsultores/ventaboletos/entidad/EmpresaCertificadoConfig.java new file mode 100644 index 000000000..c7f15049a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/EmpresaCertificadoConfig.java @@ -0,0 +1,156 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "EMPRESA_CERTIFICADO_CONFIG_SEQ", sequenceName = "EMPRESA_CERTIFICADO_CONFIG_SEQ", allocationSize = 1) +@Table(name = "EMPRESA_CERTIFICADO_CONFIG") +public class EmpresaCertificadoConfig implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "EMPRESA_CERTIFICADO_CONFIG_SEQ") + @Column(name = "EMPRESACERTIFICADOCONFIG_ID") + private Integer empresaCertificadoConfigId; + @Column(name = "NOME") + private String nome; + @Column(name = "PUBLICKEY") + private Boolean publicKey; + @Column(name = "SENHA") + private String senha; + @Column(name = "CERTIFICADO") + private byte[] certificado; + + @OneToOne + @JoinColumn(name = "EMPRESA_ID") + private Empresa empresa; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public EmpresaCertificadoConfig() { + + } + + public Integer getEmpresaCertificadoConfigId() { + return empresaCertificadoConfigId; + } + + public void setEmpresaCertificadoConfigId(Integer empresaCertificadoConfigId) { + this.empresaCertificadoConfigId = empresaCertificadoConfigId; + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public Boolean getPublicKey() { + return publicKey; + } + + public void setPublicKey(Boolean publicKey) { + this.publicKey = publicKey; + } + + public String getSenha() { + return senha; + } + + public void setSenha(String senha) { + this.senha = senha; + } + + public byte[] getCertificado() { + return certificado; + } + + public void setCertificado(byte[] certificado) { + this.certificado = certificado; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + public Boolean getActivo() { + return activo; + } + + public void setActivo(Boolean activo) { + this.activo = activo; + } + + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((empresaCertificadoConfigId == null) ? 0 : empresaCertificadoConfigId.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; + EmpresaCertificadoConfig other = (EmpresaCertificadoConfig) obj; + if (empresaCertificadoConfigId == null) { + if (other.empresaCertificadoConfigId != null) + return false; + } else if (!empresaCertificadoConfigId.equals(other.empresaCertificadoConfigId)) + return false; + return true; + } + + @Override + public String toString() { + return String.valueOf(this.getEmpresaCertificadoConfigId()); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/enums/EnumTipoCertificado.java b/src/com/rjconsultores/ventaboletos/enums/EnumTipoCertificado.java new file mode 100644 index 000000000..a8dc49c59 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/enums/EnumTipoCertificado.java @@ -0,0 +1,11 @@ +package com.rjconsultores.ventaboletos.enums; + +public enum EnumTipoCertificado { + + SAFTAO,; + + private EnumTipoCertificado() { + + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaCertificadoConfigService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaCertificadoConfigService.java new file mode 100644 index 000000000..6903947ba --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaCertificadoConfigService.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaCertificadoConfig; +import com.rjconsultores.ventaboletos.enums.EnumTipoCertificado; + +public interface EmpresaCertificadoConfigService extends GenericService { + + public EmpresaCertificadoConfig buscarPorEmpresa(Empresa empresa, EnumTipoCertificado enumTipoCertificado); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaCertificadoConfigServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaCertificadoConfigServiceImpl.java new file mode 100644 index 000000000..c63eb341b --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaCertificadoConfigServiceImpl.java @@ -0,0 +1,69 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.EmpresaCertificadoConfigDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaCertificadoConfig; +import com.rjconsultores.ventaboletos.enums.EnumTipoCertificado; +import com.rjconsultores.ventaboletos.service.EmpresaCertificadoConfigService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("empresaCertificadoConfigService") +public class EmpresaCertificadoConfigServiceImpl implements EmpresaCertificadoConfigService { + + @Autowired + private EmpresaCertificadoConfigDAO empresaCertificadoConfigDAO; + + @Override + public List obtenerTodos() { + return empresaCertificadoConfigDAO.obtenerTodos(); + } + + @Override + public EmpresaCertificadoConfig obtenerID(Integer id) { + return empresaCertificadoConfigDAO.obtenerID(id); + } + + @Override + @Transactional + public EmpresaCertificadoConfig suscribir(EmpresaCertificadoConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaCertificadoConfigDAO.suscribir(entidad); + } + + @Override + @Transactional + public EmpresaCertificadoConfig actualizacion(EmpresaCertificadoConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaCertificadoConfigDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(EmpresaCertificadoConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + empresaCertificadoConfigDAO.actualizacion(entidad); + + } + + @Override + public EmpresaCertificadoConfig buscarPorEmpresa(Empresa empresa, EnumTipoCertificado enumTipoCertificado) { + return empresaCertificadoConfigDAO.buscarPorEmpresa(empresa, enumTipoCertificado); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java b/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java index ef0c9dd82..03dbe8bdd 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java @@ -157,7 +157,7 @@ public enum CustomEnum { VALIDA_ESTOQUE_SIMPLIFICADO("MODCLI_ValidaEstoqueSimplificado"), - IS_VENDA_MACON("IsVendaMacon"); + IS_VENDA_SAFTAO("isVendaSaftao"); private String descricao;