valida Institu y Formacion antes de InstitutoFormacion
This commit is contained in:
parent
0e9c375ff8
commit
3b06e360c5
@ -187,24 +187,24 @@ public class ClasePrincipal {
|
||||
IInstitutoDAO iInstitutoDAO = new InstitutoDaoJPA();
|
||||
|
||||
for (InstitutoFormacion institutoFormacion : listaInstitutoFormacion) {
|
||||
// Se obiene el instituto en la BBDD
|
||||
InstitutoFormacion institutoFormacionBBDD = institutoFormacionDAO
|
||||
.obtenerInstitutoFormacionPorID(institutoFormacion.getIdInstitutoFormacion());
|
||||
// Sólo se insertará el InstitutoFormacion si existen tanto el Instituto como la
|
||||
// Formación en la Base de datos.
|
||||
Instituto instituto = iInstitutoDAO
|
||||
.obtenerInstitutoPorID(institutoFormacion.getInstituto().getIdentificador());
|
||||
Formacion formacion = iFormacionDAO
|
||||
.obtenerFormacionPorID(institutoFormacion.getFormacion().getCodigo());
|
||||
// Se insertará el InstitutoFormacion sólo si la formación es STEM
|
||||
if (instituto != null && formacion != null && formacion.getIndicadorSTEM() == EIndicadorSTEM.sí) {
|
||||
// Se obiene el instituto en la BBDD
|
||||
InstitutoFormacion institutoFormacionBBDD = institutoFormacionDAO
|
||||
.obtenerInstitutoFormacionPorID(institutoFormacion.getIdInstitutoFormacion());
|
||||
|
||||
// Si no existe información en la Base de datos.
|
||||
if (institutoFormacionBBDD == null) {
|
||||
|
||||
// Sólo se insertará el InstitutoFormacion si existen tanto el Instituto como la
|
||||
// Formación en la Base de datos.
|
||||
Instituto instituto = iInstitutoDAO
|
||||
.obtenerInstitutoPorID(institutoFormacion.getInstituto().getIdentificador());
|
||||
Formacion formacion = iFormacionDAO
|
||||
.obtenerFormacionPorID(institutoFormacion.getFormacion().getCodigo());
|
||||
// Se insertará el InstitutoFormacion sólo si la formación es STEM
|
||||
if (instituto != null && formacion != null && formacion.getIndicadorSTEM() == EIndicadorSTEM.sí) {
|
||||
// Si no existe información en la Base de datos.
|
||||
if (institutoFormacionBBDD == null) {
|
||||
institutoFormacion.setInstituto(instituto);
|
||||
institutoFormacion.setFormacion(formacion);
|
||||
institutoFormacionDAO.insertarInstitutoFormacion(institutoFormacion);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,14 +13,13 @@ import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
/**
|
||||
* Organización: Virgen de la Paloma
|
||||
* Programador: Isidoro Nevares Martín
|
||||
* Fecha: 26 marzo 2026
|
||||
*/
|
||||
public class InstitutoFormacionDaoHibernate implements IInstitutoFormacionDAO{
|
||||
* Organización: Virgen de la Paloma Programador: Isidoro Nevares Martín Fecha:
|
||||
* 26 marzo 2026
|
||||
*/
|
||||
public class InstitutoFormacionDaoHibernate implements IInstitutoFormacionDAO {
|
||||
@Override
|
||||
public void insertarInstitutoFormacion(InstitutoFormacion institutoFormacion) throws FormacionException {
|
||||
Transaction transaccion=null;
|
||||
Transaction transaccion = null;
|
||||
|
||||
Session sesion = null;
|
||||
try {
|
||||
@ -45,7 +44,7 @@ public class InstitutoFormacionDaoHibernate implements IInstitutoFormacionDAO{
|
||||
@Override
|
||||
public InstitutoFormacion obtenerInstitutoFormacionPorID(InstitutoFormacionID identificador)
|
||||
throws FormacionException {
|
||||
InstitutoFormacion institutoFormacion =null;
|
||||
InstitutoFormacion institutoFormacion = null;
|
||||
|
||||
// try con recursos "cerrables": Session
|
||||
try (Session sesion = GestorSesionHibernate.getSession();) {
|
||||
@ -54,7 +53,7 @@ public class InstitutoFormacionDaoHibernate implements IInstitutoFormacionDAO{
|
||||
throw new FormacionException(e, FormacionException.ERROR_CONSULTA, getClass());
|
||||
}
|
||||
|
||||
return institutoFormacion;
|
||||
return institutoFormacion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -71,6 +71,18 @@ public class InstitutoFormacion {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InstitutoFormacionID [idIntituto=" + idIntituto + ", idFormacion=" + codFormacion + "]";
|
||||
}
|
||||
public Integer getIdIntituto() {
|
||||
return idIntituto;
|
||||
}
|
||||
public void setIdIntituto(Integer idIntituto) {
|
||||
this.idIntituto = idIntituto;
|
||||
}
|
||||
public String getCodFormacion() {
|
||||
return codFormacion;
|
||||
}
|
||||
public void setCodFormacion(String codFormacion) {
|
||||
this.codFormacion = codFormacion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user