Incluye procesameinto
This commit is contained in:
commit
c88edbbfdb
42
.classpath
Normal file
42
.classpath
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?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">
|
||||||
|
<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 combineaccessrules="false" kind="src" path="/aadd_act5_5"/>
|
||||||
|
<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>aadd_act5_5_ia_swing</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
|
||||||
28
ficheros/contexto_ia_atletas.txt
Normal file
28
ficheros/contexto_ia_atletas.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Actúa como un extractor de datos JSON que, a la vez, es experto en deporte olímpico.
|
||||||
|
Analiza el texto que te van a proporcionar.
|
||||||
|
Devuelve exclusivamente un objeto JSON con esta estructura:
|
||||||
|
{
|
||||||
|
"nombre": "",
|
||||||
|
"apellidos": "",
|
||||||
|
"fecha_nacimiento": "YYYY-MM-DD",
|
||||||
|
"sexo": "H/M",
|
||||||
|
"participaciones": [
|
||||||
|
{
|
||||||
|
"disciplina": {"nombre_diciplina": "",
|
||||||
|
"diciplina_individual": "0/1",
|
||||||
|
}
|
||||||
|
|
||||||
|
"juego": {"nombre": "Ciudad_Juego(en español)",
|
||||||
|
"pais": "País_Organizador(en español)",
|
||||||
|
"anyo": YYYY,
|
||||||
|
"verano": 0/1
|
||||||
|
"mascota":{
|
||||||
|
"nombre": "Nombre_Mascota",
|
||||||
|
"url_imagen": "https://img.olympics.com/images/image/private/xxx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Si la petición no tiene que ver Atletas olímpicos, devuelve un JSON vacío.
|
||||||
|
No escribas nada de texto antes o después del JSON.
|
||||||
5
ficheros/info-atletas.csv
Normal file
5
ficheros/info-atletas.csv
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Nombre|Apellidos|Pais|Fecha_Nacimiento|Observacion
|
||||||
|
Juan|Pérez|España|15-06-1996|Atletismo
|
||||||
|
Yuki|Tanaka|Japón|4-08-1994|Natación
|
||||||
|
Michael|Johnson|Estados Unidos|13-09-1967|Atletismo
|
||||||
|
Lourdes|Pavia|España|22-04-1970|Gimnasia
|
||||||
|
23
pom.xml
Normal file
23
pom.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<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>org.lapaloma.jjoo</groupId>
|
||||||
|
<artifactId>ProyectoJJOO</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/tools.jackson.dataformat/jackson-dataformat-xml -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>tools.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Source: https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.42</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,226 @@
|
|||||||
|
package org.lapaloma.jjoo;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.ButtonGroup;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JRadioButton;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
import org.lapaloma.jjoo.procesamiento.ProcesadorOrigenDatos;
|
||||||
|
|
||||||
|
public class ClienteSwingProcesamientoJJOO extends JFrame {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private JTextArea txtPeticion;
|
||||||
|
private JButton btnEnviar;
|
||||||
|
|
||||||
|
private JRadioButton rbOpcion1;
|
||||||
|
private JRadioButton rbOpcion2;
|
||||||
|
|
||||||
|
private JPanel panelContenido;
|
||||||
|
private JLabel lblAyudaOpcion2;
|
||||||
|
|
||||||
|
public ClienteSwingProcesamientoJJOO() {
|
||||||
|
|
||||||
|
// ================= CONFIGURACIÓN VENTANA =================
|
||||||
|
setTitle("Cliente Swing - Procesamiento de Documentos");
|
||||||
|
setSize(600, 450);
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setLayout(new BorderLayout(10, 10));
|
||||||
|
|
||||||
|
// ================= PANEL NORTE =================
|
||||||
|
JPanel panelNorte = new JPanel();
|
||||||
|
panelNorte.setLayout(new BoxLayout(panelNorte, BoxLayout.Y_AXIS));
|
||||||
|
panelNorte.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10));
|
||||||
|
|
||||||
|
JLabel lblTitulo = new JLabel(
|
||||||
|
"Procesar información sobre Juegos Olímpicos (Juegos-Mascota, Atletas, Disciplinas)");
|
||||||
|
lblTitulo.setFont(new Font("SansSerif", Font.BOLD, 13));
|
||||||
|
lblTitulo.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
|
|
||||||
|
rbOpcion1 = new JRadioButton("Opción 1: Procesar ficheros varios");
|
||||||
|
rbOpcion2 = new JRadioButton("Opción 2: Procesar petición a una IA (Groq)");
|
||||||
|
|
||||||
|
ButtonGroup grupo = new ButtonGroup();
|
||||||
|
grupo.add(rbOpcion1);
|
||||||
|
grupo.add(rbOpcion2);
|
||||||
|
|
||||||
|
rbOpcion1.setSelected(true);
|
||||||
|
|
||||||
|
JPanel panelOpciones = new JPanel();
|
||||||
|
panelOpciones.setLayout(new BoxLayout(panelOpciones, BoxLayout.Y_AXIS));
|
||||||
|
panelOpciones.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
|
|
||||||
|
panelOpciones.add(rbOpcion1);
|
||||||
|
panelOpciones.add(Box.createVerticalStrut(8));
|
||||||
|
|
||||||
|
JSeparator sepOpciones = new JSeparator();
|
||||||
|
sepOpciones.setMaximumSize(new Dimension(Integer.MAX_VALUE, 1));
|
||||||
|
panelOpciones.add(sepOpciones);
|
||||||
|
|
||||||
|
panelOpciones.add(Box.createVerticalStrut(8));
|
||||||
|
panelOpciones.add(rbOpcion2);
|
||||||
|
|
||||||
|
panelNorte.add(lblTitulo);
|
||||||
|
panelNorte.add(Box.createVerticalStrut(30)); // 👈 separación clara y elegante
|
||||||
|
panelNorte.add(panelOpciones);
|
||||||
|
|
||||||
|
|
||||||
|
add(panelNorte, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
// ================= PANEL CONTENIDO (OPCIÓN 2) =================
|
||||||
|
panelContenido = new JPanel(new BorderLayout());
|
||||||
|
panelContenido.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
|
||||||
|
|
||||||
|
lblAyudaOpcion2 = new JLabel("Introduce aquí la petición que se enviará a la IA:");
|
||||||
|
lblAyudaOpcion2.setFont(new Font("SansSerif", Font.ITALIC, 11));
|
||||||
|
lblAyudaOpcion2.setForeground(Color.DARK_GRAY);
|
||||||
|
lblAyudaOpcion2.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 0));
|
||||||
|
|
||||||
|
txtPeticion = new JTextArea();
|
||||||
|
txtPeticion.setLineWrap(true);
|
||||||
|
txtPeticion.setWrapStyleWord(true);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane(txtPeticion);
|
||||||
|
scrollPane.setBorder(BorderFactory.createCompoundBorder(
|
||||||
|
BorderFactory.createEmptyBorder(10, 10, 10, 10),
|
||||||
|
BorderFactory.createLineBorder(Color.GRAY)));
|
||||||
|
|
||||||
|
JPanel panelEjemplo = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
|
JTextArea txtEjemplo = new JTextArea(
|
||||||
|
"Ejemplo: Obtén información completa, precisa y ordenada de atletas que participaron en juegos olímpicos "
|
||||||
|
+ "de las disciplinas Atletismo, Natación y Gimnasia. Incluye hombres y mujeres de distintos juegos.");
|
||||||
|
|
||||||
|
txtEjemplo.setEditable(false);
|
||||||
|
txtEjemplo.setLineWrap(true);
|
||||||
|
txtEjemplo.setWrapStyleWord(true);
|
||||||
|
txtEjemplo.setBackground(getBackground());
|
||||||
|
txtEjemplo.setForeground(new Color(100, 100, 100));
|
||||||
|
txtEjemplo.setFont(new Font("SansSerif", Font.ITALIC, 11));
|
||||||
|
txtEjemplo.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
|
||||||
|
|
||||||
|
JButton btnCopiar = new JButton("📋");
|
||||||
|
btnCopiar.setPreferredSize(new Dimension(50, 30));
|
||||||
|
btnCopiar.setToolTipText("Copiar texto al portapapeles");
|
||||||
|
|
||||||
|
btnCopiar.addActionListener(e -> {
|
||||||
|
copiarAlPortapapeles(txtEjemplo.getText());
|
||||||
|
btnCopiar.setText("✅");
|
||||||
|
new Timer(1500, ev -> btnCopiar.setText("📋")).start();
|
||||||
|
});
|
||||||
|
|
||||||
|
panelEjemplo.add(txtEjemplo, BorderLayout.CENTER);
|
||||||
|
panelEjemplo.add(btnCopiar, BorderLayout.EAST);
|
||||||
|
|
||||||
|
JPanel panelCentral = new JPanel(new BorderLayout());
|
||||||
|
panelCentral.add(scrollPane, BorderLayout.CENTER);
|
||||||
|
panelCentral.add(panelEjemplo, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
panelContenido.add(lblAyudaOpcion2, BorderLayout.NORTH);
|
||||||
|
panelContenido.add(panelCentral, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
add(panelContenido, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// ================= PANEL SUR (ACCIÓN GLOBAL) =================
|
||||||
|
JPanel panelSur = new JPanel();
|
||||||
|
panelSur.setLayout(new BoxLayout(panelSur, BoxLayout.Y_AXIS));
|
||||||
|
panelSur.setBorder(BorderFactory.createEmptyBorder(10, 20, 20, 20));
|
||||||
|
|
||||||
|
JSeparator separator = new JSeparator();
|
||||||
|
separator.setMaximumSize(new Dimension(Integer.MAX_VALUE, 1));
|
||||||
|
|
||||||
|
JPanel panelBoton = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
|
panelBoton.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0));
|
||||||
|
|
||||||
|
btnEnviar = new JButton("Procesar ➤");
|
||||||
|
btnEnviar.setPreferredSize(new Dimension(140, 36));
|
||||||
|
btnEnviar.setBackground(new Color(66, 133, 244));
|
||||||
|
btnEnviar.setForeground(Color.WHITE);
|
||||||
|
btnEnviar.setFocusPainted(false);
|
||||||
|
|
||||||
|
btnEnviar.addActionListener(e -> {
|
||||||
|
if (rbOpcion1.isSelected()) {
|
||||||
|
procesarOpcion1();
|
||||||
|
} else {
|
||||||
|
procesarOpcion2();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
panelBoton.add(btnEnviar);
|
||||||
|
|
||||||
|
panelSur.add(separator);
|
||||||
|
panelSur.add(panelBoton);
|
||||||
|
|
||||||
|
add(panelSur, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
// ================= ESTADO INICIAL =================
|
||||||
|
habilitarComponentes(panelContenido, false);
|
||||||
|
|
||||||
|
rbOpcion1.addActionListener(e -> habilitarComponentes(panelContenido, false));
|
||||||
|
rbOpcion2.addActionListener(e -> habilitarComponentes(panelContenido, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= MÉTODOS AUXILIARES =================
|
||||||
|
|
||||||
|
private void habilitarComponentes(Container container, boolean habilitar) {
|
||||||
|
for (Component c : container.getComponents()) {
|
||||||
|
c.setEnabled(habilitar);
|
||||||
|
if (c instanceof Container) {
|
||||||
|
habilitarComponentes((Container) c, habilitar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copiarAlPortapapeles(String texto) {
|
||||||
|
StringSelection selection = new StringSelection(texto.replace("Ejemplo: ", ""));
|
||||||
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
clipboard.setContents(selection, selection);
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SwingUtilities.invokeLater(() -> new ClienteSwingProcesamientoJJOO().setVisible(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void procesarOpcion1() {
|
||||||
|
System.out.println("Procesando Opción 1 (ficheros)");
|
||||||
|
|
||||||
|
// La información de los datos origen para esta opción
|
||||||
|
// se añadirá al fichero juegos.conf
|
||||||
|
ProcesadorOrigenDatos procesador = new ProcesadorOrigenDatos();
|
||||||
|
procesador.procesarDatos();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void procesarOpcion2() {
|
||||||
|
System.out.println("Procesando Opción 2: " + txtPeticion.getText());
|
||||||
|
// La información de los datos origen para esta opción
|
||||||
|
// está configurada en el fichero juegos.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* GestorFicheroConfiguracion: clase utilitaria para leer propiedades del archivo application.properties.
|
||||||
|
* Provee un método estático que devuelve el valor asociado a una clave.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
* @date 25 nov 2025
|
||||||
|
*/
|
||||||
|
package org.lapaloma.jjoo.gestores;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class GestorFicheroConfiguracionProcesamiento {
|
||||||
|
private static final Properties PROPIEDADES = new Properties();
|
||||||
|
|
||||||
|
static {
|
||||||
|
try (InputStream is = GestorFicheroConfiguracionProcesamiento.class.getClassLoader()
|
||||||
|
.getResourceAsStream("juegos.conf")) {
|
||||||
|
if (is != null) {
|
||||||
|
PROPIEDADES.load(is);
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("No se encontró application.properties en el classpath");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException("Error al cargar application.properties", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene el valor asociado a la clave especificada.
|
||||||
|
*
|
||||||
|
* @param clave la clave a buscar
|
||||||
|
* @return el valor o {@code null} si no existe
|
||||||
|
*/
|
||||||
|
public static String obtenerValor(String clave) {
|
||||||
|
return PROPIEDADES.getProperty(clave);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,237 @@
|
|||||||
|
package org.lapaloma.jjoo.procesamiento;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.IAtleta;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.IAtletaDisciplinaJuego;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.IDisciplina;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.IJuegoOlimpico;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.IMascota;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.hbnt.AtletaDisciplinaJuegoDaoHibernate;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.hbnt.DisciplinaDaoHibernate;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.hbnt.JuegoOlimpicoDaoHibernate;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.hbnt.MascotaDaoHibernate;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.jdbc.AtletaDaoJDBC;
|
||||||
|
import org.coi.juegosolimpicos.inm.dao.mngbd.DisciplinaDaoMongoDB;
|
||||||
|
import org.coi.juegosolimpicos.inm.excepcion.JuegosOlimpicosExcepcion;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.Atleta;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.AtletaDisciplinaJuego;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.AtletaDisciplinaJuego.AtletaDisciplinaJuegoID;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.Disciplina;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.JuegoOlimpico;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.Mascota;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.Sexo;
|
||||||
|
import org.lapaloma.jjoo.gestores.GestorFicheroConfiguracionProcesamiento;
|
||||||
|
import org.lapaloma.jjoo.procesamiento.json.GestorFicheroJSONJuegoMascota;
|
||||||
|
import org.lapaloma.jjoo.util.UtilidadesJuegosOlimpicos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* ProcesadorOrigenDatos: Clase que realiza ....
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
* @date 20 feb 2026
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProcesadorOrigenDatos {
|
||||||
|
|
||||||
|
public void procesarDatos() {
|
||||||
|
try {
|
||||||
|
// Realizar el tratamiento de disciplinas olímpicas
|
||||||
|
tratarDisciplinasOlimpicas();
|
||||||
|
|
||||||
|
// Realizar el tratamiento de la URL con informaión de Juegos Olímpicos y
|
||||||
|
// Mascotas
|
||||||
|
tratarJSONJuegosMascotas();
|
||||||
|
|
||||||
|
// Alta de un atleta
|
||||||
|
crearAtletasCSV();
|
||||||
|
|
||||||
|
// Asignar un atleta a una disciplina y un juego Olímpico concreto (indicando un
|
||||||
|
// puesto de competición)
|
||||||
|
asignarAtletaDisciplinaJuego();
|
||||||
|
} catch (JuegosOlimpicosExcepcion e) {
|
||||||
|
String mensajeError = "Error en la clase %s al realizar una operación de %s";
|
||||||
|
String operacion = "Operación desconocida";
|
||||||
|
int codigoError = e.getCodigoError();
|
||||||
|
switch (codigoError) {
|
||||||
|
case JuegosOlimpicosExcepcion.ERROR_GESTION_CONEXION:
|
||||||
|
operacion = "Gestión de Conexión";
|
||||||
|
break;
|
||||||
|
case JuegosOlimpicosExcepcion.ERROR_CONSULTA:
|
||||||
|
operacion = "Consulta";
|
||||||
|
break;
|
||||||
|
case JuegosOlimpicosExcepcion.ERROR_INSERCION:
|
||||||
|
operacion = "Inserción";
|
||||||
|
break;
|
||||||
|
case JuegosOlimpicosExcepcion.ERROR_BORRADO:
|
||||||
|
operacion = "Borrado";
|
||||||
|
break;
|
||||||
|
case JuegosOlimpicosExcepcion.ERROR_ACTUALIZACION:
|
||||||
|
operacion = "Actualización";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mensajeError = String.format(mensajeError, e.getClaseOrigen().getName(), operacion);
|
||||||
|
System.err.println(mensajeError);
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tratarDisciplinasOlimpicas() throws JuegosOlimpicosExcepcion {
|
||||||
|
// Consultar disciplinas en MongoDB
|
||||||
|
IDisciplina iDisciplina = new DisciplinaDaoMongoDB();
|
||||||
|
List<Disciplina> listaDisciplinas = iDisciplina.obtenerListaDisciplinas();
|
||||||
|
System.out.println(listaDisciplinas);
|
||||||
|
|
||||||
|
// Crear Disciplinas en MySQL
|
||||||
|
if (listaDisciplinas.size() != 0) {
|
||||||
|
iDisciplina = new DisciplinaDaoHibernate();
|
||||||
|
for (Disciplina disciplina : listaDisciplinas) {
|
||||||
|
Disciplina discC = iDisciplina.obtenerDisciplinaPorCodigo(disciplina.getCodigo());
|
||||||
|
if (discC == null)
|
||||||
|
iDisciplina.crearDisciplina(disciplina);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tratarJSONJuegosMascotas() throws JuegosOlimpicosExcepcion {
|
||||||
|
IJuegoOlimpico iJuegoOlimpico = null;
|
||||||
|
IMascota iMascota = null;
|
||||||
|
GestorFicheroJSONJuegoMascota gestorFicheroJSON = new GestorFicheroJSONJuegoMascota();
|
||||||
|
List<JuegoOlimpico> listaJuegos = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
listaJuegos = gestorFicheroJSON.obtenerListaJuegoMascota();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listaJuegos != null) {
|
||||||
|
iJuegoOlimpico = new JuegoOlimpicoDaoHibernate();
|
||||||
|
iMascota = new MascotaDaoHibernate();
|
||||||
|
for (JuegoOlimpico juegoOlimpico : listaJuegos) {
|
||||||
|
Mascota mascotaBBDD = iMascota.obtenerMascotaPorId(juegoOlimpico.getMascotaJuego().getIdentificador());
|
||||||
|
// Si no existe Mascota en la Base de datos se crea.
|
||||||
|
if (mascotaBBDD == null)
|
||||||
|
iMascota.crearMascota(juegoOlimpico.getMascotaJuego());
|
||||||
|
|
||||||
|
JuegoOlimpico juegoBBDD = iJuegoOlimpico.obtenerJuegoOlimpicoPorCodigo(juegoOlimpico.getCodigo());
|
||||||
|
// Si no existe JuegoOlimpico en la Base de datos se crea.
|
||||||
|
if (juegoBBDD == null)
|
||||||
|
iJuegoOlimpico.crearJuegoOlimpico(juegoOlimpico);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void crearAtletasCSV() throws JuegosOlimpicosExcepcion {
|
||||||
|
String rutaFicheroCSV = GestorFicheroConfiguracionProcesamiento.obtenerValor("ruta.fichero.atletas.csv");
|
||||||
|
|
||||||
|
try (BufferedReader br = new BufferedReader(new FileReader(rutaFicheroCSV))) {
|
||||||
|
String linea;
|
||||||
|
|
||||||
|
// Saltar cabecera
|
||||||
|
br.readLine();
|
||||||
|
|
||||||
|
IAtleta iAtleta = new AtletaDaoJDBC();
|
||||||
|
while ((linea = br.readLine()) != null) {
|
||||||
|
|
||||||
|
String[] partes = linea.split("\\|");
|
||||||
|
String nombreAtleta = partes[0];
|
||||||
|
String apellidosAtleta = partes[1];
|
||||||
|
String fechaNacimiento = partes[3];
|
||||||
|
|
||||||
|
Atleta atletaBBDD = iAtleta.obtenerAtletaPorNombreApellidos(nombreAtleta, apellidosAtleta);
|
||||||
|
// Si no existe información en la Base de datos.
|
||||||
|
if (atletaBBDD == null) {
|
||||||
|
Atleta atleta = new Atleta();
|
||||||
|
atleta.setNombre(nombreAtleta);
|
||||||
|
atleta.setApellidos(apellidosAtleta);
|
||||||
|
atleta.setFechaNacimiento(UtilidadesJuegosOlimpicos.parsearFecha(fechaNacimiento, "d-M-yyyy"));
|
||||||
|
// Asignar un sexo aleatorio (no venía en el CSV).
|
||||||
|
// Lo suyo es preguntar al usuario, pero así se pudede "jugar" con asignación aleatoriamente.
|
||||||
|
Sexo sexo = Math.random() < 0.5 ? Sexo.H :Sexo.M;
|
||||||
|
atleta.setSexo(sexo);
|
||||||
|
|
||||||
|
iAtleta.crearAtleta(atleta);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void asignarAtletaDisciplinaJuego() throws JuegosOlimpicosExcepcion {
|
||||||
|
System.out.println("#############################################");
|
||||||
|
System.out.println("Se van a asignar un Atleta a una Disciplina e un Juego Olímpico:");
|
||||||
|
System.out.println("#############################################");
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
|
// Introducir el nombre del Atleta
|
||||||
|
System.out.println("Introducir el Identificador del Atleta");
|
||||||
|
String sIDAtleta = sc.nextLine();
|
||||||
|
int idAtleta = Integer.parseInt(sIDAtleta);
|
||||||
|
// Introducir el identificador de la Disciplina
|
||||||
|
System.out.println("Introducir el código de Disciplina: ");
|
||||||
|
String codigoDisciplina = sc.nextLine();
|
||||||
|
|
||||||
|
// Introducir el código de Juego Olímpico.
|
||||||
|
System.out.println("Introducir el código de Juego Olímpico: ");
|
||||||
|
String codigoJuego = sc.nextLine();
|
||||||
|
|
||||||
|
// Introducir el código de Juego Olímpico.
|
||||||
|
System.out.println("Introducir el puesto en la competición: ");
|
||||||
|
String sPuestoCompeticion = sc.nextLine();
|
||||||
|
int puestoCompeticion = Integer.parseInt(sPuestoCompeticion);
|
||||||
|
|
||||||
|
AtletaDisciplinaJuego atletaDisciplinaJuego = null;
|
||||||
|
// Comprobar existe Atleta
|
||||||
|
IAtleta iAtleta = new AtletaDaoJDBC();
|
||||||
|
Atleta atleta = iAtleta.obtenerAtletaPorID(idAtleta);
|
||||||
|
// Comprobar existe Disciplina
|
||||||
|
IDisciplina iDisciplina = new DisciplinaDaoHibernate();
|
||||||
|
Disciplina disciplina = iDisciplina.obtenerDisciplinaPorCodigo(codigoDisciplina);
|
||||||
|
// Comprobar existe Juego
|
||||||
|
IJuegoOlimpico iJuegoOlimpico = new JuegoOlimpicoDaoHibernate();
|
||||||
|
JuegoOlimpico juego = iJuegoOlimpico.obtenerJuegoOlimpicoPorCodigo(codigoJuego);
|
||||||
|
// Cuando se ha validado que existen los 3 por separado (Atleta-Diciplina-Juego)
|
||||||
|
// se inserta
|
||||||
|
if (juego != null && disciplina != null && juego != null) {
|
||||||
|
IAtletaDisciplinaJuego iAtletaDisciplinaJuego = new AtletaDisciplinaJuegoDaoHibernate();
|
||||||
|
AtletaDisciplinaJuegoID identificadorADJ = new AtletaDisciplinaJuegoID(idAtleta, codigoDisciplina,
|
||||||
|
codigoJuego);
|
||||||
|
atletaDisciplinaJuego = iAtletaDisciplinaJuego.obtenerAtletaDisciplinaJuegoPorId(identificadorADJ);
|
||||||
|
if (atletaDisciplinaJuego == null) {
|
||||||
|
atletaDisciplinaJuego = new AtletaDisciplinaJuego();
|
||||||
|
atletaDisciplinaJuego.setIdAtletaDisciplinaJuego(identificadorADJ);
|
||||||
|
atletaDisciplinaJuego.setAtleta(atleta);
|
||||||
|
atletaDisciplinaJuego.setDisciplina(disciplina);
|
||||||
|
atletaDisciplinaJuego.setJuego(juego);
|
||||||
|
atletaDisciplinaJuego.setPuestoCompeticion(puestoCompeticion);
|
||||||
|
iAtletaDisciplinaJuego.crearAtletaDisciplinaJuego(atletaDisciplinaJuego);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Imprimir los valores
|
||||||
|
System.out.println("Informacion del atleta-diciplina-competición: " + atletaDisciplinaJuego);
|
||||||
|
|
||||||
|
sc.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.lapaloma.jjoo.procesamiento.json;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.JuegoOlimpico;
|
||||||
|
import org.coi.juegosolimpicos.inm.vo.Mascota;
|
||||||
|
import org.lapaloma.jjoo.gestores.GestorFicheroConfiguracionProcesamiento;
|
||||||
|
import org.lapaloma.jjoo.util.UtilidadesJuegosOlimpicos;
|
||||||
|
|
||||||
|
import tools.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Isidoro Nevares Martín (IES El Cañaveral)
|
||||||
|
* Fecha: 25 feb 2024
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GestorFicheroJSONJuegoMascota {
|
||||||
|
private final static String URL_JSON="url.juegos.json";
|
||||||
|
private final static String OLIMPIADA_INVIERNO="Invierno";
|
||||||
|
|
||||||
|
|
||||||
|
public List<JuegoOlimpico> obtenerListaJuegoMascota() throws IOException, InterruptedException{
|
||||||
|
List<JuegoOlimpico> listaJuegos=null;
|
||||||
|
String sUrlJSON= GestorFicheroConfiguracionProcesamiento.obtenerValor(URL_JSON);
|
||||||
|
String informacioJSON= UtilidadesJuegosOlimpicos.obtenerStringDeURL(sUrlJSON, StandardCharsets.UTF_8);
|
||||||
|
System.out.println(informacioJSON);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
ListaJuegoJSON listaJuegosJSON = objectMapper.readValue(informacioJSON,ListaJuegoJSON.class );
|
||||||
|
|
||||||
|
// Tratamiento tras gestión del fichero JSON
|
||||||
|
if (listaJuegosJSON!=null && listaJuegosJSON.getLista_juegos().size()>0) {
|
||||||
|
listaJuegos= new ArrayList<JuegoOlimpico>();
|
||||||
|
for (JuegoOlimpicoJSON juegoOlimpicoJSON : listaJuegosJSON.getLista_juegos()) {
|
||||||
|
JuegoOlimpico juego = obtenerJuegoOlimpicoFromJSON(juegoOlimpicoJSON);
|
||||||
|
listaJuegos.add(juego);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listaJuegos;
|
||||||
|
}
|
||||||
|
private JuegoOlimpico obtenerJuegoOlimpicoFromJSON(JuegoOlimpicoJSON juegoJSON) {
|
||||||
|
JuegoOlimpico juego = null;
|
||||||
|
if (juegoJSON!=null) {
|
||||||
|
boolean olimpiadaVerano=true;
|
||||||
|
if (juegoJSON.getTipo()!=null && juegoJSON.getTipo().equals(OLIMPIADA_INVIERNO)){
|
||||||
|
olimpiadaVerano=false;
|
||||||
|
}
|
||||||
|
juego= new JuegoOlimpico();
|
||||||
|
String codigo="J" + juegoJSON.getAnyo()+juegoJSON.getTipo().charAt(0);
|
||||||
|
juego.setCodigo(codigo.toUpperCase());
|
||||||
|
juego.setAnio(juegoJSON.getAnyo());
|
||||||
|
juego.setCiudad(juegoJSON.getCiudad());
|
||||||
|
juego.setPais(juegoJSON.getPais());
|
||||||
|
juego.setEsJuegoVerano(olimpiadaVerano);
|
||||||
|
Mascota mascota = obtenerMascotaFromJSON(juegoJSON.getMascota());
|
||||||
|
juego.setMascotaJuego(mascota);
|
||||||
|
}
|
||||||
|
return juego;
|
||||||
|
}
|
||||||
|
private Mascota obtenerMascotaFromJSON(MascotaJSON mascotaJSON) {
|
||||||
|
Mascota mascota=null;
|
||||||
|
if (mascotaJSON!=null) {
|
||||||
|
mascota= new Mascota();
|
||||||
|
mascota.setNombre(mascotaJSON.getNombre());
|
||||||
|
mascota.setUrlImagen(mascotaJSON.getUrl());
|
||||||
|
byte[] bytesImagen= UtilidadesJuegosOlimpicos.obtenerBytesDeURL(mascotaJSON.getUrl());
|
||||||
|
mascota.setImagen(bytesImagen);
|
||||||
|
}
|
||||||
|
return mascota;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.lapaloma.jjoo.procesamiento.json;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Isidoro Nevares Martín (IES El Cañaveral)
|
||||||
|
* Fecha: 24 feb 2024
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class JuegoOlimpicoJSON implements Serializable{
|
||||||
|
private static final long serialVersionUID = -2198660627534301810L;
|
||||||
|
|
||||||
|
private String codigo;
|
||||||
|
private int anyo;
|
||||||
|
private String ciudad;
|
||||||
|
private String pais;
|
||||||
|
private String tipo;
|
||||||
|
private MascotaJSON mascota;
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.lapaloma.jjoo.procesamiento.json;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Isidoro Nevares Martín (IES El Cañaveral)
|
||||||
|
* Fecha: 24 feb 2024
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ListaJuegoJSON implements Serializable{
|
||||||
|
private static final long serialVersionUID = -4937684627247126196L;
|
||||||
|
|
||||||
|
private List<JuegoOlimpicoJSON> lista_juegos;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.lapaloma.jjoo.procesamiento.json;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Isidoro Nevares Martín (IES El Cañaveral)
|
||||||
|
* Fecha: 24 feb 2024
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MascotaJSON implements Serializable{
|
||||||
|
private static final long serialVersionUID = -4937684627247126196L;
|
||||||
|
|
||||||
|
private int identificador;
|
||||||
|
private String nombre;
|
||||||
|
private String descripcion;
|
||||||
|
private String url;
|
||||||
|
private String creador;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.lapaloma.jjoo.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Isidoro Nevares Martín (IES El Cañaveral) Fecha: 25 feb 2024
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// Información: https://www.techiedelight.com/read-contents-of-url-into-string-java/
|
||||||
|
public class UtilidadesJuegosOlimpicos {
|
||||||
|
|
||||||
|
public static String obtenerStringDeURL(String sUrl, Charset encoding) throws IOException, InterruptedException {
|
||||||
|
String resultado = null;
|
||||||
|
HttpClient client = HttpClient.newHttpClient();
|
||||||
|
|
||||||
|
URI uri = URI.create(sUrl);
|
||||||
|
HttpRequest request = HttpRequest.newBuilder()
|
||||||
|
.uri(uri)
|
||||||
|
.GET()
|
||||||
|
.build();
|
||||||
|
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
|
||||||
|
resultado = response.body();
|
||||||
|
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] obtenerBytesDeURL(String sUrl) {
|
||||||
|
byte[] resultado = null;
|
||||||
|
InputStream is = null;
|
||||||
|
URL url = null;
|
||||||
|
try {
|
||||||
|
url = new URI(sUrl).toURL();
|
||||||
|
is = url.openStream();
|
||||||
|
resultado = is.readAllBytes();
|
||||||
|
|
||||||
|
} catch (URISyntaxException | IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocalDate parsearFecha(String fechaStr, String formato) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formato);
|
||||||
|
|
||||||
|
LocalDate fecha = LocalDate.parse(fechaStr, formatter);
|
||||||
|
return fecha;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/main/resources/juegos.conf
Normal file
13
src/main/resources/juegos.conf
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
# URL en formato JSON con información de los juegos olímpicos y mascotas
|
||||||
|
url.juegos.json=https://dam2.decieloytierra.es/juegos/juegos-olimpicos.json
|
||||||
|
|
||||||
|
# Informacion de Atletas
|
||||||
|
ruta.fichero.atletas.csv=ficheros/info-atletas.csv
|
||||||
|
|
||||||
|
|
||||||
|
# Fichero para la carga de datos de Atletas con IA (GROQ)
|
||||||
|
key.api.proveedor.ia=aquí_va_tu_api_key_de_groq
|
||||||
|
url.api.proveedor.ia=https://api.groq.com/openai/v1/chat/completions
|
||||||
|
model.proveedor.ia=openai/gpt-oss-120b
|
||||||
|
fichero.contexto.ia.atletas=ficheros/contexto_ia_atletas.txt
|
||||||
Loading…
Reference in New Issue
Block a user