Correciones 15-10-2026
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
# Fichero de continentes
|
||||
|
||||
# Ruta del fichero de continentes
|
||||
continente.ruta=informacion_continentes.csv
|
||||
continente.ruta=../fic09/informacion_continentes.csv
|
||||
|
||||
# Ruta del fichero temporal
|
||||
continente.ruta.temporal=archivo.tmp
|
||||
continente.ruta.temporal=../fic09/archivo.tmp
|
||||
|
||||
# Separador del fichero CSV de continentes
|
||||
continente.separador=#
|
||||
|
||||
# Fichero de paises
|
||||
# Ruta del fichero de paises
|
||||
pais.ruta=informacion_paises.txt
|
||||
pais.ruta=../fic09/informacion_paises.txt
|
||||
|
||||
# Separador del fichero TXT de paises
|
||||
pais.separador=,
|
||||
@@ -34,11 +34,11 @@ public class GestorMapaMundi {
|
||||
}
|
||||
|
||||
// METODOS PARA LA ENCAPSULACION DEL DAO
|
||||
|
||||
private Pais obtenerPaisPorIdentificador(int identificador) {
|
||||
Pais pais = null;
|
||||
|
||||
IPaisDAO paisDAO = new PaisDaoText();
|
||||
IContinenteDAO continenteDAO = new ContinenteDaoCsv();
|
||||
IPaisDAO paisDAO = new PaisDaoText(continenteDAO);
|
||||
pais = paisDAO.obtenerPaisPorID(identificador);
|
||||
|
||||
return pais;
|
||||
@@ -47,7 +47,8 @@ public class GestorMapaMundi {
|
||||
private List<Pais> obtenerListaPaisesPorContinente(String codContinente) {
|
||||
List<Pais> listaPaises = null;
|
||||
|
||||
IPaisDAO paisDAO = new PaisDaoText();
|
||||
IContinenteDAO continenteDAO = new ContinenteDaoCsv();
|
||||
IPaisDAO paisDAO = new PaisDaoText(continenteDAO);
|
||||
listaPaises = paisDAO.obtenerPaisesPorContinente(codContinente);
|
||||
|
||||
return listaPaises;
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
package org.palomafp.aadd.jaec.config;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Configuracion {
|
||||
|
||||
private static final String RUTA_FICHERO_CONFIGURACION = "application.properties";
|
||||
private static final Properties PROPIEDADES = new Properties();
|
||||
|
||||
// Constructor privado: de esta manera conseguimos que esta clase no se pueda
|
||||
// instanciar
|
||||
private Configuracion() {
|
||||
}
|
||||
|
||||
// Cargamos el fichero de configuracion
|
||||
static {
|
||||
try (InputStream input = new FileInputStream("config/application.properties")) {
|
||||
try (InputStream input = Configuracion.class.getClassLoader().getResourceAsStream(RUTA_FICHERO_CONFIGURACION)) {
|
||||
|
||||
if (input == null) {
|
||||
throw new IOException("No se encuentra " + RUTA_FICHERO_CONFIGURACION + " en el classpath");
|
||||
}
|
||||
|
||||
PROPIEDADES.load(input);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("No se pudo cargar config/application.properties", e);
|
||||
throw new RuntimeException("No se pudo cargar el fichero de configuración", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package org.palomafp.aadd.jaec.dao.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -31,7 +30,9 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
Path ficheroContinentes = Path.of(RUTA_FICHERO);
|
||||
|
||||
if (!Files.exists(ficheroContinentes)) {
|
||||
return null;
|
||||
System.out.println("Directorio de trabajo: " + System.getProperty("user.dir"));
|
||||
System.out.println("Ruta del CSV buscado: " + ficheroContinentes.toAbsolutePath());
|
||||
return listaContinentes;
|
||||
}
|
||||
|
||||
String linea = "";
|
||||
@@ -42,7 +43,6 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
String[] informacion = linea.split(Pattern.quote(SEPARADOR));
|
||||
|
||||
if (informacion.length >= 3) {
|
||||
int anyoContinente = Integer.parseInt(informacion[0].trim());
|
||||
String codigoContinente = informacion[1].trim();
|
||||
String nombreContinente = informacion[2].trim();
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
System.out.println(ioe.getMessage());
|
||||
System.err.println(ioe.getMessage());
|
||||
}
|
||||
|
||||
return listaContinentes;
|
||||
@@ -72,6 +72,8 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
Path ficheroContinentes = Path.of(RUTA_FICHERO);
|
||||
|
||||
if (!Files.exists(ficheroContinentes)) {
|
||||
System.out.println("Directorio de trabajo: " + System.getProperty("user.dir"));
|
||||
System.out.println("Ruta del CSV buscado: " + ficheroContinentes.toAbsolutePath());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -83,7 +85,6 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
String[] informacion = linea.split(Pattern.quote(SEPARADOR));
|
||||
|
||||
if (informacion.length >= 3) {
|
||||
int anyoContinente = Integer.parseInt(informacion[0].trim());
|
||||
String codigoContinente = informacion[1].trim();
|
||||
String nombreContinente = informacion[2].trim();
|
||||
|
||||
@@ -91,13 +92,11 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
continenteEncontrado = new Continente();
|
||||
continenteEncontrado.setCodigo(codigoContinente);
|
||||
continenteEncontrado.setNombre(nombreContinente);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException ioe) {
|
||||
System.err.println(ioe);
|
||||
}
|
||||
@@ -112,6 +111,8 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
Path ficheroContinentes = Path.of(RUTA_FICHERO);
|
||||
|
||||
if (!Files.exists(ficheroContinentes)) {
|
||||
System.out.println("Directorio de trabajo: " + System.getProperty("user.dir"));
|
||||
System.out.println("Ruta del CSV buscado: " + ficheroContinentes.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
bw.write("2026" + SEPARADOR + codContinente + SEPARADOR + nombre);
|
||||
bw.newLine();
|
||||
} catch (IOException ioe) {
|
||||
System.out.println(ioe.getMessage());
|
||||
System.err.println(ioe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +136,8 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
Path ficheroTemporal = Path.of(RUTA_FICHERO_TEMPORAL);
|
||||
|
||||
if (!Files.exists(ficheroContinentes)) {
|
||||
System.out.println("Directorio de trabajo: " + System.getProperty("user.dir"));
|
||||
System.out.println("Ruta del CSV buscado: " + ficheroContinentes.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,9 +156,7 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
String[] informacion = linea.split(Pattern.quote(SEPARADOR));
|
||||
|
||||
if (informacion.length >= 3) {
|
||||
int anyoContinente = Integer.parseInt(informacion[0].trim());
|
||||
String codigoContinente = informacion[1].trim();
|
||||
String nombreContinente = informacion[2].trim();
|
||||
|
||||
if (codContinente.trim().equalsIgnoreCase(codigoContinente)) {
|
||||
continenteEncontrado = new Continente();
|
||||
@@ -166,9 +167,9 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException ioe) {
|
||||
System.err.println(ioe);
|
||||
return;
|
||||
}
|
||||
|
||||
// Por defecto continenteEncontrado es null, pero
|
||||
@@ -199,6 +200,8 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
Path ficheroTemporal = Path.of(RUTA_FICHERO_TEMPORAL);
|
||||
|
||||
if (!Files.exists(ficheroContinentes)) {
|
||||
System.out.println("Directorio de trabajo: " + System.getProperty("user.dir"));
|
||||
System.out.println("Ruta del CSV buscado: " + ficheroContinentes.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -217,9 +220,7 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
String[] informacion = linea.split(Pattern.quote(SEPARADOR));
|
||||
|
||||
if (informacion.length >= 3) {
|
||||
int anyoContinente = Integer.parseInt(informacion[0].trim());
|
||||
String codigoContinente = informacion[1].trim();
|
||||
String nombreContinente = informacion[2].trim();
|
||||
|
||||
if (codContinente.trim().equalsIgnoreCase(codigoContinente)) {
|
||||
continenteEncontrado = new Continente();
|
||||
@@ -237,9 +238,9 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException ioe) {
|
||||
System.err.println(ioe);
|
||||
return;
|
||||
}
|
||||
|
||||
// Por defecto continenteEncontrado es null, pero
|
||||
@@ -259,5 +260,4 @@ public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,11 @@ public class PaisDaoText implements IPaisDAO {
|
||||
private static final String RUTA_FICHERO = Configuracion.get("pais.ruta");
|
||||
private static final String SEPARADOR = Configuracion.get("pais.separador");
|
||||
|
||||
private IContinenteDAO continenteDAO = new ContinenteDaoCsv();
|
||||
private IContinenteDAO continenteDAO;
|
||||
|
||||
public PaisDaoText(IContinenteDAO continenteDAO) {
|
||||
this.continenteDAO = continenteDAO;
|
||||
}
|
||||
|
||||
// Metodo para obtener un List<Pais> con objetos Pais por codigo de Continente
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user