From 00768ad6bbd7ae7e61d52e1f53afc36371740fe1 Mon Sep 17 00:00:00 2001 From: rodrigo Date: Fri, 14 Jun 2013 19:37:36 +0000 Subject: [PATCH] Mantis: 0004070 e 0004071 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@27798 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/PuntoVentaDAO.java | 14 +- .../dao/hibernate/PuntoVentaHibernateDAO.java | 91 +++++---- .../ventaboletos/entidad/PuntoVenta.java | 11 + .../service/PuntoVentaService.java | 14 +- .../service/impl/PuntoVentaServiceImpl.java | 189 +++++++++--------- 5 files changed, 175 insertions(+), 144 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/PuntoVentaDAO.java b/src/com/rjconsultores/ventaboletos/dao/PuntoVentaDAO.java index 26f806efa..a43c99114 100644 --- a/src/com/rjconsultores/ventaboletos/dao/PuntoVentaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/PuntoVentaDAO.java @@ -9,14 +9,18 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import java.util.List; /** - * + * * @author Administrador */ public interface PuntoVentaDAO extends GenericDAO { - public List buscaLike(String strEstacion); + public List buscaLike(String strEstacion); - public List busca(String nomPuntoVenta, String numPuntoVenta); - public List buscaPuntoVenta(String numPuntoVenta); - public List buscaPuntoVentaParada(Parada parada); + public List busca(String nomPuntoVenta, String numPuntoVenta); + + public List buscaPuntoVenta(String numPuntoVenta); + + public List buscaPuntoVentaParada(Parada parada); + + public List buscarPuntoVentaSubordinados(PuntoVenta puntoVenta); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PuntoVentaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PuntoVentaHibernateDAO.java index 3eb8dccf9..7e76df4f4 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/PuntoVentaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PuntoVentaHibernateDAO.java @@ -18,60 +18,69 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; /** - * + * * @author Administrador */ @Repository("puntoVentaDAO") public class PuntoVentaHibernateDAO extends GenericHibernateDAO - implements PuntoVentaDAO { + implements PuntoVentaDAO { - @Autowired - public PuntoVentaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { - setSessionFactory(factory); - } + @Autowired + public PuntoVentaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } - @Override - public List obtenerTodos() { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.addOrder(Order.asc("nombpuntoventa")); + c.addOrder(Order.asc("nombpuntoventa")); - return c.list(); - } + return c.list(); + } - public List buscaLike(String strEstacion) { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); + public List buscaLike(String strEstacion) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.add(Restrictions.like("nombpuntoventa", strEstacion, MatchMode.START)); + c.add(Restrictions.like("nombpuntoventa", strEstacion, MatchMode.START)); - return c.list(); - } + return c.list(); + } - public List busca(String nomPuntoVenta, String numPuntoVenta) { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); + public List busca(String nomPuntoVenta, String numPuntoVenta) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.add(Restrictions.eq("nombpuntoventa", nomPuntoVenta)); - c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta)); + c.add(Restrictions.eq("nombpuntoventa", nomPuntoVenta)); + c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta)); - return c.list(); - } - - public List buscaPuntoVenta(String numPuntoVenta) { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta)); + return c.list(); + } - return c.list(); - } - - public List buscaPuntoVentaParada(Parada parada){ - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.add(Restrictions.eq("parada", parada)); - - return c.list(); - } + public List buscaPuntoVenta(String numPuntoVenta) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("numPuntoVenta", numPuntoVenta)); + + return c.list(); + } + + public List buscaPuntoVentaParada(Parada parada) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("parada", parada)); + + return c.list(); + } + + @Override + public List buscarPuntoVentaSubordinados(PuntoVenta puntoVenta) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("puntoVentaPadre", puntoVenta)); + + return c.list(); + } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java index 2fef72256..209d2ed31 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java @@ -132,6 +132,9 @@ public class PuntoVenta implements Serializable { private Boolean indValidaStock; @Column(name = "TIEMPOCANCELACION") private Integer tiempoCancelacion; + @OneToOne + @JoinColumn(name = "PUNTOVENTAPADRE_ID") + private PuntoVenta puntoVentaPadre; public PtovtaComissao getComissaoId() { return comissaoId; @@ -585,4 +588,12 @@ public class PuntoVenta implements Serializable { public void setTiempoCancelacion(Integer tiempoCancelacion) { this.tiempoCancelacion = tiempoCancelacion; } + + public PuntoVenta getPuntoVentaPadre() { + return puntoVentaPadre; + } + + public void setPuntoVentaPadre(PuntoVenta puntoVentaPadre) { + this.puntoVentaPadre = puntoVentaPadre; + } } diff --git a/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java b/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java index de1bd6ded..54dbe29c9 100644 --- a/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java +++ b/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java @@ -9,14 +9,18 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import java.util.List; /** - * + * * @author Administrador */ public interface PuntoVentaService extends GenericService { - public List buscaLike(String strEstacion); + public List buscaLike(String strEstacion); - public List buscar(String nomPuntoVenta, String numPuntoVenta); - public List buscaPuntoVenta(String numPuntoVenta); - public List buscaPuntoVentaParada(Parada paradaId); + public List buscar(String nomPuntoVenta, String numPuntoVenta); + + public List buscaPuntoVenta(String numPuntoVenta); + + public List buscaPuntoVentaParada(Parada paradaId); + + public List buscarPuntoVentaSubordinados(PuntoVenta puntoVenta); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java index b3f22521f..50f5a3413 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java @@ -4,121 +4,124 @@ */ package com.rjconsultores.ventaboletos.service.impl; -import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO; -import com.rjconsultores.ventaboletos.entidad.FormaPagoDet; -import com.rjconsultores.ventaboletos.entidad.Parada; -import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresa; -import com.rjconsultores.ventaboletos.entidad.PtovtaEstoque; -import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.service.PtovtaEmpresaService; -import com.rjconsultores.ventaboletos.service.PuntoVentaService; -import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; -import java.util.ArrayList; 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.PuntoVentaDAO; +import com.rjconsultores.ventaboletos.entidad.FormaPagoDet; +import com.rjconsultores.ventaboletos.entidad.Parada; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.service.PuntoVentaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + /** - * + * * @author Administrador */ @Service("puntoVentaService") public class PuntoVentaServiceImpl implements PuntoVentaService { - @Autowired - private PuntoVentaDAO puntoVentaDAO; - @Autowired - private PtovtaEmpresaService ptoVtaService; + @Autowired + private PuntoVentaDAO puntoVentaDAO; - public List obtenerTodos() { - return puntoVentaDAO.obtenerTodos(); - } + public List obtenerTodos() { + return puntoVentaDAO.obtenerTodos(); + } - public PuntoVenta obtenerID(Integer id) { - return puntoVentaDAO.obtenerID(id); - } + public PuntoVenta obtenerID(Integer id) { + return puntoVentaDAO.obtenerID(id); + } - @Transactional - public PuntoVenta suscribir(PuntoVenta entidad) { - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.setFecmodif(Calendar.getInstance().getTime()); - entidad.setActivo(Boolean.TRUE); + @Transactional + public PuntoVenta suscribir(PuntoVenta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); - return puntoVentaDAO.suscribir(entidad); - } + return puntoVentaDAO.suscribir(entidad); + } - @Transactional - public PuntoVenta actualizacion(PuntoVenta entidad) { - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.setFecmodif(Calendar.getInstance().getTime()); - entidad.setActivo(Boolean.TRUE); + @Transactional + public PuntoVenta actualizacion(PuntoVenta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); - return puntoVentaDAO.actualizacion(entidad); - } + return puntoVentaDAO.actualizacion(entidad); + } - @Transactional - public void borrar(PuntoVenta entidad) { + @Transactional + public void borrar(PuntoVenta entidad) { - for (FormaPagoDet forma : entidad.getLsFormaPagoDet()) { - forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - forma.setFecmodif(Calendar.getInstance().getTime()); - forma.setActivo(Boolean.FALSE); - } - -// for (PtovtaEstoque forma : entidad.getPtovtaEstoqueList()) { -// forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); -// forma.setFecmodif(Calendar.getInstance().getTime()); -// forma.setActivo(Boolean.FALSE); -// } - - if(entidad.getAgenciaId() != null){ - - entidad.getAgenciaId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.getAgenciaId().setFecmodif(Calendar.getInstance().getTime()); - entidad.getAgenciaId().setActivo(Boolean.FALSE); - - } - - if(entidad.getComissaoId() != null){ - entidad.getComissaoId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.getComissaoId().setFecmodif(Calendar.getInstance().getTime()); - entidad.getComissaoId().setActivo(Boolean.FALSE); - } - - if(entidad.getDiversosId() != null){ - entidad.getDiversosId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.getDiversosId().setFecmodif(Calendar.getInstance().getTime()); - entidad.getDiversosId().setActivo(Boolean.FALSE); - } - - if(entidad.getTitularId() != null){ - entidad.getTitularId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.getTitularId().setFecmodif(Calendar.getInstance().getTime()); - entidad.getTitularId().setActivo(Boolean.FALSE); - } + for (FormaPagoDet forma : entidad.getLsFormaPagoDet()) { + forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + forma.setFecmodif(Calendar.getInstance().getTime()); + forma.setActivo(Boolean.FALSE); + } - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.setFecmodif(Calendar.getInstance().getTime()); - entidad.setActivo(Boolean.FALSE); + // for (PtovtaEstoque forma : entidad.getPtovtaEstoqueList()) { + // forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + // forma.setFecmodif(Calendar.getInstance().getTime()); + // forma.setActivo(Boolean.FALSE); + // } - puntoVentaDAO.actualizacion(entidad); - } + if (entidad.getAgenciaId() != null) { - public List buscaLike(String strEstacion) { - return puntoVentaDAO.buscaLike(strEstacion); - } + entidad.getAgenciaId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.getAgenciaId().setFecmodif(Calendar.getInstance().getTime()); + entidad.getAgenciaId().setActivo(Boolean.FALSE); - public List buscar(String nomPuntoVenta, String numPuntoVenta) { - return puntoVentaDAO.busca(nomPuntoVenta, numPuntoVenta); - } - - public List buscaPuntoVenta(String numPuntoVenta) { - return puntoVentaDAO.buscaPuntoVenta(numPuntoVenta); - } - - public List buscaPuntoVentaParada(Parada paradaId) { - return puntoVentaDAO.buscaPuntoVentaParada(paradaId); - } + } + + if (entidad.getComissaoId() != null) { + entidad.getComissaoId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.getComissaoId().setFecmodif(Calendar.getInstance().getTime()); + entidad.getComissaoId().setActivo(Boolean.FALSE); + } + + if (entidad.getDiversosId() != null) { + entidad.getDiversosId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.getDiversosId().setFecmodif(Calendar.getInstance().getTime()); + entidad.getDiversosId().setActivo(Boolean.FALSE); + } + + if (entidad.getTitularId() != null) { + entidad.getTitularId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.getTitularId().setFecmodif(Calendar.getInstance().getTime()); + entidad.getTitularId().setActivo(Boolean.FALSE); + } + + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + puntoVentaDAO.actualizacion(entidad); + } + + public List buscaLike(String strEstacion) { + return puntoVentaDAO.buscaLike(strEstacion); + } + + public List buscar(String nomPuntoVenta, String numPuntoVenta) { + return puntoVentaDAO.busca(nomPuntoVenta, numPuntoVenta); + } + + public List buscaPuntoVenta(String numPuntoVenta) { + return puntoVentaDAO.buscaPuntoVenta(numPuntoVenta); + } + + public List buscaPuntoVentaParada(Parada paradaId) { + return puntoVentaDAO.buscaPuntoVentaParada(paradaId); + } + + @Override + public List buscarPuntoVentaSubordinados(PuntoVenta puntoVenta) { + List lsPuntoVentaSubordinados = puntoVentaDAO.buscarPuntoVentaSubordinados(puntoVenta); + + return lsPuntoVentaSubordinados; + } }