AL-4135
parent
59c3411321
commit
85a3c6dee1
|
@ -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<EmpresaCertificadoConfig, Integer> {
|
||||
|
||||
public List<EmpresaCertificadoConfig> obtenerTodos();
|
||||
|
||||
public EmpresaCertificadoConfig buscarPorEmpresa(Empresa empresa, EnumTipoCertificado enumTipoCertificado);
|
||||
|
||||
}
|
|
@ -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<EmpresaCertificadoConfig, Integer>
|
||||
implements EmpresaCertificadoConfigDAO {
|
||||
|
||||
@Autowired
|
||||
public EmpresaCertificadoConfigHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmpresaCertificadoConfig> 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();
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.rjconsultores.ventaboletos.enums;
|
||||
|
||||
public enum EnumTipoCertificado {
|
||||
|
||||
SAFTAO,;
|
||||
|
||||
private EnumTipoCertificado() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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<EmpresaCertificadoConfig, Integer> {
|
||||
|
||||
public EmpresaCertificadoConfig buscarPorEmpresa(Empresa empresa, EnumTipoCertificado enumTipoCertificado);
|
||||
}
|
|
@ -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<EmpresaCertificadoConfig> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -157,7 +157,7 @@ public enum CustomEnum {
|
|||
|
||||
VALIDA_ESTOQUE_SIMPLIFICADO("MODCLI_ValidaEstoqueSimplificado"),
|
||||
|
||||
IS_VENDA_MACON("IsVendaMacon");
|
||||
IS_VENDA_SAFTAO("isVendaSaftao");
|
||||
|
||||
private String descricao;
|
||||
|
||||
|
|
Loading…
Reference in New Issue