simplification repartition class et constructeur et modif API
This commit is contained in:
@@ -27,7 +27,8 @@ public class AbstractChangementFactoryNP implements AbstractChangementFactory {
|
||||
Objects.requireNonNull(agf,"On ne peut pas créer une usine à changement dont l'usine à groupe parternaire est null");
|
||||
this.agf=agf;
|
||||
this.fenetre=fenetre;
|
||||
this.brain=new HashMap<Integer,Changement>();
|
||||
this.brain=new HashMap<Integer,Changement>();
|
||||
this.getChange();
|
||||
}
|
||||
|
||||
public AbstractChangementFactoryNP(AbstractGroupeFactory agf, JFrame fenetre, Set<Changement> liste){
|
||||
@@ -37,7 +38,8 @@ public class AbstractChangementFactoryNP implements AbstractChangementFactory {
|
||||
this.brain=new HashMap<Integer,Changement>();
|
||||
for(Changement ch:liste){
|
||||
this.brain.put(ch.getId(), ch);
|
||||
}
|
||||
}
|
||||
this.getChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -207,4 +209,40 @@ public class AbstractChangementFactoryNP implements AbstractChangementFactory {
|
||||
this.close(clos);
|
||||
}
|
||||
}
|
||||
|
||||
private void getChange(){
|
||||
Connection cnx=this.cnx();
|
||||
try{
|
||||
PreparedStatement pst=cnx.prepareStatement("SELECT * FROM `Changement` NATURAL JOIN Etudiant; ");
|
||||
ResultSet rs=pst.executeQuery();
|
||||
while(rs.next()){
|
||||
Groupe[] ab=new Groupe[2];
|
||||
this.getGroupe(rs.getInt(2), rs.getInt(3), ab, this.agf.getPromotion());
|
||||
Etudiant e=new EtudiantNP(rs.getString(5), rs.getString(6), rs.getInt(4));
|
||||
this.brain.put(rs.getInt(1), new ChangementNP(ab[0], e, ab[1], rs.getInt(1)));
|
||||
}
|
||||
pst.close();
|
||||
}catch(SQLException e){
|
||||
if(this.erreurCO())
|
||||
this.getChange();
|
||||
return;
|
||||
}
|
||||
this.close(cnx);
|
||||
}
|
||||
|
||||
private void getGroupe(int idA, int idB, Groupe[] retour, Groupe tofind){
|
||||
if(retour[0]!=null && retour[1]!=null)
|
||||
return;
|
||||
if(tofind.getId()==idA){
|
||||
retour[0]=tofind;
|
||||
}
|
||||
if(tofind.getId()==idB){
|
||||
retour[1]=tofind;
|
||||
}
|
||||
for(Groupe sous:tofind.getSousGroupes()){
|
||||
this.getGroupe(idA, idB, retour, sous);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user