Commit inicial
This commit is contained in:
commit
034e14b67d
57
.classpath
Normal file
57
.classpath
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?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/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
<attributes>
|
||||||
|
<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="src" path="target/generated-sources/annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/bin/
|
||||||
|
*.class
|
||||||
|
/target/
|
||||||
34
.project
Normal file
34
.project
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>aadd_act5_6</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>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1771843084640</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
||||||
2
.settings/org.eclipse.jdt.apt.core.prefs
Normal file
2
.settings/org.eclipse.jdt.apt.core.prefs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.apt.aptEnabled=false
|
||||||
9
.settings/org.eclipse.jdt.core.prefs
Normal file
9
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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.processAnnotations=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
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
|
||||||
44
pom.xml
Normal file
44
pom.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<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>eu.agenciaesa</groupId>
|
||||||
|
<artifactId>aadd_act5_6</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<dependencies>
|
||||||
|
<!-- Source: https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongodb-driver-sync</artifactId>
|
||||||
|
<version>5.6.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Source: https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.7.8</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>9.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.orm</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
<version>7.1.11.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 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>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
59
src/main/java/eu/agenciaesa/inm/AppAgenciaEsa.java
Normal file
59
src/main/java/eu/agenciaesa/inm/AppAgenciaEsa.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package eu.agenciaesa.inm;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.dao.IExperimentoDao;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorEntityManagerJPA;
|
||||||
|
import eu.agenciaesa.inm.vo.TipoExperimento;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clase principal que inicia la sesión de Hibernate - JPA. Al obtener un EntityManager,
|
||||||
|
* Hibernate ejecutará hbm2ddl.auto=create y recreará la base de datos según las
|
||||||
|
* entidades definidas.
|
||||||
|
*/
|
||||||
|
public class AppAgenciaEsa {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Inicio del programa.");
|
||||||
|
|
||||||
|
AppAgenciaEsa app = new AppAgenciaEsa();
|
||||||
|
|
||||||
|
// Generación de la base de datos (JPA - hibernate - PostgreSQL)
|
||||||
|
GestorEntityManagerJPA.getEntityManager();
|
||||||
|
|
||||||
|
try {
|
||||||
|
app.procesarInformacionAgenciaESA();
|
||||||
|
} catch (AgenciaESAException 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 AgenciaESAException.ERROR_GESTION_CONEXION:
|
||||||
|
operacion = "Gestión de Conexión";
|
||||||
|
break;
|
||||||
|
case AgenciaESAException.ERROR_CONSULTA:
|
||||||
|
operacion = "Consulta";
|
||||||
|
break;
|
||||||
|
case AgenciaESAException.ERROR_INSERCION:
|
||||||
|
operacion = "Inserción";
|
||||||
|
break;
|
||||||
|
case AgenciaESAException.ERROR_BORRADO:
|
||||||
|
operacion = "Borrado";
|
||||||
|
break;
|
||||||
|
case AgenciaESAException.ERROR_ACTUALIZACION:
|
||||||
|
operacion = "Actualización";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mensajeError = String.format(mensajeError, e.getClaseOrigen().getName(), operacion);
|
||||||
|
System.err.println(mensajeError);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("Fin del programa.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void procesarInformacionAgenciaESA() throws AgenciaESAException {
|
||||||
|
System.out.println(TipoExperimento.Climatológico.toString());
|
||||||
|
IExperimentoDao experimentoDao = null;
|
||||||
|
experimentoDao.obtenerListaExperimentos();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
13
src/main/java/eu/agenciaesa/inm/dao/IBaseDao.java
Normal file
13
src/main/java/eu/agenciaesa/inm/dao/IBaseDao.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package eu.agenciaesa.inm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.vo.Base;
|
||||||
|
|
||||||
|
public interface IBaseDao {
|
||||||
|
void insertarListaBases(List<Base> listaBases) throws AgenciaESAException;
|
||||||
|
|
||||||
|
List<Base> obtenerListaBases() throws AgenciaESAException;
|
||||||
|
|
||||||
|
Base obtenerBasePorCodigo(String codigo) throws AgenciaESAException;
|
||||||
|
}
|
||||||
13
src/main/java/eu/agenciaesa/inm/dao/ICuerpoCelesteDao.java
Normal file
13
src/main/java/eu/agenciaesa/inm/dao/ICuerpoCelesteDao.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package eu.agenciaesa.inm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.vo.CuerpoCeleste;
|
||||||
|
|
||||||
|
public interface ICuerpoCelesteDao {
|
||||||
|
void insertarListaCuerposCelestes(List<CuerpoCeleste> listaCuerpos) throws AgenciaESAException;
|
||||||
|
|
||||||
|
List<CuerpoCeleste> obtenerListaCuerposCelestes() throws AgenciaESAException;
|
||||||
|
|
||||||
|
CuerpoCeleste obtenerCuerpoPorNombre(String nombre) throws AgenciaESAException;
|
||||||
|
}
|
||||||
12
src/main/java/eu/agenciaesa/inm/dao/IExperimentoDao.java
Normal file
12
src/main/java/eu/agenciaesa/inm/dao/IExperimentoDao.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package eu.agenciaesa.inm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.vo.Experimento;
|
||||||
|
|
||||||
|
public interface IExperimentoDao {
|
||||||
|
void insertarListaExperimentos(List<Experimento> listaExperimentos) throws AgenciaESAException;
|
||||||
|
|
||||||
|
List<Experimento> obtenerListaExperimentos() throws AgenciaESAException;
|
||||||
|
}
|
||||||
11
src/main/java/eu/agenciaesa/inm/dao/IGeneradorDao.java
Normal file
11
src/main/java/eu/agenciaesa/inm/dao/IGeneradorDao.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package eu.agenciaesa.inm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.vo.Generador;
|
||||||
|
|
||||||
|
public interface IGeneradorDao {
|
||||||
|
void insertarListaGeneradores(List<Generador> listaGeneradores) throws AgenciaESAException;
|
||||||
|
|
||||||
|
List<Generador> obtenerListaGeneradores() throws AgenciaESAException;
|
||||||
|
}
|
||||||
11
src/main/java/eu/agenciaesa/inm/dao/IModuloDao.java
Normal file
11
src/main/java/eu/agenciaesa/inm/dao/IModuloDao.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package eu.agenciaesa.inm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.vo.Modulo;
|
||||||
|
|
||||||
|
public interface IModuloDao {
|
||||||
|
void insertarListaModulos(List<Modulo> listaModulos) throws AgenciaESAException;
|
||||||
|
|
||||||
|
List<Modulo> obtenerListaModulos() throws AgenciaESAException;
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package eu.agenciaesa.inm.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.dao.IBaseDao;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorSesionHibernate;
|
||||||
|
import eu.agenciaesa.inm.vo.Base;
|
||||||
|
|
||||||
|
public class BaseDaoHibernate implements IBaseDao {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertarListaBases(List<Base> listaBases) throws AgenciaESAException {
|
||||||
|
Transaction tx = null;
|
||||||
|
try (Session session = GestorSesionHibernate.getSession()) {
|
||||||
|
tx = session.beginTransaction();
|
||||||
|
for (Base base : listaBases) {
|
||||||
|
session.persist(base);
|
||||||
|
}
|
||||||
|
tx.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (tx != null)
|
||||||
|
tx.rollback();
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_INSERCION, BaseDaoHibernate.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Base> obtenerListaBases() throws AgenciaESAException {
|
||||||
|
try (Session session = GestorSesionHibernate.getSession()) {
|
||||||
|
Query<Base> query = session.createQuery("FROM Base", Base.class);
|
||||||
|
return query.list();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, BaseDaoHibernate.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Base obtenerBasePorCodigo(String codigo) throws AgenciaESAException {
|
||||||
|
try (Session session = GestorSesionHibernate.getSession()) {
|
||||||
|
return session.find(Base.class, codigo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, BaseDaoHibernate.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package eu.agenciaesa.inm.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.dao.IModuloDao;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorSesionHibernate;
|
||||||
|
import eu.agenciaesa.inm.vo.Modulo;
|
||||||
|
|
||||||
|
public class ModuloDaoHibernate implements IModuloDao {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertarListaModulos(List<Modulo> listaModulos) throws AgenciaESAException {
|
||||||
|
Transaction tx = null;
|
||||||
|
try (Session session = GestorSesionHibernate.getSession()) {
|
||||||
|
tx = session.beginTransaction();
|
||||||
|
for (Modulo modulo : listaModulos) {
|
||||||
|
session.persist(modulo);
|
||||||
|
}
|
||||||
|
tx.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (tx != null)
|
||||||
|
tx.rollback();
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_INSERCION, ModuloDaoHibernate.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Modulo> obtenerListaModulos() throws AgenciaESAException {
|
||||||
|
try (Session session = GestorSesionHibernate.getSession()) {
|
||||||
|
Query<Modulo> query = session.createQuery("FROM Modulo", Modulo.class);
|
||||||
|
return query.list();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, ModuloDaoHibernate.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
package eu.agenciaesa.inm.dao.jdbc;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.dao.ICuerpoCelesteDao;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorConexionJDBC;
|
||||||
|
import eu.agenciaesa.inm.vo.CuerpoCeleste;
|
||||||
|
import eu.agenciaesa.inm.vo.TipoCuerpoCeleste;
|
||||||
|
|
||||||
|
public class CuerpoCelesteDaoJDBC implements ICuerpoCelesteDao {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertarListaCuerposCelestes(List<CuerpoCeleste> listaCuerpos) throws AgenciaESAException {
|
||||||
|
String sql = "INSERT INTO T_CUERPO_CELESTE (nombre, gravedad_superficie_ms2, tipo) VALUES (?, ?, ?)";
|
||||||
|
try (Connection con = GestorConexionJDBC.getConexionSGDB();
|
||||||
|
PreparedStatement ps = con.prepareStatement(sql)) {
|
||||||
|
|
||||||
|
con.setAutoCommit(false);
|
||||||
|
for (CuerpoCeleste cuerpo : listaCuerpos) {
|
||||||
|
ps.setString(1, cuerpo.getNombre());
|
||||||
|
ps.setDouble(2, cuerpo.getGravedadSuperficioMs2());
|
||||||
|
ps.setString(3, cuerpo.getTipo() != null ? cuerpo.getTipo().name() : null);
|
||||||
|
ps.addBatch();
|
||||||
|
}
|
||||||
|
ps.executeBatch();
|
||||||
|
con.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_INSERCION, CuerpoCelesteDaoJDBC.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CuerpoCeleste> obtenerListaCuerposCelestes() throws AgenciaESAException {
|
||||||
|
List<CuerpoCeleste> lista = new ArrayList<>();
|
||||||
|
String sql = "SELECT * FROM T_CUERPO_CELESTE";
|
||||||
|
try (Connection con = GestorConexionJDBC.getConexionSGDB();
|
||||||
|
PreparedStatement ps = con.prepareStatement(sql);
|
||||||
|
ResultSet rs = ps.executeQuery()) {
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
CuerpoCeleste cuerpo = new CuerpoCeleste();
|
||||||
|
cuerpo.setIdentificador(rs.getLong("identificador"));
|
||||||
|
cuerpo.setNombre(rs.getString("nombre"));
|
||||||
|
cuerpo.setGravedadSuperficioMs2(rs.getDouble("gravedad_superficie_ms2"));
|
||||||
|
String tipoStr = rs.getString("tipo");
|
||||||
|
if (tipoStr != null) {
|
||||||
|
cuerpo.setTipo(TipoCuerpoCeleste.valueOf(tipoStr));
|
||||||
|
}
|
||||||
|
lista.add(cuerpo);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, CuerpoCelesteDaoJDBC.class);
|
||||||
|
}
|
||||||
|
return lista;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CuerpoCeleste obtenerCuerpoPorNombre(String nombre) throws AgenciaESAException {
|
||||||
|
CuerpoCeleste cuerpo = null;
|
||||||
|
String sql = "SELECT * FROM T_CUERPO_CELESTE WHERE nombre = ?";
|
||||||
|
try (Connection con = GestorConexionJDBC.getConexionSGDB();
|
||||||
|
PreparedStatement ps = con.prepareStatement(sql)) {
|
||||||
|
|
||||||
|
ps.setString(1, nombre);
|
||||||
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
|
if (rs.next()) {
|
||||||
|
cuerpo = new CuerpoCeleste();
|
||||||
|
cuerpo.setIdentificador(rs.getLong("identificador"));
|
||||||
|
cuerpo.setNombre(rs.getString("nombre"));
|
||||||
|
cuerpo.setGravedadSuperficioMs2(rs.getDouble("gravedad_superficie_ms2"));
|
||||||
|
String tipoStr = rs.getString("tipo");
|
||||||
|
if (tipoStr != null) {
|
||||||
|
cuerpo.setTipo(TipoCuerpoCeleste.valueOf(tipoStr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, CuerpoCelesteDaoJDBC.class);
|
||||||
|
}
|
||||||
|
return cuerpo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
package eu.agenciaesa.inm.dao.jdbc;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.dao.IGeneradorDao;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorConexionJDBC;
|
||||||
|
import eu.agenciaesa.inm.vo.Base;
|
||||||
|
import eu.agenciaesa.inm.vo.Generador;
|
||||||
|
import eu.agenciaesa.inm.vo.TipoGenerador;
|
||||||
|
|
||||||
|
public class GeneradorDaoJDBC implements IGeneradorDao {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertarListaGeneradores(List<Generador> listaGeneradores) throws AgenciaESAException {
|
||||||
|
String sql = "INSERT INTO T_GENERADOR (nombre, potencia_mw, tipo, cod_base) VALUES (?, ?, ?, ?)";
|
||||||
|
try (Connection con = GestorConexionJDBC.getConexionSGDB();
|
||||||
|
PreparedStatement ps = con.prepareStatement(sql)) {
|
||||||
|
|
||||||
|
con.setAutoCommit(false);
|
||||||
|
for (Generador gen : listaGeneradores) {
|
||||||
|
ps.setString(1, gen.getNombre());
|
||||||
|
ps.setDouble(2, gen.getPotenciaMW());
|
||||||
|
ps.setString(3, gen.getTipo() != null ? gen.getTipo().name() : null);
|
||||||
|
ps.setString(4, gen.getBase() != null ? gen.getBase().getCodigo() : null);
|
||||||
|
ps.addBatch();
|
||||||
|
}
|
||||||
|
ps.executeBatch();
|
||||||
|
con.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_INSERCION, GeneradorDaoJDBC.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Generador> obtenerListaGeneradores() throws AgenciaESAException {
|
||||||
|
List<Generador> lista = new ArrayList<>();
|
||||||
|
String sql = "SELECT * FROM T_GENERADOR";
|
||||||
|
try (Connection con = GestorConexionJDBC.getConexionSGDB();
|
||||||
|
PreparedStatement ps = con.prepareStatement(sql);
|
||||||
|
ResultSet rs = ps.executeQuery()) {
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
Generador gen = new Generador();
|
||||||
|
gen.setIdentificador(rs.getLong("identificador"));
|
||||||
|
gen.setNombre(rs.getString("nombre"));
|
||||||
|
gen.setPotenciaMW(rs.getDouble("potencia_mw"));
|
||||||
|
String tipoStr = rs.getString("tipo");
|
||||||
|
if (tipoStr != null) {
|
||||||
|
gen.setTipo(TipoGenerador.valueOf(tipoStr));
|
||||||
|
}
|
||||||
|
String codBase = rs.getString("cod_base");
|
||||||
|
if (codBase != null) {
|
||||||
|
Base base = new Base();
|
||||||
|
base.setCodigo(codBase);
|
||||||
|
gen.setBase(base);
|
||||||
|
}
|
||||||
|
lista.add(gen);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, GeneradorDaoJDBC.class);
|
||||||
|
}
|
||||||
|
return lista;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package eu.agenciaesa.inm.dao.jpa;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.EntityTransaction;
|
||||||
|
import jakarta.persistence.TypedQuery;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.dao.IExperimentoDao;
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorEntityManagerJPA;
|
||||||
|
import eu.agenciaesa.inm.vo.Experimento;
|
||||||
|
|
||||||
|
public class ExperimentoDaoJPA implements IExperimentoDao {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertarListaExperimentos(List<Experimento> listaExperimentos) throws AgenciaESAException {
|
||||||
|
EntityManager em = GestorEntityManagerJPA.getEntityManager();
|
||||||
|
EntityTransaction tx = em.getTransaction();
|
||||||
|
try {
|
||||||
|
tx.begin();
|
||||||
|
for (Experimento exp : listaExperimentos) {
|
||||||
|
// El campo "resultado" ya viene calculado por el ProcesadorDatos
|
||||||
|
// siguiendo las reglas de negocio, o se puede recalcular aquí.
|
||||||
|
// Según el requisito: "el campo resultado seguirá estás condiciones..."
|
||||||
|
// Me aseguro de persistir el objeto.
|
||||||
|
em.persist(exp);
|
||||||
|
}
|
||||||
|
tx.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (tx.isActive())
|
||||||
|
tx.rollback();
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_INSERCION, ExperimentoDaoJPA.class);
|
||||||
|
} finally {
|
||||||
|
em.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Experimento> obtenerListaExperimentos() throws AgenciaESAException {
|
||||||
|
EntityManager em = GestorEntityManagerJPA.getEntityManager();
|
||||||
|
try {
|
||||||
|
TypedQuery<Experimento> query = em.createQuery("SELECT e FROM Experimento e", Experimento.class);
|
||||||
|
return query.getResultList();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_CONSULTA, ExperimentoDaoJPA.class);
|
||||||
|
} finally {
|
||||||
|
em.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package eu.agenciaesa.inm.excepciones;
|
||||||
|
|
||||||
|
public class AgenciaESAException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static final int ERROR_GENERAL = 0;
|
||||||
|
public static final int ERROR_GESTION_CONEXION = 1;
|
||||||
|
public static final int ERROR_CONSULTA = 2;
|
||||||
|
public static final int ERROR_INSERCION = 3;
|
||||||
|
public static final int ERROR_ACTUALIZACION = 4;
|
||||||
|
public static final int ERROR_BORRADO = 5;
|
||||||
|
|
||||||
|
private int codigoError;
|
||||||
|
private Class<?> claseOrigen;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public AgenciaESAException(Exception excepcion, int tipoError, Class claseOrigenError) {
|
||||||
|
super(excepcion);
|
||||||
|
this.codigoError = tipoError;
|
||||||
|
this.claseOrigen = claseOrigenError;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCodigoError() {
|
||||||
|
return codigoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigoError(int codigoError) {
|
||||||
|
this.codigoError = codigoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getClaseOrigen() {
|
||||||
|
return claseOrigen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClaseOrigen(Class<?> claseOrigen) {
|
||||||
|
this.claseOrigen = claseOrigen;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package eu.agenciaesa.inm.gestores;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.excepciones.AgenciaESAException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GestorConexionJDBC: Clase que gestiona las conexiones JDBC a la base de
|
||||||
|
* datos.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
*/
|
||||||
|
public class GestorConexionJDBC {
|
||||||
|
|
||||||
|
// Evita que pueda construirse un objeto de la clase.
|
||||||
|
private GestorConexionJDBC() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Connection getConexionSGDB() throws AgenciaESAException {
|
||||||
|
Connection conexionSGDB = null;
|
||||||
|
|
||||||
|
String urlBBDD = GestorFicheroConfiguracion.obtenerValor("jdbc.url");
|
||||||
|
String usuario = GestorFicheroConfiguracion.obtenerValor("jdbc.usuario");
|
||||||
|
String contrasenya = GestorFicheroConfiguracion.obtenerValor("jdbc.password");
|
||||||
|
|
||||||
|
try {
|
||||||
|
String claseDriver = GestorFicheroConfiguracion.obtenerValor("jdbc.driver");
|
||||||
|
Class.forName(claseDriver);
|
||||||
|
conexionSGDB = DriverManager.getConnection(urlBBDD, usuario, contrasenya);
|
||||||
|
} catch (SQLException | ClassNotFoundException e) {
|
||||||
|
throw new AgenciaESAException(e, AgenciaESAException.ERROR_GESTION_CONEXION, GestorConexionJDBC.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return conexionSGDB;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package eu.agenciaesa.inm.gestores;
|
||||||
|
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoClients;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* GestorConexionMongoDB: Clase que realiza la gestión de Conexiones a MongoDB.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
* @date 30 enero 2026
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GestorConexionMongoDB {
|
||||||
|
private static MongoDatabase mongoDBDatabase= null;
|
||||||
|
|
||||||
|
private GestorConexionMongoDB() { // Constructor privado para evitar instanciación
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga la configuración desde META-INF/persistence.xml
|
||||||
|
static {
|
||||||
|
// Cadena de conexion con la base de datos MongoDB
|
||||||
|
String uri = GestorFicheroConfiguracion.obtenerValor("url.conexion.mongodb");
|
||||||
|
// Se abre la conexión con MongoDB
|
||||||
|
MongoClient clienteMongo = MongoClients.create(uri);
|
||||||
|
|
||||||
|
// Obtener una base de datos MongoDB desde Java
|
||||||
|
String bbddMongoDB= GestorFicheroConfiguracion.obtenerValor("bbdd.mongodb");
|
||||||
|
mongoDBDatabase = clienteMongo.getDatabase(bbddMongoDB);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MongoDatabase getMongoDatabase() {
|
||||||
|
return mongoDBDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package eu.agenciaesa.inm.gestores;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.EntityManagerFactory;
|
||||||
|
import jakarta.persistence.Persistence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* GestorEntityManagerJPA: Clase que realiza la gestión de EntityManagers de JPA.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
* @date 4 dic 2025
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GestorEntityManagerJPA {
|
||||||
|
private static EntityManagerFactory entityManagerFactory = null;
|
||||||
|
|
||||||
|
private GestorEntityManagerJPA() { // Constructor privado para evitar instanciación
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga la configuración desde META-INF/persistence.xml
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
entityManagerFactory = Persistence.createEntityManagerFactory("UP_AGENCIAESA_POSTGRESQL");
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
System.err.println("Error en EntityManagerFactory: " + ex);
|
||||||
|
throw new ExceptionInInitializerError(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntityManager getEntityManager() {
|
||||||
|
return entityManagerFactory.createEntityManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void closeEntityManagerFactory() {
|
||||||
|
entityManagerFactory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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 eu.agenciaesa.inm.gestores;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class GestorFicheroConfiguracion {
|
||||||
|
private static final Properties PROPIEDADES = new Properties();
|
||||||
|
|
||||||
|
static {
|
||||||
|
try (InputStream is = GestorFicheroConfiguracion.class.getClassLoader()
|
||||||
|
.getResourceAsStream("conf.properties")) {
|
||||||
|
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,42 @@
|
|||||||
|
package eu.agenciaesa.inm.gestores;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GestorSesionHibernate: gestiona las sesiones de Hibernate para la Agencia
|
||||||
|
* ESA.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
*/
|
||||||
|
public class GestorSesionHibernate {
|
||||||
|
private static SessionFactory sessionFactory = null;
|
||||||
|
|
||||||
|
private GestorSesionHibernate() {// Constructor privado para evitar instanciación
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga la configuración desde hibernate.cfg.xml
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
sessionFactory = new Configuration().configure().buildSessionFactory();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
System.err.println("Error en SessionFactory: " + ex);
|
||||||
|
throw new ExceptionInInitializerError(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Session getSession() {
|
||||||
|
return sessionFactory.openSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Session getCurrentSession() {
|
||||||
|
return sessionFactory.getCurrentSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cerrarFactoria() {
|
||||||
|
if (sessionFactory != null) {
|
||||||
|
sessionFactory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,380 @@
|
|||||||
|
package eu.agenciaesa.inm.procesamiento;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.agenciaesa.inm.gestores.GestorFicheroConfiguracion;
|
||||||
|
import eu.agenciaesa.inm.utilidades.GestorURLs;
|
||||||
|
import eu.agenciaesa.inm.vo.Base;
|
||||||
|
import eu.agenciaesa.inm.vo.CuerpoCeleste;
|
||||||
|
import eu.agenciaesa.inm.vo.Experimento;
|
||||||
|
import eu.agenciaesa.inm.vo.FuncionPrincipalBase;
|
||||||
|
import eu.agenciaesa.inm.vo.Generador;
|
||||||
|
import eu.agenciaesa.inm.vo.Modulo;
|
||||||
|
import eu.agenciaesa.inm.vo.TipoExperimento;
|
||||||
|
import eu.agenciaesa.inm.vo.TipoGenerador;
|
||||||
|
|
||||||
|
import tools.jackson.databind.JsonNode;
|
||||||
|
import tools.jackson.databind.ObjectMapper;
|
||||||
|
import tools.jackson.dataformat.xml.XmlMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProcesadorDatos: clase que procesa los distintos orígenes de información
|
||||||
|
* de la Agencia ESA (XML, JSON, CSV), usando JsonNode de Jackson sin
|
||||||
|
* anotaciones
|
||||||
|
* de mapeo.
|
||||||
|
*
|
||||||
|
* Estructura espejada de ProcesadorDatos en examen_aadd_2trim_FP.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
*/
|
||||||
|
public class ProcesadorDatos {
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// BASES Y MÓDULOS desde XML
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene la lista de Bases (con sus Módulos) desde la URL XML configurada.
|
||||||
|
*
|
||||||
|
* @return Lista de objetos Base o null si hay error.
|
||||||
|
*/
|
||||||
|
public List<Base> obtenerBasesDeURL(String urlBases) {
|
||||||
|
List<Base> listaBases = null;
|
||||||
|
|
||||||
|
String xmlContenido = GestorURLs.getTextoFromURL(urlBases);
|
||||||
|
if (xmlContenido == null || xmlContenido.isEmpty()) {
|
||||||
|
System.err.println("No se pudo obtener el XML de bases desde la URL: " + urlBases);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapeadorXML = new XmlMapper();
|
||||||
|
try {
|
||||||
|
JsonNode nodoRaiz = mapeadorXML.readTree(xmlContenido);
|
||||||
|
if (nodoRaiz != null) {
|
||||||
|
listaBases = new ArrayList<>();
|
||||||
|
|
||||||
|
// El XML tiene <bases><base id="...">...</base>...</bases>
|
||||||
|
// Jackson XML convierte el nodo raíz en el elemento "bases"
|
||||||
|
// y los hijos "base" en campos o arrays.
|
||||||
|
JsonNode nodoBases = nodoRaiz.has("base") ? nodoRaiz.get("base") : nodoRaiz;
|
||||||
|
|
||||||
|
if (nodoBases.isArray()) {
|
||||||
|
for (JsonNode nodoBase : nodoBases) {
|
||||||
|
Base base = obtenerBaseDeJsonNode(nodoBase);
|
||||||
|
if (base != null)
|
||||||
|
listaBases.add(base);
|
||||||
|
}
|
||||||
|
} else if (!nodoBases.isMissingNode() && !nodoBases.isNull()) {
|
||||||
|
Base base = obtenerBaseDeJsonNode(nodoBases);
|
||||||
|
if (base != null)
|
||||||
|
listaBases.add(base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error procesando XML de bases con JsonNode: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return listaBases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convierte un JsonNode que representa un elemento <base> del XML.
|
||||||
|
*/
|
||||||
|
private Base obtenerBaseDeJsonNode(JsonNode nodoBase) {
|
||||||
|
if (nodoBase == null || nodoBase.isNull())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Base base = new Base();
|
||||||
|
|
||||||
|
if (nodoBase.has("id")) {
|
||||||
|
base.setCodigo(nodoBase.get("id").asText(""));
|
||||||
|
}
|
||||||
|
if (nodoBase.has("nombre")) {
|
||||||
|
base.setNombre(nodoBase.get("nombre").asText(""));
|
||||||
|
}
|
||||||
|
if (nodoBase.has("fecha_establecimiento")) {
|
||||||
|
String fechaStr = nodoBase.get("fecha_establecimiento").asText("");
|
||||||
|
if (!fechaStr.isEmpty()) {
|
||||||
|
try {
|
||||||
|
base.setFechaEstablecimiento(LocalDate.parse(fechaStr));
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Fecha de establecimiento no válida: " + fechaStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nodoBase.has("funcion_ppal")) {
|
||||||
|
String funcion = nodoBase.get("funcion_ppal").asText("");
|
||||||
|
try {
|
||||||
|
base.setFuncionPrincipal(FuncionPrincipalBase.valueOf(funcion));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.err.println("Función principal desconocida: " + funcion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Cuerpo celeste referenciado por nombre en el atributo nombre del elemento
|
||||||
|
// <cuerpo>
|
||||||
|
if (nodoBase.has("cuerpo")) {
|
||||||
|
JsonNode nodoCuerpo = nodoBase.get("cuerpo");
|
||||||
|
String nombreCuerpo = nodoCuerpo.has("nombre") ? nodoCuerpo.get("nombre").asText("") : "";
|
||||||
|
if (!nombreCuerpo.isEmpty()) {
|
||||||
|
CuerpoCeleste cuerpo = new CuerpoCeleste();
|
||||||
|
cuerpo.setNombre(nombreCuerpo);
|
||||||
|
base.setCuerpo(cuerpo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene la lista de Módulos para una base a partir del JsonNode de la base.
|
||||||
|
* Se llama por el procesador de bases para extraer módulos anidados.
|
||||||
|
*/
|
||||||
|
public List<Modulo> obtenerModulosDeBase(JsonNode nodoBase, Base base) {
|
||||||
|
List<Modulo> listaModulos = new ArrayList<>();
|
||||||
|
if (nodoBase == null || !nodoBase.has("modulos"))
|
||||||
|
return listaModulos;
|
||||||
|
|
||||||
|
JsonNode nodoModulos = nodoBase.get("modulos");
|
||||||
|
JsonNode nodoModulo = nodoModulos.has("modulo") ? nodoModulos.get("modulo") : nodoModulos;
|
||||||
|
|
||||||
|
if (nodoModulo.isArray()) {
|
||||||
|
for (JsonNode m : nodoModulo) {
|
||||||
|
Modulo modulo = obtenerModuloDeJsonNode(m, base);
|
||||||
|
if (modulo != null)
|
||||||
|
listaModulos.add(modulo);
|
||||||
|
}
|
||||||
|
} else if (!nodoModulo.isMissingNode() && !nodoModulo.isNull()) {
|
||||||
|
Modulo modulo = obtenerModuloDeJsonNode(nodoModulo, base);
|
||||||
|
if (modulo != null)
|
||||||
|
listaModulos.add(modulo);
|
||||||
|
}
|
||||||
|
return listaModulos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Modulo obtenerModuloDeJsonNode(JsonNode nodoModulo, Base base) {
|
||||||
|
if (nodoModulo == null || nodoModulo.isNull())
|
||||||
|
return null;
|
||||||
|
Modulo modulo = new Modulo();
|
||||||
|
if (nodoModulo.has("id")) {
|
||||||
|
modulo.setCodigo(nodoModulo.get("id").asText(""));
|
||||||
|
}
|
||||||
|
if (nodoModulo.has("nombre")) {
|
||||||
|
modulo.setNombre(nodoModulo.get("nombre").asText(""));
|
||||||
|
}
|
||||||
|
if (nodoModulo.has("consumo_energia")) {
|
||||||
|
modulo.setConsumoEnergiaMW(nodoModulo.get("consumo_energia").asDouble(0.0));
|
||||||
|
}
|
||||||
|
modulo.setBase(base);
|
||||||
|
return modulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// EXPERIMENTOS desde JSON
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene la lista de Experimentos desde la URL JSON configurada.
|
||||||
|
* Aplica la lógica de construcción del campo "resultado" según el tipo.
|
||||||
|
*
|
||||||
|
* @return Lista de objetos Experimento o null si hay error.
|
||||||
|
*/
|
||||||
|
public List<Experimento> obtenerExperimentosDeURL(String urlExperimentos) {
|
||||||
|
List<Experimento> listaExperimentos = null;
|
||||||
|
|
||||||
|
String jsonContenido = GestorURLs.getTextoFromURL(urlExperimentos);
|
||||||
|
if (jsonContenido == null || jsonContenido.isEmpty()) {
|
||||||
|
System.err.println("No se pudo obtener el JSON de experimentos desde la URL: " + urlExperimentos);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapeadorJSON = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
JsonNode nodoRaiz = mapeadorJSON.readTree(jsonContenido);
|
||||||
|
if (nodoRaiz != null) {
|
||||||
|
listaExperimentos = new ArrayList<>();
|
||||||
|
|
||||||
|
// El JSON puede ser un array de experimentos directamente o
|
||||||
|
// un objeto con un campo "experimentos" o similar.
|
||||||
|
JsonNode elementos = nodoRaiz.isArray() ? nodoRaiz
|
||||||
|
: (nodoRaiz.has("experimentos") ? nodoRaiz.get("experimentos") : nodoRaiz);
|
||||||
|
|
||||||
|
if (elementos.isArray()) {
|
||||||
|
for (JsonNode nodo : elementos) {
|
||||||
|
Experimento exp = obtenerExperimentoDeJsonNode(nodo);
|
||||||
|
if (exp != null)
|
||||||
|
listaExperimentos.add(exp);
|
||||||
|
}
|
||||||
|
} else if (!elementos.isMissingNode() && !elementos.isNull()) {
|
||||||
|
// Iterar los campos del objeto por si cada campo es un experimento
|
||||||
|
Iterator<JsonNode> campos = elementos.elements();
|
||||||
|
while (campos.hasNext()) {
|
||||||
|
Experimento exp = obtenerExperimentoDeJsonNode(campos.next());
|
||||||
|
if (exp != null)
|
||||||
|
listaExperimentos.add(exp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error procesando JSON de experimentos con JsonNode: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return listaExperimentos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convierte un JsonNode que representa un experimento en el objeto Experimento,
|
||||||
|
* incluyendo la construcción del campo resultado según el tipo.
|
||||||
|
*/
|
||||||
|
private Experimento obtenerExperimentoDeJsonNode(JsonNode nodoExp) {
|
||||||
|
if (nodoExp == null || nodoExp.isNull())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Experimento experimento = new Experimento();
|
||||||
|
|
||||||
|
if (nodoExp.has("nombre")) {
|
||||||
|
experimento.setNombre(nodoExp.get("nombre").asText(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tipo de experimento
|
||||||
|
TipoExperimento tipo = null;
|
||||||
|
if (nodoExp.has("tipo")) {
|
||||||
|
try {
|
||||||
|
tipo = TipoExperimento.valueOf(nodoExp.get("tipo").asText(""));
|
||||||
|
experimento.setTipo(tipo);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.err.println("Tipo de experimento desconocido: " + nodoExp.get("tipo").asText(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Módulo asociado (solo se asocia código para que el DAO resuelva la relación)
|
||||||
|
if (nodoExp.has("cod_modulo")) {
|
||||||
|
Modulo modulo = new Modulo();
|
||||||
|
modulo.setCodigo(nodoExp.get("cod_modulo").asText(""));
|
||||||
|
experimento.setModulo(modulo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construcción del campo "resultado" según la lógica de negocio del
|
||||||
|
// ContextoProyecto
|
||||||
|
String resultado = construirResultado(tipo, nodoExp);
|
||||||
|
experimento.setResultado(resultado);
|
||||||
|
|
||||||
|
return experimento;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aplica las reglas de negocio del ContextoProyecto para el campo resultado:
|
||||||
|
* <ul>
|
||||||
|
* <li><b>Geológico</b>: "Muestra de {material} obtenida a {profundidad} m de
|
||||||
|
* profundidad."</li>
|
||||||
|
* <li><b>Biológico</b>: "Análisis de {organismo} realizado bajo nivel {nivel}
|
||||||
|
* de bioseguridad.</li>
|
||||||
|
* <li><b>Climatológico</b>: "Estudio de {variable} durante {dias} días con
|
||||||
|
* frecuencia {frecuencia}."</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
private String construirResultado(TipoExperimento tipo, JsonNode nodo) {
|
||||||
|
if (tipo == null)
|
||||||
|
return "Resultado no determinado.";
|
||||||
|
switch (tipo) {
|
||||||
|
case Geológico:
|
||||||
|
String material = nodo.has("material") ? nodo.get("material").asText("Basalto") : "Basalto";
|
||||||
|
String profundidad = nodo.has("profundidad") ? nodo.get("profundidad").asText("120") : "120";
|
||||||
|
return String.format("Muestra de %s obtenida a %s m de profundidad.", material, profundidad);
|
||||||
|
|
||||||
|
case Biológico:
|
||||||
|
String organismo = nodo.has("organismo") ? nodo.get("organismo").asText("Microorganismo")
|
||||||
|
: "Microorganismo";
|
||||||
|
String nivel = nodo.has("nivel") ? nodo.get("nivel").asText("3") : "3";
|
||||||
|
return String.format("Análisis de %s realizado bajo nivel %s de bioseguridad.", organismo, nivel);
|
||||||
|
|
||||||
|
case Climatológico:
|
||||||
|
String variable = nodo.has("variable") ? nodo.get("variable").asText("Temperatura") : "Temperatura";
|
||||||
|
String dias = nodo.has("dias") ? nodo.get("dias").asText("30") : "30";
|
||||||
|
String frecuencia = nodo.has("frecuencia") ? nodo.get("frecuencia").asText("Diaria") : "Diaria";
|
||||||
|
return String.format("Estudio de %s durante %s días con frecuencia %s.", variable, dias, frecuencia);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "Resultado no determinado.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// GENERADORES desde CSV
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtiene la lista de Generadores desde un fichero CSV.
|
||||||
|
* Cabecera esperada: identificador,nombre,potencia_mw,tipo,cod_base
|
||||||
|
*
|
||||||
|
* @param rutaCSV ruta al fichero CSV
|
||||||
|
* @return Lista de Generador o null si hay error.
|
||||||
|
*/
|
||||||
|
public List<Generador> obtenerGeneradoresDeFicheroCSV(String rutaCSV) {
|
||||||
|
List<Generador> listaGeneradores = null;
|
||||||
|
|
||||||
|
try (BufferedReader reader = new BufferedReader(new FileReader(rutaCSV))) {
|
||||||
|
listaGeneradores = new ArrayList<>();
|
||||||
|
String linea;
|
||||||
|
boolean primeraLinea = true;
|
||||||
|
|
||||||
|
while ((linea = reader.readLine()) != null) {
|
||||||
|
if (primeraLinea) {
|
||||||
|
// Saltar cabecera
|
||||||
|
primeraLinea = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (linea.trim().isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Generador generador = obtenerGeneradorDeLineaCSV(linea);
|
||||||
|
if (generador != null)
|
||||||
|
listaGeneradores.add(generador);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Error leyendo CSV de generadores: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return listaGeneradores;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsea una línea del CSV y devuelve un Generador.
|
||||||
|
* Formato: nombre,potencia_mw,tipo,cod_base
|
||||||
|
*/
|
||||||
|
private Generador obtenerGeneradorDeLineaCSV(String linea) {
|
||||||
|
String[] partes = linea.split(",");
|
||||||
|
if (partes.length < 4) {
|
||||||
|
System.err.println("Línea CSV de generador con formato incorrecto: " + linea);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Generador generador = new Generador();
|
||||||
|
generador.setNombre(partes[0].trim());
|
||||||
|
try {
|
||||||
|
generador.setPotenciaMW(Double.parseDouble(partes[1].trim()));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
System.err.println("Potencia MW no válida: " + partes[1].trim());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
generador.setTipo(TipoGenerador.valueOf(partes[2].trim()));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.err.println("Tipo de generador desconocido: " + partes[2].trim());
|
||||||
|
}
|
||||||
|
if (partes.length >= 4 && !partes[3].trim().isEmpty()) {
|
||||||
|
Base base = new Base();
|
||||||
|
base.setCodigo(partes[3].trim());
|
||||||
|
generador.setBase(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
return generador;
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/main/java/eu/agenciaesa/inm/utilidades/GestorURLs.java
Normal file
42
src/main/java/eu/agenciaesa/inm/utilidades/GestorURLs.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package eu.agenciaesa.inm.utilidades;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GestorURLs: Clase de utilidades para descargar contenido de URLs.
|
||||||
|
*
|
||||||
|
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
|
||||||
|
*/
|
||||||
|
public class GestorURLs {
|
||||||
|
|
||||||
|
// Evita que pueda construirse un objeto de la clase.
|
||||||
|
private GestorURLs() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descarga el contenido textual de la URL indicada.
|
||||||
|
*
|
||||||
|
* @param rutaURL URL de la que obtener el texto
|
||||||
|
* @return Texto de la respuesta o null si ocurre un error
|
||||||
|
*/
|
||||||
|
public static String getTextoFromURL(String rutaURL) {
|
||||||
|
String resultadoURL = null;
|
||||||
|
|
||||||
|
HttpClient cliente = HttpClient.newHttpClient();
|
||||||
|
URI uriPrueba = URI.create(rutaURL);
|
||||||
|
HttpRequest request = HttpRequest.newBuilder().uri(uriPrueba).GET().build();
|
||||||
|
try {
|
||||||
|
HttpResponse<String> respuesta = cliente.send(request, BodyHandlers.ofString());
|
||||||
|
resultadoURL = respuesta.body();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultadoURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
76
src/main/java/eu/agenciaesa/inm/vo/Base.java
Normal file
76
src/main/java/eu/agenciaesa/inm/vo/Base.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_BASE.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_BASE")
|
||||||
|
public class Base {
|
||||||
|
@Id
|
||||||
|
@Column(name = "codigo", columnDefinition = "char(4)")
|
||||||
|
private String codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "fecha_establecimiento")
|
||||||
|
private LocalDate fechaEstablecimiento;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING) // Se almacena el valor de un enumerado
|
||||||
|
@Column(name = "funcion_principal", nullable = false)
|
||||||
|
private FuncionPrincipalBase funcionPrincipal;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "id_cuerpo", referencedColumnName = "identificador")
|
||||||
|
private CuerpoCeleste cuerpo;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getFechaEstablecimiento() {
|
||||||
|
return fechaEstablecimiento;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFechaEstablecimiento(LocalDate fechaEstablecimiento) {
|
||||||
|
this.fechaEstablecimiento = fechaEstablecimiento;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FuncionPrincipalBase getFuncionPrincipal() {
|
||||||
|
return funcionPrincipal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFuncionPrincipal(FuncionPrincipalBase funcionPrincipal) {
|
||||||
|
this.funcionPrincipal = funcionPrincipal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CuerpoCeleste getCuerpo() {
|
||||||
|
return cuerpo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCuerpo(CuerpoCeleste cuerpo) {
|
||||||
|
this.cuerpo = cuerpo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Base [codigo=" + codigo + ", nombre=" + nombre + ", fechaEstablecimiento=" + fechaEstablecimiento
|
||||||
|
+ ", funcionPrincipal=" + funcionPrincipal + ", cuerpo=" + cuerpo + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
61
src/main/java/eu/agenciaesa/inm/vo/CuerpoCeleste.java
Normal file
61
src/main/java/eu/agenciaesa/inm/vo/CuerpoCeleste.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_CUERPO_CELESTE.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_CUERPO_CELESTE")
|
||||||
|
public class CuerpoCeleste {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long identificador;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "gravedad_superficie_ms2", nullable = false)
|
||||||
|
private double gravedadSuperficioMs2;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING) // Se almacena el valor de un enumerado
|
||||||
|
private TipoCuerpoCeleste tipo;
|
||||||
|
|
||||||
|
public Long getIdentificador() {
|
||||||
|
return identificador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentificador(Long identificador) {
|
||||||
|
this.identificador = identificador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getGravedadSuperficioMs2() {
|
||||||
|
return gravedadSuperficioMs2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGravedadSuperficioMs2(double gravedadSuperficioMs2) {
|
||||||
|
this.gravedadSuperficioMs2 = gravedadSuperficioMs2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipoCuerpoCeleste getTipo() {
|
||||||
|
return tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTipo(TipoCuerpoCeleste tipo) {
|
||||||
|
this.tipo = tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CuerpoCeleste [identificador=" + identificador + ", nombre=" + nombre + ", gravedadSuperficioMs2="
|
||||||
|
+ gravedadSuperficioMs2 + ", tipo=" + tipo + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
84
src/main/java/eu/agenciaesa/inm/vo/Experimento.java
Normal file
84
src/main/java/eu/agenciaesa/inm/vo/Experimento.java
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_EXPERIMENTO.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_EXPERIMENTO")
|
||||||
|
public class Experimento {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long identificador;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "resultado", nullable = false)
|
||||||
|
private String resultado;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING) // Se almacena el valor de un enumerado
|
||||||
|
private TipoExperimento tipo;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "cod_modulo", referencedColumnName ="codigo" )
|
||||||
|
private Modulo modulo;
|
||||||
|
|
||||||
|
public Long getIdentificador() {
|
||||||
|
return identificador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentificador(Long identificador) {
|
||||||
|
this.identificador = identificador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResultado() {
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultado(String resultado) {
|
||||||
|
this.resultado = resultado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipoExperimento getTipo() {
|
||||||
|
return tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTipo(TipoExperimento tipo) {
|
||||||
|
this.tipo = tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Modulo getModulo() {
|
||||||
|
return modulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModulo(Modulo modulo) {
|
||||||
|
this.modulo = modulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Experimento [identificador=" + identificador + ", nombre=" + nombre + ", resultado=" + resultado
|
||||||
|
+ ", tipo=" + tipo + ", modulo=" + modulo + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
public enum FuncionPrincipalBase {
|
||||||
|
Investigación, Logística, Control;
|
||||||
|
|
||||||
|
}
|
||||||
84
src/main/java/eu/agenciaesa/inm/vo/Generador.java
Normal file
84
src/main/java/eu/agenciaesa/inm/vo/Generador.java
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_GENERADOR.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_GENERADOR")
|
||||||
|
public class Generador {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "identificador")
|
||||||
|
private Long identificador;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "potencia_mw", nullable = false)
|
||||||
|
private double potenciaMW;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING) // Se almacena el valor de un enumerado
|
||||||
|
private TipoGenerador tipo;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "cod_base", referencedColumnName = "codigo")
|
||||||
|
private Base base;
|
||||||
|
|
||||||
|
public Long getIdentificador() {
|
||||||
|
return identificador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentificador(Long identificador) {
|
||||||
|
this.identificador = identificador;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPotenciaMW() {
|
||||||
|
return potenciaMW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPotenciaMW(double potenciaMW) {
|
||||||
|
this.potenciaMW = potenciaMW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipoGenerador getTipo() {
|
||||||
|
return tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTipo(TipoGenerador tipo) {
|
||||||
|
this.tipo = tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Base getBase() {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBase(Base base) {
|
||||||
|
this.base = base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Generador [identificador=" + identificador + ", nombre=" + nombre + ", potenciaMW=" + potenciaMW
|
||||||
|
+ ", tipo=" + tipo + ", base=" + base + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
39
src/main/java/eu/agenciaesa/inm/vo/Mision.java
Normal file
39
src/main/java/eu/agenciaesa/inm/vo/Mision.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.EmbeddedId;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.MapsId;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_MISION.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_MISION")
|
||||||
|
public class Mision {
|
||||||
|
@EmbeddedId
|
||||||
|
private MisionID idMision;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@MapsId("codigoNave")
|
||||||
|
@JoinColumn(name = "cod_nave", nullable = false, insertable = false, updatable = false)
|
||||||
|
private Nave nave;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@MapsId("idCuerpoCeleste")
|
||||||
|
@JoinColumn(name = "id_cuerpo_celeste", nullable = false, insertable = false, updatable = false)
|
||||||
|
private CuerpoCeleste cuerpoCeleste;
|
||||||
|
|
||||||
|
@Column(name = "fecha_fin", nullable = true)
|
||||||
|
private LocalDate fechaFin;
|
||||||
|
|
||||||
|
@Column(name = "objetivo_principal", nullable = false)
|
||||||
|
private String objetivoPrincipal;
|
||||||
|
|
||||||
|
}
|
||||||
80
src/main/java/eu/agenciaesa/inm/vo/MisionID.java
Normal file
80
src/main/java/eu/agenciaesa/inm/vo/MisionID.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Embeddable;
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
|
public class MisionID implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Column(name = "cod_nave", nullable = false)
|
||||||
|
private String codigoNave;
|
||||||
|
|
||||||
|
@Column(name = "id_cuerpo_celeste", nullable = false)
|
||||||
|
private Long idCuerpoCeleste;
|
||||||
|
|
||||||
|
@Column(name = "fecha_inicio", nullable = false)
|
||||||
|
private LocalDate fechaInicio;
|
||||||
|
|
||||||
|
public MisionID() {}
|
||||||
|
|
||||||
|
public MisionID(String codigoNave, Long idCuerpoCeleste, LocalDate fechaInicio) {
|
||||||
|
this.codigoNave = codigoNave;
|
||||||
|
this.idCuerpoCeleste = idCuerpoCeleste;
|
||||||
|
this.fechaInicio = fechaInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MisionID that = (MisionID) o;
|
||||||
|
|
||||||
|
return codigoNave == that.codigoNave && idCuerpoCeleste == that.idCuerpoCeleste && fechaInicio == that.fechaInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(codigoNave, idCuerpoCeleste, fechaInicio);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodigoNave() {
|
||||||
|
return codigoNave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodigoNave(String codigoNave) {
|
||||||
|
this.codigoNave = codigoNave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getIdCuerpoCeleste() {
|
||||||
|
return idCuerpoCeleste;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdCuerpoCeleste(Long idCuerpoCeleste) {
|
||||||
|
this.idCuerpoCeleste = idCuerpoCeleste;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getFechaInicio() {
|
||||||
|
return fechaInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFechaInicio(LocalDate fechaInicio) {
|
||||||
|
this.fechaInicio = fechaInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MisionID [codigoNave=" + codigoNave + ", idCuerpoCeleste=" + idCuerpoCeleste + ", fechaInicio="
|
||||||
|
+ fechaInicio + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
68
src/main/java/eu/agenciaesa/inm/vo/Modulo.java
Normal file
68
src/main/java/eu/agenciaesa/inm/vo/Modulo.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_MODULO.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_MODULO")
|
||||||
|
public class Modulo {
|
||||||
|
@Id
|
||||||
|
@Column(name = "codigo", columnDefinition = "char(4)")
|
||||||
|
private String codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 100)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "consumo_energia_mw", nullable = false)
|
||||||
|
private double consumoEnergiaMW;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "cod_base", referencedColumnName = "codigo")
|
||||||
|
private Base base;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getConsumoEnergiaMW() {
|
||||||
|
return consumoEnergiaMW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConsumoEnergiaMW(double consumoEnergiaMW) {
|
||||||
|
this.consumoEnergiaMW = consumoEnergiaMW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Base getBase() {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBase(Base base) {
|
||||||
|
this.base = base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Modulo [codigo=" + codigo + ", nombre=" + nombre + ", consumoEnergiaMW=" + consumoEnergiaMW + ", base="
|
||||||
|
+ base + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
78
src/main/java/eu/agenciaesa/inm/vo/Nave.java
Normal file
78
src/main/java/eu/agenciaesa/inm/vo/Nave.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entidad que representa la tabla T_NAVE.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_NAVE")
|
||||||
|
public class Nave {
|
||||||
|
@Id
|
||||||
|
@Column(name = "codigo", columnDefinition = "char(4)")
|
||||||
|
private String codigo;
|
||||||
|
|
||||||
|
@Column(name = "nombre", nullable = false, length = 255)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column(name = "capacidad_tripulacion", nullable = false)
|
||||||
|
private int capacidadTripulación;
|
||||||
|
|
||||||
|
@Column(name = "autonomia_dias", nullable =false)
|
||||||
|
private int autonomiaDias;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING) // Se almacena el valor de un enumerado
|
||||||
|
private TipoNave tipo;
|
||||||
|
|
||||||
|
public TipoNave getTipo() {
|
||||||
|
return tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTipo(TipoNave tipo) {
|
||||||
|
this.tipo = tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCapacidadTripulación() {
|
||||||
|
return capacidadTripulación;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCapacidadTripulación(int capacidadTripulación) {
|
||||||
|
this.capacidadTripulación = capacidadTripulación;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAutonomiaDias() {
|
||||||
|
return autonomiaDias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutonomiaDias(int autonomiaDias) {
|
||||||
|
this.autonomiaDias = autonomiaDias;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Nave [codigo=" + codigo + ", nombre=" + nombre + ", capacidadTripulación=" + capacidadTripulación
|
||||||
|
+ ", autonomiaDias=" + autonomiaDias + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
public enum TipoCuerpoCeleste {
|
||||||
|
Planeta, Satélite, Asteroide, Planetoide;
|
||||||
|
|
||||||
|
}
|
||||||
6
src/main/java/eu/agenciaesa/inm/vo/TipoExperimento.java
Normal file
6
src/main/java/eu/agenciaesa/inm/vo/TipoExperimento.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
public enum TipoExperimento {
|
||||||
|
Biológico, Climatológico, Geológico;
|
||||||
|
|
||||||
|
}
|
||||||
6
src/main/java/eu/agenciaesa/inm/vo/TipoGenerador.java
Normal file
6
src/main/java/eu/agenciaesa/inm/vo/TipoGenerador.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
public enum TipoGenerador {
|
||||||
|
Nuclear, Solar, Geotérmica;
|
||||||
|
|
||||||
|
}
|
||||||
6
src/main/java/eu/agenciaesa/inm/vo/TipoNave.java
Normal file
6
src/main/java/eu/agenciaesa/inm/vo/TipoNave.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package eu.agenciaesa.inm.vo;
|
||||||
|
|
||||||
|
public enum TipoNave {
|
||||||
|
Transporte, Reconocimiento, Científica, Mantenimiento;
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/resources/META-INF/persistence.xml
Normal file
24
src/main/resources/META-INF/persistence.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
|
||||||
|
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||||
|
<!-- Unidad Persistencia Hibernate -->
|
||||||
|
<persistence-unit name="UP_AGENCIAESA_POSTGRESQL" transaction-type="RESOURCE_LOCAL">
|
||||||
|
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||||
|
<!-- Clases a "mapear" -->
|
||||||
|
<class>eu.agenciaesa.inm.vo.Experimento</class>
|
||||||
|
|
||||||
|
<!-- Configuración para la conexión a la Base de Datos -->
|
||||||
|
<properties>
|
||||||
|
<property name="jakarta.persistence.jdbc.driver" value="org.postgresql.Driver" />
|
||||||
|
<property name="jakarta.persistence.jdbc.url" value="jdbc:postgresql://192.168.1.36:5432/agencia_esa_inm" />
|
||||||
|
<property name="jakarta.persistence.jdbc.user" value="postgres" />
|
||||||
|
<property name="jakarta.persistence.jdbc.password" value="postgres_123" />
|
||||||
|
|
||||||
|
<property name="hibernate.show_sql" value="true" />
|
||||||
|
<property name="hibernate.hbm2ddl.auto" value="update" />
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
5
src/main/resources/conf.properties
Normal file
5
src/main/resources/conf.properties
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
url.conexion.mongodb=mongodb://admin:mongodb_123@192.168.1.36:27017
|
||||||
|
bbdd.mongodb=agencia_esa_inm
|
||||||
|
url.bases=https://dam2.decieloytierra.es/agenciaesa/bases-modulos.xml
|
||||||
|
url.experimentos=https://aulavirtual35.educa.madrid.org/ies.lapaloma.madrid/pluginfile.php/232510/mod_assign/intro/experimentos_modulos.json?time=1771520391646
|
||||||
|
ruta.csv=info-generadores.csv
|
||||||
26
src/main/resources/hibernate.cfg.xml
Normal file
26
src/main/resources/hibernate.cfg.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<!DOCTYPE hibernate-configuration PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Configuration DTD//EN"
|
||||||
|
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||||
|
<hibernate-configuration>
|
||||||
|
<session-factory>
|
||||||
|
<property name="connection.url">jdbc:postgresql://192.168.1.36:5432/agencia_esa_inm</property>
|
||||||
|
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
|
||||||
|
|
||||||
|
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
|
||||||
|
|
||||||
|
<property name="connection.username">postgres</property>
|
||||||
|
<property name="connection.password">postgres_123</property>
|
||||||
|
|
||||||
|
<!-- Configuración de Hibernate -->
|
||||||
|
<property name="hibernate.hbm2ddl.auto">update</property> <!-- 'update' para mantener el esquema en sincronía con las entidades -->
|
||||||
|
<property name="hibernate.show_sql">true</property> <!-- Muestra las consultas SQL -->
|
||||||
|
<property name="hibernate.format_sql">true</property> <!-- Da formato a las consultas SQL -->
|
||||||
|
<property name="hibernate.use_sql_comments">false</property> <!-- Añade comentarios en las consultas SQL -->
|
||||||
|
|
||||||
|
<mapping class="eu.agenciaesa.inm.vo.Base"></mapping>
|
||||||
|
<mapping class="eu.agenciaesa.inm.vo.Modulo"></mapping>
|
||||||
|
|
||||||
|
|
||||||
|
</session-factory>
|
||||||
|
</hibernate-configuration>
|
||||||
Loading…
Reference in New Issue
Block a user