diff --git a/src/com/rjconsultores/ventaboletos/dao/RutaDAO.java b/src/com/rjconsultores/ventaboletos/dao/RutaDAO.java index 7cdaf43fc..92bf33de5 100644 --- a/src/com/rjconsultores/ventaboletos/dao/RutaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/RutaDAO.java @@ -56,7 +56,8 @@ public interface RutaDAO extends GenericDAO { public List buscaRutasFromOrgao(OrgaoConcedente orgao); - public List buscarPorRutaPorEmpresas(List lsEmpresas); + + public List buscarRutasPorEmpresaOrgaoConcedente(Empresa empresa, OrgaoConcedente orgao); } diff --git a/src/com/rjconsultores/ventaboletos/dao/RutaEmpresaDAO.java b/src/com/rjconsultores/ventaboletos/dao/RutaEmpresaDAO.java index 8996a13b1..d47cd61da 100644 --- a/src/com/rjconsultores/ventaboletos/dao/RutaEmpresaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/RutaEmpresaDAO.java @@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.dao; import java.util.List; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.entidad.RutaEmpresa; /** @@ -14,6 +15,8 @@ import com.rjconsultores.ventaboletos.entidad.RutaEmpresa; * @author Administrador */ public interface RutaEmpresaDAO extends GenericDAO { - + public List obtenerPorEmpresa(Empresa empresa); + + public List obtenerPorRuta(Ruta ruta); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaEmpresaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaEmpresaHibernateDAO.java index 114b5eae5..7ce85b732 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaEmpresaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaEmpresaHibernateDAO.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.RutaEmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.entidad.RutaEmpresa; /** @@ -40,4 +41,12 @@ public class RutaEmpresaHibernateDAO extends GenericHibernateDAO obtenerPorRuta(Ruta ruta) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("ruta", ruta)); + + return c.list(); + } } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaHibernateDAO.java index 50607adeb..23465617a 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaHibernateDAO.java @@ -205,5 +205,24 @@ public class RutaHibernateDAO extends GenericHibernateDAO impleme List lsRuta = sq.list(); return lsRuta; } - + + @Override + public List buscarRutasPorEmpresaOrgaoConcedente(Empresa empresa, OrgaoConcedente orgao) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.ne("rutaId", -1)); + + if (empresa != null && empresa.getEmpresaId() != -1) { + c.createCriteria("lsRutaEmpresa").add(Restrictions.eq("empresa", empresa)); + } + + if (orgao != null && orgao.getOrgaoConcedenteId() != -1) { + c.add(Restrictions.eq("orgaoConcedente", orgao)); + } + + c.addOrder(Order.asc("descruta")); + + return c.list(); + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/RutaEmpresaService.java b/src/com/rjconsultores/ventaboletos/service/RutaEmpresaService.java index 70aeaed57..779b704f0 100644 --- a/src/com/rjconsultores/ventaboletos/service/RutaEmpresaService.java +++ b/src/com/rjconsultores/ventaboletos/service/RutaEmpresaService.java @@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.service; import java.util.List; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.entidad.RutaEmpresa; /** @@ -16,4 +17,6 @@ import com.rjconsultores.ventaboletos.entidad.RutaEmpresa; public interface RutaEmpresaService extends GenericService { public List obtenerPorEmpresa(Empresa empresa); + + public List obtenerPorRuta(Ruta ruta); } diff --git a/src/com/rjconsultores/ventaboletos/service/RutaService.java b/src/com/rjconsultores/ventaboletos/service/RutaService.java index 6a7539f16..98f3322fa 100644 --- a/src/com/rjconsultores/ventaboletos/service/RutaService.java +++ b/src/com/rjconsultores/ventaboletos/service/RutaService.java @@ -104,4 +104,6 @@ public interface RutaService { */ public List verificarSeqRutaNaoGerada(Ruta ruta, List lsParadasSequencia); + public List buscarRutasPorEmpresaOrgaoConcedente(Empresa empresa, OrgaoConcedente orgao); + } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/RutaEmpresaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/RutaEmpresaServiceImpl.java index 4bb1a5535..b14008a61 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/RutaEmpresaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/RutaEmpresaServiceImpl.java @@ -6,6 +6,7 @@ package com.rjconsultores.ventaboletos.service.impl; import com.rjconsultores.ventaboletos.dao.RutaEmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Ruta; import com.rjconsultores.ventaboletos.entidad.RutaEmpresa; import com.rjconsultores.ventaboletos.service.RutaEmpresaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -66,4 +67,10 @@ public class RutaEmpresaServiceImpl implements RutaEmpresaService { public List obtenerPorEmpresa(Empresa empresa) { return rutaEmpresaDAO.obtenerPorEmpresa(empresa); } + + @Override + public List obtenerPorRuta(Ruta ruta) { + return rutaEmpresaDAO.obtenerPorRuta(ruta); + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java index 350adb9c9..57c4efd9d 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java @@ -405,4 +405,9 @@ public class RutaServiceImpl implements RutaService { return sequencias; } + + @Override + public List buscarRutasPorEmpresaOrgaoConcedente(Empresa empresa, OrgaoConcedente orgao) { + return rutaDAO.buscarRutasPorEmpresaOrgaoConcedente(empresa, orgao); + } }