Primer commit
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="config">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Simulacion_RedMetro</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=24
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=24
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=24
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,19 @@
|
||||
# Parámetros de una conexión a un SGBD MySQL
|
||||
sgdb.conexion.url=jdbc:mysql://192.168.1.36:3306/
|
||||
bbdd.nombre=red_metro_eva1
|
||||
bbdd.usuario=root
|
||||
bbdd.clave=mysql_123
|
||||
|
||||
# #####################
|
||||
# Ficheros Examen #
|
||||
# #####################
|
||||
|
||||
# Fichero CSV
|
||||
cochera.fichero.csv=ficheros/cocherasRM.csv
|
||||
cochera.csv.separador=;
|
||||
|
||||
# Fichero XML Lectura
|
||||
tren.fichero.lectura.xml=ficheros/trenes_estaciones_accesos.xml
|
||||
|
||||
# Fichero XML Escritura
|
||||
tren.fichero.escritura.xml=ficheros/trenes_linea_color.xml
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
# Parámetros de una conexión a un SGBD MySQL
|
||||
sgdb.conexion.url=jdbc:mysql://192.168.1.36:3306/
|
||||
bbdd.nombre=red_metro_eva1
|
||||
bbdd.usuario=root
|
||||
bbdd.clave=mysql_123
|
||||
|
||||
# #####################
|
||||
# Ficheros Examen #
|
||||
# #####################
|
||||
|
||||
# Fichero CSV
|
||||
cochera.fichero.csv=ficheros/cocherasRM.csv
|
||||
cochera.csv.separador=;
|
||||
|
||||
# Fichero XML Lectura
|
||||
tren.fichero.lectura.xml=ficheros/trenes_estaciones_accesos.xml
|
||||
|
||||
# Fichero XML Escritura
|
||||
tren.fichero.escritura.xml=ficheros/trenes_linea_color.xml
|
||||
@@ -0,0 +1,153 @@
|
||||
DROP TABLE IF EXISTS T_LINEA_ESTACION;
|
||||
DROP TABLE IF EXISTS T_ACCESO;
|
||||
DROP TABLE IF EXISTS T_TREN;
|
||||
DROP TABLE IF EXISTS T_LINEA;
|
||||
DROP TABLE IF EXISTS T_COCHERA;
|
||||
DROP TABLE IF EXISTS T_COLOR;
|
||||
DROP TABLE IF EXISTS T_ESTACION;
|
||||
/* */
|
||||
# Crear la tabla T_COCHERA
|
||||
CREATE TABLE IF NOT EXISTS T_COCHERA(
|
||||
cod_cochera INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
nombre VARCHAR(255) NOT NULL,
|
||||
direccion VARCHAR(255) NOT NULL,
|
||||
deposito INT -- Valores 1 y 0
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
# Crear la tabla T_COLOR
|
||||
CREATE TABLE IF NOT EXISTS T_COLOR(
|
||||
cod_color INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
nombre VARCHAR(100) NOT NULL,
|
||||
cod_hexadecimal VARCHAR(7) NOT NULL
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
# Crear la tabla T_ESTACION
|
||||
CREATE TABLE IF NOT EXISTS T_ESTACION(
|
||||
cod_estacion INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
nombre VARCHAR(100) NOT NULL,
|
||||
direccion VARCHAR(255) NOT NULL
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
# Crear la tabla T_ACCESO
|
||||
CREATE TABLE IF NOT EXISTS T_ACCESO(
|
||||
cod_acceso INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
nombre VARCHAR(100) NOT NULL,
|
||||
acceso_discapacidad INT NOT NULL, -- 1 y 0
|
||||
cod_estacion INT NOT NULL,
|
||||
CONSTRAINT FK_ACCCESO_ESTACION FOREIGN KEY (cod_estacion) REFERENCES T_ESTACION(cod_estacion)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
# Crear la tabla T_LINEA
|
||||
CREATE TABLE IF NOT EXISTS T_LINEA(
|
||||
cod_linea INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
nombre_corto VARCHAR(50) NOT NULL,
|
||||
nombre_largo VARCHAR(100) NOT NULL,
|
||||
-- fecha_inauguracion DATE NOT NULL,
|
||||
cod_color INT NOT NULL,
|
||||
kilometros FLOAT(5,2) NOT NULL,
|
||||
CONSTRAINT FK_LINEA_COLOR FOREIGN KEY (cod_color) REFERENCES T_COLOR(cod_color)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
# Crear la tabla T_TREN
|
||||
CREATE TABLE IF NOT EXISTS T_TREN(
|
||||
cod_tren INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
modelo VARCHAR(100) NOT NULL,
|
||||
empresa_constructora VARCHAR(255) NOT NULL,
|
||||
fecha_incorporacion DATE ,
|
||||
cod_cochera INT NOT NULL,
|
||||
cod_linea INT NOT NULL,
|
||||
CONSTRAINT FK_TREN_COCHERA FOREIGN KEY (cod_cochera) REFERENCES T_COCHERA(cod_cochera),
|
||||
CONSTRAINT FK_TREN_LINEA FOREIGN KEY (cod_linea) REFERENCES T_LINEA(cod_linea)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
|
||||
# Crear la tabla T_LINEA_ESTACION
|
||||
CREATE TABLE IF NOT EXISTS T_LINEA_ESTACION(
|
||||
cod_linea INT NOT NULL,
|
||||
cod_estacion INT NOT NULL,
|
||||
orden INT NOT NULL,
|
||||
CONSTRAINT PRIMARY KEY (cod_linea, cod_estacion),
|
||||
CONSTRAINT FK_LINEAESTACION_LINEA FOREIGN KEY (cod_linea) REFERENCES T_LINEA(cod_linea),
|
||||
CONSTRAINT FK_LINEAESTACION_ESTACION FOREIGN KEY (cod_estacion) REFERENCES T_ESTACION(cod_estacion)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
/* Carga de información */
|
||||
-- Tabla T_COLOR --
|
||||
INSERT INTO T_COLOR VALUES (1, 'Azul', '#438dc0');
|
||||
INSERT INTO T_COLOR VALUES (2, 'Rojo', '#fc3738');
|
||||
INSERT INTO T_COLOR VALUES (3, 'Amarillo', '#fec128');
|
||||
INSERT INTO T_COLOR VALUES (4, 'Marrón', '#741013');
|
||||
INSERT INTO T_COLOR VALUES (5, 'Verde', '#83b41c');
|
||||
INSERT INTO T_COLOR VALUES (6, 'Gris', '#939493');
|
||||
INSERT INTO T_COLOR VALUES (7, 'Naranja', '#fd9924');
|
||||
INSERT INTO T_COLOR VALUES (8, 'Rosa', '#f5418e');
|
||||
INSERT INTO T_COLOR VALUES (9, 'Morado', '#8a026b');
|
||||
INSERT INTO T_COLOR VALUES (10, 'Azul marino', '#09117e');
|
||||
INSERT INTO T_COLOR VALUES (11, 'Verde oscuro', '#065a16');
|
||||
INSERT INTO T_COLOR VALUES (12, 'Verde oliva', '#7f7f01');
|
||||
INSERT INTO T_COLOR VALUES (13, 'Blanco ramal', '#ffffff');
|
||||
|
||||
-- Tabla T_ESTACION --
|
||||
-- Tabla T_TREN --
|
||||
-- Tabla T_ACCESO --
|
||||
-- Tabla T_LINEA --
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (5, 'Línea 4', 'Arguelles - Pinar de Chamartín', 4, 7.5);
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (6, 'Línea 5', 'Alameda de Osuna - Casa de Campo', 5, 6.5);
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (9, 'Línea 8', 'Nuevos Ministerios - Aeropuerto', 8, 7.45);
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (10, 'Línea 9', 'Paco de Lucía - Arganda del Rey', 9, 10.75);
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (11, 'Línea 10', 'Hospital Infanta Sofía - Puerta del Sur', 10, 12.75);
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (12, 'Línea 11', 'Plaza Elíptica - La Fortuna', 11, 3.75);
|
||||
INSERT INTO T_LINEA (cod_linea,nombre_corto, nombre_largo,cod_color,kilometros) values (13, 'Línea 12', 'Metrour', 12, 10.75);
|
||||
|
||||
|
||||
-- Tabla T_LINEA_ESTACION --
|
||||
|
||||
-- Tabla T_COCHERA --
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (1, 1, 'PUERTA DE ARGANDA', 'CARRETERA M-203 KM 2,300 (CAMINO DE VALLECAS A MEJORADA)');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (2, 1, 'UNIVERSIDAD REY JUAN CARLOS', 'AVENIDA ALCALDE DE MÓSTOLES Nº 35');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (3, 1, 'EL BERCIAL', 'PRÓXIMO A CARRETERA DE TURQUÍA (BARRIO DE EL BERCIAL)');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (4, 1, 'ARGANZUELA - PLANETARIO', 'C/ BRONCE Nº 1');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (5, 1, 'CIUDAD UNIVERSITARIA', 'PLAZA RAMÓN Y CAJAL');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (6, 1, 'MIGUEL HERNANDEZ', 'AVENIDA DE LA ALBUFERA ESQ. CALLE RAFAEL ALBERTI');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (7, 1, 'ARGÜELLES', 'C/ PRINCESA Nº 56');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (8, 1, 'ALMENDRALES', 'AVENIDA DE CÓRDOBA, 21');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (9, 1, 'MONCLOA', 'C/ PRINCESA, 96');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (10, 1, 'NUEVOS MINISTERIOS', 'PASEO DE LA CASTELLANA Nº 67');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (11, 0, 'CUATRO CAMINOS', 'VIRGEN DE NIEVA S/N');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (12, 0, 'VENTAS', 'ALMERÍA 6');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (13, 0, 'PLAZA DE CASTILLA', 'SAN BENITO S/N');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (14, 0, 'CANILLEJAS', 'NECTAR S/N');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (15, 0, 'ALUCHE', 'AVDA. DE LOS POBLADOS Nº 11');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (16, 0, 'FUENCARRAL', 'AVENIDA CAMPO DE CALATRAVA Nº 86');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (17, 0, 'SACEDAL', 'VENTISQUERO DE LA CONDESA S/N');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (18, 0, 'LAGUNA', 'GOTAREDURA Nº 3');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (19, 0, 'HORTALEZA', 'C/ MANUEL AZAÑA');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (20, 0, 'CUATRO VIENTOS', 'CRTA. DE CANALEJAS S/N');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (21, 0, 'LORANCA', 'AVDA. DE LA ALEGRÍA (FUENLABRADA)');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (22, 0, 'VALDECARROS', 'AVENIDA CERRO MILANO 0103 ENSANCHE DE VALLECAS, 73 ');
|
||||
INSERT INTO T_COCHERA (cod_cochera, deposito ,nombre, direccion) VALUES (23, 0, 'VILLAVERDE', 'AVENIDA REAL DE PINTO');
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
OPERACION;COD_COCHERA;DEPOSITO;DENOMINACION;LOCALIZACION
|
||||
1;1;1;PUEEEEEEEEEEERTA DE ARGANDA;CARRETERA M-203 KM 2,300 (CAMINO DE VALLECAS A MEJORADA)
|
||||
1;2;1;UNIVERSIDAD REY JUAN CARLOS;AVENIDA ALCALDE DE MÓSTOLES Nº 35
|
||||
1;3;1;EL BERCIAL;PRÓXIMO A CARRETERA DE TURQUÍA (BARRIO DE EL BERCIAL)
|
||||
1;4;1;ARGANZUELA - PLANETARIO;C/ BRONCE Nº 1
|
||||
1;5;1;CIUDAD UNIVERSITARIA;PLAZA RAMÓN Y CAJAL
|
||||
1;6;1;MIGUEL HERNANDEZ;AVENIDA DE LA ALBUFERA ESQ. CALLE RAFAEL ALBERTI
|
||||
0;7;1;ARGÜELLES;C/ PRINCESA Nº 56
|
||||
1;8;1;ALMENDRALES;AVENIDA DE CÓRDOBA, 21
|
||||
1;9;1;MONCLOA;C/ PRINCESA, 96
|
||||
1;10;1;NUEVOS MINISTERIOS;PASEO DE LA CASTELLANA Nº 67
|
||||
0;11;0;CUATRO CAMINOS;VIRGEN DE NIEVA S/N
|
||||
1;12;0;VENTAS;ALMERÍA 6
|
||||
1;13;0;PLAZA DE CASTILLA;SAN BENITO S/N
|
||||
1;14;0;CANILLEJAS;NECTAR S/N
|
||||
1;15;0;ALUCHE;AVDA. DE LOS POBLADOS Nº 11
|
||||
1;16;0;FUENCARRAL;AVENIDA CAMPO DE CALATRAVA Nº 86
|
||||
0;17;0;SACEDAL;VENTISQUERO DE LA CONDESA S/N
|
||||
1;18;0;LAGUNA;GOTAREDURA Nº 3
|
||||
1;19;0;HORTALEZA;C/ MANUEL AZAÑA
|
||||
1;20;0;CUATRO VIENTOS CUATRO;CRTA. DE CANALEJAS y DE QUIEN LO MATO S/N
|
||||
1;21;0;LORANCA;AVDA. DE LA ALEGRÍA (FUENLABRADA)
|
||||
1;22;0;VALDECARROS;AVENIDA CERRO MILANO 0103 ENSANCHE DE VALLECAS, 73
|
||||
1;23;0;VILLAVERDE;AVENIDA REAL DE PINTO
|
||||
2;1;1;PUERTA DE ARGANDA;CARRETERA M-203 KM 2,300 (CAMINO DE VALLECAS A MEJORADA)
|
||||
0;14;0;CANILLEJAS;NECTAR S/N
|
||||
0;15;0;ALUCHE;AVDA. DE LOS POBLADOS Nº 11
|
||||
0;16;0;FUENCARRAL;AVENIDA CAMPO DE CALATRAVA Nº 86
|
||||
0;17;0;SACEDAL;VENTISQUERO DE LA CONDESA S/N
|
||||
0;18;0;LAGUNA;GOTAREDURA Nº 3
|
||||
3;13;0;PLAZA DE CASTILLA;SAN BENITO S/N
|
||||
|
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<info-trenes-estaciones-accesos>
|
||||
<!-- Información trenes -->
|
||||
<trenes>
|
||||
<tren id="1">
|
||||
<modelo>Serie 2000-A</modelo>
|
||||
<anyo_incorporacion>2000</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>15</cod_cochera>
|
||||
<id_linea>5</id_linea>
|
||||
</tren>
|
||||
<tren id="2">
|
||||
<modelo>Serie 2000-B</modelo>
|
||||
<anyo_incorporacion>2005</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>15</cod_cochera>
|
||||
<id_linea>5</id_linea>
|
||||
</tren>
|
||||
<tren id="3">
|
||||
<modelo>Serie 3000</modelo>
|
||||
<anyo_incorporacion>2010</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>15</cod_cochera>
|
||||
<id_linea>5</id_linea>
|
||||
</tren>
|
||||
<tren id="4">
|
||||
<modelo>Serie 5000</modelo>
|
||||
<anyo_incorporacion>2010</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>2</cod_cochera>
|
||||
<id_linea>9</id_linea>
|
||||
</tren>
|
||||
|
||||
</trenes>
|
||||
|
||||
<!-- Información estaciones -->
|
||||
<estaciones>
|
||||
<estacion id="1">
|
||||
<nombre>Alameda de Osuna</nombre>
|
||||
<direccion>C/ de la Corbeta,14</direccion>
|
||||
<accesos>
|
||||
<acceso id="1">
|
||||
<nombre>Corbeta: C/ de la Corbeta,14 (esquina calle de La Rioja)</nombre>
|
||||
<acceso_discapacidad>0</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="2">
|
||||
<nombre>Ascensor: C/ de la Corbeta,14 (esquina calle de La Rioja)</nombre>
|
||||
<acceso_discapacidad>1</acceso_discapacidad>
|
||||
</acceso>
|
||||
</accesos>
|
||||
</estacion>
|
||||
<estacion id="2">
|
||||
<nombre>Pueblo Nuevo</nombre>
|
||||
<direccion>C/. Alcalá, 373</direccion>
|
||||
<accesos>
|
||||
<acceso id="3">
|
||||
<nombre>Hermanos de Pablo: Alcalá, 373 (próx. Hnos. de Pablo)</nombre>
|
||||
<acceso_discapacidad>0</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="4">
|
||||
<nombre>Emilio Ferrari: Alcalá, 364</nombre>
|
||||
<acceso_discapacidad>0</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="5">
|
||||
<nombre>Ascensor: Alcalá, 366</nombre>
|
||||
<acceso_discapacidad>1</acceso_discapacidad>
|
||||
</acceso>
|
||||
</accesos>
|
||||
</estacion>
|
||||
<estacion id="3">
|
||||
<nombre>Avenida de América</nombre>
|
||||
<direccion>Avenida de América nº 25</direccion>
|
||||
<accesos>
|
||||
<acceso id="6">
|
||||
<nombre>Intercambiador: Avenida de América frente al nº 25</nombre>
|
||||
<acceso_discapacidad>1</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="7">
|
||||
<nombre>Pedro Valdivia: Pedro Valdivia, 31 (Francisco Silvela - Príncipe de Vergara)</nombre>
|
||||
<acceso_discapacidad>0</acceso_discapacidad>
|
||||
</acceso>
|
||||
</accesos>
|
||||
</estacion>
|
||||
<estacion id="4">
|
||||
<nombre>Núñez de Balboa</nombre>
|
||||
<direccion>C/. Núñez de Balboa, 85</direccion>
|
||||
<accesos>
|
||||
<acceso id="8">
|
||||
<nombre>Núñez de Balboa: Núñez de Balboa, 85 (Esq. Juan Bravo, 13)</nombre>
|
||||
<acceso_discapacidad>1</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="9">
|
||||
<nombre>Velázquez: Velázquez, 92 (Esq. Juan Bravo, 11)</nombre>
|
||||
<acceso_discapacidad>0</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="10">
|
||||
<nombre>Aparcamiento: Aparcamiento Pza. Marqués de Salamanca (Sólo entrada)</nombre>
|
||||
<acceso_discapacidad>1</acceso_discapacidad>
|
||||
</acceso>
|
||||
<acceso id="11">
|
||||
<nombre>Pza. Marqués de Salamanca: Pza. Marqués de Salamanca, 10</nombre>
|
||||
<acceso_discapacidad>0</acceso_discapacidad>
|
||||
</acceso>
|
||||
</accesos>
|
||||
</estacion>
|
||||
</estaciones>
|
||||
</info-trenes-estaciones-accesos>
|
||||
@@ -0,0 +1,37 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>Simulacion_RedMetro</groupId>
|
||||
<artifactId>Simulacion_RedMetro</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<!-- Source: https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>26.10.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>config</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<release>24</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import es.madrid.redmetro.eva1.ficheros.GestorFicheroCSV;
|
||||
import es.madrid.redmetro.eva1.ficheros.GestorFicherosXML;
|
||||
import es.madrid.redmetro.eva1.model.Linea;
|
||||
import es.madrid.redmetro.eva1.service.LineaService;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 28 nov 2024
|
||||
*/
|
||||
public class RedMetroApp {
|
||||
public static void main(String[] args) {
|
||||
RedMetroApp app = new RedMetroApp();
|
||||
|
||||
// Tratamiento de lógica de negocio
|
||||
String operacion = app.obtenerOperacionProcesar();
|
||||
|
||||
app.ejecutarFuncionalidadesRedMetro(operacion);
|
||||
}
|
||||
|
||||
private String obtenerOperacionProcesar() {
|
||||
Scanner entrada = new Scanner(System.in);
|
||||
|
||||
System.out.println("Menú:");
|
||||
System.out.println(" A: Consultar Información Línea-Color");
|
||||
System.out.println(" B: Procesar fichero Cocheras.csv");
|
||||
System.out.println(" C: Procesar Fichero XML de Trenes-Estaciones-Accesos");
|
||||
System.out.println(" D: Cargar información Trenes-Linea-Color en fichero XML");
|
||||
System.out.println("----------------------------------------------------------");
|
||||
System.out.println("Introduce la operación a realizar:");
|
||||
// Operación recogida
|
||||
String operacion = entrada.nextLine().trim();
|
||||
|
||||
while (!("ABCD".contains(operacion))) {
|
||||
System.out.println("Has seleccionado un operación errónea (ha de ser un número entre A y D)");
|
||||
System.out.print("Introduce la operación a realizar:");
|
||||
|
||||
// Operación recogida
|
||||
operacion = entrada.nextLine();
|
||||
}
|
||||
System.out.println("Operación a realizar: " + operacion);
|
||||
// Cerrar la entrada del Scanner
|
||||
entrada.close();
|
||||
|
||||
return operacion;
|
||||
}
|
||||
|
||||
public void ejecutarFuncionalidadesRedMetro(String operacion) {
|
||||
try {
|
||||
switch (operacion) {
|
||||
case "A": { // Consulta Linea-Color
|
||||
System.out.println("Ejecutar consultarLineaColor");
|
||||
LineaService lineaService= new LineaService();
|
||||
Linea linea = lineaService.obtenerLineaPorClave(13);
|
||||
|
||||
String textoLinea = "La Línea %s (%d) tiene como color %s (%s)";
|
||||
textoLinea = textoLinea.formatted(linea.getNombreLargo(), linea.getIdentificador(),
|
||||
linea.getColor().getNombre(), linea.getColor().getCodigoHexadecimal());
|
||||
System.out.println(textoLinea);
|
||||
break;
|
||||
}
|
||||
case "B": { // Procesar Fichero CSV Cocheras
|
||||
System.out.println("Ejecutar procesarFicheroCocheraCSV");
|
||||
GestorFicheroCSV gestorFicheros = new GestorFicheroCSV();
|
||||
gestorFicheros.procesarFicheroCocheraCSV();
|
||||
break;
|
||||
}
|
||||
case "C": { // Procesar Fichero XML Trenes
|
||||
System.out.println("Ejecutar procesarFicheroTrenXML");
|
||||
GestorFicherosXML gestorFicheros = new GestorFicherosXML();
|
||||
|
||||
gestorFicheros.procesarListaTrenesDeDOM();
|
||||
break;
|
||||
}
|
||||
case "D": { // Crear fichero XML a partir de información de Trenes-Línea-Color
|
||||
System.out.println("Ejecutar crearFicheroXMLInforTrenes");
|
||||
GestorFicherosXML gestorFicheros = new GestorFicherosXML();
|
||||
|
||||
gestorFicheros.escribirFicheroXMLDOMDeBBDD();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 04 nov 2026
|
||||
*/
|
||||
public interface IAccesoDAO {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.model.Cochera;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 04 nov 2026
|
||||
*/
|
||||
public interface ICocheraDAO {
|
||||
public boolean existeCochera(int idCochera) throws RedMetroException;
|
||||
|
||||
public void insertarCochera(Cochera cochera) throws RedMetroException;
|
||||
|
||||
public void borrarCochera(int idCochera) throws RedMetroException;
|
||||
|
||||
public void actualizarCochera(Cochera cochera) throws RedMetroException;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* IColordDAO: Clase que maneja las operaciones de acceso a datos para la entidad Color.
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 04 nov 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IColorDAO {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.model.Linea;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 04 nov 2026
|
||||
*/
|
||||
public interface ILineaDAO {
|
||||
public Linea obtenerInformacionLinea(int idLinea) throws RedMetroException;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* IColordDAO: Clase que maneja las operaciones de acceso a datos para la entidad Color.
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 04 nov 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public interface ILineaEstacionDAO {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.model.Tren;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 04 nov 2026
|
||||
*/
|
||||
public interface ITrenDAO {
|
||||
public void insertarTren(Tren tren) throws RedMetroException;
|
||||
|
||||
public List<Tren> obtenerListaTrenes() throws RedMetroException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import es.madrid.redmetro.eva1.dao.ICocheraDAO;
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.model.Cochera;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class CocheraDaoJDBC implements ICocheraDAO {
|
||||
private final Connection conexion;
|
||||
|
||||
public CocheraDaoJDBC(Connection conexion) {
|
||||
this.conexion = conexion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existeCochera(int idCochera) throws RedMetroException{
|
||||
boolean existeCochera = false;
|
||||
String sentenciaSQL = """
|
||||
SELECT EXISTS(
|
||||
SELECT 1
|
||||
FROM T_COCHERA
|
||||
WHERE identificador = ?
|
||||
) AS existe_cochera
|
||||
""";
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, idCochera);
|
||||
System.out.println(pstm);
|
||||
|
||||
ResultSet resultadoSentencia = pstm.executeQuery();
|
||||
if (resultadoSentencia.next()) {
|
||||
existeCochera = resultadoSentencia.getBoolean("existe_cochera");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al validar si existe una cochera.", e);
|
||||
}
|
||||
|
||||
return existeCochera;
|
||||
}
|
||||
|
||||
public void insertarCochera(Cochera cochera) throws RedMetroException{
|
||||
|
||||
String sentenciaSQL = "INSERT INTO T_COCHERA VALUES (?, ?, ? , ?)";
|
||||
|
||||
// try con recursos "cerrables": PreparedStatement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, cochera.getIdentificador());
|
||||
pstm.setString(2, cochera.getNombre());
|
||||
pstm.setString(3, cochera.getDireccion());
|
||||
pstm.setBoolean(4, cochera.isDeposito());
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al crear una nueva cochera.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void borrarCochera(int idCochera) throws RedMetroException{
|
||||
|
||||
String sentenciaSQL = "DELETE FROM T_COCHERA WHERE identificador = ?";
|
||||
|
||||
// try con recursos "cerrables": PreparedStatement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, idCochera);
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al borrar una cochera.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void actualizarCochera(Cochera cochera) throws RedMetroException{
|
||||
|
||||
String sentenciaSQL = """
|
||||
UPDATE T_COCHERA
|
||||
SET nombre = ?, direccion = ? , deposito = ?
|
||||
WHERE identificador = ?
|
||||
""";
|
||||
|
||||
// try con recursos "cerrables": PreparedStatement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
System.out.println(sentenciaSQL);
|
||||
|
||||
pstm.setString(1, cochera.getNombre());
|
||||
pstm.setString(2, cochera.getDireccion());
|
||||
pstm.setBoolean(3, cochera.isDeposito());
|
||||
pstm.setInt(4, cochera.getIdentificador());
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al actualizar una cochera.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import es.madrid.redmetro.eva1.dao.ILineaDAO;
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.model.Color;
|
||||
import es.madrid.redmetro.eva1.model.Linea;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class LineaDaoJDBC implements ILineaDAO {
|
||||
private final Connection conexion;
|
||||
|
||||
public LineaDaoJDBC(Connection conexion) {
|
||||
this.conexion = conexion;
|
||||
}
|
||||
|
||||
public Linea obtenerInformacionLinea(int idLinea) throws RedMetroException{
|
||||
Linea linea = null;
|
||||
|
||||
String sentenciaSQL = """
|
||||
SELECT *
|
||||
FROM T_COLOR color JOIN T_LINEA linea
|
||||
ON color.identificador = linea.id_color
|
||||
WHERE linea.identificador = ?
|
||||
""";
|
||||
// try con recursos "cerrables": PreparedStatement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
pstm.setInt(1, idLinea);
|
||||
// System.out.println(pstm);
|
||||
ResultSet resultadoSentencia = pstm.executeQuery();
|
||||
|
||||
if (resultadoSentencia.next()) {
|
||||
|
||||
linea = new Linea();
|
||||
linea.setIdentificador(resultadoSentencia.getInt("linea.identificador"));
|
||||
linea.setNombreCorto(resultadoSentencia.getString("linea.nombre_corto"));
|
||||
linea.setNombreLargo(resultadoSentencia.getString("linea.nombre_largo"));
|
||||
linea.setKilometros(resultadoSentencia.getFloat("linea.kilometros"));
|
||||
|
||||
Color color = new Color();
|
||||
color.setIdentificador(resultadoSentencia.getInt("color.identificador"));
|
||||
color.setCod_hexadecimal(resultadoSentencia.getString("color.cod_hexadecimal"));
|
||||
color.setNombre(resultadoSentencia.getString("color.nombre"));
|
||||
|
||||
linea.setColor(color);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al obtener la información de una línea de metro.", e);
|
||||
}
|
||||
|
||||
return linea;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import es.madrid.redmetro.eva1.dao.ITrenDAO;
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.model.Cochera;
|
||||
import es.madrid.redmetro.eva1.model.Color;
|
||||
import es.madrid.redmetro.eva1.model.Linea;
|
||||
import es.madrid.redmetro.eva1.model.Tren;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class TrenDaoJDBC implements ITrenDAO {
|
||||
private final Connection conexion;
|
||||
|
||||
public TrenDaoJDBC(Connection conexion) {
|
||||
this.conexion = conexion;
|
||||
}
|
||||
|
||||
public void insertarTren(Tren tren) throws RedMetroException {
|
||||
String sentenciaSQL = "INSERT INTO T_TREN VALUES (?, ?, ? , ?, ?, ?)";
|
||||
|
||||
// try con recursos "cerrables": PreparedStatement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, tren.getIdentificador());
|
||||
pstm.setString(2, tren.getModelo());
|
||||
pstm.setString(3, tren.getEmpresaConstructora());
|
||||
// Obtener java.sql.Date de Un java.util.Date
|
||||
pstm.setDate(4, Date.valueOf(tren.getFechaIncorporacion()));
|
||||
pstm.setInt(5, tren.getCochera().getIdentificador());
|
||||
pstm.setInt(6, tren.getLinea().getIdentificador());
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al crear un nuevo tren.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tren> obtenerListaTrenes() throws RedMetroException {
|
||||
List<Tren> listaTrenes = null;
|
||||
|
||||
String sentenciaSQL = """
|
||||
SELECT *
|
||||
FROM T_TREN tren join T_LINEA linea
|
||||
ON tren.id_linea =linea.identificador
|
||||
join T_COCHERA cochera
|
||||
on tren.id_cochera =cochera.identificador
|
||||
join T_COLOR color
|
||||
on linea.id_color =color.identificador
|
||||
""";
|
||||
|
||||
// try con recursos "cerrables": PreparedStatement, ResultSet
|
||||
try (PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
ResultSet resultadoSentencia = pstm.executeQuery();
|
||||
while (resultadoSentencia.next()) {
|
||||
if (listaTrenes == null) {
|
||||
listaTrenes = new ArrayList<Tren>();
|
||||
}
|
||||
Tren tren = new Tren();
|
||||
tren.setIdentificador(resultadoSentencia.getInt("tren.identificador"));
|
||||
tren.setEmpresaConstructora(resultadoSentencia.getString("tren.empresa_constructora"));
|
||||
tren.setModelo(resultadoSentencia.getString("tren.modelo"));
|
||||
tren.setFechaIncorporacion(resultadoSentencia.getDate("tren.fecha_incorporacion").toLocalDate());
|
||||
|
||||
// Información de la Línea
|
||||
Linea linea = new Linea();
|
||||
linea.setIdentificador(resultadoSentencia.getInt("linea.identificador"));
|
||||
linea.setKilometros(resultadoSentencia.getFloat("linea.kilometros"));
|
||||
linea.setNombreCorto(resultadoSentencia.getString("linea.nombre_corto"));
|
||||
linea.setNombreLargo(resultadoSentencia.getString("linea.nombre_largo"));
|
||||
|
||||
// Información de Color
|
||||
Color color = new Color();
|
||||
color.setIdentificador(resultadoSentencia.getInt("color.identificador"));
|
||||
color.setNombre(resultadoSentencia.getString("color.nombre"));
|
||||
color.setCod_hexadecimal(resultadoSentencia.getString("color.cod_hexadecimal"));
|
||||
|
||||
linea.setColor(color);
|
||||
|
||||
tren.setLinea(linea);
|
||||
|
||||
// Información de la Cochera
|
||||
Cochera cochera = new Cochera();
|
||||
cochera.setIdentificador(resultadoSentencia.getInt("cochera.identificador"));
|
||||
cochera.setDeposito(resultadoSentencia.getBoolean("cochera.deposito"));
|
||||
cochera.setDireccion(resultadoSentencia.getString("cochera.direccion"));
|
||||
cochera.setNombre(resultadoSentencia.getString("cochera.nombre"));
|
||||
tren.setCochera(cochera);
|
||||
|
||||
listaTrenes.add(tren);
|
||||
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al obtener la lista de trenes existentes.", e);
|
||||
}
|
||||
|
||||
return listaTrenes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package es.madrid.redmetro.eva1.excepcion;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* FormacionException: Clase abstracta que representa la excepción base del proyecto Formacion
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 15 oct 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class RedMetroException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public RedMetroException(String mensaje) {
|
||||
super(mensaje);
|
||||
}
|
||||
|
||||
public RedMetroException(String mensaje, Throwable causa) {
|
||||
super(mensaje, causa);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.ficheros;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.gestores.GestorConfiguracion;
|
||||
import es.madrid.redmetro.eva1.model.Cochera;
|
||||
import es.madrid.redmetro.eva1.service.CocheraService;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 20267
|
||||
*/
|
||||
public class GestorFicheroCSV {
|
||||
private CocheraService cocheraService;
|
||||
|
||||
private final static String SEPARADOR_CSV = GestorConfiguracion.getSeparadorFicheroCSVCochera();
|
||||
|
||||
public void procesarFicheroCocheraCSV() throws RedMetroException {
|
||||
|
||||
String nombreFicheroCSV = GestorConfiguracion.getRutaFicheroCSVCochera();
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(nombreFicheroCSV));) {
|
||||
br.readLine(); // Saltar la cabecera
|
||||
String linea;
|
||||
while ((linea = br.readLine()) != null) {
|
||||
String[] datosLinea = linea.split(SEPARADOR_CSV);
|
||||
int operacion = Integer.parseInt(datosLinea[0]);
|
||||
int idCochera = Integer.parseInt(datosLinea[1]);
|
||||
int depositoInt = Integer.parseInt(datosLinea[2]);
|
||||
boolean esDeposito = (depositoInt == 1) ? true : false;
|
||||
String nombre = datosLinea[3];
|
||||
String direccion = datosLinea[4];
|
||||
|
||||
// se cargan los datos en el objeto Cochera
|
||||
Cochera cochera = new Cochera();
|
||||
cochera.setIdentificador(idCochera);
|
||||
cochera.setNombre(nombre);
|
||||
cochera.setDireccion(direccion);
|
||||
cochera.setDeposito(esDeposito);
|
||||
|
||||
cocheraService = new CocheraService();
|
||||
if (operacion == 1) {
|
||||
boolean existeCochera = cocheraService.existeCocheraPorClave(cochera.getIdentificador());
|
||||
if (!existeCochera) { // Si no existe, la insertamos
|
||||
cocheraService.insertarCochera(cochera);
|
||||
}
|
||||
} else if (operacion == 2) {
|
||||
cocheraService.actualizarCochera(cochera);
|
||||
} else if (operacion == 3) {
|
||||
cocheraService.borrarCochera(idCochera);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.ficheros;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.gestores.GestorConfiguracion;
|
||||
import es.madrid.redmetro.eva1.model.Cochera;
|
||||
import es.madrid.redmetro.eva1.model.Linea;
|
||||
import es.madrid.redmetro.eva1.model.Tren;
|
||||
import es.madrid.redmetro.eva1.service.TrenService;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 28 nov 2024
|
||||
*/
|
||||
public class GestorFicherosXML {
|
||||
TrenService trenService;
|
||||
|
||||
public void procesarListaTrenesDeDOM() throws RedMetroException {
|
||||
String nombreFicheroXML = GestorConfiguracion.getRutaFicheroLecturaXMLTren();
|
||||
// Tratamiento del fichero XML
|
||||
File file = new File(nombreFicheroXML);
|
||||
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder;
|
||||
Document doc = null;
|
||||
try {
|
||||
dBuilder = dbFactory.newDocumentBuilder();
|
||||
doc = dBuilder.parse(file);
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// estos métodos podemos usarlos combinados para normalizar el archivo XML
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
// Obtener la lista de nodos cuya etiqueta es "tren"
|
||||
NodeList nList = doc.getElementsByTagName("tren");
|
||||
|
||||
System.out.println("Número de Trenes: " + nList.getLength());
|
||||
trenService = new TrenService();
|
||||
// Recorrer los distintos nodos Tren
|
||||
for (int temp = 0; temp < nList.getLength(); temp++) {
|
||||
Node nodoTren = nList.item(temp);
|
||||
|
||||
if (nodoTren.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element eElement = (Element) nodoTren;
|
||||
// Obtener información del tren
|
||||
int idTren = Integer.parseInt(eElement.getAttribute("id"));
|
||||
String modelo = eElement.getElementsByTagName("modelo").item(0).getTextContent();
|
||||
String anyoFabricacion = eElement.getElementsByTagName("anyo_incorporacion").item(0).getTextContent();
|
||||
String empresaConstructora = eElement.getElementsByTagName("empresa_constructora").item(0)
|
||||
.getTextContent();
|
||||
int idCochera = Integer.parseInt(eElement.getElementsByTagName("cod_cochera").item(0).getTextContent());
|
||||
int idLinea = Integer.parseInt(eElement.getElementsByTagName("id_linea").item(0).getTextContent());
|
||||
|
||||
Tren tren = new Tren();
|
||||
tren.setIdentificador(idTren);
|
||||
tren.setEmpresaConstructora(empresaConstructora);
|
||||
tren.setModelo(modelo);
|
||||
|
||||
LocalDate fechaFabricacion = LocalDate.of(Integer.parseInt(anyoFabricacion), 1, 1);
|
||||
tren.setFechaIncorporacion(fechaFabricacion);
|
||||
|
||||
tren.setModelo(modelo);
|
||||
|
||||
Cochera cochera = new Cochera();
|
||||
cochera.setIdentificador(idCochera);
|
||||
tren.setCochera(cochera);
|
||||
Linea linea = new Linea();
|
||||
linea.setIdentificador(idLinea);
|
||||
;
|
||||
tren.setLinea(linea);
|
||||
|
||||
// Insertar el tren en la base de datos
|
||||
trenService.insertarTren(tren);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void escribirFicheroXMLDOMDeBBDD() throws RedMetroException {
|
||||
// Obtener la información de Trenes-Línea-Color desde BBDD
|
||||
trenService = new TrenService();
|
||||
List<Tren> listaTrenes = trenService.obtenerListaTrenes();
|
||||
System.out.println(listaTrenes);
|
||||
|
||||
String nombreFicheroXML = GestorConfiguracion.getRutaFicheroEscrituraXMLTren();
|
||||
// Tratamiento del fichero XML
|
||||
File file = new File(nombreFicheroXML);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder;
|
||||
Document doc = null;
|
||||
try {
|
||||
dBuilder = dbFactory.newDocumentBuilder();
|
||||
doc = dBuilder.newDocument();
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Elemento raíz
|
||||
Element raiz = doc.createElement("info-trenes-linea-color");
|
||||
doc.appendChild(raiz);
|
||||
|
||||
Element trenes = doc.createElement("trenes");
|
||||
raiz.appendChild(trenes);
|
||||
|
||||
// Recorrer la lista de trenes
|
||||
for (Tren tren : listaTrenes) {
|
||||
// Elemento tren
|
||||
Element trenElement = doc.createElement("tren");
|
||||
trenElement.setAttribute("id", String.valueOf(tren.getIdentificador()));
|
||||
|
||||
// Elemento modelo
|
||||
Element modeloElement = doc.createElement("modelo");
|
||||
modeloElement.appendChild(doc.createTextNode(tren.getModelo()));
|
||||
trenElement.appendChild(modeloElement);
|
||||
|
||||
// Elemento anyo_incorporacion
|
||||
int anyoIncorporacion = tren.getFechaIncorporacion().getYear();
|
||||
Element anyoElement = doc.createElement("anyo_incorporacion");
|
||||
anyoElement.appendChild(doc.createTextNode(String.valueOf(anyoIncorporacion)));
|
||||
trenElement.appendChild(anyoElement);
|
||||
|
||||
// Elemento empresa_constructora
|
||||
Element empresaElement = doc.createElement("empresa_constructora");
|
||||
empresaElement.appendChild(doc.createTextNode(tren.getEmpresaConstructora()));
|
||||
trenElement.appendChild(empresaElement);
|
||||
|
||||
// Elemento cod_cochera
|
||||
Element cocheraElement = doc.createElement("cod_cochera");
|
||||
cocheraElement.appendChild(doc.createTextNode(String.valueOf(tren.getCochera().getIdentificador())));
|
||||
trenElement.appendChild(cocheraElement);
|
||||
|
||||
// Elemento linea
|
||||
Element lineaElement = doc.createElement("linea");
|
||||
lineaElement.setAttribute("id", String.valueOf(tren.getIdentificador()));
|
||||
// Elemento nombre
|
||||
Element nombreLineaElement = doc.createElement("nombre_l");
|
||||
nombreLineaElement.appendChild(doc.createTextNode(tren.getLinea().getNombreLargo()));
|
||||
lineaElement.appendChild(nombreLineaElement);
|
||||
// Elemento color
|
||||
Element colorElement = doc.createElement("color");
|
||||
colorElement.setAttribute("id", String.valueOf(tren.getLinea().getColor().getIdentificador()));
|
||||
colorElement.setAttribute("cod_hex", String.valueOf(tren.getLinea().getColor().getCodigoHexadecimal()));
|
||||
// Elemento descripcion del color
|
||||
Element descripocionColorElement = doc.createElement("descripcion");
|
||||
descripocionColorElement.appendChild(doc.createTextNode(tren.getLinea().getColor().getNombre()));
|
||||
colorElement.appendChild(descripocionColorElement);
|
||||
|
||||
// Añadir la línea al elemento tren
|
||||
lineaElement.appendChild(colorElement);
|
||||
|
||||
// Añadir la línea al elemento tren
|
||||
trenElement.appendChild(lineaElement);
|
||||
|
||||
// Añadir el tren al elemento raíz
|
||||
trenes.appendChild(trenElement);
|
||||
}
|
||||
|
||||
// Con el objeto DOM se escribe el documento XML en el fichero
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer;
|
||||
try {
|
||||
transformer = transformerFactory.newTransformer();
|
||||
// Opcional: Configurar para una salida legible (indentación)
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{xml.apache.org}indent-amount", "4");
|
||||
|
||||
DOMSource source = new DOMSource(doc);
|
||||
StreamResult result = new StreamResult(file);
|
||||
|
||||
// Transformar (escribir) el documento en el archivo
|
||||
transformer.transform(source, result);
|
||||
|
||||
System.out.println("Archivo XML ' " + trenService + "' creado exitosamente.");
|
||||
} catch (TransformerConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (TransformerException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package es.madrid.redmetro.eva1.gestores;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* GestorConfiguracion: Clase que carga la configuración de la aplicación desde
|
||||
* un fichero de propiedades
|
||||
*
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 8 oct 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class GestorConexionesBBDD {
|
||||
|
||||
// Constructor privado: de esta manera conseguimos que esta clase no se puede
|
||||
// instanciar.
|
||||
private GestorConexionesBBDD() {
|
||||
}
|
||||
|
||||
public static Connection obtenerConexion() throws SQLException {
|
||||
Connection conexion = null;
|
||||
|
||||
String urlConexionCompleta = GestorConfiguracion.getConexionURL() + GestorConfiguracion.getNombreBBDD();
|
||||
String usuarioBBDD = GestorConfiguracion.getUsuarioBBDD();
|
||||
String claveBBDD = GestorConfiguracion.getClaveBBDD();
|
||||
conexion = DriverManager.getConnection(urlConexionCompleta, usuarioBBDD, claveBBDD);
|
||||
|
||||
return conexion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package es.madrid.redmetro.eva1.gestores;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
* GestorConfiguracion: Clase que carga la configuración de la aplicación desde
|
||||
* un fichero de propiedades
|
||||
*
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 8 oct 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class GestorConfiguracion {
|
||||
private static final String RUTA_FICHERO_CONFIGURACION = "app.properties";
|
||||
private static final Properties PROPIEDADES_CONFIGURACION = new Properties();
|
||||
|
||||
// Constructor privado: de esta manera conseguimos que esta clase no se puede
|
||||
// instanciar.
|
||||
private GestorConfiguracion() {
|
||||
}
|
||||
|
||||
// Este bloque se ejecuta una sola vez, cuando se carga la clase
|
||||
// GestorConfiguracion
|
||||
static {
|
||||
try (InputStream inputStream = GestorConfiguracion.class.getClassLoader().getResourceAsStream(RUTA_FICHERO_CONFIGURACION);)
|
||||
{
|
||||
|
||||
if (inputStream == null) {
|
||||
throw new IOException(
|
||||
"No se encuentra "+ RUTA_FICHERO_CONFIGURACION + " en el classpath");
|
||||
}
|
||||
PROPIEDADES_CONFIGURACION.load(inputStream);
|
||||
// System.out.println(PROPIEDADES_CONFIGURACION);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("No se ha podido cargar el fichero de configuración", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getClaseDriver() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("sgdb.clase.driver");
|
||||
}
|
||||
|
||||
public static String getConexionURL() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("sgdb.conexion.url");
|
||||
}
|
||||
|
||||
public static String getNombreBBDD() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("bbdd.nombre");
|
||||
}
|
||||
|
||||
public static String getUsuarioBBDD() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("bbdd.usuario");
|
||||
}
|
||||
|
||||
public static String getClaveBBDD() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("bbdd.clave");
|
||||
}
|
||||
|
||||
public static String getRutaFicheroCSVCochera() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("cochera.fichero.csv");
|
||||
}
|
||||
public static String getSeparadorFicheroCSVCochera() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("cochera.csv.separador");
|
||||
}
|
||||
|
||||
public static String getRutaFicheroLecturaXMLTren() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("tren.fichero.lectura.xml");
|
||||
}
|
||||
|
||||
public static String getRutaFicheroEscrituraXMLTren() {
|
||||
return PROPIEDADES_CONFIGURACION.getProperty("tren.fichero.escritura.xml");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class Acceso implements Serializable {
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private boolean accesible;
|
||||
private Estacion estacion;
|
||||
|
||||
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
public boolean isAccesible() {
|
||||
return accesible;
|
||||
}
|
||||
|
||||
public void setAccesible(boolean accesible) {
|
||||
this.accesible = accesible;
|
||||
}
|
||||
|
||||
public Estacion getEstacion() {
|
||||
return estacion;
|
||||
}
|
||||
|
||||
public void setEstacion(Estacion estacion) {
|
||||
this.estacion = estacion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Acceso [identificador=" + identificador + ", nombre=" + nombre + ", accesible=" + accesible
|
||||
+ ", estacion=" + estacion + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 04 nov 2026
|
||||
*/
|
||||
public class Cochera implements Serializable{
|
||||
private static final long serialVersionUID = 3155379009944780512L;
|
||||
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String direccion;
|
||||
private boolean deposito;
|
||||
|
||||
|
||||
/**
|
||||
* @return the nombre
|
||||
*/
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
/**
|
||||
* @param nombre the nombre to set
|
||||
*/
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
/**
|
||||
* @return the direccion
|
||||
*/
|
||||
public String getDireccion() {
|
||||
return direccion;
|
||||
}
|
||||
/**
|
||||
* @param direccion the direccion to set
|
||||
*/
|
||||
public void setDireccion(String direccion) {
|
||||
this.direccion = direccion;
|
||||
}
|
||||
/**
|
||||
* @return the deposito
|
||||
*/
|
||||
public boolean isDeposito() {
|
||||
return deposito;
|
||||
}
|
||||
/**
|
||||
* @param deposito the deposito to set
|
||||
*/
|
||||
public void setDeposito(boolean deposito) {
|
||||
this.deposito = deposito;
|
||||
}
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cochera [identificador=" + identificador + ", nombre=" + nombre + ", direccion=" + direccion
|
||||
+ ", deposito=" + deposito + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class Color implements Serializable {
|
||||
private static final long serialVersionUID = 3295865115889018033L;
|
||||
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String codigoHexadecimal;
|
||||
|
||||
/**
|
||||
* @return the nombre
|
||||
*/
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nombre the nombre to set
|
||||
*/
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cod_hexadecimal
|
||||
*/
|
||||
public String getCodigoHexadecimal() {
|
||||
return codigoHexadecimal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cod_hexadecimal the cod_hexadecimal to set
|
||||
*/
|
||||
public void setCod_hexadecimal(String cod_hexadecimal) {
|
||||
this.codigoHexadecimal = cod_hexadecimal;
|
||||
}
|
||||
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
|
||||
public void setCodigoHexadecimal(String codigoHexadecimal) {
|
||||
this.codigoHexadecimal = codigoHexadecimal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Color [identificador=" + identificador + ", nombre=" + nombre + ", codigoHexadecimal="
|
||||
+ codigoHexadecimal + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class Estacion implements Serializable {
|
||||
private static final long serialVersionUID = -4550346449635360036L;
|
||||
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String direccion;
|
||||
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
public String getDireccion() {
|
||||
return direccion;
|
||||
}
|
||||
|
||||
public void setDireccion(String direccion) {
|
||||
this.direccion = direccion;
|
||||
}
|
||||
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Estacion [identificador=" + identificador + ", nombre=" + nombre + ", direccion=" + direccion + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class Linea implements Serializable {
|
||||
private static final long serialVersionUID = 2546017016457301339L;
|
||||
|
||||
private int identificador;
|
||||
private String nombreCorto;
|
||||
private String nombreLargo;
|
||||
private LocalDate fechaInauguracion;
|
||||
private float kilometros;
|
||||
private Color color;
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nombreCorto
|
||||
*/
|
||||
public String getNombreCorto() {
|
||||
return nombreCorto;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nombreCorto the nombreCorto to set
|
||||
*/
|
||||
public void setNombreCorto(String nombreCorto) {
|
||||
this.nombreCorto = nombreCorto;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nombreLargo
|
||||
*/
|
||||
public String getNombreLargo() {
|
||||
return nombreLargo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nombreLargo the nombreLargo to set
|
||||
*/
|
||||
public void setNombreLargo(String nombreLargo) {
|
||||
this.nombreLargo = nombreLargo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the kilometros
|
||||
*/
|
||||
public float getKilometros() {
|
||||
return kilometros;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param kilometros the kilometros to set
|
||||
*/
|
||||
public void setKilometros(float kilometros) {
|
||||
this.kilometros = kilometros;
|
||||
}
|
||||
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
|
||||
public LocalDate getFechaInauguracion() {
|
||||
return fechaInauguracion;
|
||||
}
|
||||
|
||||
public void setFechaInauguracion(LocalDate fechaInauguracion) {
|
||||
this.fechaInauguracion = fechaInauguracion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Linea [identificador=" + identificador + ", nombreCorto=" + nombreCorto + ", nombreLargo=" + nombreLargo
|
||||
+ ", fechaInauguracion=" + fechaInauguracion + ", kilometros=" + kilometros + ", color=" + color + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 04 nov 2026*
|
||||
*
|
||||
*/
|
||||
|
||||
public class LineaEstacion {
|
||||
private Estacion estacion;
|
||||
private Linea linea;
|
||||
private int orden;
|
||||
|
||||
public Estacion getEstacion() {
|
||||
return estacion;
|
||||
}
|
||||
|
||||
public void setEstacion(Estacion estacion) {
|
||||
this.estacion = estacion;
|
||||
}
|
||||
|
||||
public Linea getLinea() {
|
||||
return linea;
|
||||
}
|
||||
|
||||
public void setLinea(Linea linea) {
|
||||
this.linea = linea;
|
||||
}
|
||||
|
||||
public int getOrden() {
|
||||
return orden;
|
||||
}
|
||||
|
||||
public void setOrden(int orden) {
|
||||
this.orden = orden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LineaEstacion [estacion=" + estacion + ", linea=" + linea + ", orden=" + orden + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 04 nov 2026
|
||||
*/
|
||||
public class Tren implements Serializable {
|
||||
private static final long serialVersionUID = 3033036838329546838L;
|
||||
|
||||
private int identificador;
|
||||
private String modelo;
|
||||
private String empresaConstructora;
|
||||
private LocalDate fechaIncorporacion;
|
||||
private Cochera cochera;
|
||||
private Linea linea;
|
||||
|
||||
/**
|
||||
* @return the modelo
|
||||
*/
|
||||
public String getModelo() {
|
||||
return modelo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelo the modelo to set
|
||||
*/
|
||||
public void setModelo(String modelo) {
|
||||
this.modelo = modelo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the empresaConstructora
|
||||
*/
|
||||
public String getEmpresaConstructora() {
|
||||
return empresaConstructora;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param empresaConstructora the empresaConstructora to set
|
||||
*/
|
||||
public void setEmpresaConstructora(String empresaConstructora) {
|
||||
this.empresaConstructora = empresaConstructora;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cochera
|
||||
*/
|
||||
public Cochera getCochera() {
|
||||
return cochera;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cochera the cochera to set
|
||||
*/
|
||||
public void setCochera(Cochera cochera) {
|
||||
this.cochera = cochera;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the linea
|
||||
*/
|
||||
public Linea getLinea() {
|
||||
return linea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param linea the linea to set
|
||||
*/
|
||||
public void setLinea(Linea linea) {
|
||||
this.linea = linea;
|
||||
}
|
||||
|
||||
public int getIdentificador() {
|
||||
return identificador;
|
||||
}
|
||||
|
||||
public void setIdentificador(int identificador) {
|
||||
this.identificador = identificador;
|
||||
}
|
||||
|
||||
public LocalDate getFechaIncorporacion() {
|
||||
return fechaIncorporacion;
|
||||
}
|
||||
|
||||
public void setFechaIncorporacion(LocalDate fechaIncorporacion) {
|
||||
this.fechaIncorporacion = fechaIncorporacion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tren [identificador=" + identificador + ", modelo=" + modelo + ", empresaConstructora="
|
||||
+ empresaConstructora + ", fechaIncorporacion=" + fechaIncorporacion + ", cochera=" + cochera
|
||||
+ ", linea=" + linea + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package es.madrid.redmetro.eva1.service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import es.madrid.redmetro.eva1.dao.ILineaDAO;
|
||||
import es.madrid.redmetro.eva1.dao.impl.LineaDaoJDBC;
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.gestores.GestorConexionesBBDD;
|
||||
import es.madrid.redmetro.eva1.model.Linea;
|
||||
|
||||
/**
|
||||
*
|
||||
* LineaService: Clase que realiza la lógica de negocio de una línea de metro.
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 4 nov 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class LineaService {
|
||||
public Linea obtenerLineaPorClave(int idLinea) throws RedMetroException {
|
||||
Linea linea = null;
|
||||
|
||||
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
|
||||
ILineaDAO iLineaDAO = new LineaDaoJDBC(conexion);
|
||||
linea = iLineaDAO.obtenerInformacionLinea(idLinea);
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al obtener la conexión", e);
|
||||
}
|
||||
return linea;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package es.madrid.redmetro.eva1.service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import es.madrid.redmetro.eva1.dao.ITrenDAO;
|
||||
import es.madrid.redmetro.eva1.dao.impl.TrenDaoJDBC;
|
||||
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
|
||||
import es.madrid.redmetro.eva1.gestores.GestorConexionesBBDD;
|
||||
import es.madrid.redmetro.eva1.model.Tren;
|
||||
|
||||
/**
|
||||
*
|
||||
* TrenService: Clase que realiza la lógica de negocio de un tren.
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 4 nov 2026
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class TrenService {
|
||||
public List<Tren> obtenerListaTrenes() throws RedMetroException {
|
||||
List<Tren> listaTrenes = null;
|
||||
|
||||
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
|
||||
ITrenDAO iTrenDAO = new TrenDaoJDBC(conexion);
|
||||
listaTrenes = iTrenDAO.obtenerListaTrenes();
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al obtener la conexión", e);
|
||||
}
|
||||
return listaTrenes;
|
||||
}
|
||||
|
||||
public void insertarTren(Tren tren) throws RedMetroException {
|
||||
|
||||
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
|
||||
ITrenDAO iTrenDAO = new TrenDaoJDBC(conexion);
|
||||
iTrenDAO.insertarTren(tren);
|
||||
} catch (SQLException e) {
|
||||
throw new RedMetroException("Error al obtener la conexión", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Manifest-Version: 1.0
|
||||
Build-Jdk-Spec: 25
|
||||
Created-By: Maven Integration for Eclipse
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Wed Nov 04 11:34:06 CET 2026
|
||||
artifactId=Simulacion_RedMetro
|
||||
groupId=Simulacion_RedMetro
|
||||
m2e.projectLocation=C\:\\Users\\ineva\\INM\\Personal\\Trabajo\\00-Educaci\u00F3n - CM\\10-Curso 2026-2027\\02-Acceso de datos -DAM2\\workspace\\Simulacion_RedMetro
|
||||
m2e.projectName=Simulacion_RedMetro
|
||||
version=0.0.1-SNAPSHOT
|
||||
@@ -0,0 +1,37 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>Simulacion_RedMetro</groupId>
|
||||
<artifactId>Simulacion_RedMetro</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<!-- Source: https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>26.10.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>config</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<release>24</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,19 @@
|
||||
# Parámetros de una conexión a un SGBD MySQL
|
||||
sgdb.conexion.url=jdbc:mysql://192.168.1.36:3306/
|
||||
bbdd.nombre=red_metro_eva1
|
||||
bbdd.usuario=root
|
||||
bbdd.clave=mysql_123
|
||||
|
||||
# #####################
|
||||
# Ficheros Examen #
|
||||
# #####################
|
||||
|
||||
# Fichero CSV
|
||||
cochera.fichero.csv=ficheros/cocherasRM.csv
|
||||
cochera.csv.separador=;
|
||||
|
||||
# Fichero XML Lectura
|
||||
tren.fichero.lectura.xml=ficheros/trenes_estaciones_accesos.xml
|
||||
|
||||
# Fichero XML Escritura
|
||||
tren.fichero.escritura.xml=ficheros/trenes_linea_color.xml
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user