primer commit
This commit is contained in:
commit
1917a92ec1
41
.classpath
Normal file
41
.classpath
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-25">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" 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>
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/bin/
|
||||
*.class
|
||||
/target/
|
||||
23
.project
Normal file
23
.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>red_metro</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.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
13
.settings/org.eclipse.jdt.core.prefs
Normal file
13
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
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.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=24
|
||||
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
153
ficheros/bbdd-redmetro.sql
Normal file
153
ficheros/bbdd-redmetro.sql
Normal file
@ -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');
|
||||
|
||||
31
ficheros/cocherasRM.csv
Normal file
31
ficheros/cocherasRM.csv
Normal file
@ -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
|
||||
|
107
ficheros/trenes_estaciones_accesos.xml
Normal file
107
ficheros/trenes_estaciones_accesos.xml
Normal file
@ -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>
|
||||
53
ficheros/trenes_linea_color.xml
Normal file
53
ficheros/trenes_linea_color.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<info-trenes-linea-color>
|
||||
<trenes>
|
||||
<tren id="1">
|
||||
<modelo>Serie 2000-A</modelo>
|
||||
<anyo_incorporacion>2000</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>15</cod_cochera>
|
||||
<linea id="1">
|
||||
<nombre_l>Arguelles - Pinar de Chamartín</nombre_l>
|
||||
<color cod_hex="#741013" id="4">
|
||||
<descripcion>Marrón</descripcion>
|
||||
</color>
|
||||
</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>
|
||||
<linea id="2">
|
||||
<nombre_l>Arguelles - Pinar de Chamartín</nombre_l>
|
||||
<color cod_hex="#741013" id="4">
|
||||
<descripcion>Marrón</descripcion>
|
||||
</color>
|
||||
</linea>
|
||||
</tren>
|
||||
<tren id="3">
|
||||
<modelo>Serie 3000</modelo>
|
||||
<anyo_incorporacion>2010</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>15</cod_cochera>
|
||||
<linea id="3">
|
||||
<nombre_l>Arguelles - Pinar de Chamartín</nombre_l>
|
||||
<color cod_hex="#741013" id="4">
|
||||
<descripcion>Marrón</descripcion>
|
||||
</color>
|
||||
</linea>
|
||||
</tren>
|
||||
<tren id="4">
|
||||
<modelo>Serie 5000</modelo>
|
||||
<anyo_incorporacion>2010</anyo_incorporacion>
|
||||
<empresa_constructora>CAF</empresa_constructora>
|
||||
<cod_cochera>2</cod_cochera>
|
||||
<linea id="4">
|
||||
<nombre_l>Nuevos Ministerios - Aeropuerto</nombre_l>
|
||||
<color cod_hex="#f5418e" id="8">
|
||||
<descripcion>Rosa</descripcion>
|
||||
</color>
|
||||
</linea>
|
||||
</tren>
|
||||
</trenes>
|
||||
</info-trenes-linea-color>
|
||||
32
pom.xml
Normal file
32
pom.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<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>red_metro</groupId>
|
||||
<artifactId>red_metro</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<!-- Librería OpenCSV -->
|
||||
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>5.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Conector MySQL -->
|
||||
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>9.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JACKSON XML -->
|
||||
<!-- https://mvnrepository.com/artifact/tools.jackson.dataformat/jackson-dataformat-xml -->
|
||||
<dependency>
|
||||
<groupId>tools.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
96
src/main/java/es/madrid/redmetro/eva1/RedMetroApp.java
Normal file
96
src/main/java/es/madrid/redmetro/eva1/RedMetroApp.java
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import es.madrid.redmetro.eva1.dao.ILineaDAO;
|
||||
import es.madrid.redmetro.eva1.dao.impl.LineaDaoJDBC;
|
||||
import es.madrid.redmetro.eva1.ficheros.GestorFicheroCSV;
|
||||
import es.madrid.redmetro.eva1.ficheros.GestorFicherosXML;
|
||||
import es.madrid.redmetro.eva1.vo.Linea;
|
||||
|
||||
/**
|
||||
* @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");
|
||||
ILineaDAO iColorDao = new LineaDaoJDBC();
|
||||
Linea linea = iColorDao.obtenerInformacionLinea(13);
|
||||
|
||||
String textoLinea = "La Línea %s (%d) tiene como color %s (%s)";
|
||||
textoLinea = textoLinea.formatted(linea.getNombreLargo(), linea.getCodigoLinea(),
|
||||
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.procesarFicheroTrenXML();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/main/java/es/madrid/redmetro/eva1/dao/IAccesoDAO.java
Normal file
18
src/main/java/es/madrid/redmetro/eva1/dao/IAccesoDAO.java
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import es.madrid.redmetro.eva1.vo.Cochera;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public interface IAccesoDAO {
|
||||
public int insertarCochera(Cochera cochera);
|
||||
|
||||
public int borrarCochera(int iDCochera);
|
||||
|
||||
public int actualizarCochera(Cochera cochera);
|
||||
}
|
||||
20
src/main/java/es/madrid/redmetro/eva1/dao/ICocheraDAO.java
Normal file
20
src/main/java/es/madrid/redmetro/eva1/dao/ICocheraDAO.java
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import es.madrid.redmetro.eva1.vo.Cochera;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public interface ICocheraDAO {
|
||||
public boolean existeCochera(int idCochera);
|
||||
|
||||
public void insertarCochera(Cochera cochera);
|
||||
|
||||
public void borrarCochera(int idCochera);
|
||||
|
||||
public void actualizarCochera(Cochera cochera);
|
||||
}
|
||||
15
src/main/java/es/madrid/redmetro/eva1/dao/IColorDAO.java
Normal file
15
src/main/java/es/madrid/redmetro/eva1/dao/IColorDAO.java
Normal file
@ -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 25 nov 2025
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IColorDAO {
|
||||
|
||||
}
|
||||
|
||||
14
src/main/java/es/madrid/redmetro/eva1/dao/ILineaDAO.java
Normal file
14
src/main/java/es/madrid/redmetro/eva1/dao/ILineaDAO.java
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import es.madrid.redmetro.eva1.vo.Linea;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public interface ILineaDAO {
|
||||
public Linea obtenerInformacionLinea(int idLinea);
|
||||
}
|
||||
@ -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 25 nov 2025
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public interface ILineaEstacionDAO {
|
||||
|
||||
}
|
||||
|
||||
19
src/main/java/es/madrid/redmetro/eva1/dao/ITrenDAO.java
Normal file
19
src/main/java/es/madrid/redmetro/eva1/dao/ITrenDAO.java
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import es.madrid.redmetro.eva1.vo.Tren;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 25 nov 2025
|
||||
*/
|
||||
public interface ITrenDAO {
|
||||
public void insertarTren(Tren tren);
|
||||
|
||||
public List<Tren> obtenerListaTrenes();
|
||||
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.gestores.GestorConexionJDBC;
|
||||
import es.madrid.redmetro.eva1.vo.Cochera;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 25 nov 2025
|
||||
*/
|
||||
public class CocheraDaoJDBC implements ICocheraDAO {
|
||||
@Override
|
||||
public boolean existeCochera(int idCochera) {
|
||||
boolean existe = false;
|
||||
String sentenciaSQL = """
|
||||
SELECT *
|
||||
FROM T_COCHERA
|
||||
WHERE cod_cochera = ?
|
||||
""";
|
||||
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, idCochera);
|
||||
System.out.println(pstm);
|
||||
|
||||
ResultSet resultadoSentencia = pstm.executeQuery();
|
||||
if (resultadoSentencia.next()) {
|
||||
existe = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return existe;
|
||||
}
|
||||
|
||||
public void insertarCochera(Cochera cochera) {
|
||||
|
||||
String sentenciaSQL = "INSERT INTO T_COCHERA VALUES (?, ?, ? , ?)";
|
||||
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, cochera.getCodigoCochera());
|
||||
pstm.setString(2, cochera.getNombre());
|
||||
pstm.setString(3, cochera.getDireccion());
|
||||
pstm.setBoolean(4, cochera.isDeposito());
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void borrarCochera(int idCochera) {
|
||||
|
||||
String sentenciaSQL = "DELETE FROM T_COCHERA WHERE cod_cochera = ?";
|
||||
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, idCochera);
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void actualizarCochera(Cochera cochera) {
|
||||
|
||||
String sentenciaSQL = """
|
||||
UPDATE T_COCHERA
|
||||
SET nombre = ?, direccion = ? , deposito = ?
|
||||
WHERE cod_cochera = ?
|
||||
""";
|
||||
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
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.getCodigoCochera());
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.gestores.GestorConexionJDBC;
|
||||
import es.madrid.redmetro.eva1.vo.Color;
|
||||
import es.madrid.redmetro.eva1.vo.Linea;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 25 nov 2025
|
||||
*/
|
||||
public class LineaDaoJDBC implements ILineaDAO {
|
||||
|
||||
public Linea obtenerInformacionLinea(int idLinea) {
|
||||
Linea linea = null;
|
||||
|
||||
String sentenciaSQL = """
|
||||
SELECT * FROM T_COLOR color, T_LINEA linea
|
||||
WHERE linea.cod_color= color.cod_color
|
||||
and linea.cod_linea = ?
|
||||
""";
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
pstm.setInt(1, idLinea);
|
||||
System.out.println(pstm);
|
||||
ResultSet resultadoSentencia = pstm.executeQuery();
|
||||
|
||||
if (resultadoSentencia.next()) {
|
||||
|
||||
linea = new Linea();
|
||||
linea.setCodigoLinea(resultadoSentencia.getInt("linea.cod_linea"));
|
||||
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.setCodigoColor(resultadoSentencia.getInt("color.cod_color"));
|
||||
color.setCod_hexadecimal(resultadoSentencia.getString("color.cod_hexadecimal"));
|
||||
color.setNombre(resultadoSentencia.getString("color.nombre"));
|
||||
|
||||
linea.setColor(color);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return linea;
|
||||
}
|
||||
}
|
||||
117
src/main/java/es/madrid/redmetro/eva1/dao/impl/TrenDaoJDBC.java
Normal file
117
src/main/java/es/madrid/redmetro/eva1/dao/impl/TrenDaoJDBC.java
Normal file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.gestores.GestorConexionJDBC;
|
||||
import es.madrid.redmetro.eva1.vo.Cochera;
|
||||
import es.madrid.redmetro.eva1.vo.Color;
|
||||
import es.madrid.redmetro.eva1.vo.Linea;
|
||||
import es.madrid.redmetro.eva1.vo.Tren;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 25 nov 2025
|
||||
*/
|
||||
public class TrenDaoJDBC implements ITrenDAO {
|
||||
|
||||
public void insertarTren(Tren tren) {
|
||||
String sentenciaSQL = "INSERT INTO T_TREN VALUES (?, ?, ? , ?, ?, ?)";
|
||||
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
PreparedStatement pstm = conexion.prepareStatement(sentenciaSQL);) {
|
||||
|
||||
pstm.setInt(1, tren.getCodigoTren());
|
||||
pstm.setString(2, tren.getModelo());
|
||||
pstm.setString(3, tren.getEmpresaConstructora());
|
||||
// Obtener java.sql.Date de Un java.util.Date
|
||||
Date fechaBBDD = new Date(tren.getFechaIncorporacion().getTime());
|
||||
pstm.setDate(4, fechaBBDD);
|
||||
pstm.setInt(5, tren.getCochera().getCodigoCochera());
|
||||
pstm.setInt(6, tren.getLinea().getCodigoLinea());
|
||||
|
||||
System.out.println(pstm);
|
||||
|
||||
pstm.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tren> obtenerListaTrenes() {
|
||||
List<Tren> listaTrenes = null;
|
||||
|
||||
String sentenciaSQL = """
|
||||
SELECT *
|
||||
FROM T_TREN tren join T_LINEA linea
|
||||
ON tren.cod_linea =linea.cod_linea
|
||||
join T_COCHERA cochera
|
||||
on tren.cod_cochera =cochera.cod_cochera
|
||||
join T_COLOR color
|
||||
on linea.cod_color =color.cod_color
|
||||
""";
|
||||
|
||||
// try con recursos "cerrables": Connection, Statement, ResultSet
|
||||
try (Connection conexion = GestorConexionJDBC.getConexionSGDB();
|
||||
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.setCodigoTren(resultadoSentencia.getInt("tren.cod_tren"));
|
||||
tren.setEmpresaConstructora(resultadoSentencia.getString("tren.empresa_constructora"));
|
||||
tren.setModelo(resultadoSentencia.getString("tren.modelo"));
|
||||
tren.setFechaIncorporacion(resultadoSentencia.getDate("tren.fecha_incorporacion"));
|
||||
|
||||
// Información de la Línea
|
||||
Linea linea = new Linea();
|
||||
linea.setCodigoLinea(resultadoSentencia.getInt("linea.cod_linea"));
|
||||
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.setCodigoColor(resultadoSentencia.getInt("color.cod_color"));
|
||||
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.setCodigoCochera(resultadoSentencia.getInt("cochera.cod_cochera"));
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return listaTrenes;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.dao.ICocheraDAO;
|
||||
import es.madrid.redmetro.eva1.dao.impl.CocheraDaoJDBC;
|
||||
import es.madrid.redmetro.eva1.gestores.GestorFicheroConfiguracion;
|
||||
import es.madrid.redmetro.eva1.vo.Cochera;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 25 nov 2025
|
||||
*/
|
||||
public class GestorFicheroCSV {
|
||||
private final static String SEPARADOR_CSV = GestorFicheroConfiguracion.getInfoConfiguracion("csv.separador");
|
||||
|
||||
public void procesarFicheroCocheraCSV() {
|
||||
|
||||
String nombreFicheroCSV = GestorFicheroConfiguracion.getInfoConfiguracion("nombre.fichero.cochera.csv");
|
||||
|
||||
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 codigoCochera = 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.setCodigoCochera(codigoCochera);
|
||||
cochera.setNombre(nombre);
|
||||
cochera.setDireccion(direccion);
|
||||
cochera.setDeposito(esDeposito);
|
||||
|
||||
ICocheraDAO iCocheraDAO = null;
|
||||
if (operacion == 1) {
|
||||
iCocheraDAO = new CocheraDaoJDBC();
|
||||
boolean existeCochera = iCocheraDAO.existeCochera(cochera.getCodigoCochera());
|
||||
if (!existeCochera) { // Si no existe, la insertamos
|
||||
iCocheraDAO.insertarCochera(cochera);
|
||||
}
|
||||
} else if (operacion == 2) {
|
||||
iCocheraDAO = new CocheraDaoJDBC();
|
||||
iCocheraDAO.actualizarCochera(cochera);
|
||||
} else if (operacion == 3) {
|
||||
iCocheraDAO = new CocheraDaoJDBC();
|
||||
iCocheraDAO.borrarCochera(cochera.getCodigoCochera());
|
||||
}
|
||||
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,264 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.ficheros;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
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 es.madrid.redmetro.eva1.dao.ITrenDAO;
|
||||
import es.madrid.redmetro.eva1.dao.impl.TrenDaoJDBC;
|
||||
import es.madrid.redmetro.eva1.gestores.GestorFicheroConfiguracion;
|
||||
import es.madrid.redmetro.eva1.vo.Cochera;
|
||||
import es.madrid.redmetro.eva1.vo.Linea;
|
||||
import es.madrid.redmetro.eva1.vo.Tren;
|
||||
import tools.jackson.databind.JsonNode;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
import tools.jackson.dataformat.xml.XmlMapper;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 28 nov 2024
|
||||
*/
|
||||
public class GestorFicherosXML {
|
||||
|
||||
public void procesarFicheroTrenXML() {
|
||||
// Dos opciones: 1. Usar Jackson - 2. Usar DOM (Elegir una de las dos)
|
||||
// 1. Usar Jackson (JsonNode)
|
||||
procesarListaTrenesJackson();;
|
||||
|
||||
// 2. Usar DOM
|
||||
//procesarListaTrenesDeDOM();
|
||||
}
|
||||
|
||||
public void procesarListaTrenesJackson() {
|
||||
String nombreFicheroXML = GestorFicheroConfiguracion.getInfoConfiguracion("nombre.fichero.tren.lectura.xml");
|
||||
// Tratamiento del fichero XML
|
||||
File file = new File(nombreFicheroXML);
|
||||
JsonNode nodoRaiz = null;
|
||||
ObjectMapper mapper = new XmlMapper();
|
||||
|
||||
nodoRaiz = mapper.readTree(file);
|
||||
JsonNode nodoTrenes = nodoRaiz.path("trenes");
|
||||
JsonNode listaTrenes = nodoTrenes.path("tren");
|
||||
System.out.println("Número de Trenes: " + listaTrenes.size());
|
||||
ITrenDAO iTrenDAO = new TrenDaoJDBC();
|
||||
// Recorrer los distintos nodos Tren
|
||||
for (JsonNode nodoTren : listaTrenes) {
|
||||
int idTren = Integer.parseInt(nodoTren.path("id").asString());
|
||||
String modelo = nodoTren.path("modelo").asString();
|
||||
String anyoFabricacion = nodoTren.path("anyo_incorporacion").asString();
|
||||
String empresaConstructora = nodoTren.path("empresa_constructora").asString();
|
||||
int codigoCochera = Integer.parseInt(nodoTren.path("cod_cochera").asString());
|
||||
int idLinea = Integer.parseInt(nodoTren.path("id_linea").asString());
|
||||
|
||||
Tren tren = new Tren();
|
||||
tren.setCodigoTren(idTren);
|
||||
tren.setEmpresaConstructora(empresaConstructora);
|
||||
tren.setModelo(modelo);
|
||||
|
||||
// Convertir el año a Date
|
||||
SimpleDateFormat formato = new SimpleDateFormat("yyyy");
|
||||
Date fechaIncorporacion = null;
|
||||
try {
|
||||
fechaIncorporacion = formato.parse(anyoFabricacion);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
tren.setFechaIncorporacion(fechaIncorporacion);
|
||||
|
||||
tren.setModelo(modelo);
|
||||
|
||||
Cochera cochera = new Cochera();
|
||||
cochera.setCodigoCochera(codigoCochera);
|
||||
tren.setCochera(cochera);
|
||||
Linea linea = new Linea();
|
||||
linea.setCodigoLinea(idLinea);
|
||||
tren.setLinea(linea);
|
||||
|
||||
// Insertar el tren en la base de datos
|
||||
iTrenDAO.insertarTren(tren);
|
||||
}
|
||||
}
|
||||
|
||||
public void procesarListaTrenesDeDOM() {
|
||||
String nombreFicheroXML = GestorFicheroConfiguracion.getInfoConfiguracion("nombre.fichero.tren.lectura.xml");
|
||||
// Tratamiento del fichero XML
|
||||
File file = new File(nombreFicheroXML);
|
||||
try {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.parse(file);
|
||||
|
||||
// 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());
|
||||
ITrenDAO iTrenDAO = new TrenDaoJDBC();
|
||||
// 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 codigoCochera = 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.setCodigoTren(idTren);
|
||||
tren.setEmpresaConstructora(empresaConstructora);
|
||||
tren.setModelo(modelo);
|
||||
|
||||
// Convertir el año a Date
|
||||
SimpleDateFormat formato = new SimpleDateFormat("yyyy");
|
||||
Date fechaIncorporacion = null;
|
||||
try {
|
||||
fechaIncorporacion = formato.parse(anyoFabricacion);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
tren.setFechaIncorporacion(fechaIncorporacion);
|
||||
|
||||
tren.setModelo(modelo);
|
||||
|
||||
Cochera cochera = new Cochera();
|
||||
cochera.setCodigoCochera(codigoCochera);
|
||||
tren.setCochera(cochera);
|
||||
Linea linea = new Linea();
|
||||
linea.setCodigoLinea(idLinea);
|
||||
tren.setLinea(linea);
|
||||
|
||||
// Insertar el tren en la base de datos
|
||||
iTrenDAO.insertarTren(tren);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void escribirFicheroXMLDOMDeBBDD() {
|
||||
// Obtener la información de Trenes-Línea-Color desde BBDD
|
||||
ITrenDAO iTrenDAO = new TrenDaoJDBC();
|
||||
List<Tren> listaTrenes = iTrenDAO.obtenerListaTrenes();
|
||||
System.out.println(listaTrenes);
|
||||
|
||||
String nombreFicheroXML = GestorFicheroConfiguracion.getInfoConfiguracion("nombre.fichero.tren.escritura.xml");
|
||||
// Tratamiento del fichero XML
|
||||
File file = new File(nombreFicheroXML);
|
||||
try {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.newDocument();
|
||||
|
||||
// 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.getCodigoTren()));
|
||||
|
||||
// Elemento modelo
|
||||
Element modeloElement = doc.createElement("modelo");
|
||||
modeloElement.appendChild(doc.createTextNode(tren.getModelo()));
|
||||
trenElement.appendChild(modeloElement);
|
||||
|
||||
// Elemento anyo_incorporacion
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(tren.getFechaIncorporacion());
|
||||
int anyoIncorporacion = calendar.get(Calendar.YEAR);
|
||||
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().getCodigoCochera())));
|
||||
trenElement.appendChild(cocheraElement);
|
||||
|
||||
// Elemento linea
|
||||
Element lineaElement = doc.createElement("linea");
|
||||
lineaElement.setAttribute("id", String.valueOf(tren.getCodigoTren()));
|
||||
// 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().getCodigoColor()));
|
||||
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 = 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 'trenes_linea_color.xml' creado exitosamente.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package es.madrid.redmetro.eva1.gestores;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* GestorConexionJDBC: Clase que realiza la gestión de la conexión con el SGDB
|
||||
*
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 25 nov 2025
|
||||
*
|
||||
*/
|
||||
public class GestorConexionJDBC {
|
||||
private GestorConexionJDBC() {
|
||||
// Constructor privado para evitar instanciación
|
||||
}
|
||||
|
||||
public static Connection getConexionSGDB() {
|
||||
Connection conexionSGDB = null;
|
||||
|
||||
// Datos URL
|
||||
String urlBBDD = GestorFicheroConfiguracion.getInfoConfiguracion("url.bbdd");
|
||||
|
||||
String usuario = GestorFicheroConfiguracion.getInfoConfiguracion("usuario.sgdb");
|
||||
String contrasenya = GestorFicheroConfiguracion.getInfoConfiguracion("clave.sgdb");
|
||||
|
||||
try {
|
||||
String claseDriver = GestorFicheroConfiguracion.getInfoConfiguracion("driver.sgdb");
|
||||
Class.forName(claseDriver);
|
||||
|
||||
conexionSGDB = DriverManager.getConnection(urlBBDD, usuario, contrasenya);
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return conexionSGDB;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package es.madrid.redmetro.eva1.gestores;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 25 nov 2025
|
||||
*/
|
||||
public class GestorFicheroConfiguracion {
|
||||
private static final String RUTA_FICHERO_CONFIGURACION = "aplicacion.properties";
|
||||
|
||||
private static Properties propiedades=null;
|
||||
static {
|
||||
propiedades= new Properties();
|
||||
try {
|
||||
// Fichero que está en el classpath
|
||||
propiedades.load(GestorFicheroConfiguracion.class.getClassLoader().getResourceAsStream(RUTA_FICHERO_CONFIGURACION));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getInfoConfiguracion(String clave) {
|
||||
String valor = null;
|
||||
valor = propiedades.getProperty(clave);
|
||||
return valor;
|
||||
}
|
||||
|
||||
}
|
||||
57
src/main/java/es/madrid/redmetro/eva1/vo/Acceso.java
Normal file
57
src/main/java/es/madrid/redmetro/eva1/vo/Acceso.java
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma) Fecha: 28 nov 2024
|
||||
*/
|
||||
public class Acceso implements Serializable {
|
||||
private static final long serialVersionUID = -3028184461287096322L;
|
||||
|
||||
private int codigo;
|
||||
private String nombre;
|
||||
private boolean accesible;
|
||||
private Estacion estacion;
|
||||
|
||||
public int getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public void setCodigo(int codigo) {
|
||||
this.codigo = codigo;
|
||||
}
|
||||
|
||||
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 [codigo=" + codigo + ", nombre=" + nombre + ", accesible=" + accesible + ", estacion=" + estacion
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
||||
72
src/main/java/es/madrid/redmetro/eva1/vo/Cochera.java
Normal file
72
src/main/java/es/madrid/redmetro/eva1/vo/Cochera.java
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public class Cochera implements Serializable{
|
||||
private static final long serialVersionUID = 3155379009944780512L;
|
||||
|
||||
private int codigoCochera;
|
||||
private String nombre;
|
||||
private String direccion;
|
||||
private boolean deposito;
|
||||
/**
|
||||
* @return the codCochera
|
||||
*/
|
||||
public int getCodigoCochera() {
|
||||
return codigoCochera;
|
||||
}
|
||||
/**
|
||||
* @param codCochera the codCochera to set
|
||||
*/
|
||||
public void setCodigoCochera(int codCochera) {
|
||||
this.codigoCochera = codCochera;
|
||||
}
|
||||
/**
|
||||
* @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 String toString() {
|
||||
return "Cochera [codCochera=" + codigoCochera + ", nombre=" + nombre + ", direccion=" + direccion + ", deposito="
|
||||
+ deposito + "]";
|
||||
}
|
||||
|
||||
}
|
||||
59
src/main/java/es/madrid/redmetro/eva1/vo/Color.java
Normal file
59
src/main/java/es/madrid/redmetro/eva1/vo/Color.java
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public class Color implements Serializable{
|
||||
private static final long serialVersionUID = 3295865115889018033L;
|
||||
|
||||
private int codigoColor;
|
||||
private String nombre;
|
||||
private String codigoHexadecimal;
|
||||
/**
|
||||
* @return the codigoColor
|
||||
*/
|
||||
public int getCodigoColor() {
|
||||
return codigoColor;
|
||||
}
|
||||
/**
|
||||
* @param codigoColor the codigoColor to set
|
||||
*/
|
||||
public void setCodigoColor(int codigoColor) {
|
||||
this.codigoColor = codigoColor;
|
||||
}
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Color [codigoColor=" + codigoColor + ", nombre=" + nombre + ", codigoHexadecimal=" + codigoHexadecimal
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
42
src/main/java/es/madrid/redmetro/eva1/vo/Estacion.java
Normal file
42
src/main/java/es/madrid/redmetro/eva1/vo/Estacion.java
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public class Estacion implements Serializable{
|
||||
private static final long serialVersionUID = -4550346449635360036L;
|
||||
|
||||
private String codigo;
|
||||
private String nombre;
|
||||
private String direccion;
|
||||
|
||||
public String getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
public void setCodigo(String codigo) {
|
||||
this.codigo = codigo;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Estacion [codigo=" + codigo + ", nombre=" + nombre + ", direccion=" + direccion + "]";
|
||||
}
|
||||
|
||||
}
|
||||
94
src/main/java/es/madrid/redmetro/eva1/vo/Linea.java
Normal file
94
src/main/java/es/madrid/redmetro/eva1/vo/Linea.java
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public class Linea implements Serializable{
|
||||
private static final long serialVersionUID = 2546017016457301339L;
|
||||
|
||||
private int codigoLinea;
|
||||
private String nombreCorto;
|
||||
private String nombreLargo;
|
||||
private Date fechaInauguracion;
|
||||
private float kilometros;
|
||||
private Color color;
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
/**
|
||||
* @return the codigoLinea
|
||||
*/
|
||||
public int getCodigoLinea() {
|
||||
return codigoLinea;
|
||||
}
|
||||
/**
|
||||
* @param codigoLinea the codigoLinea to set
|
||||
*/
|
||||
public void setCodigoLinea(int codigoLinea) {
|
||||
this.codigoLinea = codigoLinea;
|
||||
}
|
||||
/**
|
||||
* @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 fechaInauguracion
|
||||
*/
|
||||
public Date getFechaInauguracion() {
|
||||
return fechaInauguracion;
|
||||
}
|
||||
/**
|
||||
* @param fechaInauguracion the fechaInauguracion to set
|
||||
*/
|
||||
public void setFechaInauguracion(Date fechaInauguracion) {
|
||||
this.fechaInauguracion = fechaInauguracion;
|
||||
}
|
||||
/**
|
||||
* @return the kilometros
|
||||
*/
|
||||
public float getKilometros() {
|
||||
return kilometros;
|
||||
}
|
||||
/**
|
||||
* @param kilometros the kilometros to set
|
||||
*/
|
||||
public void setKilometros(float kilometros) {
|
||||
this.kilometros = kilometros;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Linea [codigoLinea=" + codigoLinea + ", nombreCorto=" + nombreCorto + ", nombreLargo=" + nombreLargo
|
||||
+ ", fechaInauguracion=" + fechaInauguracion + ", kilometros=" + kilometros + ", color=" + color + "]";
|
||||
}
|
||||
}
|
||||
44
src/main/java/es/madrid/redmetro/eva1/vo/LineaEstacion.java
Normal file
44
src/main/java/es/madrid/redmetro/eva1/vo/LineaEstacion.java
Normal file
@ -0,0 +1,44 @@
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||
* @date 25 nov 2025 *
|
||||
*
|
||||
*/
|
||||
|
||||
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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
100
src/main/java/es/madrid/redmetro/eva1/vo/Tren.java
Normal file
100
src/main/java/es/madrid/redmetro/eva1/vo/Tren.java
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package es.madrid.redmetro.eva1.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Isidoro Nevares Martín (IES Virgen de la Paloma)
|
||||
* Fecha: 28 nov 2024
|
||||
*/
|
||||
public class Tren implements Serializable{
|
||||
private static final long serialVersionUID = 3033036838329546838L;
|
||||
|
||||
private int codigoTren;
|
||||
private String modelo;
|
||||
private String empresaConstructora;
|
||||
private Date fechaIncorporacion;
|
||||
private Cochera cochera;
|
||||
private Linea linea;
|
||||
|
||||
/**
|
||||
* @return the codigoTren
|
||||
*/
|
||||
public int getCodigoTren() {
|
||||
return codigoTren;
|
||||
}
|
||||
/**
|
||||
* @param codigoTren the codigoTren to set
|
||||
*/
|
||||
public void setCodigoTren(int codigoTren) {
|
||||
this.codigoTren = codigoTren;
|
||||
}
|
||||
/**
|
||||
* @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 fechaIncorporacion
|
||||
*/
|
||||
public Date getFechaIncorporacion() {
|
||||
return fechaIncorporacion;
|
||||
}
|
||||
/**
|
||||
* @param fechaIncorporacion the fechaIncorporacion to set
|
||||
*/
|
||||
public void setFechaIncorporacion(Date fechaIncorporacion) {
|
||||
this.fechaIncorporacion = fechaIncorporacion;
|
||||
}
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tren [codigoTren=" + codigoTren + ", modelo=" + modelo + ", empresaConstructora=" + empresaConstructora
|
||||
+ ", fechaIncorporacion=" + fechaIncorporacion + ", cochera=" + cochera + ", linea=" + linea + "]\n";
|
||||
}
|
||||
}
|
||||
20
src/main/resources/aplicacion.properties
Normal file
20
src/main/resources/aplicacion.properties
Normal file
@ -0,0 +1,20 @@
|
||||
# Parámetros de una conexión a un SGBD MySQL
|
||||
driver.sgdb=com.mysql.cj.jdbc.Driver
|
||||
url.bbdd=jdbc:mysql://192.168.1.36:3306/red_metro_eva1
|
||||
|
||||
usuario.sgdb=root
|
||||
clave.sgdb=mysql_123
|
||||
|
||||
# #####################
|
||||
# Ficheros Examen #
|
||||
# #####################
|
||||
|
||||
# Fichero CSV
|
||||
nombre.fichero.cochera.csv=ficheros/cocherasRM.csv
|
||||
csv.separador=;
|
||||
|
||||
# Fichero XML Lectura
|
||||
nombre.fichero.tren.lectura.xml=ficheros/trenes_estaciones_accesos.xml
|
||||
|
||||
# Fichero XML Escritura
|
||||
nombre.fichero.tren.escritura.xml=ficheros/trenes_linea_color.xml
|
||||
Loading…
Reference in New Issue
Block a user