From 01c442d10f61172605264a8db2eda817410d531e Mon Sep 17 00:00:00 2001 From: leonardo Date: Wed, 4 Dec 2013 21:57:13 +0000 Subject: [PATCH] =?UTF-8?q?Refatora=C3=A7=C3=A3o=20do=20m=C3=A9todo=20de?= =?UTF-8?q?=20salvar=20empresa.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@32415 d1611594-4594-4d17-8e1d-87c2c4800839 --- .classpath | 2 +- .../ventaboletos/service/EmpresaService.java | 13 ++++++++++- .../service/impl/EmpresaServiceImpl.java | 23 +++++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.classpath b/.classpath index d3e9d5b33..5970965a6 100644 --- a/.classpath +++ b/.classpath @@ -100,7 +100,7 @@ - + diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaService.java index 2301059b8..9487e2368 100644 --- a/src/com/rjconsultores/ventaboletos/service/EmpresaService.java +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaService.java @@ -8,12 +8,23 @@ import java.util.List; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.exception.BusinessException; /** * * @author Administrador */ -public interface EmpresaService extends GenericService { +public interface EmpresaService { + + public List obtenerTodos(); + + public Empresa obtenerID(Integer id); + + public Empresa suscribir(Empresa entidad); + + public Empresa suscribirActualizacion(Empresa entidad) throws BusinessException; + + public void borrar(Empresa entidad); public List buscar(String nombempresa, Boolean indExterna, Short indTipo); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java index 9c1380fbf..3525604fc 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java @@ -10,10 +10,13 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.zkoss.util.resource.Labels; +import org.zkoss.zul.Messagebox; import com.rjconsultores.ventaboletos.dao.EmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -45,12 +48,28 @@ public class EmpresaServiceImpl implements EmpresaService { } @Transactional - public Empresa actualizacion(Empresa entidad) { - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + public Empresa suscribirActualizacion(Empresa entidad) throws BusinessException { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); + + List lsEmpresa = + buscar(entidad.getNombempresa(), entidad.getIndExterna(), + entidad.getIndTipo()); + if (entidad.getEmpresaId() == null) { + + if (!lsEmpresa.isEmpty()) { + throw new BusinessException("MSG.Registro.Existe"); + } + return empresaDAO.suscribir(entidad); + } + + if (lsEmpresa.get(0).getEmpresaId() != entidad.getEmpresaId()){ + throw new BusinessException("MSG.Registro.Existe"); + } return empresaDAO.actualizacion(entidad); + } @Transactional