correction de bugs
This commit is contained in:
@@ -118,9 +118,10 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
*/
|
||||
public void deleteGroupe(Groupe g){
|
||||
Objects.requireNonNull(g,"On ne peut pas enlever un groupe null car null n'est pas un groupe autorisé");
|
||||
if (!this.knows(g)){
|
||||
throw new IllegalArgumentException("Impossible d'enlever un groupe inconnu");
|
||||
}
|
||||
//if (!this.knows(g)){
|
||||
//throw new IllegalArgumentException("Impossible d'enlever un groupe inconnu");
|
||||
//possible maintenant
|
||||
//}
|
||||
g.getPointPoint().removeSousGroupe(g);
|
||||
this.brain.remove(Integer.valueOf(g.getId()));
|
||||
this.suprGroupe(g);
|
||||
@@ -140,9 +141,10 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
Objects.requireNonNull(pere,"Le groupe pere ne peut pas être null");
|
||||
Objects.requireNonNull(name,"Le nouveau groupe ne peut pas avoir null comme nom");
|
||||
|
||||
if (!this.knows(pere)){
|
||||
throw new IllegalArgumentException("Interdit d'ajouter un fils à un groupe inconnu");
|
||||
}
|
||||
//if (!this.knows(pere)){
|
||||
// throw new IllegalArgumentException("Interdit d'ajouter un fils à un groupe inconnu");
|
||||
//Possible maintenant
|
||||
//}
|
||||
if (pere.getType().equals(TypeGroupe.PARTITION)){
|
||||
throw new IllegalArgumentException("Impossible d'ajouter un groupe à une parition. Il faut utiliser createPartition pour créer une partition");
|
||||
}
|
||||
@@ -175,9 +177,10 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
public void createPartition(Groupe pere, String name, int n){
|
||||
Objects.requireNonNull(pere,"Le groupe pere ne peut pas être null");
|
||||
Objects.requireNonNull(name,"Le nouveau groupe ne peut pas avoir null comme nom");
|
||||
if (!this.knows(pere)){
|
||||
throw new IllegalArgumentException("Impossible de partitionner ce groupe inconnu");
|
||||
}
|
||||
//if (!this.knows(pere)){
|
||||
//throw new IllegalArgumentException("Impossible de partitionner ce groupe inconnu");
|
||||
//possible maintenant
|
||||
//}
|
||||
if (pere.getType().equals(TypeGroupe.PARTITION)){
|
||||
throw new IllegalArgumentException("Impossible de créer une partition à ce niveau. Il faut soit repartitionner le groupe au dessus, soit partitionner une partition en dessous.");
|
||||
}
|
||||
@@ -221,9 +224,10 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
public void addToGroupe(Groupe g, Etudiant e){
|
||||
Objects.requireNonNull(g,"Le groupe ne peut pas être null");
|
||||
Objects.requireNonNull(e,"L'étudiant ne peut pas être null");
|
||||
if (!this.knows(g)){
|
||||
throw new IllegalArgumentException("Impossible d'ajouter l'étudiant car le est groupe inconnu");
|
||||
}
|
||||
//if (!this.knows(g)){
|
||||
//throw new IllegalArgumentException("Impossible d'ajouter l'étudiant car le est groupe inconnu");
|
||||
//rendu possible maintenant par la syncronisation en temps réel
|
||||
//}
|
||||
g.addEtudiant(e);
|
||||
this.saveEtu(e, g);
|
||||
}
|
||||
@@ -241,9 +245,10 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
public void dropFromGroupe(Groupe g, Etudiant e){
|
||||
Objects.requireNonNull(g,"Le groupe ne peut pas être null");
|
||||
Objects.requireNonNull(e,"L'étudiant ne peut pas être null");
|
||||
if (!this.knows(g)){
|
||||
throw new IllegalArgumentException("Impossible d'ajouter l'étudiant car le est groupe inconnu");
|
||||
}
|
||||
//if (!this.knows(g)){
|
||||
//throw new IllegalArgumentException("Impossible de suprimer l'étudiant car le est groupe inconnu");
|
||||
//Possible maintenant
|
||||
//}
|
||||
g.removeEtudiant(e);
|
||||
this.deleteEtu(e, g);
|
||||
}
|
||||
@@ -292,8 +297,6 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// **********************
|
||||
// FONCTION POUR SIMPLIFIER LES Modification BD
|
||||
// ***********************
|
||||
@@ -339,28 +342,34 @@ public class AbstractGroupeFactoryNP implements AbstractGroupeFactory {
|
||||
"DELETE FROM CONTIENT WHERE idGroupe=? AND idEt=?; "
|
||||
);
|
||||
pst.setInt(2, et.getId());
|
||||
this.deleteEtu(pst, cnx, g);
|
||||
this.deleteEtu(pst, cnx, g.getId());
|
||||
pst.close();
|
||||
}catch(SQLException e){
|
||||
System.out.println(e.toString());
|
||||
if(this.erreurSQL()){
|
||||
this.deleteEtu(et, g);
|
||||
this.deleteEtu(et, brain.get(g.getId()));
|
||||
}
|
||||
}
|
||||
this.close(cnx);
|
||||
}
|
||||
|
||||
private void deleteEtu(PreparedStatement pst, Connection cnx, Groupe g){
|
||||
private void deleteEtu(PreparedStatement pst, Connection cnx, int id){
|
||||
try{
|
||||
pst.setInt(1, g.getId());
|
||||
pst.setInt(1, id);
|
||||
pst.executeUpdate();
|
||||
for(Groupe sous: g.getSousGroupes()){
|
||||
this.deleteEtu(pst, cnx, sous);
|
||||
|
||||
PreparedStatement sous=cnx.prepareStatement(
|
||||
"SELECT * FROM Groupe WHERE `id-parent`=? AND `id-parent`!=id; "
|
||||
);
|
||||
sous.setInt(1, id);
|
||||
ResultSet rs=sous.executeQuery();
|
||||
while(rs.next()){
|
||||
this.deleteEtu(pst, cnx, rs.getInt(1));
|
||||
}
|
||||
}catch(SQLException e){
|
||||
System.out.println(e.toString());
|
||||
if(this.erreurSQL()){
|
||||
this.deleteEtu(pst, cnx, g);
|
||||
this.deleteEtu(pst, cnx, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user