Commit Inicial

This commit is contained in:
Isidoro Nevares Martín 2026-01-27 12:34:10 +01:00
commit db86b06769
10 changed files with 333 additions and 0 deletions

41
.classpath Normal file
View 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">
<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
View File

@ -0,0 +1,3 @@
/bin/
*.class
/target/

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>aadd_act4_4_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>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

2
config/config.properties Normal file
View File

@ -0,0 +1,2 @@
url.proyectosies.ingresos=https://proylapaloma.decieloytierra.es/api/ingresos/proyecto/$id_proyecto/curso/$cod_curso
url.proyectosies.gastos=https://proylapaloma.decieloytierra.es/api/gastos/proyecto/$id_proyecto/curso/$cod_curso

23
pom.xml Normal file
View 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>aadd_act4_4_swing</groupId>
<artifactId>aadd_act4_4_swing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
<!-- Httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,181 @@
package org.lapaloma.gui.proyectos;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.lapaloma.gui.proyectos.gestor.GestorFicheroConfiguracion;
public class AppProyectosIESSwing {
// Clase interna para representar el objetos con Clave y Valor (para curso y
// proyecto)
static class ClaseClaveValor {
private String codigo;
private String nombre;
public ClaseClaveValor(String nombre, String codigo) {
this.nombre = nombre;
this.codigo = codigo;
}
public String getNombre() {
return nombre;
}
public String getCodigo() {
return codigo;
}
@Override
public String toString() {
// Esto define cómo se mostrará en el JComboBox
return nombre;
}
}
public static void main(String[] args) {
// Crear la ventana principal
JFrame frame = new JFrame("Selección de Curso y Proyecto");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Establecer el tamaño de la ventana a 600x400 píxeles
frame.setSize(600, 400);
// Centrar la ventana en la pantalla
frame.setLocationRelativeTo(null);
// Configurar el layout del frame
frame.setLayout(new BorderLayout());
// Crear panel para los JComboBox (Curso y Proyecto)
JPanel panelComboBoxes = new JPanel();
panelComboBoxes.setLayout(new GridBagLayout()); // Usar GridBagLayout para mayor control de los márgenes
GridBagConstraints gbc = new GridBagConstraints();
// Crear los cursos con su nombre y código
ArrayList<ClaseClaveValor> cursosAcademicos = new ArrayList<>();
cursosAcademicos.add(new ClaseClaveValor("Curso 2022/2023", "2022-2023"));
cursosAcademicos.add(new ClaseClaveValor("Curso 2023/2024", "2023-2024"));
// Crear JComboBox para cursos académicos usando los objetos Curso
JComboBox<ClaseClaveValor> comboCursos = new JComboBox<>(cursosAcademicos.toArray(new ClaseClaveValor[0]));
comboCursos.setPreferredSize(new Dimension(150, 25));
// Crear los proyectos con su nombre y código
ArrayList<ClaseClaveValor> proyectos = new ArrayList<>();
proyectos.add(new ClaseClaveValor("Hiperbaric", "1"));
proyectos.add(new ClaseClaveValor("EcoMotors", "2"));
proyectos.add(new ClaseClaveValor("Speedster", "3"));
// Crear JComboBox para proyectos usando los objetos Proyecto
JComboBox<ClaseClaveValor> comboProyectos = new JComboBox<>(proyectos.toArray(new ClaseClaveValor[0]));
comboProyectos.setPreferredSize(new Dimension(150, 25));
// Establecer los márgenes entre los componentes con GridBagConstraints
gbc.insets = new Insets(15, 0, 15, 0); // Espacio de 15px entre filas
// Añadir componentes al panel con GridBagLayout
gbc.gridx = 0;
gbc.gridy = 0;
panelComboBoxes.add(new JLabel("Curso Académico: "), gbc);
gbc.gridx = 1;
panelComboBoxes.add(comboCursos, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
panelComboBoxes.add(new JLabel(" Proyecto: "), gbc);
gbc.gridx = 1;
panelComboBoxes.add(comboProyectos, gbc);
// Crear panel para el botón y centrarlo
JPanel panelBoton = new JPanel();
panelBoton.setLayout(new FlowLayout(FlowLayout.CENTER)); // Centrar el botón
// Crear botón "Migrar a MongoDB"
JButton botonMigrar = new JButton("Procesar URL -> ObjectDB");
// Añadir ActionListener al botón
botonMigrar.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Obtener el curso y el proyecto seleccionados
String codigoProyecto = ((ClaseClaveValor) comboProyectos.getSelectedItem()).getCodigo();
String codigoCursoSeleccionado = ((ClaseClaveValor) comboCursos.getSelectedItem()).getCodigo();
// Cargar los ingresos del proyecto IES a ObjectDB
cargarIngresosProyectoIESObjectDB(codigoProyecto, codigoCursoSeleccionado);
// Cargar los gastos del proyecto IES a ObjectDB
cargarGastosProyectoIESObjectDB(codigoProyecto, codigoCursoSeleccionado);
}
});
// Añadir el botón al panel
panelBoton.add(botonMigrar);
// Añadir los paneles al frame
frame.add(panelComboBoxes, BorderLayout.CENTER); // Panel con los JComboBox en el centro
frame.add(panelBoton, BorderLayout.SOUTH); // Panel con el botón en la parte inferior
// Hacer visible la ventana
frame.setVisible(true);
}
private static void cargarIngresosProyectoIESObjectDB(String codigoProyecto, String codigoCurso) {
System.out.println("Inicio proceso de carga de INGRESOS en ObjectDB.");
// Obtener el endpoint URL desde el fichero de configuración
String urlPeticionIngresos = GestorFicheroConfiguracion.getValorfromClave("url.proyectosies.ingresos");
System.out.println(urlPeticionIngresos);
// Procesar la petición HTTP y cargar los datos de INGRESOS en ObjectDB
System.out.println("Fin proceso de carga de INGRESOS en ObjectDB.\n");
}
private static void cargarGastosProyectoIESObjectDB(String codigoProyecto, String codigoCurso) {
// Procesar la petición HTTP y cargar los datos de GASTOS en ObjectDB
System.out.println("Inicio proceso de carga de GASTOS en ObjectDB.");
// Obtener el endpoint URL desde el fichero de configuración
String urlPeticionGastos = GestorFicheroConfiguracion.getValorfromClave("url.proyectosies.gastos");
System.out.println(urlPeticionGastos);
// Procesar la petición HTTP y cargar los datos de INGRESOS en ObjectDB
System.out.println("Fin proceso de carga de GASTOS en ObjectDB.\n");
}
}

View File

@ -0,0 +1,46 @@
package org.lapaloma.gui.proyectos.gestor;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
*
* GestorConfiguracion: Clase que se encarga de gestionar la configuración de
* los ficheros.
*
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 10 oct 2025
*
*
*/
public class GestorFicheroConfiguracion {
private final static String RUTA_FICHERO_CONFIGURACION = "config/config.properties";
private static Properties propiedades = null;
private GestorFicheroConfiguracion() {
// Constructor privado para evitar instanciación
}
// Bloque estático que se ejecuta una única vez al cargar la clase
static {
cargarPropiedadesFichero();
}
private static void cargarPropiedadesFichero() {
propiedades = new Properties();
try {
// Fichero con ruta relativa al proyecto
propiedades.load(new FileInputStream(RUTA_FICHERO_CONFIGURACION));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static String getValorfromClave(String clave) {
return propiedades.getProperty(clave);
}
}