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.ConexionCtrlDAO; import com.rjconsultores.ventaboletos.entidad.Conexion; import com.rjconsultores.ventaboletos.entidad.ConexionConf; import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; import com.rjconsultores.ventaboletos.service.ConexionConfService; import com.rjconsultores.ventaboletos.service.ConexionCtrlService; import com.rjconsultores.ventaboletos.service.ConexionService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @Service("conexionCtrlService") public class ConexionCtrlServiceImpl implements ConexionCtrlService { @Autowired private ConexionCtrlDAO conexionCtrlDAO; @Autowired private ConexionService conexionDAO; @Autowired private ConexionConfService conexionConfDAO; public List obtenerTodos() { return conexionCtrlDAO.obtenerTodos(); } public ConexionCtrl obtenerID(Long id) { return conexionCtrlDAO.obtenerID(id); } @Transactional public ConexionCtrl suscribir(ConexionCtrl entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); return conexionCtrlDAO.suscribir(entidad); } @Transactional public ConexionCtrl actualizacion(ConexionCtrl entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); return conexionCtrlDAO.actualizacion(entidad); } @Transactional public void borrar(ConexionCtrl entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.FALSE); List lsConexion = conexionDAO.buscarPorConexionCtrl(entidad.getConexionctrlId()); for (Conexion conexion : lsConexion) { conexionDAO.borrar(conexion); } List lsConexionConf = conexionConfDAO.buscarPorConexionCtrl(entidad); for (ConexionConf conexionConf : lsConexionConf) { conexionConfDAO.borrar(conexionConf); } conexionCtrlDAO.actualizacion(entidad); } }