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