Fin des Fonctionnalités demander, debut debogage et simplification

This commit is contained in:
2022-12-03 17:52:10 +01:00
parent 4e087ad4ba
commit 8dd7db7396
16 changed files with 473 additions and 16 deletions

View File

@@ -265,6 +265,7 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
s.add(new EtudiantNP(rs.getString(2), rs.getString(3), rs.getInt(1)));
}
}catch(SQLException e){
System.out.println(e.toString());
if(this.erreurCO())
return this.getEtudiants(nomEtu);
return null;
@@ -323,6 +324,7 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
"chaignea", "Chaigneauphpmyadmin");
return cnx;
}catch(Exception e){
System.out.println(e.toString());
if(this.erreurCO()==true){
return this.cnx();
}
@@ -390,6 +392,7 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
try{
clos.close();
}catch(Exception e){
System.out.println(e.toString());
if(this.erreurCO()==true)
this.close(clos);
}
@@ -503,7 +506,6 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
"SELECT `id`, `nom`, `min`, `max`, `value`, `id-parent` FROM `Groupe` join `TYPE` on Groupe.Type=TYPE.name ORDER BY Groupe.id ASC;");
ResultSet rs = pst.executeQuery();
rs=pst.executeQuery();
try{
//Si il existe bien une promotion
if(rs.next()){
//On créer le groupe de promo
@@ -520,11 +522,12 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
//Si aucune ligne et donc pas de promo:
this.promo=null;
}
}catch(SQLException e){
}
rs.close();
pst.close();
}catch(SQLException e){
System.out.println(e.toString());
if(this.erreurCO())
this.init();
}
this.close(cnx);
}
@@ -557,6 +560,7 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
}
rs.close();
}catch(SQLException e){
System.out.println(e);
if(this.erreurCO())
this.addSousGroupe(g, cnx);
}
@@ -593,6 +597,7 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
rs.close();
pst.close();
}catch(SQLException e){
System.out.println(e.toString());
if(this.erreurCO())
this.addBDEtudiant(g, cnx);
}
@@ -640,7 +645,7 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
for(Etudiant gr:et){
g.removeEtudiant(gr);
}
this.addSousGroupe(g, cnx);
this.addSousGroupePasRecursif(g, cnx);
}else{
if(g==g.getPointPoint()){
g=null;
@@ -650,6 +655,7 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
}
rs.close();
}catch(SQLException e){
System.out.println(e.toString());
if(this.erreurCO())
this.refreshGroupe(g, cnx);
}
@@ -675,4 +681,38 @@ private boolean saveEtu(Etudiant etudiant, Groupe g){
this.close(cnx);
return g;
}
/**
* Fonction recursive permettant de récuperrer les sous groupe a partir de la BD
* @param g le groupe
* @param cnx la connection a la BD (evite de la surcharger)
* @param pourcent le pourcentage de ce groupe dans le chargement
*/
private void addSousGroupePasRecursif(Groupe g, Connection cnx){
try{
//On récupere les Groupe qui ont le parent :g
PreparedStatement pst= cnx.prepareStatement(
"SELECT `id`, `nom`, `min`, `max`, `value`, `id-parent` FROM `Groupe` join `TYPE` on Groupe.Type=TYPE.name where Groupe.`id-parent`=? and Groupe.id!=Groupe.`id-parent`;");
pst.setString(1, String.valueOf(g.getId()));
ResultSet rs=pst.executeQuery();
rs=pst.executeQuery();
//autrement si le groupe as des sous groupe
while(rs.next()){
//on les ajoute
Groupe nouveau=new GroupeNP(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getInt(4), TypeGroupe.getType(rs.getString(5)), g);
//Si one le connait pas
if(this.brain.get(nouveau.getId())==null){
this.brain.put(nouveau.getId(), nouveau);
}
g.addSousGroupe(nouveau);
//on ajoute les sous groupe des sous-groupe
}
rs.close();
}catch(SQLException e){
System.out.println(e.toString());
if(this.erreurCO())
this.addSousGroupe(g, cnx);
}
}
}