diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaSaferConfigDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaSaferConfigDAO.java new file mode 100644 index 000000000..3f2440ecd --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaSaferConfigDAO.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.EmpresaSaferConfig; + +public interface EmpresaSaferConfigDAO extends GenericDAO { + + public List obtenerTodos(); + + public EmpresaSaferConfig buscarPorEmpresa(Empresa empresa); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaSaferConfigHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaSaferConfigHibernateDAO.java new file mode 100644 index 000000000..fa4c7979d --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaSaferConfigHibernateDAO.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.EmpresaSaferConfigDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaSaferConfig; + +@Repository("empresaSaferConfigDAO") +public class EmpresaSaferConfigHibernateDAO extends GenericHibernateDAO + implements EmpresaSaferConfigDAO { + + @Autowired + public EmpresaSaferConfigHibernateDAO(@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 EmpresaSaferConfig buscarPorEmpresa(Empresa empresa) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("empresa", empresa)); + + return (EmpresaSaferConfig) c.uniqueResult(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/EmpresaSaferConfig.java b/src/com/rjconsultores/ventaboletos/entidad/EmpresaSaferConfig.java new file mode 100644 index 000000000..9f04461c2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/EmpresaSaferConfig.java @@ -0,0 +1,157 @@ +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_SAFER_CONFIG_SEQ", sequenceName = "EMPRESA_SAFER_CONFIG_SEQ", allocationSize = 1) +@Table(name = "EMPRESA_SAFER_CONFIG") +public class EmpresaSaferConfig implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "EMPRESA_SAFER_CONFIG_SEQ") + @Column(name = "EMPRESASAFERCONFIG_ID") + private Integer empresaSaferConfigId; + @Column(name = "PARTNERID") + private String partnerId; + @Column(name = "CONTRACTID") + private String contractId; + @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 EmpresaSaferConfig() { + + } + + public Integer getEmpresaSaferConfigId() { + return empresaSaferConfigId; + } + + public void setEmpresaSaferConfigId(Integer empresaSaferConfigId) { + this.empresaSaferConfigId = empresaSaferConfigId; + } + + public String getPartnerId() { + return partnerId; + } + + public void setPartnerId(String partnerId) { + this.partnerId = partnerId; + } + + public String getContractId() { + return contractId; + } + + public void setContractId(String contractId) { + this.contractId = contractId; + } + + 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 + + ((empresaSaferConfigId == null) ? 0 : empresaSaferConfigId.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; + EmpresaSaferConfig other = (EmpresaSaferConfig) obj; + if (empresaSaferConfigId == null) { + if (other.empresaSaferConfigId != null) + return false; + } else if (!empresaSaferConfigId.equals(other.empresaSaferConfigId)) + return false; + return true; + } + + @Override + public String toString() { + return String.valueOf(this.getEmpresaSaferConfigId()); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/Pricing.java b/src/com/rjconsultores/ventaboletos/entidad/Pricing.java index 771755ef1..920001c4c 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Pricing.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Pricing.java @@ -119,6 +119,9 @@ public class Pricing implements Serializable { @Column(name = "INDPRICINGDIVIDIRIDAEVOLTA") private Boolean indPricingDividirIdaEVolta; + + @Column(name = "INDSAFER") + private Boolean indSafer; public enum GerarFeriado { // Declaração dos enum @@ -560,4 +563,12 @@ public class Pricing implements Serializable { this.indPricingDividirIdaEVolta = indPricingDividirIdaEVolta; } + public Boolean getIndSafer() { + return indSafer; + } + + public void setIndSafer(Boolean indSafer) { + this.indSafer = indSafer; + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaSaferConfigService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaSaferConfigService.java new file mode 100644 index 000000000..611a117b9 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaSaferConfigService.java @@ -0,0 +1,9 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaSaferConfig; + +public interface EmpresaSaferConfigService extends GenericService { + + public EmpresaSaferConfig buscarPorEmpresa(Empresa empresa); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaSaferConfigServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaSaferConfigServiceImpl.java new file mode 100644 index 000000000..e044ea039 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaSaferConfigServiceImpl.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.EmpresaSaferConfigDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaSaferConfig; +import com.rjconsultores.ventaboletos.service.EmpresaSaferConfigService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("empresaSaferConfigService") +public class EmpresaSaferConfigServiceImpl implements EmpresaSaferConfigService { + + @Autowired + private EmpresaSaferConfigDAO empresaSaferConfigDAO; + + @Override + public List obtenerTodos() { + return empresaSaferConfigDAO.obtenerTodos(); + } + + @Override + public EmpresaSaferConfig obtenerID(Integer id) { + return empresaSaferConfigDAO.obtenerID(id); + } + + @Override + @Transactional + public EmpresaSaferConfig suscribir(EmpresaSaferConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaSaferConfigDAO.suscribir(entidad); + } + + @Override + @Transactional + public EmpresaSaferConfig actualizacion(EmpresaSaferConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaSaferConfigDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(EmpresaSaferConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + empresaSaferConfigDAO.actualizacion(entidad); + + } + + @Override + public EmpresaSaferConfig buscarPorEmpresa(Empresa empresa) { + return empresaSaferConfigDAO.buscarPorEmpresa(empresa); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java b/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java index d145a4c82..3e4244107 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/CustomEnum.java @@ -151,7 +151,9 @@ public enum CustomEnum { IS_VALIDAR_CONSTANTE_REMESSA("isValidarConstanteRemessa"), - IS_DESABILITA_USUARIO_ADMINISTRADORES_PERFIL("dasabilitaUsuarioAdministradoresPerfil"); + IS_DESABILITA_USUARIO_ADMINISTRADORES_PERFIL("dasabilitaUsuarioAdministradoresPerfil"), + + INTEGRACION_SAFER("integracion.safer"); private String descricao;