From 8040c1e5b89836ae1add485c529d5e920d163c8b Mon Sep 17 00:00:00 2001 From: Leonardo Oliveira Date: Wed, 24 Jul 2024 17:55:44 -0300 Subject: [PATCH] =?UTF-8?q?Bolivariano=20-=20Autoriza=C3=A7=C3=A3o=20de=20?= =?UTF-8?q?viagem=20fixes=20bug#AL-4453?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../dao/CategoriaFormAutorizacaoDAO.java | 12 ++ .../CategoriaFormAutorizacaoHibernateDAO.java | 51 +++++++++ .../ventaboletos/entidad/Categoria.java | 25 ++++ .../entidad/CategoriaFormAutorizacao.java | 107 ++++++++++++++++++ .../CategoriaFormAutorizacaoService.java | 14 +++ .../CategoriaFormAutorizacaoServiceImpl.java | 76 +++++++++++++ 7 files changed, 286 insertions(+), 1 deletion(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/CategoriaFormAutorizacaoDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaFormAutorizacaoHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/CategoriaFormAutorizacao.java create mode 100644 src/com/rjconsultores/ventaboletos/service/CategoriaFormAutorizacaoService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/CategoriaFormAutorizacaoServiceImpl.java diff --git a/pom.xml b/pom.xml index aa5811334..fdf9d5d7d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 br.com.rjconsultores ModelWeb - 1.78.0 + 1.79.0 diff --git a/src/com/rjconsultores/ventaboletos/dao/CategoriaFormAutorizacaoDAO.java b/src/com/rjconsultores/ventaboletos/dao/CategoriaFormAutorizacaoDAO.java new file mode 100644 index 000000000..f636a1784 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/CategoriaFormAutorizacaoDAO.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.CategoriaFormAutorizacao; + +public interface CategoriaFormAutorizacaoDAO extends GenericDAO { + + public CategoriaFormAutorizacao pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId); + public List obtenerTodosPorCategoria(Integer categoriaId); + public CategoriaFormAutorizacao saverOrUpdate(CategoriaFormAutorizacao form); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaFormAutorizacaoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaFormAutorizacaoHibernateDAO.java new file mode 100644 index 000000000..f386016f7 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/CategoriaFormAutorizacaoHibernateDAO.java @@ -0,0 +1,51 @@ +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.CategoriaFormAutorizacaoDAO; +import com.rjconsultores.ventaboletos.entidad.CategoriaDescuento; +import com.rjconsultores.ventaboletos.entidad.CategoriaFormAutorizacao; + +@Repository("CategoriaDescuentoDAO") +public class CategoriaFormAutorizacaoHibernateDAO extends GenericHibernateDAO +implements CategoriaFormAutorizacaoDAO { + + @Autowired + public CategoriaFormAutorizacaoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodosPorCategoria(Integer categoriaId) { + Criteria c = getSession().createCriteria(getPersistentClass()) + .add(Restrictions.eq("activo", Boolean.TRUE)) + .add(Restrictions.eq("categoria.categoriaId", categoriaId)); + + return c.list(); + } + + @Override + public CategoriaFormAutorizacao pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId){ + Criteria c = getSession().createCriteria(getPersistentClass()) + .add(Restrictions.eq("activo", Boolean.TRUE)) + .add(Restrictions.eq("empresaId", empresaId)) + .add(Restrictions.eq("categoriaId", categoriaId)); + c.setMaxResults(1); + + return (CategoriaFormAutorizacao) c.uniqueResult(); + } + + @Override + public CategoriaFormAutorizacao saverOrUpdate(CategoriaFormAutorizacao form) { + getHibernateTemplate().saveOrUpdate(form); + return form; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/Categoria.java b/src/com/rjconsultores/ventaboletos/entidad/Categoria.java index f6cb8364a..bfce59f44 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Categoria.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Categoria.java @@ -13,6 +13,7 @@ import javax.persistence.Basic; 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; @@ -129,6 +130,12 @@ public class Categoria implements Serializable, Auditavel{ @Column(name = "INDINTEGRACAOAGR") private Boolean indIntegracaoAGR; + @Column(name = "INDEMITEFORMAUTORIZACAO") + private Boolean indEmiteFormularioAutorizacao; + + @OneToMany(mappedBy = "categoria", cascade = CascadeType.ALL) + private List formsAutorizacao = new ArrayList(); + public Categoria() { } @@ -355,4 +362,22 @@ public class Categoria implements Serializable, Auditavel{ public void setIndIntegracaoAGR(Boolean indIntegracaoAGR) { this.indIntegracaoAGR = indIntegracaoAGR; } + + public Boolean getIndEmiteFormularioAutorizacao() { + return indEmiteFormularioAutorizacao == null ? false : indEmiteFormularioAutorizacao; + } + + public void setIndEmiteFormularioAutorizacao(Boolean indEmiteFormularioAutorizacao) { + this.indEmiteFormularioAutorizacao = indEmiteFormularioAutorizacao; + } + + public List getFormsAutorizacao() { + return formsAutorizacao; + } + + public void setFormsAutorizacao(List formsAutorizacao) { + this.formsAutorizacao = formsAutorizacao; + } + + } diff --git a/src/com/rjconsultores/ventaboletos/entidad/CategoriaFormAutorizacao.java b/src/com/rjconsultores/ventaboletos/entidad/CategoriaFormAutorizacao.java new file mode 100644 index 000000000..54c15e10f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/CategoriaFormAutorizacao.java @@ -0,0 +1,107 @@ +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.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name = "CATEGORIA_FORM_AUTORIZACAO") +public class CategoriaFormAutorizacao implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @JoinColumn(name = "CATEGORIA_ID", referencedColumnName = "CATEGORIA_ID") + @ManyToOne() + private Categoria categoria; + @Id + @JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID") + @ManyToOne() + private Empresa empresa; + @Column(name = "TEXTO") + private String texto; + @Basic(optional = false) + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Categoria getCategoria() { + return categoria; + } + public void setCategoria(Categoria categoria) { + this.categoria = categoria; + } + public Empresa getEmpresa() { + return empresa; + } + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + public String getTexto() { + return texto; + } + public void setTexto(String texto) { + this.texto = texto; + } + 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; + } + + public Boolean getActivo() { + return activo; + } + public void setActivo(Boolean activo) { + this.activo = activo; + } + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CategoriaFormAutorizacao other = (CategoriaFormAutorizacao) obj; + if (this.categoria != other.categoria && (this.categoria == null || !this.categoria.equals(other.categoria))) { + return false; + } + if (this.empresa.getEmpresaId() != other.empresa.getEmpresaId() && (this.empresa.getEmpresaId() == null || !this.empresa.getEmpresaId().equals(other.empresa.getEmpresaId()))) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 97 * hash + (this.categoria != null ? this.categoria.hashCode() : 0); + hash = 97 * hash + (this.empresa != null ? this.empresa.getEmpresaId().hashCode() : 0); + return hash; + } + + @Override + public String toString() { + return "com.rjconsultores.ventaboletos.entidad.CategoriaFormAutorizacao[categoriaId=" + (categoria != null ? categoria.getDesccategoria() : "") + ", empresaId=" + (empresa != null ? empresa.getNombempresa() : "") + "]"; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/CategoriaFormAutorizacaoService.java b/src/com/rjconsultores/ventaboletos/service/CategoriaFormAutorizacaoService.java new file mode 100644 index 000000000..0a776aa4a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/CategoriaFormAutorizacaoService.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.CategoriaFormAutorizacao; + +public interface CategoriaFormAutorizacaoService extends GenericService { + + public List obtenerTodosPorCategoria(Integer categoriaId); + + public CategoriaFormAutorizacao pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId); + + public CategoriaFormAutorizacao salvar(CategoriaFormAutorizacao entidad); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/CategoriaFormAutorizacaoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/CategoriaFormAutorizacaoServiceImpl.java new file mode 100644 index 000000000..f4b6c43b6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/CategoriaFormAutorizacaoServiceImpl.java @@ -0,0 +1,76 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; +import com.rjconsultores.ventaboletos.dao.CategoriaFormAutorizacaoDAO; +import com.rjconsultores.ventaboletos.entidad.CategoriaFormAutorizacao; +import com.rjconsultores.ventaboletos.service.CategoriaFormAutorizacaoService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("CategoriaFormAutorizacaoService") +public class CategoriaFormAutorizacaoServiceImpl implements CategoriaFormAutorizacaoService{ + + @Autowired + private CategoriaFormAutorizacaoDAO categoriaFormAutorizacaoDAO; + private static Logger log = LogManager.getLogger(CategoriaFormAutorizacaoServiceImpl.class); + + + @Override + public List obtenerTodos() { + return categoriaFormAutorizacaoDAO.obtenerTodos(); + } + + @Override + public CategoriaFormAutorizacao obtenerID(Integer id) { + return categoriaFormAutorizacaoDAO.obtenerID(id); + } + + @Transactional + public CategoriaFormAutorizacao suscribir(CategoriaFormAutorizacao entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return categoriaFormAutorizacaoDAO.suscribir(entidad); + } + + @Transactional + public CategoriaFormAutorizacao actualizacion(CategoriaFormAutorizacao entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + return categoriaFormAutorizacaoDAO.actualizacion(entidad); + } + + @Transactional + public CategoriaFormAutorizacao salvar(CategoriaFormAutorizacao entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return categoriaFormAutorizacaoDAO.saverOrUpdate(entidad); + } + + @Transactional + public void borrar(CategoriaFormAutorizacao entidad) { + categoriaFormAutorizacaoDAO.borrar(entidad); + } + + @Override + public List obtenerTodosPorCategoria(Integer categoriaId) { + return categoriaFormAutorizacaoDAO.obtenerTodosPorCategoria(categoriaId); + } + + @Override + public CategoriaFormAutorizacao pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId) { + return categoriaFormAutorizacaoDAO.pesquisarPorCategoriaEmpresa(categoriaId, empresaId); + } +}