Primer commit

This commit is contained in:
Isidoro Nevares Martín
2026-11-04 11:45:16 +01:00
commit 77f38f82db
89 changed files with 2038 additions and 0 deletions
@@ -0,0 +1,65 @@
package es.madrid.redmetro.eva1.service;
import java.sql.Connection;
import java.sql.SQLException;
import es.madrid.redmetro.eva1.dao.ICocheraDAO;
import es.madrid.redmetro.eva1.dao.impl.CocheraDaoJDBC;
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
import es.madrid.redmetro.eva1.gestores.GestorConexionesBBDD;
import es.madrid.redmetro.eva1.model.Cochera;
/**
*
* CocheraService: Clase que realiza la lógica de negocio de una cochera.
*
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 4 nov 2026
*
*
*/
public class CocheraService {
public boolean existeCocheraPorClave(int idCochera) throws RedMetroException {
boolean existeFP = false;
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
existeFP = iCocheraDAO.existeCochera(idCochera);
} catch (SQLException e) {
throw new RedMetroException("Error al obtener la conexión", e);
}
return existeFP;
}
public void insertarCochera(Cochera cochera) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
iCocheraDAO.insertarCochera(cochera);
} catch (SQLException e) {
throw new RedMetroException("Error al obtener la conexión", e);
}
}
public void actualizarCochera(Cochera cochera) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
iCocheraDAO.actualizarCochera(cochera);
} catch (SQLException e) {
throw new RedMetroException("Error al obtener la conexión", e);
}
}
public void borrarCochera(int idCochera) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
iCocheraDAO.borrarCochera(idCochera);
} catch (SQLException e) {
throw new RedMetroException("Error al obtener la conexión", e);
}
}
}