From bc6aa0a23defc93f1af0d4a54723aee7b7f12962 Mon Sep 17 00:00:00 2001 From: gleimar Date: Fri, 20 Dec 2013 18:48:49 +0000 Subject: [PATCH] git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@32816 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/service/EstacionService.java | 3 +-- .../service/impl/EstacionServiceImpl.java | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/service/EstacionService.java b/src/com/rjconsultores/ventaboletos/service/EstacionService.java index 2f23e5c3d..302d5a0c4 100644 --- a/src/com/rjconsultores/ventaboletos/service/EstacionService.java +++ b/src/com/rjconsultores/ventaboletos/service/EstacionService.java @@ -8,7 +8,6 @@ import java.util.List; import com.rjconsultores.ventaboletos.entidad.Estacion; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.entidad.Usuario; import com.rjconsultores.ventaboletos.exception.BusinessException; /** @@ -31,7 +30,7 @@ public interface EstacionService { */ public Estacion suscribirActualizar(Estacion entidad) throws BusinessException; - public void borrar(Estacion entidad); + public void borrar(Estacion entidad) throws BusinessException; public List buscar(String descEstacion, String descMac, Long nunCaja, PuntoVenta pv); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java index 5317b769d..4b1e3da79 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EstacionServiceImpl.java @@ -15,7 +15,6 @@ import com.rjconsultores.ventaboletos.dao.EstacionDAO; import com.rjconsultores.ventaboletos.entidad.Estacion; import com.rjconsultores.ventaboletos.entidad.EstacionSitef; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.entidad.Usuario; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.AutorizaFolioService; import com.rjconsultores.ventaboletos.service.EstacionService; @@ -46,14 +45,8 @@ public class EstacionServiceImpl implements EstacionService { @Transactional(rollbackFor = BusinessException.class) public Estacion suscribirActualizar(Estacion estacion) throws BusinessException { - if (!ApplicationProperties.getInstance().generarRotinaFolios()){ - Estacion estacionPuntoVentaAnterior = estacionDAO.obtenerID(estacion.getEstacionId()); - if (!estacionPuntoVentaAnterior.getPuntoVenta().equals(estacion.getPuntoVenta())){ - if (estacionDAO.temEstoque(estacionPuntoVentaAnterior.getPuntoVenta(), estacion)){ - throw new BusinessException("estacionServiceImpl.msg.hayStock"); - } - } - } + validarEstoque(estacion); + Boolean esMacDuplicado = Boolean.FALSE; List lsEstacionMac = estacionDAO.buscar(estacion.getDescmac()); if (!lsEstacionMac.isEmpty()) { @@ -100,8 +93,22 @@ public class EstacionServiceImpl implements EstacionService { } + private void validarEstoque(Estacion estacion) throws BusinessException { + if (!ApplicationProperties.getInstance().generarRotinaFolios()){ + Estacion estacionPuntoVentaAnterior = estacionDAO.obtenerID(estacion.getEstacionId()); + if (!estacionPuntoVentaAnterior.getPuntoVenta().equals(estacion.getPuntoVenta())){ + if (estacionDAO.temEstoque(estacionPuntoVentaAnterior.getPuntoVenta(), estacion)){ + throw new BusinessException("estacionServiceImpl.msg.hayStock"); + } + } + } + } + @Transactional - public void borrar(Estacion entidad) { + public void borrar(Estacion entidad) throws BusinessException { + + validarEstoque(entidad); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.FALSE);