Primer commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
continente.ruta.fichero=D:/Documentos/DAM 2/AC - Acceso a Datos/Practicas/aadd/fic10/informacion_continentes.csv
|
||||
continente.csv.separador=#
|
||||
pais.ruta.fichero=D:/Documentos/DAM 2/AC - Acceso a Datos/Practicas/aadd/fic10/informacion_paises.txt
|
||||
pais.txt.separador=,
|
||||
@@ -0,0 +1,209 @@
|
||||
package org.palomafp.aadd.smmb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.palomafp.aadd.smmb.dao.IContinenteDAO;
|
||||
import org.palomafp.aadd.smmb.dao.IPaisDAO;
|
||||
import org.palomafp.aadd.smmb.dao.impl.ContinenteDaoFichero;
|
||||
import org.palomafp.aadd.smmb.dao.impl.PaisDaoFichero;
|
||||
import org.palomafp.aadd.smmb.excepciones.AccesoDatosException;
|
||||
import org.palomafp.aadd.smmb.excepciones.MapaMundiException;
|
||||
import org.palomafp.aadd.smmb.excepciones.TecnicoException;
|
||||
import org.palomafp.aadd.smmb.model.Continente;
|
||||
import org.palomafp.aadd.smmb.model.Pais;
|
||||
|
||||
public class GestorMapaMundi {
|
||||
|
||||
private final IContinenteDAO continenteDao;
|
||||
private final IPaisDAO paisDao;
|
||||
|
||||
public GestorMapaMundi() throws TecnicoException {
|
||||
this.continenteDao = new ContinenteDaoFichero();
|
||||
this.paisDao = new PaisDaoFichero(continenteDao);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
|
||||
GestorMapaMundi gmm = new GestorMapaMundi();
|
||||
String operacion = args[0];
|
||||
|
||||
switch (operacion) {
|
||||
|
||||
case "1": {
|
||||
List<Continente> continentes = gmm.obtenerListaDeContinentes();
|
||||
|
||||
for (Continente c : continentes) {
|
||||
System.out.println(c);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "2": {
|
||||
String codContinente = args[1];
|
||||
Continente continente = gmm.obtenerContinentePorCodigo(codContinente);
|
||||
|
||||
if (continente != null) {
|
||||
System.out.println(continente);
|
||||
} else {
|
||||
System.out.println("No existe ningún continente con el código " + codContinente);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "3": {
|
||||
|
||||
String codContinente = args[1];
|
||||
String nombreContinente = args[2];
|
||||
|
||||
gmm.insertarContinente(codContinente, nombreContinente);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "4": {
|
||||
|
||||
String codContinente = args[1];
|
||||
|
||||
gmm.borrarContinente(codContinente);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "5": {
|
||||
|
||||
String codContinente = args[1];
|
||||
String nombreContinente = args[2];
|
||||
|
||||
gmm.actualizarContinente(codContinente, nombreContinente);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "6": {
|
||||
|
||||
int idPais = Integer.parseInt(args[1]);
|
||||
Pais pais = gmm.obtenerPaisPorId(idPais);
|
||||
|
||||
if (pais != null) {
|
||||
System.out.println(pais);
|
||||
} else {
|
||||
System.out.println("No existe ningún país con el identificador " + idPais);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "7": {
|
||||
|
||||
String codContinente = args[1];
|
||||
List<Pais> paises = gmm.obtenerPaisesPorContinente(codContinente);
|
||||
|
||||
if (paises.isEmpty()) {
|
||||
System.out.println("No se encontraron países para el continente " + codContinente);
|
||||
} else {
|
||||
for (Pais p : paises) {
|
||||
System.out.println(p);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
System.out.println("Operación no válida");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (AccesoDatosException e) {
|
||||
System.err.println("Error de acceso a datos: " + e.getMessage());
|
||||
} catch (TecnicoException e) {
|
||||
System.err.println("Error técnico: " + e.getMessage());
|
||||
} catch (MapaMundiException e) {
|
||||
System.err.println("Error de la aplicación: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Continente obtenerContinentePorCodigo(String codContinente) throws AccesoDatosException {
|
||||
|
||||
return continenteDao.obtenerContinentePorCodigo(codContinente);
|
||||
}
|
||||
|
||||
private List<Continente> obtenerListaDeContinentes() throws AccesoDatosException {
|
||||
|
||||
return continenteDao.obtenerListaContinentes();
|
||||
}
|
||||
|
||||
private void insertarContinente(String codContinente, String nombreContinente) throws AccesoDatosException {
|
||||
|
||||
Continente existe = continenteDao.obtenerContinentePorCodigo(codContinente);
|
||||
|
||||
if (existe == null) {
|
||||
|
||||
Continente continente = new Continente();
|
||||
continente.setCodigo(codContinente);
|
||||
continente.setNombre(nombreContinente);
|
||||
|
||||
continenteDao.insertarContinente(continente);
|
||||
|
||||
System.out.println(nombreContinente + " insertado correctamente");
|
||||
|
||||
} else {
|
||||
System.out.println("El continente ya existe");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void borrarContinente(String codContinente) throws AccesoDatosException {
|
||||
|
||||
Continente existe = continenteDao.obtenerContinentePorCodigo(codContinente);
|
||||
|
||||
if (existe != null) {
|
||||
|
||||
continenteDao.borrarContinente(codContinente);
|
||||
System.out.println("Continente borrado");
|
||||
|
||||
} else {
|
||||
|
||||
System.out.println("El continente no existe");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void actualizarContinente(String codContinente, String nombreContinente) throws AccesoDatosException {
|
||||
|
||||
Continente existe = continenteDao.obtenerContinentePorCodigo(codContinente);
|
||||
|
||||
if (existe != null) {
|
||||
|
||||
Continente continente = new Continente();
|
||||
continente.setCodigo(codContinente);
|
||||
continente.setNombre(nombreContinente);
|
||||
|
||||
continenteDao.actualizarContinente(continente);
|
||||
|
||||
System.out.println("Continente actualizado");
|
||||
} else {
|
||||
|
||||
System.out.println("No existe ningun continente");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<Pais> obtenerPaisesPorContinente(String codContinente) throws AccesoDatosException {
|
||||
|
||||
return paisDao.obtenerPaisesPorContinente(codContinente);
|
||||
}
|
||||
|
||||
private Pais obtenerPaisPorId(int idPais) throws AccesoDatosException {
|
||||
|
||||
return paisDao.obtenerPaisPorID(idPais);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.palomafp.aadd.smmb.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.palomafp.aadd.smmb.excepciones.AccesoDatosException;
|
||||
import org.palomafp.aadd.smmb.model.Continente;
|
||||
|
||||
public interface IContinenteDAO {
|
||||
|
||||
Continente obtenerContinentePorCodigo(String idContinente) throws AccesoDatosException;
|
||||
List<Continente> obtenerListaContinentes() throws AccesoDatosException;
|
||||
void insertarContinente(Continente continente) throws AccesoDatosException;
|
||||
void borrarContinente(String codigoContinente) throws AccesoDatosException;
|
||||
void actualizarContinente(Continente continente) throws AccesoDatosException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.palomafp.aadd.smmb.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.palomafp.aadd.smmb.excepciones.AccesoDatosException;
|
||||
import org.palomafp.aadd.smmb.model.Pais;
|
||||
|
||||
public interface IPaisDAO {
|
||||
|
||||
public Pais obtenerPaisPorID(int idPais) throws AccesoDatosException;
|
||||
public List<Pais> obtenerPaisesPorContinente(String codContinente) throws AccesoDatosException;
|
||||
void insertarPais(Pais pais) throws AccesoDatosException;
|
||||
void borrarPais(int idPais) throws AccesoDatosException;
|
||||
void actualizarPais(Pais pais) throws AccesoDatosException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package org.palomafp.aadd.smmb.dao.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.palomafp.aadd.smmb.dao.IContinenteDAO;
|
||||
import org.palomafp.aadd.smmb.excepciones.AccesoDatosException;
|
||||
import org.palomafp.aadd.smmb.excepciones.TecnicoException;
|
||||
import org.palomafp.aadd.smmb.gestores.GestorConfiguracion;
|
||||
import org.palomafp.aadd.smmb.model.Continente;
|
||||
|
||||
public class ContinenteDaoFichero implements IContinenteDAO {
|
||||
|
||||
private final String ficheroContinentes;
|
||||
private final String separador;
|
||||
|
||||
public ContinenteDaoFichero() throws TecnicoException {
|
||||
this.ficheroContinentes = GestorConfiguracion.getRutaFicheroContinente();
|
||||
this.separador = GestorConfiguracion.getSeparadorCsvFicheroContinente();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Continente> obtenerListaContinentes() throws AccesoDatosException {
|
||||
|
||||
List<Continente> continentes = new ArrayList<>();
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(ficheroContinentes))) {
|
||||
|
||||
br.readLine();
|
||||
|
||||
String linea = "";
|
||||
|
||||
while ((linea = br.readLine()) != null) {
|
||||
|
||||
if (!linea.trim().isEmpty()) {
|
||||
|
||||
String[] campos = linea.split(separador);
|
||||
String codContinente = campos[1].trim();
|
||||
String nombre = campos[2].trim();
|
||||
|
||||
continentes.add(construirContinente(codContinente, nombre));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error leyendo el fichero de continentes", e);
|
||||
}
|
||||
|
||||
return continentes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Continente obtenerContinentePorCodigo(String codigo) throws AccesoDatosException {
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(ficheroContinentes))) {
|
||||
|
||||
br.readLine();
|
||||
|
||||
String linea = "";
|
||||
|
||||
while ((linea = br.readLine()) != null) {
|
||||
|
||||
if (!linea.trim().isEmpty()) {
|
||||
|
||||
String[] campos = linea.split(separador);
|
||||
|
||||
String codContinente = campos[1].trim();
|
||||
|
||||
if (codContinente.equals(codigo)) {
|
||||
|
||||
String nombre = campos[2].trim();
|
||||
|
||||
return construirContinente(codContinente, nombre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error leyendo el fichero de continentes", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertarContinente(Continente continente) throws AccesoDatosException {
|
||||
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(ficheroContinentes, true))) {
|
||||
|
||||
String linea = "2026" + separador + continente.getCodigo() + separador + continente.getNombre();
|
||||
|
||||
bw.newLine();
|
||||
bw.write(linea);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error escribiendo en el fichero de continentes", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void borrarContinente(String codigoContinente) throws AccesoDatosException {
|
||||
|
||||
List<Continente> continentes = obtenerListaContinentes();
|
||||
String cabecera = leerCabecera();
|
||||
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(ficheroContinentes))) {
|
||||
|
||||
bw.write(cabecera);
|
||||
|
||||
for (Continente c : continentes) {
|
||||
|
||||
if (!c.getCodigo().equals(codigoContinente)) {
|
||||
|
||||
bw.newLine();
|
||||
bw.write("2026" + separador + c.getCodigo() + separador + c.getNombre());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error escribiendo en el fichero de continentes", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actualizarContinente(Continente continente) throws AccesoDatosException {
|
||||
|
||||
List<Continente> continentes = obtenerListaContinentes();
|
||||
String cabecera = leerCabecera();
|
||||
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(ficheroContinentes))) {
|
||||
|
||||
bw.write(cabecera);
|
||||
|
||||
for (Continente c : continentes) {
|
||||
|
||||
if (c.getCodigo().equals(continente.getCodigo())) {
|
||||
c.setNombre(continente.getNombre());
|
||||
}
|
||||
|
||||
bw.newLine();
|
||||
bw.write("2026" + separador + c.getCodigo() + separador + c.getNombre());
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error escribiendo en el fichero de continentes", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String leerCabecera() throws AccesoDatosException {
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(ficheroContinentes))) {
|
||||
|
||||
return br.readLine();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error leyendo la cabecera del fichero de continentes", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Continente construirContinente(String codContinente, String nombre) {
|
||||
|
||||
Continente continente = new Continente();
|
||||
|
||||
continente.setCodigo(codContinente);
|
||||
continente.setNombre(nombre);
|
||||
|
||||
return continente;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package org.palomafp.aadd.smmb.dao.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.palomafp.aadd.smmb.dao.IContinenteDAO;
|
||||
import org.palomafp.aadd.smmb.dao.IPaisDAO;
|
||||
import org.palomafp.aadd.smmb.excepciones.AccesoDatosException;
|
||||
import org.palomafp.aadd.smmb.excepciones.TecnicoException;
|
||||
import org.palomafp.aadd.smmb.gestores.GestorConfiguracion;
|
||||
import org.palomafp.aadd.smmb.model.Continente;
|
||||
import org.palomafp.aadd.smmb.model.Pais;
|
||||
|
||||
public class PaisDaoFichero implements IPaisDAO {
|
||||
|
||||
private final String ficheroPaises;
|
||||
private final String separador;
|
||||
private final IContinenteDAO continenteDao;
|
||||
|
||||
public PaisDaoFichero(IContinenteDAO continenteDao) throws TecnicoException {
|
||||
this.ficheroPaises = GestorConfiguracion.getRutaFicheroPais();
|
||||
this.separador = GestorConfiguracion.getSeparadorTxtFicheroPais();
|
||||
this.continenteDao = continenteDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pais obtenerPaisPorID(int idPais) throws AccesoDatosException {
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(ficheroPaises))) {
|
||||
|
||||
String linea = "";
|
||||
|
||||
while ((linea = br.readLine()) != null) {
|
||||
|
||||
if (esLineaValida(linea)) {
|
||||
|
||||
Pais pais = parsearLinea(linea);
|
||||
|
||||
if (pais.getIdentificador() == idPais) {
|
||||
return pais;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error leyendo el fichero de países", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pais> obtenerPaisesPorContinente(String codContinente) throws AccesoDatosException {
|
||||
|
||||
List<Pais> paises = new ArrayList<>();
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(ficheroPaises))) {
|
||||
|
||||
String linea = "";
|
||||
|
||||
while ((linea = br.readLine()) != null) {
|
||||
|
||||
if (esLineaValida(linea)) {
|
||||
|
||||
Pais pais = parsearLinea(linea);
|
||||
|
||||
if (pais.getContinente().getCodigo().equals(codContinente)) {
|
||||
paises.add(pais);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new AccesoDatosException("Error leyendo el fichero de países", e);
|
||||
}
|
||||
|
||||
return paises;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertarPais(Pais pais) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void borrarPais(int idPais) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actualizarPais(Pais pais) {
|
||||
}
|
||||
|
||||
private boolean esLineaValida(String linea) {
|
||||
String limpia = linea.trim();
|
||||
|
||||
boolean vacia = limpia.isEmpty();
|
||||
boolean comentario = limpia.startsWith("#");
|
||||
|
||||
return !vacia && !comentario;
|
||||
}
|
||||
|
||||
private Pais parsearLinea(String linea) throws AccesoDatosException {
|
||||
|
||||
String[] campos = linea.split(separador);
|
||||
|
||||
if (campos.length < 4) {
|
||||
throw new AccesoDatosException("Línea de país no válida: " + linea);
|
||||
}
|
||||
|
||||
String codContinente = campos[0].trim().replace("\"", "");
|
||||
int identificador;
|
||||
|
||||
try {
|
||||
identificador = Integer.parseInt(campos[1].trim());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new AccesoDatosException("Identificador de país no válido en la línea: " + linea, e);
|
||||
}
|
||||
|
||||
String nombre = campos[2].trim().replace("\"", "");
|
||||
String capital = campos[3].trim().replace("\"", "");
|
||||
|
||||
Continente continente = continenteDao.obtenerContinentePorCodigo(codContinente);
|
||||
|
||||
if (continente == null) {
|
||||
throw new AccesoDatosException("El país " + identificador + " (" + nombre
|
||||
+ ") referencia un continente que no existe: " + codContinente);
|
||||
}
|
||||
|
||||
Pais pais = new Pais();
|
||||
pais.setIdentificador(identificador);
|
||||
pais.setNombre(nombre);
|
||||
pais.setNombreCapital(capital);
|
||||
pais.setContinente(continente);
|
||||
|
||||
return pais;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.palomafp.aadd.smmb.excepciones;
|
||||
|
||||
public class AccesoDatosException extends TecnicoException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AccesoDatosException(String mensaje) {
|
||||
super(mensaje);
|
||||
}
|
||||
public AccesoDatosException(String mensaje, Throwable causa) {
|
||||
super(mensaje, causa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.palomafp.aadd.smmb.excepciones;
|
||||
|
||||
public class MapaMundiException extends Exception{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Constructor protegido en clase abstracta
|
||||
// Conseguimos que esta clase no se puede "instanciar directamente", solo a través de sus subclases.
|
||||
protected MapaMundiException(String mensaje) {
|
||||
super(mensaje);
|
||||
}
|
||||
|
||||
// Constructor protegido en clase abstracta
|
||||
protected MapaMundiException(String mensaje, Throwable causa) {
|
||||
super(mensaje, causa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.palomafp.aadd.smmb.excepciones;
|
||||
|
||||
public class NegocioException extends MapaMundiException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Constructor con mensaje como parámetro.
|
||||
public NegocioException(String mensaje) {
|
||||
super(mensaje);
|
||||
}
|
||||
|
||||
// No se incluye el constructor con Throwable; se asume que una excepción de negocio
|
||||
// no viene de otro error.
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.palomafp.aadd.smmb.excepciones;
|
||||
|
||||
public class TecnicoException extends MapaMundiException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Error de tipo "técnico" que no está asociado a una excepción concreta.
|
||||
public TecnicoException(String mensaje) {
|
||||
super(mensaje);
|
||||
}
|
||||
|
||||
public TecnicoException(String mensaje, Throwable causa) {
|
||||
super(mensaje, causa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.palomafp.aadd.smmb.gestores;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.palomafp.aadd.smmb.excepciones.TecnicoException;
|
||||
|
||||
public class GestorConfiguracion {
|
||||
|
||||
private static final String RUTA_FICHERO_CONFIGURACION = "application.properties";
|
||||
private static final Properties PROPIEDADES = new Properties();
|
||||
private static boolean cargado = false;
|
||||
|
||||
private GestorConfiguracion() {
|
||||
}
|
||||
|
||||
private static void cargarPropiedades() throws TecnicoException {
|
||||
|
||||
if (cargado) {
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream is = GestorConfiguracion.class.getClassLoader()
|
||||
.getResourceAsStream(RUTA_FICHERO_CONFIGURACION)) {
|
||||
|
||||
if (is == null) {
|
||||
throw new TecnicoException(
|
||||
"No se ha encontrado el fichero de configuración: " + RUTA_FICHERO_CONFIGURACION);
|
||||
}
|
||||
|
||||
PROPIEDADES.load(is);
|
||||
cargado = true;
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new TecnicoException("No se ha podido cargar el fichero de configuración", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRutaFicheroContinente() throws TecnicoException {
|
||||
cargarPropiedades();
|
||||
return PROPIEDADES.getProperty("continente.ruta.fichero");
|
||||
}
|
||||
|
||||
public static String getSeparadorCsvFicheroContinente() throws TecnicoException {
|
||||
cargarPropiedades();
|
||||
return PROPIEDADES.getProperty("continente.csv.separador", "#");
|
||||
}
|
||||
|
||||
public static String getRutaFicheroPais() throws TecnicoException {
|
||||
cargarPropiedades();
|
||||
return PROPIEDADES.getProperty("pais.ruta.fichero");
|
||||
}
|
||||
|
||||
public static String getSeparadorTxtFicheroPais() throws TecnicoException {
|
||||
cargarPropiedades();
|
||||
return PROPIEDADES.getProperty("pais.txt.separador", ",");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.palomafp.aadd.smmb.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Continente implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String codigo;
|
||||
private String nombre;
|
||||
|
||||
public Continente() {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.nombre + " (" + this.codigo + ")";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.palomafp.aadd.smmb.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Pais implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int identificador;
|
||||
private String nombre;
|
||||
private String nombreCapital;
|
||||
private Continente continente;
|
||||
|
||||
public Pais() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 String getNombreCapital() {
|
||||
return nombreCapital;
|
||||
}
|
||||
public void setNombreCapital(String capital) {
|
||||
this.nombreCapital = capital;
|
||||
}
|
||||
|
||||
public void setContinente(Continente continente) {
|
||||
this.continente = continente;
|
||||
}
|
||||
public Continente getContinente() {
|
||||
return continente;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.nombre + " (" + this.identificador + ") con capital en " + this.nombreCapital +
|
||||
" pertenece al continente " + this.continente;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user