86 lines
2.9 KiB
Java
86 lines
2.9 KiB
Java
/*
|
|
* To change this template, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package com.rjconsultores.ventaboletos.service.impl;
|
|
|
|
import java.math.BigDecimal;
|
|
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.AlertaCtrlDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.AlertaCtrl;
|
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
|
import com.rjconsultores.ventaboletos.entidad.Corrida;
|
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
|
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
|
import com.rjconsultores.ventaboletos.service.AlertaCtrlService;
|
|
import com.rjconsultores.ventaboletos.service.RutaService;
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
/**
|
|
*
|
|
* @author Administrador
|
|
*/
|
|
@Service("alertaCtrlService")
|
|
public class AlertaCtrlServiceImpl implements AlertaCtrlService {
|
|
|
|
@Autowired
|
|
private AlertaCtrlDAO alertaCtrlDAO;
|
|
|
|
@Autowired
|
|
private RutaService rutaService;
|
|
|
|
public List<AlertaCtrl> obtenerTodos() {
|
|
return alertaCtrlDAO.obtenerTodos();
|
|
}
|
|
|
|
public AlertaCtrl obtenerID(Integer id) {
|
|
return alertaCtrlDAO.obtenerID(id);
|
|
}
|
|
|
|
@Transactional(rollbackFor=BusinessException.class)
|
|
public AlertaCtrl suscribirActualizar(AlertaCtrl entidad) throws BusinessException {
|
|
if (entidad.getRuta() != null) {
|
|
if (!rutaService.paradaExisteEnLaRuta(entidad.getOrigem(), entidad.getRuta())) {
|
|
throw new BusinessException("editarAlertaCtrlController.MSG.origenNoExisteRuta");
|
|
}
|
|
if (!rutaService.paradaExisteEnLaRuta(entidad.getDestino(), entidad.getRuta())) {
|
|
throw new BusinessException("editarAlertaCtrlController.MSG.destinoNoExisteRuta");
|
|
}
|
|
}
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.TRUE);
|
|
|
|
if (entidad.getAlertactrlId() == null) {
|
|
return alertaCtrlDAO.suscribir(entidad);
|
|
} else {
|
|
return alertaCtrlDAO.actualizacion(entidad);
|
|
}
|
|
}
|
|
@Transactional
|
|
public void borrar(AlertaCtrl entidad) {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.FALSE);
|
|
|
|
alertaCtrlDAO.actualizacion(entidad);
|
|
}
|
|
|
|
public List<AlertaCtrl> buscar(Parada origem, Parada destino, Ruta ruta, ClaseServicio claseServicio, Integer tiempoAlta, Integer tiempoBaja, BigDecimal percAlta,
|
|
BigDecimal percBaja) {
|
|
return alertaCtrlDAO.buscar(origem, destino, ruta, claseServicio, tiempoAlta, tiempoBaja, percAlta, percBaja);
|
|
}
|
|
|
|
public List<AlertaCtrl> buscarCorrida(Corrida corrida) {
|
|
return alertaCtrlDAO.buscarCorrida(corrida);
|
|
}
|
|
|
|
}
|