diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java index 79766cbd6..87e066bbc 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java @@ -11,6 +11,8 @@ import org.apache.commons.lang.StringUtils; 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.ParadaDAO; import com.rjconsultores.ventaboletos.dao.TramoDAO; @@ -30,6 +32,8 @@ import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @Service("paradaService") public class ParadaServiceImpl implements ParadaService { + private static final int MAX_ANTT = 99999; + @Autowired private ParadaDAO paradaDAO; @Autowired @@ -42,43 +46,49 @@ public class ParadaServiceImpl implements ParadaService { @Transactional public Parada suscribirActualizar(Parada entidad) throws BusinessException { + Integer antt = entidad.getCodantt() != null ? entidad.getCodantt() : null; + if (antt != null) { + if (antt.equals(MAX_ANTT)) { + throw new BusinessException("editarCatalogoDeParadaController.MSG.maxAntt"); + } + } + List lsParadas = paradaDAO.buscar(entidad.getCodantt()); if (!lsParadas.isEmpty()) { if (entidad.getParadaId() == null) { throw new BusinessException("busquedaCatalogoDeParadaController.msg.codAnttJaExiste"); } else { - if (!lsParadas.contains(entidad)){ + if (!lsParadas.contains(entidad)) { throw new BusinessException("busquedaCatalogoDeParadaController.msg.codAnttJaExiste"); } } } lsParadas = paradaDAO.buscar(entidad.getDescparada(), entidad.getCveparada(), entidad.getCiudad(), entidad.getTipoParada(), entidad.getNodo()); - - if (!lsParadas.isEmpty()){ - if (entidad.getParadaId() == null){ + + if (!lsParadas.isEmpty()) { + if (entidad.getParadaId() == null) { throw new BusinessException("MSG.Registro.Existe"); - }else{ - if (!lsParadas.contains(entidad)){ + } else { + if (!lsParadas.contains(entidad)) { throw new BusinessException("MSG.Registro.Existe"); } } } - - + lsParadas = buscarCVE(entidad.getCveparada()); if (!lsParadas.isEmpty()) { if (entidad.getParadaId() == null) { throw new BusinessException("editarCatalogoDeParadaController.registroIATAExiste"); } else { - if (!lsParadas.contains(entidad)){ + if (!lsParadas.contains(entidad)) { throw new BusinessException("editarCatalogoDeParadaController.registroIATAExiste"); } } } - + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE);