From 96d6358a50d120790dd705fbc88f9977ace4f261 Mon Sep 17 00:00:00 2001 From: gleimar Date: Wed, 20 Feb 2013 22:17:01 +0000 Subject: [PATCH] git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@24525 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../service/impl/EstadoServiceImpl.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EstadoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EstadoServiceImpl.java index 7f51915e9..fa45a43f1 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EstadoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EstadoServiceImpl.java @@ -4,16 +4,20 @@ */ package com.rjconsultores.ventaboletos.service.impl; +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.CiudadDAO; import com.rjconsultores.ventaboletos.dao.EstadoDAO; import com.rjconsultores.ventaboletos.entidad.Estado; import com.rjconsultores.ventaboletos.entidad.Pais; import com.rjconsultores.ventaboletos.service.EstadoService; +import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; -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; /** * @@ -24,6 +28,8 @@ public class EstadoServiceImpl implements EstadoService { @Autowired private EstadoDAO estadoDAO; + @Autowired + private CiudadDAO ciudadDAO; public List obtenerTodos() { return estadoDAO.obtenerTodos(); @@ -53,6 +59,11 @@ public class EstadoServiceImpl implements EstadoService { @Transactional public void borrar(Estado entidad) { + + if (ciudadDAO.count("estado", entidad) > 0l){ + throw new RegistroConDependenciaException(); + } + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.FALSE);