@@ -1,11 +0,0 @@
|
||||
package org.palomafp.dam2.aadd.anp.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.palomafp.dam2.aadd.anp.model.Continente;
|
||||
|
||||
public interface IContinenteDAO {
|
||||
|
||||
Continente obtenerContinente(String codigoContinente);
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.palomafp.dam2.aadd.anp.dao.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.palomafp.dam2.aadd.anp.dao.IContinenteDAO;
|
||||
import org.palomafp.dam2.aadd.anp.model.Continente;
|
||||
|
||||
public class ContinenteDaoCsv implements IContinenteDAO {
|
||||
|
||||
private static final String FICHERO = "C:\\Users\\PC GAMING\\aadd\\fic05\\informacion_continentes.csv";
|
||||
|
||||
@Override
|
||||
public Continente obtenerContinente(String codigoContinente) {
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(FICHERO))) {
|
||||
|
||||
br.readLine();
|
||||
|
||||
String linea;
|
||||
|
||||
while ((linea = br.readLine()) != null) {
|
||||
|
||||
String[] datos = linea.split("#");
|
||||
|
||||
String codigo = datos[1].trim();
|
||||
String nombre = datos[2].trim();
|
||||
|
||||
if (codigo.equals(codigoContinente)) {
|
||||
return new Continente(codigo, nombre);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import org.palomafp.dam2.aadd.anp.model.*;
|
||||
|
||||
public class PaisDaoText implements IPaisDAO {
|
||||
|
||||
private static final String ruta =
|
||||
"C:\\Users\\PC GAMING\\aadd\\fic05\\informacion_paises.txt";
|
||||
|
||||
private static final String ruta = "C:\\Users\\PC GAMING\\aadd\\fic03\\informacion_paises.txt";
|
||||
|
||||
|
||||
@Override
|
||||
public Pais obtenerPais(int identificadorPais) {
|
||||
|
||||
@@ -45,6 +45,8 @@ public class PaisDaoText implements IPaisDAO {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Pais> obtenerPaisesPorContinente(
|
||||
String codigoContinente) {
|
||||
@@ -85,6 +87,8 @@ public class PaisDaoText implements IPaisDAO {
|
||||
return paises;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Pais convertirLineaAPais(String linea) {
|
||||
|
||||
linea = linea.replace("\"", "");
|
||||
@@ -99,11 +103,8 @@ public class PaisDaoText implements IPaisDAO {
|
||||
|
||||
String capital = datos[3].trim();
|
||||
|
||||
// DAO encargado de obtener los datos del continente
|
||||
IContinenteDAO continenteDAO = new ContinenteDaoCsv();
|
||||
|
||||
Continente continente =
|
||||
continenteDAO.obtenerContinente(codigoContinente);
|
||||
new Continente(codigoContinente, nombre);
|
||||
|
||||
return new Pais(
|
||||
id,
|
||||
@@ -112,4 +113,4 @@ public class PaisDaoText implements IPaisDAO {
|
||||
continente
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user