diff --git a/src/com/rjconsultores/ventaboletos/dao/FechamentoParamgeralDAO.java b/src/com/rjconsultores/ventaboletos/dao/FechamentoParamgeralDAO.java index 5a0f1e736..e4fa0e2cc 100644 --- a/src/com/rjconsultores/ventaboletos/dao/FechamentoParamgeralDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/FechamentoParamgeralDAO.java @@ -4,7 +4,7 @@ import java.util.List; import com.rjconsultores.ventaboletos.entidad.FechamentoParamgeral; -public interface FechamentoParamgeralDAO extends GenericDAO { +public interface FechamentoParamgeralDAO extends GenericDAO { public List buscaParametrosPorEmpresas(List empresasId); public List buscaParametrosPorEmpresa(Integer empresasId); diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamgeralHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamgeralHibernateDAO.java index 9e08ff384..8a7af369b 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamgeralHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamgeralHibernateDAO.java @@ -1,9 +1,9 @@ package com.rjconsultores.ventaboletos.dao.hibernate; +import java.util.Calendar; import java.util.List; import org.hibernate.Criteria; -import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; @@ -11,11 +11,11 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.FechamentoParamgeralDAO; -import com.rjconsultores.ventaboletos.entidad.AbastoCentral; import com.rjconsultores.ventaboletos.entidad.FechamentoParamgeral; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @Repository("fechamentoParamgeralDAO") -public class FechamentoParamgeralHibernateDAO extends GenericHibernateDAO implements FechamentoParamgeralDAO { +public class FechamentoParamgeralHibernateDAO extends GenericHibernateDAO implements FechamentoParamgeralDAO { @Autowired @@ -26,11 +26,6 @@ public class FechamentoParamgeralHibernateDAO extends GenericHibernateDAO buscaParametrosPorEmpresas(List empresasId) { -// String queryStr = "from FechamentoParamgeral params where params.activo = true and params.empresa.id in (:empresasId)"; -// -// Query query = getSession().createQuery(queryStr); -// query.setParameterList("empresasId", empresasId); - Criteria query = getSession().createCriteria(getPersistentClass()); query.createAlias("empresa", "emp"); query.add(Restrictions.in("emp.empresaId", empresasId)); @@ -49,11 +44,6 @@ public class FechamentoParamgeralHibernateDAO extends GenericHibernateDAO buscaParametrosPorEmpresa(Integer empresaId) { -// String queryStr = "from FechamentoParamgeral params where params.activo = true and params.empresa.id = :empresaId"; -// -// Query query = getSession().createQuery(queryStr); -// query.setInteger("empresaId", empresaId); - Criteria query = getSession().createCriteria(getPersistentClass()); query.createAlias("empresa", "emp"); query.add(Restrictions.eq("emp.empresaId", empresaId)); @@ -61,5 +51,13 @@ public class FechamentoParamgeralHibernateDAO extends GenericHibernateDAO)query.list(); } + + @Override + public void borrar(FechamentoParamgeral entity) { + entity.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entity.setFecmodif(Calendar.getInstance().getTime()); + entity.setActivo(Boolean.FALSE); + actualizacion(entity); + } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamgeral.java b/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamgeral.java index 91886b046..66e771ce4 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamgeral.java +++ b/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamgeral.java @@ -18,6 +18,8 @@ import javax.persistence.TemporalType; @Table(name = "FECHAMENTO_PARAMGERAL") public class FechamentoParamgeral implements java.io.Serializable { + private static final long serialVersionUID = 1L; + private Long fechamentoparamgeralId; private Empresa empresa; private String boletoBancoCod; @@ -32,7 +34,7 @@ public class FechamentoParamgeral implements java.io.Serializable { private Boolean activo; public FechamentoParamgeral() { - + super(); } public FechamentoParamgeral(Empresa empresa, String boletoBancoCod, @@ -40,7 +42,7 @@ public class FechamentoParamgeral implements java.io.Serializable { String boletoBancoContaDigito, String boletoBancoCarteira, Integer boletoDiasVenc, Date fecmodif, Integer usuarioId, Boolean activo) { - super(); + this(); this.empresa = empresa; this.boletoBancoCod = boletoBancoCod; this.boletoBancoAgencia = boletoBancoAgencia; @@ -58,7 +60,7 @@ public class FechamentoParamgeral implements java.io.Serializable { String boletoBancoAgencia, String boletoBancoConta, String boletoBancoContaDigito, String boletoBancoCarteira, Integer boletoDiasVenc, Integer usuarioId) { - super(); + this(); this.empresa = empresa; this.boletoBancoCod = boletoBancoCod; this.boletoBancoAgencia = boletoBancoAgencia; @@ -120,7 +122,7 @@ public class FechamentoParamgeral implements java.io.Serializable { public String getBoletoBancoContaDigito() { return boletoBancoContaDigito; } - public void setboletoBancoContaDigito(String boletoBancoContaDigito) { + public void setBoletoBancoContaDigito(String boletoBancoContaDigito) { this.boletoBancoContaDigito = boletoBancoContaDigito; } @@ -132,7 +134,7 @@ public class FechamentoParamgeral implements java.io.Serializable { this.boletoBancoCarteira = boletoBancoCarteira; } - @Column(name = "BOLETO_BANCO_DIAS_VENC", length = 3) + @Column(name = "BOLETO_DIAS_VENC", length = 3) public Integer getBoletoDiasVenc() { return boletoDiasVenc; } @@ -164,4 +166,29 @@ public class FechamentoParamgeral implements java.io.Serializable { public void setActivo(Boolean activo) { this.activo = activo; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fechamentoparamgeralId == null) ? 0 : fechamentoparamgeralId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof FechamentoParamgeral)) + return false; + FechamentoParamgeral other = (FechamentoParamgeral) obj; + if (fechamentoparamgeralId == null) { + if (other.fechamentoparamgeralId != null) + return false; + } else if (!fechamentoparamgeralId.equals(other.fechamentoparamgeralId)) + return false; + return true; + } } diff --git a/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java b/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java index 5800f19b9..e2f06b1cb 100644 --- a/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java +++ b/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java @@ -5,9 +5,10 @@ import java.util.List; import com.rjconsultores.ventaboletos.dao.GenericDAO; import com.rjconsultores.ventaboletos.entidad.FechamentoParamgeral; -public interface FechamentoParamgeralService extends GenericDAO { +public interface FechamentoParamgeralService extends GenericDAO { public List buscaParametrosPorEmpresas(List empresasId); public List buscaParametrosPorEmpresa(Integer empresasId); + public FechamentoParamgeral suscribirOrActualizacion(FechamentoParamgeral fechamentoParamgeral); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java index 2659246bf..b0450e1f6 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java @@ -1,9 +1,11 @@ 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.FechamentoParamgeralDAO; import com.rjconsultores.ventaboletos.entidad.FechamentoParamgeral; @@ -21,21 +23,24 @@ public class FechamentoParamgeralServiceImpl implements FechamentoParamgeralServ } @Override - public FechamentoParamgeral obtenerID(Integer id) { + public FechamentoParamgeral obtenerID(Long id) { return fechamentoParamgeralDAO.obtenerID(id); } @Override + @Transactional public FechamentoParamgeral suscribir(FechamentoParamgeral entidad) { return fechamentoParamgeralDAO.suscribir(entidad); } @Override + @Transactional public FechamentoParamgeral actualizacion(FechamentoParamgeral entidad) { return fechamentoParamgeralDAO.actualizacion(entidad); } @Override + @Transactional public void borrar(FechamentoParamgeral entidad) { fechamentoParamgeralDAO.borrar(entidad); } @@ -54,4 +59,15 @@ public class FechamentoParamgeralServiceImpl implements FechamentoParamgeralServ public List buscaParametrosPorEmpresa(Integer empresasId) { return fechamentoParamgeralDAO.buscaParametrosPorEmpresa(empresasId); } + + @Override + @Transactional + public FechamentoParamgeral suscribirOrActualizacion(FechamentoParamgeral fechamentoParamgeral) { + if(fechamentoParamgeral != null && fechamentoParamgeral.getFechamentoparamgeralId() == null) { + return suscribir(fechamentoParamgeral); + } else if(fechamentoParamgeral != null && fechamentoParamgeral.getFechamentoparamgeralId() != null) { + return actualizacion(fechamentoParamgeral); + } + return null; + } }