From b40ce55930f332b1afb7c7aaeeaa332a22d8dc15 Mon Sep 17 00:00:00 2001 From: "valdir.cordeiro" Date: Thu, 11 Jan 2024 15:29:07 -0300 Subject: [PATCH] bug#al-3609 Documentacao_integracao_PM_ARTESP dev: qua: --- pom.xml | 2 +- .../dao/EmpresaPMArtespConfigDAO.java | 14 ++ .../EmpresaPMArtespConfigHibernateDAO.java | 41 +++++ .../entidad/EmpresaPMArtespConfig.java | 174 ++++++++++++++++++ .../service/EmpresaPMArtespConfigService.java | 9 + .../EmpresaPMArtespConfigServiceImpl.java | 68 +++++++ 6 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/EmpresaPMArtespConfigDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaPMArtespConfigHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/EmpresaPMArtespConfig.java create mode 100644 src/com/rjconsultores/ventaboletos/service/EmpresaPMArtespConfigService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/EmpresaPMArtespConfigServiceImpl.java diff --git a/pom.xml b/pom.xml index 5d96fe4b7..7b374ecba 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 br.com.rjconsultores ModelWeb - 1.30.0 + 1.31.0 diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaPMArtespConfigDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaPMArtespConfigDAO.java new file mode 100644 index 000000000..9091bfd86 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaPMArtespConfigDAO.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig; + +public interface EmpresaPMArtespConfigDAO extends GenericDAO { + + public List obtenerTodos(); + + public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaPMArtespConfigHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaPMArtespConfigHibernateDAO.java new file mode 100644 index 000000000..9b23368d5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaPMArtespConfigHibernateDAO.java @@ -0,0 +1,41 @@ +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.EmpresaPMArtespConfigDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig; + +@Repository("empresaPMArtespConfigDAO") +public class EmpresaPMArtespConfigHibernateDAO extends GenericHibernateDAO + implements EmpresaPMArtespConfigDAO { + + @Autowired + public EmpresaPMArtespConfigHibernateDAO(@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 EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("empresa", empresa)); + + return (EmpresaPMArtespConfig) c.uniqueResult(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/EmpresaPMArtespConfig.java b/src/com/rjconsultores/ventaboletos/entidad/EmpresaPMArtespConfig.java new file mode 100644 index 000000000..e60846859 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/EmpresaPMArtespConfig.java @@ -0,0 +1,174 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +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_PMARTESP_CONFIG_SEQ", sequenceName = "EMPRESA_PMARTESP_CONFIG_SEQ", allocationSize = 1) +@Table(name = "EMPRESA_PMARTESP_CONFIG") +public class EmpresaPMArtespConfig implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "EMPRESA_PMARTESP_CONFIG_SEQ") + @Column(name = "EMPRESAPMARTESPCONFIG_ID") + private Integer empresaPMArtespConfigId; + + @OneToOne + @JoinColumn(name = "EMPRESA_ID") + private Empresa empresa; + + @Column(name = "VALIDACAO_ATIVA") + private Boolean validacaoAtiva; + + @Column(name = "URL_API") + private String urlApi; + + @Column(name = "API_KEY") + private String apiKey; + + @OneToOne + @JoinColumn(name = "ORGAOCONCEDENTE_ID") + private OrgaoConcedente orgaoConcedente; + + @OneToOne + @JoinColumn(name = "CATEGORIA_ID") + private Categoria categoria; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Integer getEmpresaPMArtespConfigId() { + return empresaPMArtespConfigId; + } + + public void setEmpresaPMArtespConfigId(Integer empresaPMArtespConfigId) { + this.empresaPMArtespConfigId = empresaPMArtespConfigId; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + public Boolean getValidacaoAtiva() { + return validacaoAtiva == null ? false : validacaoAtiva; + } + + public void setValidacaoAtiva(Boolean valida) { + this.validacaoAtiva = valida; + } + + public String getUrlApi() { + return urlApi; + } + + public void setUrlApi(String urlApi) { + this.urlApi = urlApi; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public OrgaoConcedente getOrgaoConcedente() { + return orgaoConcedente; + } + + public void setOrgaoConcedente(OrgaoConcedente orgaoConcedente) { + this.orgaoConcedente = orgaoConcedente; + } + + public Categoria getCategoria() { + return categoria; + } + + public void setCategoria(Categoria categoria) { + this.categoria = categoria; + } + + 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() { + return Objects.hash(activo, apiKey, categoria, empresa, empresaPMArtespConfigId, fecmodif, orgaoConcedente, + urlApi, usuarioId, validacaoAtiva); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EmpresaPMArtespConfig other = (EmpresaPMArtespConfig) obj; + return Objects.equals(activo, other.activo) && Objects.equals(apiKey, other.apiKey) + && Objects.equals(categoria, other.categoria) && Objects.equals(empresa, other.empresa) + && Objects.equals(empresaPMArtespConfigId, other.empresaPMArtespConfigId) + && Objects.equals(fecmodif, other.fecmodif) && Objects.equals(orgaoConcedente, other.orgaoConcedente) + && Objects.equals(urlApi, other.urlApi) && Objects.equals(usuarioId, other.usuarioId) + && Objects.equals(validacaoAtiva, other.validacaoAtiva); + } + + @Override + public String toString() { + return "EmpresaPMArtespConfig [empresaPMArtespConfigId=" + empresaPMArtespConfigId + ", empresa=" + empresa + + ", validacaoAtiva=" + validacaoAtiva + ", urlApi=" + urlApi + ", apiKey=" + apiKey + ", orgaoConcedente=" + + orgaoConcedente + ", categoria=" + categoria + ", activo=" + activo + ", fecmodif=" + fecmodif + + ", usuarioId=" + usuarioId + "]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaPMArtespConfigService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaPMArtespConfigService.java new file mode 100644 index 000000000..52dd5e649 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaPMArtespConfigService.java @@ -0,0 +1,9 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig; + +public interface EmpresaPMArtespConfigService extends GenericService { + + public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaPMArtespConfigServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaPMArtespConfigServiceImpl.java new file mode 100644 index 000000000..a16962276 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaPMArtespConfigServiceImpl.java @@ -0,0 +1,68 @@ +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.EmpresaPMArtespConfigDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig; +import com.rjconsultores.ventaboletos.service.EmpresaPMArtespConfigService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("EmpresaPMArtespConfigService") +public class EmpresaPMArtespConfigServiceImpl implements EmpresaPMArtespConfigService { + + @Autowired + private EmpresaPMArtespConfigDAO empresaPMArtespConfigDAO; + + @Override + public List obtenerTodos() { + return empresaPMArtespConfigDAO.obtenerTodos(); + } + + @Override + public EmpresaPMArtespConfig obtenerID(Integer id) { + return empresaPMArtespConfigDAO.obtenerID(id); + } + + @Override + @Transactional + public EmpresaPMArtespConfig suscribir(EmpresaPMArtespConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaPMArtespConfigDAO.suscribir(entidad); + } + + @Override + @Transactional + public EmpresaPMArtespConfig actualizacion(EmpresaPMArtespConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaPMArtespConfigDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(EmpresaPMArtespConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + empresaPMArtespConfigDAO.actualizacion(entidad); + + } + + @Override + public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa) { + return empresaPMArtespConfigDAO.buscarPorEmpresa(empresa); + } + +}